/* ============================================================
   AIQs リニューアル案 v2 — 「夜明けの祭壇 / AURORA」
   Aceternity 級の製品エフェクトを移植：動くオーロラ背景 / カーソル追従
   スポットライト / 回る光の枠線(border-beam) / 流星 / グレイン / グラス。
   タップ構造（main.js / data-state）は不変。
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #060410;
  --ink: #f6f2ff;
  --muted: #a99fcf;
  --soft: #d9d3f2;
  --violet: #b78cff;
  --pink: #ff8fe0;
  --blue: #74c8ff;
  --teal: #6ff0d0;
  --warm: #f0cd83;
  --green: #86e0b0;
  --line: rgba(184, 156, 255, 0.16);
  --line-2: rgba(184, 156, 255, 0.32);
  --glass: rgba(122, 92, 200, 0.07);
  --glass-2: rgba(150, 120, 230, 0.12);
  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 26px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 20px 60px rgba(0, 0, 0, 0.55);
  --glow-violet: 0 0 40px rgba(150, 90, 255, 0.45);
  --font: "Zen Kaku Gothic New", ui-sans-serif, -apple-system, "Segoe UI", "Noto Sans JP", sans-serif;
  --serif: "Shippori Mincho", "Zen Kaku Gothic New", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--blue) 80%, transparent); outline-offset: 3px; }

/* ════════ エフェクト層（全画面・操作透過） ════════ */
.fx-aurora, .fx-grain, .fx-spotlight, .fx-meteors {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
/* 動くオーロラ */
.fx-aurora {
  background:
    radial-gradient(38% 44% at 16% 12%, rgba(123, 92, 255, 0.42), transparent 60%),
    radial-gradient(34% 40% at 84% 18%, rgba(116, 200, 255, 0.32), transparent 60%),
    radial-gradient(44% 50% at 70% 88%, rgba(255, 143, 224, 0.34), transparent 60%),
    radial-gradient(40% 46% at 30% 80%, rgba(111, 240, 208, 0.22), transparent 60%),
    linear-gradient(180deg, #0c0722, #060410 60%);
  filter: saturate(1.15) blur(8px);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%, 100% 100%;
  animation: aurora 26s ease-in-out infinite;
}
@keyframes aurora {
  0%, 100% { background-position: 0% 0%, 100% 0%, 70% 100%, 30% 80%, 0 0; }
  50% { background-position: 60% 40%, 30% 60%, 40% 70%, 70% 40%, 0 0; }
}
/* カーソル追従スポットライト */
.fx-spotlight {
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 12%), rgba(183, 140, 255, 0.18), transparent 60%);
  transition: background 120ms linear;
  z-index: 1;
}
/* フィルムグレイン（質感） */
.fx-grain {
  z-index: 2;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* 流星 */
.fx-meteors { z-index: 1; overflow: hidden; }
.meteor {
  position: absolute;
  top: -10%;
  width: 2px; height: 2px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 8px 1px rgba(183, 140, 255, 0.7);
}
.meteor::after {
  content: "";
  position: absolute;
  top: 50%; left: 0;
  width: 120px; height: 1px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, rgba(183, 140, 255, 0.7), transparent);
}
@keyframes meteor-fall {
  0% { transform: translate(0, 0) rotate(215deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(-340px, 340px) rotate(215deg); opacity: 0; }
}

.app { position: relative; z-index: 3; 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 200ms ease, border-color 200ms ease, box-shadow 240ms ease, color 160ms ease;
}
.primary-action:active, .secondary-action:active, .home-strip button:active,
.choice-stack button:active, .list-panel button:active, .visual-select:active,
.icon-btn:active, .segmented button:active, .counter button:active { transform: scale(0.985); }

/* ════════ シェル / トップバー ════════ */
.shell { width: min(100%, 480px); margin: 0 auto; padding: 22px clamp(18px, 5vw, 26px) 128px; }
.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(--serif); font-size: 23px; font-weight: 700; letter-spacing: 0.06em;
  background: linear-gradient(100deg, #fff, var(--violet) 55%, var(--pink));
  -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(--glass);
  backdrop-filter: blur(10px); color: var(--muted); font-size: 12px; font-weight: 600;
  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(--glass);
  backdrop-filter: blur(10px); color: var(--soft);
}
.icon-btn:hover { background: var(--glass-2); border-color: var(--line-2); box-shadow: 0 0 22px rgba(183, 140, 255, 0.25); }
.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(--pink); box-shadow: 0 0 0 2px var(--bg), 0 0 10px var(--pink);
}

/* ════════ ページ ════════ */
.page { display: none; animation: page-in 280ms cubic-bezier(.2,.7,.2,1) both; }
.page.active { display: grid; gap: 16px; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.page-head { display: grid; gap: 6px; }
.page-head span { color: var(--violet); font-size: 11px; font-weight: 700; letter-spacing: 0.26em; text-transform: uppercase; }
.page-head h1, .hero-card h1 {
  margin: 0; font-family: var(--serif); font-size: clamp(26px, 5.6vw, 40px);
  font-weight: 600; line-height: 1.18; color: var(--ink);
}

/* ════════ border-beam（回る光の枠線）共通 ════════ */
.beam { position: relative; }
.beam::before {
  content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit;
  background: conic-gradient(from var(--a, 0deg), transparent 0%, var(--violet) 18%, var(--pink) 30%, transparent 42%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
  animation: beam-rot 6s linear infinite;
}
@keyframes beam-rot { to { --a: 360deg; } }
@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }

/* ════════ ホーム（コマンド） ════════ */
.home-command {
  position: relative; display: grid; gap: 20px; padding: 30px 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.14), transparent 55%),
    var(--glass);
  backdrop-filter: blur(16px); box-shadow: var(--shadow); overflow: hidden;
}
.home-command::before {
  content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit;
  background: conic-gradient(from var(--a, 0deg), transparent 0 60%, var(--violet) 72%, var(--pink) 82%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
  animation: beam-rot 7s linear infinite;
}
.command-state { display: grid; gap: 4px; position: relative; }
.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(--serif); font-size: clamp(36px, 10vw, 56px); font-weight: 700; line-height: 1;
  background: linear-gradient(100deg, #fff, var(--violet) 65%, var(--pink));
  -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; }

/* ════════ 主操作 / 副操作 ════════ */
.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;
}
.primary-action {
  position: relative; overflow: hidden; border: none; color: #1a0b2e;
  background: linear-gradient(120deg, var(--violet), var(--pink) 60%, #ffb6cd);
  box-shadow: var(--glow-violet);
}
.primary-action::after { /* シマー（光の走り） */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%); animation: shimmer 3.6s ease-in-out infinite;
}
@keyframes shimmer { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.primary-action:hover { transform: translateY(-2px); box-shadow: 0 18px 50px rgba(170, 110, 255, 0.5); }
.primary-action svg { width: 19px; height: 19px; stroke-width: 2.2; position: relative; }
.secondary-action { border-color: var(--line-2); background: var(--glass); color: var(--ink); backdrop-filter: blur(10px); }
.secondary-action:hover { background: var(--glass-2); }
.split-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ════════ リスト系（ホーム/選択/一覧） ════════ */
.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(--glass);
  backdrop-filter: blur(10px); color: var(--ink); text-align: left; font-weight: 500; font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); overflow: hidden;
}
.home-strip button:hover, .choice-stack button:hover, .list-panel button:hover {
  background: var(--glass-2); border-color: var(--line-2); transform: translateY(-2px);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.4), 0 0 26px rgba(183, 140, 255, 0.22);
}
.home-strip button svg, .choice-stack button svg, .list-panel button svg {
  width: 42px; height: 42px; padding: 10px; border-radius: 12px;
  background: linear-gradient(140deg, rgba(183, 140, 255, 0.2), rgba(255, 143, 224, 0.12));
  color: var(--violet); 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 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(--pink), var(--violet));
  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-2); box-shadow: 0 0 26px rgba(183, 140, 255, 0.22); }

/* ════════ ビジュアル選択 ════════ */
.visual-select {
  display: grid; min-height: 248px; place-items: center; padding: 28px;
  border: 1px dashed var(--line-2); border-radius: var(--radius-lg);
  background: var(--glass); backdrop-filter: blur(12px); color: var(--ink); text-align: center;
}
.visual-select strong { font-family: var(--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 0 40px rgba(134, 224, 176, 0.22);
}
.visual-select svg { width: 52px; height: 52px; margin-bottom: 14px; color: var(--violet); stroke-width: 1.5; filter: drop-shadow(0 4px 16px rgba(183, 140, 255, 0.55)); }
.visual-select.selected svg { color: var(--green); filter: drop-shadow(0 4px 16px rgba(134, 224, 176, 0.6)); }

/* ════════ ヒーローカード ════════ */
.hero-card {
  position: relative; display: grid; min-height: 224px; place-items: center; padding: 28px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: radial-gradient(80% 60% at 50% 0%, rgba(183, 140, 255, 0.16), transparent 60%), var(--glass);
  backdrop-filter: blur(14px); box-shadow: var(--shadow); 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 { width: 54px; height: 54px; margin-bottom: 14px; color: var(--violet); stroke-width: 1.5; filter: drop-shadow(0 6px 20px rgba(183, 140, 255, 0.6)); }

/* ════════ フォーム / カード ════════ */
.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(--glass); backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.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(6, 4, 16, 0.55); color: var(--ink); font-size: 15px;
}
.form-card input:focus, .form-card textarea:focus { border-color: color-mix(in srgb, var(--violet) 60%, transparent); background: rgba(6, 4, 16, 0.75); box-shadow: 0 0 0 3px rgba(183, 140, 255, 0.15); }
.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-2); border-radius: var(--radius-sm); background: rgba(6, 4, 16, 0.4); color: var(--muted);
}
.image-picker svg { width: 30px; height: 30px; color: var(--violet); stroke-width: 1.6; }
.image-picker:hover { background: var(--glass-2); color: var(--ink); }
.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: linear-gradient(140deg, rgba(183, 140, 255, 0.2), rgba(255, 143, 224, 0.12)); color: var(--violet); }
.record-card strong { font-size: 16px; font-weight: 600; }
.record-card span { color: var(--muted); font-size: 13px; }
.balance-card { position: relative; place-items: center; text-align: center; gap: 4px; padding: 34px 20px; overflow: hidden; }
.balance-card::before {
  content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit;
  background: conic-gradient(from var(--a, 0deg), transparent 0 65%, var(--warm) 78%, transparent 90%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; animation: beam-rot 8s linear infinite;
}
.balance-card strong {
  font-family: var(--serif); font-size: clamp(48px, 14vw, 76px); font-weight: 700; line-height: 1;
  background: linear-gradient(120deg, var(--warm), #fff 60%, 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(6, 4, 16, 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(--violet), var(--pink)); 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-2); background: var(--glass); color: var(--ink); font-size: 26px; font-weight: 600; }
.counter button:hover { background: var(--glass-2); box-shadow: 0 0 22px rgba(183, 140, 255, 0.25); }
.counter strong { font-family: var(--serif); font-size: 46px; font-weight: 700; }

/* ════════ ボトムナビ（浮遊ガラス） ════════ */
.bottom-nav {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30;
  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: 22px; background: rgba(14, 9, 28, 0.7);
  backdrop-filter: blur(22px) saturate(1.3); box-shadow: var(--shadow);
}
.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(--glass-2); color: var(--ink); }
.bottom-nav button.active { color: var(--violet); background: rgba(183, 140, 255, 0.14); box-shadow: 0 0 22px rgba(183, 140, 255, 0.3) inset; }
.bottom-nav button:disabled { opacity: 0.34; pointer-events: none; }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 40;
  padding: 11px 18px; border: 1px solid var(--line-2); border-radius: 999px;
  background: rgba(14, 9, 28, 0.92); backdrop-filter: blur(16px); color: var(--soft); font-size: 13px; box-shadow: var(--shadow);
  animation: page-in 200ms ease both;
}

@media (prefers-reduced-motion: reduce) {
  .fx-aurora, .primary-action::after, .beam::before, .home-command::before, .balance-card::before, .meteor { animation: none !important; }
}
