/* マドリセカンド 送客機能の共通デザイン（デザイントークンと部品）
   要件書 12-3「デザイン方針」に沿う。色・文字・角丸はここだけで調整する。
   ダークモードは対応しない（要件書どおり）。 */

:root {
  /* 色 */
  --bg: #FAFAF7;          /* ページの背景（温かみのある白） */
  --surface: #FFFFFF;     /* カード・入力欄 */
  --text: #2B2F33;        /* 本文 */
  --muted: #6B6F76;       /* 補足文字 */
  --line: #E7E5E0;        /* 枠線・区切り */
  /* 色のルール（2026-10-10）：メインは緑（--main）1色、差し色はオレンジ（--accent）1色。差し色は小さな印・マーカーだけで、ボタンには使わない */
  --main: #1F7F73;        /* ボタン・リンク・選択中 */
  --main-dark: #186A60;   /* ボタンを押しているとき */
  --main-soft: #E6F4F1;   /* 選択中の背景・提携先カードの強調 */
  --accent: #F4A261;      /* バッジ・新着（使いすぎない） */
  --accent-text: #B4561B; /* アクセントの文字 */
  --accent-soft: #FDF1E7;
  --caution: #E9A23B;     /* 要確認 */
  --caution-soft: #FDF5E6;
  --error: #D9534F;       /* 入力エラー */
  --error-soft: #FBECEB;

  /* 文字 */
  --font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  --fs-xs: 13px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 26px;
  --lh: 1.7;

  /* 形 */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(43, 47, 51, .04), 0 4px 16px rgba(43, 47, 51, .05);
  --tap: 48px;            /* ボタン・タップできる部分の高さ（44px以上） */

  /* 余白 */
  --gutter: 20px;
  --gap: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--main); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.4; margin: 0; }
/* 見出しは文節で折り返す（対応しているブラウザだけ。言葉の途中で改行しないように） */
h1, h2, h3, .card-title { word-break: auto-phrase; }
/* スマホでの改行：見出しは行の長さをそろえる（文節での区切りは assets/phrase.js）。
   本文には text-wrap: pretty を使わない（iPhone の Safari では段落全体の行の長さが変わり、右端がガタガタになるため） */
h1, h2, h3, h4 { text-wrap: balance; }
.nb { white-space: nowrap; } /* ここでは改行しない（日時・ひとまとまりの言葉） */
/* hidden を指定した要素は、部品の display 指定より優先して隠す */
[hidden] { display: none !important; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-xl); font-weight: 700; }
h3 { font-size: var(--fs-lg); font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--gap); }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* レイアウト */
.page { max-width: 560px; margin: 0 auto; padding: 24px var(--gutter) 64px; }
.page.wide { max-width: 1120px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px var(--gutter); display: flex; align-items: center; gap: 12px; min-height: 56px; }
/* スマホ：パートナーの画面など、右に「使い方」「担当者」「ログアウト」などが並ぶ帯は、入りきらなければ2段に折り返す（横にぐらぐらしないように。2026-10-14） */
@media (max-width: 560px) {
  .topbar-inner:has(#logout), .topbar-inner:has(.icon-btn):has(.brand) { flex-wrap: wrap; row-gap: 0; column-gap: 16px; padding-top: 8px; padding-bottom: 6px; }
  .topbar-inner:has(.icon-btn):has(.brand) > .spacer { flex: 1 0 0; }
  /* ログアウトのある帯は、1段目にロゴ、2段目に「使い方・担当者・ログアウト」をそろえて並べる */
  .topbar-inner:has(#logout) > .spacer { flex: 0 0 100%; height: 0; }
  .topbar-inner:has(#logout) > a.small, .topbar-inner:has(#logout) > #logout { margin-left: 0 !important; min-height: 36px; display: inline-flex; align-items: center; font-size: var(--fs-sm); }
  .topbar-inner:has(#logout) > #logout { margin-left: auto !important; }
}
@media (max-width: 420px) {
  .topbar-inner:has(.icon-btn):has(.brand) .brand small { display: none; }
}
.brand { font-weight: 700; font-size: var(--fs-base); color: var(--text); text-decoration: none; letter-spacing: .02em; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: var(--fs-xs); margin-left: 6px; }

/* アイコン（線のシンプルなもの。mock.js が <i data-icon> を差し替える） */
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.icon.lg { width: 28px; height: 28px; }

/* カード */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.soft { background: var(--main-soft); border-color: #CDE8E2; box-shadow: none; }
.card.soft .badge-partner { background: var(--surface); box-shadow: inset 0 0 0 1px #BFE0D9; }
.card-title { font-size: var(--fs-lg); font-weight: 700; line-height: 1.5; }

/* ボタン（主ボタンは1画面に1つ） */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 20px; width: 100%;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: inherit; font-size: var(--fs-base); font-weight: 700; line-height: 1.4;
  text-decoration: none; cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--main); color: #fff; }
.btn-primary:hover { background: var(--main-dark); }
.btn-secondary { background: var(--surface); color: var(--main); border-color: var(--main); }
.btn-secondary:hover { background: var(--main-soft); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #F3F2EE; }
.btn:disabled, .btn[aria-disabled="true"] { background: #E4E2DC; color: #9A9DA3; border-color: transparent; cursor: not-allowed; }
.btn-line { background: #06C755; color: #fff; }
.btn-google { background: #fff; color: #1F1F1F; border-color: #D5D3CD; }
.btn-x { background: #0F1419; color: #fff; }
.btn-x:hover { background: #272C30; }
.btn-line:hover { background: #05B34C; }
.btn-ig { background: linear-gradient(45deg, #F58529, #DD2A7B 55%, #8134AF); color: #fff; }
.btn-ig:hover { filter: brightness(0.95); }
.brand-logo { width: 18px; height: 18px; fill: currentColor; stroke: none; flex: none; }
.btn.auto { width: auto; }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: var(--fs-sm); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; padding: 8px 0; font: inherit; font-weight: 700; color: var(--main); cursor: pointer; min-height: 44px; text-decoration: none; }

/* バッジ・ラベル（色だけで伝えない：文字も必ず入れる） */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; line-height: 1; padding: 6px 10px; border-radius: var(--radius-pill); white-space: nowrap; }
.badge-partner { background: var(--main-soft); color: var(--main); }
.badge-pr { background: #F1F0EC; color: var(--muted); }
.badge-new { background: var(--accent-soft); color: var(--accent-text); }
.badge-caution { background: var(--caution-soft); color: #8A5A10; }
.badge-done { background: #EEF0F2; color: #4A4F55; }

/* フォーム */
.field > label, .field > .label { display: block; font-weight: 700; font-size: var(--fs-sm); margin-bottom: 8px; }
.req { color: var(--accent-text); font-size: var(--fs-xs); margin-left: 6px; font-weight: 700; }
.opt { color: var(--muted); font-size: var(--fs-xs); margin-left: 6px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; font-size: var(--fs-base); color: var(--text);
  background: var(--surface); border: 1px solid #D5D3CD; border-radius: var(--radius-sm);
  appearance: none; -webkit-appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
textarea.input { min-height: 112px; resize: vertical; }
.input:focus { outline: 3px solid rgba(31, 127, 115, .25); border-color: var(--main); }
.input.is-error { border-color: var(--error); background: var(--error-soft); }
.help { font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }
.error-text { font-size: var(--fs-sm); color: var(--error); margin-top: 6px; display: flex; gap: 6px; }
.choices { display: grid; gap: 8px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice { position: relative; display: flex; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span { display: flex; align-items: center; min-height: var(--tap); padding: 10px 8px; border: 1px solid #D5D3CD; border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; flex: 1; justify-content: center; text-align: center; word-break: auto-phrase; }
.choice input:checked + span { border-color: var(--main); background: var(--main-soft); color: var(--main); font-weight: 700; box-shadow: inset 0 0 0 1px var(--main); }
.choice input:focus-visible + span { outline: 3px solid rgba(31, 127, 115, .25); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--main); flex: none; }

/* 進み具合 */
.progress { display: flex; gap: 6px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.progress span.on { background: var(--main); }

/* お知らせ枠 */
.note { border-radius: var(--radius-sm); padding: 14px 16px; font-size: var(--fs-sm); display: flex; gap: 10px; }
.note-info { background: var(--main-soft); color: #185A52; }
.note-caution { background: var(--caution-soft); color: #6E4A10; }

/* 一覧の行 */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; min-height: 64px; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #FBFBF9; }
.unread { min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }

/* メッセージ */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 84%; }
.msg.me { align-self: flex-end; }
.bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 12px 14px; font-size: var(--fs-base); white-space: pre-wrap; overflow-wrap: anywhere; } /* 長いURLも折り返す（スマホで横にぐらぐらしないように） */
.msg.me .bubble { background: var(--main); color: #fff; border-color: var(--main); border-radius: 16px 16px 4px 16px; }
.msg-meta { font-size: var(--fs-xs); color: var(--muted); margin: 4px 4px 0; }
.msg.me .msg-meta { text-align: right; }
.msg-sys { align-self: center; font-size: var(--fs-xs); color: var(--muted); background: #F1F0EC; border-radius: var(--radius-pill); padding: 6px 12px; }
.attach { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255,255,255,.15); font-size: var(--fs-sm); }
.msg:not(.me) .attach { background: #F5F4F0; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); }
.composer-box { display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid #D5D3CD; border-radius: 16px; padding: 8px; }
.composer-box textarea { flex: 1; border: none; resize: none; font: inherit; min-height: 40px; max-height: 160px; padding: 8px; background: transparent; }
.composer-box textarea:focus { outline: none; }
.composer-box.is-drop { border-color: #1F7F73; box-shadow: 0 0 0 2px #E6F4F1; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: none; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn.send { background: var(--main); color: #fff; }

/* 表（パートナー・運営者の画面） */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.table th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FBFBF9; white-space: nowrap; }
table.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.table tr:last-child td { border-bottom: none; }
table.table tr.attention td { background: #FFFBF4; }
table.table tr.attention td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
/* 見送り（終了）にした相談：行ごと薄いグレーに（2026-10-17。ほかの相談と見分けやすく） */
table.table tr.is-lost td { background: #F3F3F1; color: #8A8F94; }
table.table tr.is-lost td a { color: #6F757B; }
table.table a { font-weight: 700; }

/* 空の状態 */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: #B8B6B0; margin-bottom: 8px; }

/* 読み込み中（スケルトン） */
.skeleton { background: linear-gradient(90deg, #EFEEE9 25%, #F6F5F1 37%, #EFEEE9 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 2段組（パートナーのリード詳細） */
.split { display: grid; gap: 24px; }
.split > * { min-width: 0; } /* 中の長い文字で枠ごと広がらないように */
@media (min-width: 960px) { .split { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } }
.kv { display: grid; grid-template-columns: 8em minmax(0, 1fr); gap: 10px 16px; font-size: var(--fs-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } /* 長いメールアドレス・URLも折り返す */
.timeline { list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); }
.timeline li { padding: 8px 0 8px 18px; position: relative; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--main); }
