/* styles.css — 手机优先，单列竖屏，拇指区操作 */

:root {
  --bg: #f5f6fb;
  --bg-soft: #eceefa;
  --card: #ffffff;
  --card-2: #f8f9fe;
  --text: #14172b;
  --text-dim: #6b7089;
  --text-faint: #9aa0b8;
  --line: #e5e7f2;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #ece9fe;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --bad: #dc2626;
  --bad-soft: #fdeaea;
  --shadow: 0 8px 24px rgba(20, 23, 43, 0.07);
  --shadow-lg: 0 16px 44px rgba(20, 23, 43, 0.12);
  --heat-1: #cdc9f6;
  --heat-2: #9d95ee;
  --bar-bg: rgba(245, 246, 251, 0.86);
  --radius: 18px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d101c;
    --bg-soft: #131829;
    --card: #181d2e;
    --card-2: #1e2438;
    --text: #eef0f8;
    --text-dim: #a2a9c2;
    --text-faint: #6f7694;
    --line: #262c42;
    --accent: #8b83ff;
    --accent-2: #a78bfa;
    --accent-soft: #232042;
    --ok: #4ade80;
    --ok-soft: #14261c;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --bad: #f87171;
    --bad-soft: #2b1616;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.45);
    --heat-1: #34315c;
    --heat-2: #5b54a8;
    --bar-bg: rgba(13, 16, 28, 0.86);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: contain;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); }

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
}

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0;
}

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.streak-chip.zero { background: var(--bg-soft); color: var(--text-faint); }

/* ---------------------------------------------------------------- 主区 */

main {
  flex: 1;
  padding: 6px 16px calc(96px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--warn-soft);
  color: var(--warn);
}
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner strong { font-weight: 700; }
.banner .x { margin-left: auto; color: inherit; opacity: .6; font-size: 18px; line-height: 1; padding: 0 2px; }

/* 今日 */

.today-hero {
  display: flex;
  align-items: center;
  gap: 18px;
}

.ring { position: relative; width: 108px; height: 108px; flex: none; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .track { stroke: var(--bg-soft); }
.ring .bar { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset .45s ease; }
.ring .num {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}
.ring .num b { font-size: 24px; line-height: 1.1; letter-spacing: -0.03em; }
.ring .num span { font-size: 11px; color: var(--text-faint); }

.hero-text { flex: 1; min-width: 0; }
.hero-text h2 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-text p { margin: 0; font-size: 13.5px; color: var(--text-dim); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: var(--card-2); color: var(--text-dim);
  border: 1px solid var(--line);
}
.chip.new { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.rev { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px;
  border-radius: 16px;
  font-size: 17px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 24px -8px rgba(79, 70, 229, 0.55);
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .55; box-shadow: none; }
.btn.ghost {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); box-shadow: none;
}
.btn.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.btn.sm { min-height: 44px; font-size: 15px; border-radius: 13px; width: auto; padding: 0 16px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}
.mini-stats div b { display: block; font-size: 19px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.mini-stats div span { font-size: 11.5px; color: var(--text-faint); }

.sec-title {
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  color: var(--text-faint); text-transform: uppercase;
  margin: 4px 2px -4px;
}

/* 进度 */

.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat i {
  aspect-ratio: 1; border-radius: 5px; background: var(--bg-soft); display: block;
}
.heat i.d1 { background: var(--heat-1); background: color-mix(in srgb, var(--accent) 30%, var(--bg-soft)); }
.heat i.d2 { background: var(--heat-2); background: color-mix(in srgb, var(--accent) 60%, var(--bg-soft)); }
.heat i.d3 { background: var(--accent); }
.heat i.today { outline: 2px solid var(--accent-2); outline-offset: 1px; }

.lesson-list { display: flex; flex-direction: column; gap: 2px; }
.lesson-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.lesson-row:last-child { border-bottom: none; }
.lesson-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-row .ct { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tag { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 7px; white-space: nowrap; }
.tag.imported { background: var(--bg-soft); color: var(--text-faint); }
.tag.done { background: var(--ok-soft); color: var(--ok); }
.tag.current { background: var(--accent-soft); color: var(--accent); }
.tag.todo { background: transparent; color: var(--text-faint); }

.search {
  width: 100%; min-height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2);
  padding: 0 13px; outline: none;
}
.search:focus { border-color: var(--accent); }

.word-list { display: flex; flex-direction: column; }
.word-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.word-row:last-child { border-bottom: none; }
.word-row .w { font-weight: 600; }
.word-row .m { color: var(--text-dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.word-row .st { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.word-row .st.due { color: var(--warn); font-weight: 700; }
.word-row .st.mastered { color: var(--ok); }

/* 设置 */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13.5px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--text-faint); line-height: 1.45; }
.input, select.input {
  width: 100%; min-height: 46px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2);
  padding: 0 13px; outline: none;
}
.input:focus { border-color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; inset: 0; z-index: 2; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--bg-soft); transition: background .18s ease;
}
.switch span::after {
  content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .18s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------------------------------------------------------------- 底部导航 */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding: 8px 14px calc(8px + var(--safe-b));
  background: var(--bar-bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar-inner {
  max-width: 520px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.tab {
  min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 13px; font-size: 11.5px; color: var(--text-faint); font-weight: 600;
}
.tab .ic { font-size: 18px; line-height: 1; filter: grayscale(1); opacity: .55; }
.tab[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); }
.tab[aria-selected="true"] .ic { filter: none; opacity: 1; }

/* ---------------------------------------------------------------- 背诵页 */

.session {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: var(--safe-t) 0 calc(14px + var(--safe-b));
}
.session[hidden] { display: none; }

.session-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 6px;
}
.session-head .close {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  background: var(--card); color: var(--text-dim);
  font-size: 18px; display: grid; place-items: center;
  border: 1px solid var(--line);
}
.pbar { flex: 1; height: 7px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s ease; }
.session-head .cnt { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

.card-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 10px 16px;
  min-height: 0;
}

.wordcard {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 26px 22px;
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
  animation: pop .22s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.wordcard .kind {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  color: var(--text-faint); text-transform: uppercase;
}
.wordcard .kind.new { color: var(--accent); }
.wordcard .kind.review { color: var(--ok); }
.wordcard .kind.round2 { color: var(--warn); }

.wordcard h1 {
  margin: 2px 0 0;
  font-size: clamp(30px, 9vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  word-break: break-word;
}
.wordcard .phon {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 15px;
}
.wordcard .phon button {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 15px;
}

.reveal { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.reveal .pos { color: var(--accent); font-weight: 700; font-size: 13px; }
.reveal .mean { font-size: 21px; font-weight: 650; line-height: 1.4; letter-spacing: -0.01em; }
.reveal .eg { font-size: 14.5px; color: var(--text-dim); line-height: 1.55; }
.reveal .eg em { font-style: normal; color: var(--text); }
.reveal .egcn { font-size: 13.5px; color: var(--text-faint); }
.reveal .note {
  font-size: 13px; color: var(--text-dim);
  background: var(--card-2); border-radius: 11px; padding: 9px 11px;
  border-left: 3px solid var(--accent-2);
}
.reveal .note b { color: var(--accent-2); font-weight: 700; }
.card-hint { text-align: center; font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.card-hint.hidden { visibility: hidden; }

.session-foot { padding: 8px 16px 0; display: flex; flex-direction: column; gap: 10px; }
.answer-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }
.answer {
  min-height: 62px;
  border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 15px; font-weight: 700;
  border: 1.5px solid transparent;
  transition: transform .1s ease;
}
.answer:active { transform: scale(.97); }
.answer small { font-size: 10.5px; font-weight: 500; opacity: .7; }
.answer.know { background: var(--ok-soft); color: var(--ok); }
.answer.vague { background: var(--warn-soft); color: var(--warn); }
.answer.unknown { background: var(--bad-soft); color: var(--bad); }
.answer[disabled] { opacity: .4; }

/* 结算 */

.done-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.done-wrap .em { font-size: 54px; line-height: 1; }
.done-wrap h2 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.done-wrap p { margin: 0; color: var(--text-dim); font-size: 14px; }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0; }
.done-stats div { background: var(--card); border-radius: 14px; padding: 12px 6px; box-shadow: var(--shadow); }
.done-stats b { display: block; font-size: 21px; }
.done-stats span { font-size: 11.5px; color: var(--text-faint); }

.wrong-list { text-align: left; background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); max-height: 30vh; overflow-y: auto; }
.wrong-list h3 { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.wrong-item { display: flex; gap: 8px; font-size: 14px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.wrong-item:last-child { border-bottom: none; }
.wrong-item b { flex: none; }
.wrong-item span { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* toast */

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b));
  transform: translate(-50%, 12px);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s ease;
  z-index: 100; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--text-faint); font-size: 12.5px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}