/* 考測通 OpenExamTW — 高級黑白灰極簡基調
   語意色僅保留在「答案回饋」：綠＝正確、紅＝錯誤，其餘全灰階。
   對比層次：#0a0a0a 底 → #141414 卡 → #1e1e1e 浮層 → #fafafa 白字 → #a3a3a3 灰字 */

:root {
  --bg: #0a0a0a;
  --card: #141414;
  --card2: #1e1e1e;
  --border: #2a2a2a;
  --border-lt: #3d3d3d;
  --fg: #fafafa;
  --muted: #a3a3a3;
  --faint: #6b6b6b;
  --white: #ffffff;
  --accent: #fafafa;      /* 主按鈕＝白底黑字（黑白對反，非彩色） */
  --accent2: #d4d4d4;     /* 強調文字＝亮灰 */
  --danger: #f87171;
  --ok: #4ade80;
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans TC", -apple-system, "Microsoft JhengHei", sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #fafafa; color: #0a0a0a; }
a { color: var(--fg); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 24px; }

/* ---- nav ---- */
nav {
  display: flex; align-items: center; gap: 28px;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(10,10,10,.88); backdrop-filter: blur(10px); z-index: 10;
}
nav .logo { font-weight: 700; font-size: 1.05rem; color: var(--fg); letter-spacing: .02em; }
nav .logo span { color: var(--faint); font-weight: 400; margin-left: 6px; font-size: .92rem; }
nav a.navlink { color: var(--muted); font-size: .92rem; }
nav a.navlink:hover { color: var(--fg); text-decoration: none; }

/* ---- hero ---- */
.hero { padding: 84px 0 48px; }
.hero h1 { font-size: 2.6rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; color: var(--faint); font-weight: 400; }
.hero p.sub { color: var(--muted); margin-top: 16px; max-width: 640px; }

/* ---- buttons：白底黑字主按鈕 / 細框幽靈按鈕 ---- */
.btn {
  display: inline-block; padding: 12px 24px; border-radius: 8px;
  background: var(--accent); color: #0a0a0a; font-weight: 700; border: none; cursor: pointer;
  font-size: .95rem; letter-spacing: .01em;
}
.btn.ghost { background: transparent; border: 1px solid var(--border-lt); color: var(--fg); font-weight: 500; }
.btn:hover { background: var(--white); text-decoration: none; }
.btn.ghost:hover { background: var(--card2); }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 48px 0; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.stat { background: var(--card); padding: 22px 18px; text-align: center; }
.stat b { display: block; font-size: 1.7rem; color: var(--fg); font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .82rem; }

h2.section { margin: 56px 0 20px; font-size: 1.35rem; font-weight: 700; }

/* ---- grid / cards：細邊＋hover 微亮 ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; display: block; color: var(--fg);
  transition: border-color .15s, background .15s;
}
.card:hover { border-color: var(--border-lt); background: var(--card2); text-decoration: none; }
.card h3 { font-size: 1rem; margin-bottom: 8px; letter-spacing: .01em; }
.card p { color: var(--muted); font-size: .86rem; line-height: 1.7; }
.card .tag { display: inline-block; margin-top: 12px; font-size: .8rem; color: var(--accent2); }

footer { margin: 72px 0 36px; color: var(--faint); font-size: .82rem; border-top: 1px solid var(--border); padding-top: 24px; line-height: 1.8; }

/* ---- quiz ---- */
.quiz { max-width: 780px; }
.qcard { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 26px; margin-bottom: 16px; }
.qcard .meta { color: var(--faint); font-size: .8rem; margin-bottom: 12px; letter-spacing: .03em; }
.qcard .q { font-weight: 600; font-size: 1.06rem; margin-bottom: 18px; line-height: 1.8; }
.choice {
  display: block; width: 100%; text-align: left; margin: 8px 0; padding: 13px 16px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); cursor: pointer; font-size: .96rem; font-family: inherit; line-height: 1.7;
  transition: border-color .12s;
}
.choice:hover { border-color: var(--border-lt); }
.choice.correct { border-color: var(--ok); background: rgba(74,222,128,.08); }
.choice.wrong { border-color: var(--danger); background: rgba(248,113,113,.07); }
.explain { margin-top: 16px; padding: 16px; border-radius: 8px; background: var(--card2); border: 1px solid var(--border); font-size: .9rem; color: var(--muted); display: none; }
.explain .ref { color: var(--faint); font-size: .8rem; margin-top: 10px; }
.progress { color: var(--muted); font-size: .88rem; margin-bottom: 16px; font-variant-numeric: tabular-nums; }

/* tabs：選中＝白底黑字膠囊 */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tab { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: .88rem; }
.tab:hover { color: var(--fg); text-decoration: none; border-color: var(--border-lt); }
.tab.on { background: var(--accent); border-color: var(--accent); color: #0a0a0a; font-weight: 700; }
.tab.mode { font-size: .84rem; padding: 6px 14px; }
.tab.mode.empty { opacity: .45; }
.wbadge { color: var(--danger); font-size: .78rem; font-weight: 600; }
.modebar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; padding-top: 4px; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { border: 1px solid var(--border); padding: 11px 14px; text-align: left; vertical-align: top; }
.tbl th { background: var(--card2); color: var(--muted); font-weight: 600; font-size: .82rem; letter-spacing: .03em; }
.tbl td:first-child { color: var(--fg); font-weight: 600; white-space: nowrap; }

.qopts { list-style: none; margin: 10px 0; }
.qopts li { padding: 9px 14px; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; font-size: .93rem; }
.ans { color: var(--accent2); font-size: .9rem; margin-top: 8px; }
.law-nav { display: flex; gap: 18px; margin: 14px 0 4px; font-size: .9rem; }
.note-box, .note { color: var(--muted); font-size: .86rem; margin-top: 14px; max-width: 780px; line-height: 1.8; }
.score { font-size: 1.3rem; font-weight: 800; }

/* ---- flashcards ---- */
.fc-stage { max-width: 720px; margin: 0 auto; }
.fc {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  min-height: 230px; padding: 36px; cursor: pointer; display: flex; flex-direction: column; justify-content: center;
}
.fc .front { font-size: 1.25rem; font-weight: 700; }
.fc .back { font-size: .98rem; color: var(--muted); margin-top: 16px; display: none; white-space: pre-wrap; }
.fc.flipped .back { display: block; }
.fc .src { font-size: .76rem; color: var(--faint); margin-top: 18px; }
.fc-ctrl { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }

/* ---- exam ---- */
.exambar { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 14px; }
.timer { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--danger); }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pal { width: 34px; height: 34px; border-radius: 6px; background: var(--card2); border: 1px solid var(--border); color: var(--muted); cursor: pointer; font-size: .84rem; font-family: inherit; font-variant-numeric: tabular-nums; }
.pal:hover { color: var(--fg); border-color: var(--border-lt); }
.pal.done { background: var(--accent); border-color: var(--accent); color: #0a0a0a; }
.pal.on { outline: 2px solid var(--border-lt); outline-offset: 1px; }
.choice.picked { border-color: var(--fg); background: rgba(250,250,250,.07); }
.examnav { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---- law ---- */
.law-search { width: 100%; padding: 13px 16px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); color: var(--fg); font-size: 1rem; font-family: inherit; margin-bottom: 18px; }
.law-search:focus { outline: none; border-color: var(--border-lt); }
.article { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 10px; }
.article b { color: var(--accent2); }
.article p { font-size: .92rem; color: var(--fg); white-space: pre-wrap; margin-top: 6px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2,1fr); }
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 56px 0 36px; }
  .qcard { padding: 20px; }
}

/* ---- AI 家教 ---- */
.chat { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; min-height: 120px; }
.msg { max-width: 86%; padding: 14px 18px; border-radius: 12px; font-size: .95rem; line-height: 1.75; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #0a0a0a; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--border); color: var(--muted); border-bottom-left-radius: 4px; }
.chatinput { display: flex; gap: 10px; margin-top: 8px; }
.chatinput input { flex: 1; padding: 13px 16px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); color: var(--fg); font-size: 1rem; font-family: inherit; }
.chatinput input:focus { outline: none; border-color: var(--border-lt); }
.suggest { margin-top: 16px; font-size: .88rem; color: var(--faint); }
.suggest a { color: var(--muted); margin: 0 10px; }
.suggest a:hover { color: var(--fg); }

/* ---- 課程頁 ---- */
.courses { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 22px 0; }
.course { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.course h3 { margin-bottom: 8px; font-size: 1rem; }
.course p { font-size: .88rem; color: var(--muted); margin-bottom: 16px; line-height: 1.7; }
.note-box { background: var(--card); border: 1px dashed var(--border-lt); border-radius: 10px; padding: 16px 20px; font-size: .9rem; line-height: 1.8; color: var(--muted); }
