/* 靈光指引 Lumina Guide — 東方雅緻夜色主題 */
:root {
  --bg: #14152b;
  --bg2: #1c1e3d;
  --card: #21234a;
  --card2: #2a2d5c;
  --line: #3a3d75;
  --text: #eceafd;
  --muted: #a9a7d4;
  --gold: #ffd66b;
  --gold2: #f5b93e;
  --violet: #8a6df0;
  --good: #6fd8a0;
  --bad: #ef7d8e;
  --mid: #ffd66b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Serif TC", "PMingLiU", "Microsoft JhengHei", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(138,109,240,.18), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(255,214,107,.10), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
  min-height: 100vh;
}
header.site {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px 6px;
  max-width: 1080px; margin: 0 auto;
}
header.site .logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 0 24px rgba(255,214,107,.35); }
header.site h1 { font-size: 1.5rem; margin: 0; letter-spacing: .12em; }
header.site h1 small { display: block; font-size: .72rem; color: var(--muted); letter-spacing: .3em; font-weight: 400; }
nav.tabs {
  max-width: 1080px; margin: 10px auto 0; padding: 0 22px;
  display: flex; gap: 8px;
}
nav.tabs button {
  appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,.03);
  color: var(--muted); font: inherit; padding: 9px 18px; border-radius: 999px; cursor: pointer;
  transition: all .18s ease;
}
nav.tabs button:hover { color: var(--text); border-color: var(--violet); }
nav.tabs button.active { background: linear-gradient(135deg, var(--violet), #6a4fd8); color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(138,109,240,.35); }
main { max-width: 1080px; margin: 18px auto 60px; padding: 0 22px; }
.page { display: none; }
.page.active { display: block; }

/* 卡片 */
.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 1.15rem; letter-spacing: .06em; }
.card .hint { color: var(--muted); font-size: .85rem; margin: 2px 0 14px; }

/* skills 卡片 */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.skill-card {
  background: var(--card2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: all .18s ease; position: relative; user-select: none;
}
.skill-card:hover { transform: translateY(-2px); border-color: var(--violet); }
.skill-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 8px 24px rgba(255,214,107,.18); }
.skill-card .sk-icon { font-size: 1.7rem; }
.skill-card .sk-name { font-weight: 700; margin-top: 4px; }
.skill-card .sk-name small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.skill-card .sk-tag { color: var(--gold); font-size: .78rem; margin-top: 2px; }
.skill-card .sk-desc { color: var(--muted); font-size: .8rem; margin-top: 6px; line-height: 1.5; }
.skill-card .sk-check { position: absolute; top: 10px; right: 12px; color: var(--gold); opacity: 0; transition: opacity .15s; font-size: 1.1rem; }
.skill-card.selected .sk-check { opacity: 1; }
.skill-card .sk-options { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.skill-card .sk-options label { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin: 6px 0; cursor: pointer; }
.skill-card .sk-options select, .skill-card .sk-options input[type="number"], .skill-card .sk-options input[type="text"], .skill-card .sk-options textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: .85rem; margin-top: 4px;
}
.manual-input { margin-top: 4px; }

/* 表單 */
textarea#question, input[type="text"], input[type="password"], input[type="number"], input[type="url"], select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font: inherit;
}
textarea#question { min-height: 88px; resize: vertical; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 1px; }
label.block { display: block; margin: 12px 0 6px; color: var(--muted); font-size: .88rem; }
label.inline { display: inline-flex; align-items: center; gap: 7px; margin: 6px 12px 6px 0; color: var(--muted); font-size: .88rem; cursor: pointer; }
.purpose-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.purpose-row button {
  appearance: none; font: inherit; font-size: .88rem; cursor: pointer;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
  padding: 8px 16px; border-radius: 999px; transition: all .15s;
}
.purpose-row button.active { background: rgba(255,214,107,.14); color: var(--gold); border-color: var(--gold); }

/* 按鈕 */
.btn {
  appearance: none; font: inherit; cursor: pointer; border-radius: 999px;
  padding: 11px 26px; border: none; font-weight: 700; letter-spacing: .1em;
  background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #3a2b06;
  box-shadow: 0 8px 22px rgba(255,214,107,.28); transition: all .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(255,214,107,.4); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.violet { background: linear-gradient(135deg, var(--violet), #6a4fd8); color: #fff; box-shadow: 0 8px 22px rgba(138,109,240,.3); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover { color: var(--text); border-color: var(--violet); }
.btn.small { padding: 7px 16px; font-size: .85rem; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(239,125,142,.4); box-shadow: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* 占卜結果 */
.cast-head { font-size: 1.08rem; font-weight: 700; color: var(--gold); margin-bottom: 8px; letter-spacing: .04em; }
.cast-sub { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.cast-note { color: var(--muted); font-size: .78rem; margin-top: 10px; }
.cast-poem { font-size: 1.02rem; line-height: 1.9; margin: 10px 0; color: #f5f2ff; }
.cast-fields { margin: 10px 0 0; }
.cast-fields dt { color: var(--gold); font-size: .82rem; margin-top: 10px; letter-spacing: .08em; }
.cast-fields dd { margin: 3px 0 0; line-height: 1.75; font-size: .92rem; color: #ddd9f8; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.b-good { background: rgba(111,216,160,.16); color: var(--good); }
.b-mid { background: rgba(255,214,107,.16); color: var(--gold); }
.b-bad { background: rgba(239,125,142,.16); color: var(--bad); }

/* 易經爻線 */
.yaos { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 7px; max-width: 300px; }
.yao-row { display: flex; align-items: center; gap: 12px; }
.yao-label { font-size: .78rem; color: var(--muted); min-width: 88px; }
.yao-tag { color: var(--gold); font-size: .72rem; }
.yao { display: flex; gap: 8px; height: 12px; flex: 1; max-width: 190px; }
.yao.yang { background: linear-gradient(90deg, var(--gold), #ffe7a8); border-radius: 3px; }
.yao.yin i { display: block; flex: 1; background: rgba(236,234,253,.55); border-radius: 3px; }
.yao.chg { box-shadow: 0 0 10px rgba(255,214,107,.8); }

/* 塔羅牌 */
.tarot-cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.tarot-card {
  background: linear-gradient(160deg, #2e2a5e, #1d1f44); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; min-width: 108px; text-align: center;
}
.tarot-card.rev { background: linear-gradient(160deg, #4a2a52, #251d3f); }
.tarot-card .tc-idx { font-size: .7rem; color: var(--muted); }
.tarot-card .tc-name { font-weight: 700; margin-top: 2px; font-size: .92rem; }
.tarot-card .tc-name small { display: block; color: var(--muted); font-weight: 400; font-size: .68rem; }
.tarot-card .tc-orient { font-size: .74rem; color: var(--gold); margin-top: 4px; }

/* AI 解讀 */
.ai-section { border-left: 3px solid var(--violet); padding-left: 14px; margin: 14px 0; }
.ai-section h3 { margin: 0 0 8px; font-size: .98rem; color: var(--violet); display: flex; align-items: center; gap: 8px; }
.ai-section h3 .skill-emoji { font-size: 1.1rem; }
.ai-body { line-height: 1.9; font-size: .95rem; white-space: pre-wrap; word-break: break-word; }
.ai-body.streaming::after { content: "▍"; color: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.synthesis { border-left-color: var(--gold); }
.synthesis h3 { color: var(--gold); }

/* 歷史 */
.hist-item { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--card); overflow: hidden; }
.hist-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; }
.hist-head:hover { background: rgba(255,255,255,.03); }
.hist-time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.hist-q { flex: 1; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-badges { display: flex; gap: 6px; }
.hist-badge { font-size: .72rem; background: rgba(138,109,240,.18); color: #c9bcff; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.hist-detail { display: none; border-top: 1px solid var(--line); padding: 14px 16px; max-height: 640px; overflow: auto; }
.hist-item.open .hist-detail { display: block; }
.hist-detail .ai-body { font-size: .88rem; }
.hist-sec-title { margin: 14px 0 6px; font-size: .88rem; color: var(--gold); letter-spacing: .08em; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.hist-cast { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0; background: rgba(255,255,255,.02); }
.hist-cast .cast-head { font-size: .96rem; }
.hist-cast .cast-poem { font-size: .95rem; }
.hist-cast .cast-fields dt { font-size: .78rem; margin-top: 8px; }
.hist-cast .cast-fields dd { font-size: .88rem; }

/* 設定 */
.setting-status { font-size: .82rem; margin-top: 8px; min-height: 1.2em; }
.setting-status.ok { color: var(--good); }
.setting-status.err { color: var(--bad); }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .8em; background: rgba(255,255,255,.06); padding: 1px 6px; border-radius: 5px; }
.privacy { color: var(--muted); font-size: .8rem; line-height: 1.7; border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 14px; }

/* 交付 */
.handoff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.handoff-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; color: var(--text); font: inherit; transition: all .15s;
}
.handoff-btn:hover { border-color: var(--gold); transform: translateY(-2px); }
.handoff-btn .hf-icon { font-size: 1.5rem; }
.handoff-btn .hf-name { font-weight: 700; }
.handoff-btn .hf-note { font-size: .72rem; color: var(--muted); }
.prompt-box { width: 100%; min-height: 200px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; font-size: .82rem; white-space: pre-wrap; }
.incognito-warn { background: rgba(255,214,107,.08); border: 1px solid rgba(255,214,107,.3); color: #ffe7a8; border-radius: 10px; padding: 10px 14px; font-size: .85rem; line-height: 1.7; }

/* Toast */
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #2c2e5e; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 10px 22px; font-size: .88rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99; }
#toast.show { opacity: 1; }

/* RWD */
@media (max-width: 640px) {
  header.site h1 { font-size: 1.2rem; }
  main { padding: 0 14px; }
  .card { padding: 16px; }
  /* 歷史條目改堆疊：時間＋徽章一行，問題文字獨佔一行 */
  .hist-head { flex-wrap: wrap; }
  .hist-q { order: 3; flex-basis: 100%; white-space: normal; line-height: 1.5; }
  .hist-time { margin-right: auto; }
}
