/* AICX ホワイトペーパーUX
 *
 * 見た目の正は三宮さん提供のプロトタイプ（ref/AICXな初期診断.html）。
 * 変数・数値はプロトタイプの最終 :root と実際のルールから写している。
 * 迷ったときの参照先は aicx.jp。
 *
 * この意匠の要点（崩さないこと）:
 * - 白。背景に色を敷かない。カードは角丸ゼロ・1px の細い罫・影なし
 * - 見出しは大きく、字間を詰める（letter-spacing はマイナス）。太らせない
 * - 差し色は金（--gold）1色。いま選ばれているものだけが金になる
 * - ラベルは小さく、字間を開ける（01 / YOUR CONTEXT）
 *
 * スマートフォン優先で書く。幅が広がったときだけ @media で足す。
 */

:root {
  --paper: #ffffff;
  --ink: #1d2a44;
  --navy: #192a46;
  --muted: #6f7887;
  --text: #3f4a57;
  --line: #dfe3e8;
  --line2: #d5dae1;
  --blue: #315fae;
  --gold: #d4b65e;
  --gold-deep: #9b8343;
  --success: #2b7b61;
  --red: #a05c62;
  --soft: #f6f7f9;
  --mist: #f2f4f7;
  --ivory: #fbfaf7;

  /* 日本語フォントを明示列挙する。sans-serif だけだと環境によって中国語字形に落ちる */
  --font: "Helvetica Neue", "Avenir Next", Arial, "Hiragino Sans",
          "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;

  --pad: 16px;
  --dock: 58px;
  --header: 58px;
}

* { box-sizing: border-box; }

html { background: var(--paper); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.78;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
}

svg text { font-family: inherit; }

a { color: var(--blue); }

button, .btn, select, input, textarea, summary { font-family: inherit; }

:focus-visible { outline: 2px solid #3a79d8; outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 土台 ───────────────────────────────────────────── */

.wp-header {
  position: sticky; top: 0; z-index: 120;
  height: var(--header);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--pad);
  background: #fff;
  border-bottom: 1px solid #e2e5ea;
}

.wp-brand { display: flex; flex-direction: column; justify-content: center; min-width: 0; line-height: 1.2; }
.wp-brand-main { font-size: 17px; font-weight: 700; color: var(--navy); letter-spacing: -.01em; white-space: nowrap; }
.wp-brand-sub {
  font-size: 8px; color: #8b939f; letter-spacing: .12em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wp-header .spacer { flex: 1; }

.wp-main { padding: 0 var(--pad) calc(var(--dock) + 32px); max-width: 1180px; margin: 0 auto; }

.wp-footer {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding: 20px var(--pad) calc(var(--dock) + 20px);
  color: var(--muted); font-size: 11px; letter-spacing: .04em;
}

/* ── 部品 ───────────────────────────────────────────── */

/* カードは角丸ゼロ・影なしの細い罫。プロトタイプの .panel と同じ */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 16px 14px 14px;
  margin: 12px 0;
}

/* ファーストビューの2枚だけは、白地から浮かせるために淡い影を持つ */
.panel.raised { box-shadow: 0 20px 52px rgba(23, 43, 68, .07); }

/* 「01 / YOUR CONTEXT」のような小さい通し番号ラベル */
.kicker {
  font-size: 9px; font-weight: 900; letter-spacing: .11em;
  color: var(--gold-deep); text-transform: none;
}

.panel-head { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; }
.panel-head h2 {
  margin: 0; color: var(--navy); font-size: 15px; font-weight: 700;
  letter-spacing: -.025em; line-height: 1.45;
}
.panel-head small { grid-column: 2; font-size: 10.5px; color: #84909c; letter-spacing: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 9px 18px; border-radius: 999px;
  border: 1px solid var(--line2); background: #fff; color: #55606e;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #b9c1cc; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

/* 帯状の主行動（プロトタイプの「このアジェンダで読む ↓」） */
.cta {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 46px; margin-top: 12px;
  background: var(--navy); color: #fff; border: 0; border-radius: 0;
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  cursor: pointer; text-decoration: none;
}

.live {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--success); color: #fff;
  font-size: 9px; font-weight: 900; letter-spacing: .12em;
}

.lead { font-size: 13.5px; color: var(--text); margin: 8px 0 0; }
.note { font-size: 11.5px; color: var(--muted); letter-spacing: 0; line-height: 1.75; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 10px; padding: 4px 10px; border-radius: 999px;
  background: var(--mist); color: #5b6675; border: 1px solid var(--line);
  letter-spacing: .02em;
}

.placeholder-bar {
  margin: 14px 0 0; padding: 9px 12px;
  background: var(--ivory); border-left: 2px solid var(--gold);
  color: #7d6a33; font-size: 11.5px; line-height: 1.7;
}

.error { color: var(--red); font-size: 12.5px; margin: 10px 0 0; }

/* ── ログイン ───────────────────────────────────────── */

.gate { max-width: 460px; margin: 0 auto; padding-top: 26px; }
.gate h1 {
  color: var(--navy); font-size: 30px; font-weight: 450;
  line-height: 1.14; letter-spacing: -.04em; margin: 8px 0 0;
}
.gate h1 em { font-style: normal; color: var(--blue); }

.field { display: block; margin: 14px 0 0; }
.field > span { display: block; font-size: 10.5px; font-weight: 700; color: var(--navy); letter-spacing: .04em; margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; font-size: 16px; /* iOS の自動ズーム回避に 16px 以上 */
  border: 1px solid var(--line2); border-radius: 2px; background: #fff; color: var(--ink);
}
.field input.code {
  font-size: 26px; letter-spacing: .48em; text-align: center;
  font-variant-numeric: tabular-nums; padding-left: .48em; font-weight: 700; color: var(--navy);
}

.steps { display: flex; gap: 5px; margin: 0 0 10px; }
.steps i { flex: 1; height: 2px; background: var(--line2); display: block; }
.steps i.on { background: var(--gold); }

/* ── ファーストビュー ───────────────────────────────── */

/* 巨大なゴースト文字はプロトタイプ最大の見どころなので落とさない */
.hero { position: relative; overflow: hidden; padding: 42px 0 6px; }
.hero.stamped:before {
  content: "AICX\A LIVING";
  white-space: pre; position: absolute; right: -3%; top: 0;
  font-size: clamp(58px, 17vw, 142px); line-height: .78; font-weight: 400;
  color: #f2f3f5; letter-spacing: -.03em; z-index: 0; pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.hero-kicker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-kicker .k { font-size: 9.5px; font-weight: 900; letter-spacing: .16em; color: var(--gold-deep); }

.hero h1 {
  color: var(--navy); font-weight: 450;
  font-size: clamp(28px, 8vw, 72px); line-height: 1.1; letter-spacing: -.045em;
  margin: 10px 0 10px; max-width: 690px;
}
.hero h1 em { font-style: normal; color: var(--blue); }
.hero p { margin: 0; color: var(--text); font-size: 13px; max-width: 620px; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 12px; }

.select-field > span { display: block; font-size: 10px; font-weight: 700; color: var(--navy); letter-spacing: .03em; margin-bottom: 4px; }
.select-field select {
  width: 100%; padding: 9px 10px; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line2); border-radius: 2px; background: #fff;
}

.depth-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.depth-row > span { font-size: 10px; font-weight: 700; color: var(--navy); letter-spacing: .03em; }
.depth { display: flex; gap: 6px; }
.depth button {
  min-height: 30px; padding: 5px 13px; border-radius: 999px;
  border: 1px solid var(--line2); background: #fff;
  font-size: 11px; font-weight: 800; color: #6f7885; cursor: pointer;
}
.depth button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #fff; }

/* ── あなた専用アジェンダ ───────────────────────────── */

/* 番号は金、見出しは紺。項目のあいだは罫で区切る */
.agenda { display: grid; grid-template-columns: 1fr; margin-top: 12px; }
.agenda-item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line);
  padding: 12px 2px 13px;
}
.agenda-item:first-child { border-top: 0; }
.agenda-item .no {
  display: block; font-size: 11px; font-weight: 900; color: var(--gold-deep);
  letter-spacing: .1em; font-variant-numeric: tabular-nums;
}
.agenda-item .t { display: block; font-size: 14px; font-weight: 700; color: var(--navy); line-height: 1.5; margin-top: 3px; }
.agenda-item .d {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  font-size: 11.5px; color: var(--muted); line-height: 1.7; margin-top: 3px;
}

@keyframes reflow { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.agenda.reflow .agenda-item { animation: reflow .26s ease both; }
.agenda.reflow .agenda-item:nth-child(2) { animation-delay: .04s; }
.agenda.reflow .agenda-item:nth-child(3) { animation-delay: .08s; }
.agenda.reflow .agenda-item:nth-child(4) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) { .agenda.reflow .agenda-item { animation: none; } }

/* 並べ替えの理由。プロトタイプは LIVE バッジ＋一文 */
.why-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; }
.why { font-size: 11.5px; line-height: 1.75; color: var(--text); letter-spacing: 0; }

/* ── 本文 ───────────────────────────────────────────── */

.node { scroll-margin-top: calc(var(--header) + 34px); border-top: 1px solid var(--line); padding: 26px 0 22px; margin: 0; }
.node .kicker { display: block; }
.node > h2 {
  color: var(--navy); font-size: clamp(21px, 5.4vw, 34px); font-weight: 450;
  line-height: 1.24; letter-spacing: -.035em; margin: 6px 0 0;
}
.node .point { margin: 10px 0 0; font-size: 14px; color: var(--text); max-width: 720px; }

.body-blocks { margin-top: 4px; max-width: 760px; }
.body-blocks h3 {
  font-size: 13.5px; font-weight: 700; color: var(--navy);
  margin: 22px 0 0; letter-spacing: -.01em; line-height: 1.6;
}
.body-blocks h3:before { content: "— "; color: var(--gold); }
.body-blocks p { margin: 8px 0 0; color: var(--text); }
.body-blocks ul { margin: 8px 0 0; padding-left: 1.1em; color: var(--text); }
.body-blocks li { margin-top: 3px; }

.table-scroll { overflow-x: auto; margin-top: 14px; -webkit-overflow-scrolling: touch; }
.body-blocks table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.body-blocks th, .body-blocks td {
  border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; line-height: 1.7;
}
.body-blocks th { background: var(--mist); font-weight: 700; color: var(--navy); white-space: nowrap; }

.node-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.source { margin-top: 14px; font-size: 10.5px; color: #8b939f; letter-spacing: .02em; }

.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 18px; background: var(--line); border: 1px solid var(--line); }
.prevnext a { background: #fff; padding: 10px 12px; text-decoration: none; color: var(--navy); font-size: 12px; line-height: 1.5; }
.prevnext a .dir { display: block; font-size: 9px; color: var(--gold-deep); font-weight: 900; letter-spacing: .1em; }
.prevnext a.next { text-align: right; }
.prevnext a.empty { visibility: hidden; }

/* ── 現在地・ドック ─────────────────────────────────── */

.wayfinding {
  position: sticky; top: var(--header); z-index: 100;
  display: flex; align-items: center; gap: 10px;
  padding: 7px var(--pad); margin: 0 calc(var(--pad) * -1);
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
  font-size: 10px; color: var(--muted); letter-spacing: .06em;
}
.wayfinding .now { color: var(--navy); font-weight: 700; letter-spacing: 0; }
.wayfinding .progress { flex: 1; height: 1px; background: var(--line2); }
.wayfinding .progress i { display: block; height: 100%; background: var(--gold); }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 130;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.dock a, .dock button {
  flex: 1; border: 0; background: none; padding: 9px 2px; cursor: pointer;
  font-size: 9.5px; letter-spacing: .06em; color: var(--muted); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.dock .mark { font-size: 11px; line-height: 1; }
.dock [aria-current="page"] { color: var(--navy); font-weight: 800; }
.dock [aria-current="page"] .mark { color: var(--gold); }

/* ── AI 対話 ────────────────────────────────────────── */

.ai-dialog { position: fixed; inset: 0; z-index: 200; display: none; background: rgba(25, 42, 70, .42); }
.ai-dialog[open] { display: flex; align-items: flex-end; justify-content: center; }

.ai-panel { display: flex; flex-direction: column; width: 100%; height: 100%; background: #fff; overflow: hidden; }

.ai-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ai-head .topic { font-size: 14px; font-weight: 700; color: var(--navy); line-height: 1.4; letter-spacing: -.02em; }
.ai-head .who { font-size: 9.5px; color: var(--muted); margin-top: 2px; letter-spacing: .04em; }
.ai-head .close {
  margin-left: auto; border: 1px solid var(--line2); background: #fff; border-radius: 999px;
  min-height: 34px; padding: 6px 13px; font-size: 11px; font-weight: 700; color: #55606e; cursor: pointer;
}

.ai-log { flex: 1; overflow-y: auto; padding: 16px 14px; -webkit-overflow-scrolling: touch; }

.msg { margin-bottom: 14px; }
.msg .bubble { display: inline-block; max-width: 100%; padding: 11px 13px; font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; }
.msg.me { text-align: right; }
.msg.me .bubble { background: var(--navy); color: #fff; text-align: left; }
.msg.ai .bubble { background: var(--soft); border-left: 2px solid var(--gold); color: var(--text); }
.msg .sources { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.msg .sources button {
  font-size: 10.5px; padding: 5px 11px; border-radius: 999px; min-height: 30px;
  border: 1px solid var(--line2); background: #fff; cursor: pointer; color: var(--blue);
}

.thinking { color: var(--muted); font-size: 12.5px; }
.thinking i { font-style: normal; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.ai-foot { border-top: 1px solid var(--line); padding: 10px 12px; background: #fff; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.quick button {
  white-space: nowrap; font-size: 11px; padding: 6px 12px; border-radius: 999px; min-height: 32px;
  border: 1px solid var(--line2); background: #fff; color: #55606e; cursor: pointer;
}
.ai-form { display: flex; gap: 8px; align-items: flex-end; }
.ai-form textarea {
  flex: 1; resize: none; border: 1px solid var(--line2); border-radius: 2px;
  padding: 9px 11px; font-size: 16px; line-height: 1.6; max-height: 120px;
}

/* ── 成果物 ─────────────────────────────────────────── */

.kind-grid { display: grid; grid-template-columns: 1fr; margin-top: 10px; border-top: 1px solid var(--line); }
.kind {
  text-align: left; padding: 13px 2px; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--line); background: none;
  display: flex; flex-direction: column; gap: 2px;
}
.kind .name { font-size: 14px; font-weight: 700; color: var(--navy); }
.kind .desc { font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.kind[aria-pressed="true"] { background: var(--ivory); box-shadow: inset 2px 0 0 var(--gold); padding-left: 12px; }

.artifact > h2 { color: var(--navy); font-size: 20px; font-weight: 450; letter-spacing: -.03em; margin: 6px 0 0; line-height: 1.35; }
.artifact h3 { font-size: 11px; font-weight: 900; color: var(--gold-deep); letter-spacing: .1em; margin: 18px 0 0; }
.artifact p { margin: 6px 0 0; color: var(--text); font-size: 13.5px; }
.artifact ul { margin: 6px 0 0; padding-left: 1.1em; color: var(--text); font-size: 13.5px; }
.artifact li { margin-top: 3px; }

/* ── 持ち帰り ───────────────────────────────────────── */

.brief-item { padding: 14px 0; border-top: 1px solid var(--line); }
.brief-item:first-child { border-top: 0; }
.brief-item .k { font-size: 9.5px; font-weight: 900; letter-spacing: .12em; color: var(--gold-deep); }
.brief-item h3 { font-size: 14px; font-weight: 700; color: var(--navy); margin: 3px 0 0; line-height: 1.5; }
.brief-item p { font-size: 12.5px; color: var(--text); margin: 5px 0 0; }
.brief-empty { text-align: center; color: var(--muted); font-size: 12.5px; padding: 28px 0; }

/* ── 幅が広いとき ───────────────────────────────────── */

@media (min-width: 700px) {
  :root { --pad: 34px; --header: 70px; }
  body { font-size: 15.5px; }

  /* 紙面の左右に細い罫を落とす（プロトタイプの署名的な意匠） */
  body:before {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
    background: linear-gradient(90deg, transparent 0 7%, rgba(25, 42, 70, .018) 7% 7.08%,
                transparent 7.08% 92.92%, rgba(25, 42, 70, .018) 92.92% 93%, transparent 93%);
  }

  .wp-brand-main { font-size: 20px; }
  .wp-main { padding-bottom: 40px; }
  .wp-footer { padding-bottom: 24px; }
  .dock { display: none; }

  .hero { padding: 46px 0 10px; }
  .hero p { font-size: 14px; }
  .panel { padding: 22px 24px 20px; margin: 16px 0; }
  .panel-head h2 { font-size: 22px; }
  .profile-grid { grid-template-columns: repeat(4, 1fr); }

  .agenda { grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
  .agenda-item { border-top: 0; border-left: 1px solid var(--line); padding: 16px 16px 18px; }
  .agenda-item:first-child { border-left: 0; }
  .agenda-item .d { -webkit-line-clamp: 3; }

  .node { padding: 46px 0 38px; }
  .node .point { font-size: 15px; }

  .kind-grid { grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-top: 1px solid var(--line); }
  .kind { border-bottom: 0; border-left: 1px solid var(--line); padding: 18px 16px; }
  .kind:first-child { border-left: 0; }
  .kind[aria-pressed="true"] { box-shadow: inset 0 2px 0 var(--gold); padding-left: 16px; }

  .ai-dialog[open] { align-items: center; }
  .ai-panel { width: min(1000px, calc(100vw - 64px)); height: min(82vh, 780px); border: 1px solid var(--line); }

  .gate h1 { font-size: 38px; }
}

/* ファーストビューを2段組にする（左に見出し・右に操作） */
@media (min-width: 1000px) {
  .firstview {
    position: relative; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 44px; align-items: center;
    min-height: min(calc(100svh - var(--header)), 820px);
  }
  /* ゴースト文字は帯そのものが持つ（左カラムに置くと見出しへ重なる） */
  .firstview:before {
    content: "AICX\A LIVING";
    white-space: pre; position: absolute; right: 0; top: 0;
    font-size: clamp(74px, 7vw, 116px); line-height: .8; font-weight: 400;
    color: #f2f3f5; letter-spacing: -.03em; z-index: 0; pointer-events: none;
  }
  .firstview > * { position: relative; z-index: 1; }
  .firstview .hero.stamped:before { display: none; }
  .firstview .hero { padding: 24px 0; }
  .firstview-panels { padding: 24px 0; }
  .firstview-panels .panel:first-child { margin-top: 0; }
}
