/* ============================================================
   AIQs リニューアル案 — 「夜明けの祭壇 / Calm Mystic」
   現行 v14 の dark-violet minimal を"本物の紫＋奥行き＋階層"へ。
   神秘性は背景の空気に。操作は静かで信頼できる大手プロダクト感。
   ※ 提案プロトタイプ。hermes-ops 原本は不変。
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #0a0712;
  --surface: rgba(140, 110, 220, 0.06);
  --surface-solid: #160f29;
  --surface-2: rgba(150, 120, 230, 0.11);
  --line: rgba(178, 150, 255, 0.14);
  --line-strong: rgba(178, 150, 255, 0.30);
  --text: #f4f0ff;
  --muted: #a89ece;
  --soft: #d8d2f0;
  --accent: #b78cff;
  --accent-2: #ff8fe0;
  --accent-3: #74c8ff;
  --warm: #e9c87a;
  --green: #86e0b0;
  --focus: #a9c7ff;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 26px;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 10px 34px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 20px 56px rgba(0, 0, 0, 0.6);
  --glow: 0 10px 36px rgba(150, 90, 255, 0.4);
  --font: "Zen Kaku Gothic New", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  --font-serif: "Shippori Mincho", "Zen Kaku Gothic New", serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

/* ── 背景の空気感（神秘性はここに沈める・控えめ） ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 18% 8%, rgba(123, 92, 255, 0.20), transparent 60%),
    radial-gradient(50% 42% at 88% 14%, rgba(116, 200, 255, 0.12), transparent 60%),
    radial-gradient(70% 60% at 50% 108%, rgba(255, 143, 224, 0.14), transparent 60%),
    linear-gradient(170deg, #120a26 0%, #0a0712 46%, #0c0a1a 100%);
  background-size: 180% 180%, 180% 180%, 180% 180%, 100% 100%;
  animation: drift 30s ease-in-out infinite;
}
@keyframes drift {
  0%, 100% { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
  50% { background-position: 100% 40%, 0% 60%, 50% 0%, 0 0; }
}

button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--focus) 80%, transparent); outline-offset: 3px; }

.app { min-height: 100dvh; }
.rail { display: none; }

/* インタラクション共通 */
.icon-btn, .route-chip, .primary-action, .secondary-action,
.home-strip button, .choice-stack button, .list-panel button,
.visual-select, .image-picker, .segmented button, .counter button,
.bottom-nav button {
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 140ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}
.primary-action:active, .secondary-action:active,
.home-strip button:active, .choice-stack button:active, .list-panel button:active,
.visual-select:active, .image-picker:active, .segmented button:active,
.counter button:active, .icon-btn:active, .route-chip:active { transform: scale(0.985); }

/* ── シェル（スマホアプリの幅で中央寄せ） ── */
.shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 22px clamp(18px, 5vw, 26px) 124px;
}

/* ── トップバー ── */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.identity strong {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(100deg, #fff, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.route-chip {
  justify-self: start;
  min-height: 30px;
  max-width: 100%;
  padding: 0 12px;
  border-color: var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-actions { display: flex; gap: 9px; }
.icon-btn {
  position: relative;
  display: grid;
  width: 44px; height: 44px;
  place-items: center;
  border-color: var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--soft);
  backdrop-filter: blur(10px);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.icon-btn svg { width: 20px; height: 20px; stroke-width: 1.7; }
.badge-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 0 2px var(--bg), 0 0 10px var(--accent-2);
}

/* ── ページ ── */
.page { display: none; animation: page-in 240ms ease both; }
.page.active { display: grid; gap: 16px; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: grid; gap: 6px; margin-bottom: 2px; }
.page-head span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}
.page-head h1, .hero-card h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(26px, 5.6vw, 40px);
  font-weight: 600;
  line-height: 1.18;
  color: var(--text);
}

/* ── ヒーローカード（受付済み・完了など） ── */
.hero-card {
  display: grid;
  min-height: 224px;
  place-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(183, 140, 255, 0.14), transparent 60%),
    var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.hero-card.small-ok { min-height: 200px; }
.hero-card p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.hero-card svg, .visual-select svg {
  width: 52px; height: 52px; margin-bottom: 14px;
  color: var(--accent);
  stroke-width: 1.5;
  filter: drop-shadow(0 4px 14px rgba(183, 140, 255, 0.5));
}

/* ── 主操作 / 副操作 ── */
.primary-action, .secondary-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px;
  padding: 0 22px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.primary-action {
  border: none;
  color: #1a0b2e;
  background: linear-gradient(120deg, var(--accent), var(--accent-2) 70%, #ffb0c8);
  box-shadow: var(--glow);
}
.primary-action:hover { transform: translateY(-2px); box-shadow: 0 16px 44px rgba(170, 110, 255, 0.5); }
.primary-action svg { width: 19px; height: 19px; stroke-width: 2.2; }
.secondary-action {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
  backdrop-filter: blur(10px);
}
.secondary-action:hover { background: var(--surface-2); }
.split-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ── ホーム（コマンド） ── */
.home-command {
  display: grid;
  gap: 20px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(70% 80% at 100% 0%, rgba(255, 143, 224, 0.16), transparent 55%),
    radial-gradient(60% 70% at 0% 100%, rgba(116, 200, 255, 0.12), transparent 55%),
    var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-2);
}
.command-state { display: grid; gap: 4px; }
.command-state span {
  font-size: 11px; font-weight: 700; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--green);
}
.command-state h1 {
  margin: 2px 0; font-family: var(--font-serif);
  font-size: clamp(34px, 9vw, 52px); font-weight: 700; line-height: 1;
  background: linear-gradient(100deg, #fff, var(--accent) 70%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.command-state p { margin: 0; color: var(--warm); font-weight: 600; font-size: 14px; }
.home-command .primary-action { width: 100%; min-height: 60px; font-size: 17px; }

/* ── リスト系（ホーム・選択・一覧） ── */
.home-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-stack, .list-panel { display: grid; gap: 10px; }

.home-strip button, .choice-stack button, .list-panel button {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 72px;
  padding: 0 16px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--text);
  text-align: left;
  font-weight: 500;
  font-size: 15px;
  box-shadow: var(--shadow-1);
}
.home-strip button:hover, .choice-stack button:hover, .list-panel button:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  transform: translateY(-2px);
}
/* アイコンをアクセントの角丸タイルに */
.home-strip button svg, .choice-stack button svg, .list-panel button svg {
  width: 42px; height: 42px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(183, 140, 255, 0.13);
  color: var(--accent);
  stroke-width: 1.7;
}
/* 右端のシェブロン（押せる手がかり） */
.home-strip button::after, .choice-stack button::after, .list-panel button::after {
  content: "›";
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  justify-self: end;
}
.home-strip button > span, .choice-stack button > span, .list-panel button > span { min-width: 0; }
/* ホームの件数バッジ（シェブロンの手前） */
.home-strip b {
  grid-column: 3;
  display: grid; place-items: center;
  min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  color: #1a0b2e; font-size: 12px; font-weight: 700;
}
.home-strip button:has(b)::after { content: ""; }

.list-panel.result button:first-child { border-color: var(--line-strong); }

/* ── ビジュアル選択（ターゲット） ── */
.visual-select {
  display: grid;
  min-height: 248px;
  place-items: center;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  text-align: center;
}
.visual-select strong { font-family: var(--font-serif); font-size: clamp(28px, 7vw, 48px); font-weight: 600; line-height: 1; }
.visual-select span { margin-top: 10px; color: var(--muted); font-size: 14px; }
.visual-select.selected {
  border-style: solid;
  border-color: color-mix(in srgb, var(--green) 55%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--green) 30%, transparent), 0 14px 40px rgba(134, 224, 176, 0.18);
}
.visual-select.selected svg { color: var(--green); filter: drop-shadow(0 4px 14px rgba(134, 224, 176, 0.5)); }

/* ── フォーム / 要約 / 記録 / 残高カード ── */
.form-card, .summary-card, .record-card, .balance-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
}
.form-card label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.form-card input, .form-card textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 7, 18, 0.5);
  color: var(--text);
  font-size: 15px;
}
.form-card input:focus, .form-card textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: rgba(10, 7, 18, 0.7);
}
.form-card textarea { min-height: 96px; resize: vertical; line-height: 1.6; }

.image-picker {
  display: grid; place-items: center; gap: 8px;
  min-height: 132px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(10, 7, 18, 0.4);
  color: var(--muted);
}
.image-picker svg { width: 30px; height: 30px; color: var(--accent); stroke-width: 1.6; }
.image-picker:hover { background: var(--surface-2); color: var(--text); }

/* 要約・記録・残高 */
.summary-card { grid-template-columns: 1fr auto; align-items: center; gap: 8px 16px; }
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card strong { font-size: 16px; font-weight: 600; text-align: right; }
.record-card { grid-template-columns: 44px 1fr auto; align-items: center; }
.record-card svg { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: rgba(183, 140, 255, 0.13); color: var(--accent); }
.record-card strong { font-size: 16px; font-weight: 600; }
.record-card span { color: var(--muted); font-size: 13px; }
.balance-card { place-items: center; text-align: center; gap: 4px; padding: 32px 20px; }
.balance-card strong {
  font-family: var(--font-serif); font-size: clamp(46px, 13vw, 72px); font-weight: 700; line-height: 1;
  background: linear-gradient(120deg, var(--warm), #fff 70%, var(--warm));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.balance-card span { color: var(--muted); letter-spacing: 0.2em; text-transform: uppercase; font-size: 12px; }

/* ── セグメント / カウンター ── */
.segmented { display: grid; grid-auto-flow: column; gap: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 999px; background: rgba(10, 7, 18, 0.5); }
.segmented button { min-height: 40px; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.segmented button.active { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #1a0b2e; }

.counter { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 14px; justify-items: center; padding: 8px 0; }
.counter button { width: 56px; height: 56px; border-radius: 16px; border-color: var(--line-strong); background: var(--surface); color: var(--text); font-size: 26px; font-weight: 600; }
.counter button:hover { background: var(--surface-2); }
.counter strong { font-family: var(--font-serif); font-size: 44px; font-weight: 700; }

/* ── ボトムナビ（浮遊ガラスバー） ── */
.bottom-nav {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 448px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(18, 12, 34, 0.72);
  backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: var(--shadow-2);
  z-index: 20;
}
.bottom-nav button {
  display: grid; place-items: center; gap: 3px;
  min-height: 54px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.bottom-nav button svg { width: 21px; height: 21px; stroke-width: 1.8; }
.bottom-nav button:hover { background: var(--surface-2); color: var(--text); }
.bottom-nav button.active { color: var(--accent); background: rgba(183, 140, 255, 0.12); }
.bottom-nav button:disabled { opacity: 0.34; pointer-events: none; }

/* ── トースト（/wiki 等の遷移通知） ── */
.toast {
  position: fixed;
  left: 50%; bottom: 92px;
  transform: translateX(-50%);
  padding: 11px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(18, 12, 34, 0.92);
  backdrop-filter: blur(16px);
  color: var(--soft);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  z-index: 40;
  animation: page-in 200ms ease both;
}
