:root {
  --bg: #f4f3ec;
  --surface: #ffffff;
  --surface-soft: #eeeee6;
  --ink: #17221d;
  --muted: #6b756f;
  --muted-2: #959d98;
  --line: #e4e5dc;
  --line-strong: #d7d9cf;
  --brand: #115f52;
  --brand-deep: #0b433a;
  --brand-soft: #dcece7;
  --accent: #f1b35b;
  --accent-soft: #fff0d6;
  --danger: #c85546;
  --danger-soft: #fae6e2;
  --success: #347b5a;
  --shadow-sm: 0 1px 2px rgba(28, 45, 36, .06), 0 7px 20px rgba(28, 45, 36, .04);
  --shadow-md: 0 18px 44px rgba(24, 46, 36, .12);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-size: 16px;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -6%, rgba(241, 179, 91, .23), transparent 28rem),
    radial-gradient(circle at 98% 4%, rgba(17, 95, 82, .12), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(241, 179, 91, .7);
  outline-offset: 2px;
}
svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.6rem, 7vw, 2.1rem); line-height: 1.2; letter-spacing: -.04em; }
h2 { font-size: 1.25rem; line-height: 1.25; letter-spacing: -.02em; }
h3 { font-size: 1rem; line-height: 1.3; }
small { font-size: .78rem; }
.hidden { display: none !important; }

.app-shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; position: relative; }
.app-header {
  width: min(100%, 760px);
  position: fixed;
  z-index: 30;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: calc(68px + env(safe-area-inset-top, 0px));
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(244, 243, 236, .88);
  border-bottom: 1px solid rgba(215, 217, 207, .58);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}
.app-header.study-header { background: rgba(244, 243, 236, .75); }
.brand { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 0; min-width: 0; cursor: pointer; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--brand); color: white; border-radius: 13px; box-shadow: 0 7px 16px rgba(17, 95, 82, .22); }
.brand-mark svg { width: 24px; height: 24px; }
.brand-copy { display: grid; text-align: left; line-height: 1.08; }
.brand-copy b { font-size: 1.04rem; letter-spacing: -.03em; }
.brand-copy small { color: var(--muted); margin-top: 4px; letter-spacing: .02em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.streak-chip, .icon-button {
  min-height: 40px;
  border: 1px solid rgba(215, 217, 207, .9);
  background: rgba(255, 255, 255, .7);
  border-radius: 999px;
  cursor: pointer;
}
.streak-chip { display: flex; align-items: center; gap: 6px; padding: 0 12px; color: #8d5b13; font-size: .82rem; font-weight: 700; }
.streak-chip svg { width: 18px; height: 18px; fill: rgba(241, 179, 91, .18); }
.icon-button { width: 40px; display: grid; place-items: center; padding: 0; }
.icon-button svg { width: 19px; height: 19px; }

.main { padding: calc(88px + env(safe-area-inset-top, 0px)) 18px calc(104px + var(--safe-bottom)); min-height: 100vh; }
.main.study-main { padding-top: calc(76px + env(safe-area-inset-top, 0px)); padding-bottom: calc(18px + var(--safe-bottom)); }
.bottom-nav {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 760px);
  min-height: calc(70px + var(--safe-bottom));
  padding: 8px 14px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.bottom-nav button { min-height: 52px; border: 0; background: transparent; color: #87908a; display: grid; place-items: center; align-content: center; gap: 3px; font-size: .72rem; border-radius: 14px; cursor: pointer; transition: color .18s ease, background .18s ease; }
.bottom-nav button svg { width: 22px; height: 22px; }
.bottom-nav button.active { color: var(--brand); background: var(--brand-soft); font-weight: 700; }

.screen { animation: screen-in .24s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 5px 0 0; font-size: .88rem; }
.page-title { margin: 0; font-size: 1.75rem; letter-spacing: -.045em; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head h2 { margin: 0; }
.text-button { border: 0; background: transparent; color: var(--brand); font-weight: 700; font-size: .84rem; padding: 8px 2px; cursor: pointer; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.pressable { transition: transform .12s ease, box-shadow .18s ease; }
.pressable:active { transform: scale(.985); }

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  color: white;
  background: linear-gradient(145deg, #156f60, #0b4a40);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 45px rgba(15, 82, 71, .2);
}
.hero-card::before { content: ""; position: absolute; width: 220px; height: 220px; right: -85px; top: -110px; border: 35px solid rgba(255,255,255,.08); border-radius: 50%; }
.hero-card::after { content: ""; position: absolute; width: 110px; height: 110px; right: 30px; bottom: -75px; border-radius: 50%; background: rgba(241,179,91,.19); }
.hero-top { position: relative; display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.hero-copy { max-width: 65%; }
.hero-copy small { color: rgba(255,255,255,.72); display: block; margin-bottom: 6px; }
.hero-copy h1 { margin-bottom: 10px; }
.hero-copy p { color: rgba(255,255,255,.78); font-size: .88rem; margin: 0; }
.progress-ring {
  --size: 94px;
  --progress: 0%;
  position: relative;
  flex: 0 0 auto;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) var(--progress), rgba(255,255,255,.15) 0);
}
.progress-ring::before { content: ""; position: absolute; inset: 8px; border-radius: inherit; background: #10584c; }
.progress-ring-inner { position: relative; text-align: center; line-height: 1; }
.progress-ring-inner b { font-size: 1.15rem; display: block; }
.progress-ring-inner small { color: rgba(255,255,255,.65); font-size: .64rem; display: block; margin-top: 7px; }
.hero-actions { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 24px; }
.btn { min-height: 48px; border: 0; border-radius: 15px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; cursor: pointer; transition: transform .12s ease, opacity .18s ease, background .18s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #382406; box-shadow: 0 10px 22px rgba(50, 32, 4, .18); }
.btn-brand { background: var(--brand); color: white; }
.btn-soft { background: var(--brand-soft); color: var(--brand-deep); }
.btn-light { background: rgba(255,255,255,.13); color: white; border: 1px solid rgba(255,255,255,.18); }
.btn-outline { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-icon { width: 48px; padding: 0; }
.btn svg { width: 19px; height: 19px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat-card { padding: 15px 12px; text-align: center; border-radius: 17px; background: rgba(255,255,255,.72); border: 1px solid var(--line); }
.stat-card b { display: block; font-size: 1.25rem; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); display: block; margin-top: 3px; }
.due-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px; }
.due-card-left { display: flex; gap: 13px; align-items: center; min-width: 0; }
.due-icon { width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 15px; color: var(--brand); background: var(--brand-soft); }
.due-card h3 { margin: 0 0 3px; }
.due-card p { margin: 0; color: var(--muted); font-size: .82rem; }
.due-number { font-size: 1.65rem; font-weight: 800; color: var(--brand); letter-spacing: -.05em; }
.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.book-card { position: relative; overflow: hidden; padding: 18px; min-height: 157px; display: flex; flex-direction: column; cursor: pointer; }
.book-card::after { content: attr(data-number); position: absolute; right: -3px; bottom: -30px; font-weight: 900; font-size: 5.6rem; line-height: 1; color: rgba(17,95,82,.055); letter-spacing: -.09em; }
.book-badge { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--brand-soft); color: var(--brand); font-weight: 850; }
.book-card:nth-child(2) .book-badge { background: var(--accent-soft); color: #925f16; }
.book-card h3 { margin: 13px 0 2px; font-size: 1.03rem; }
.book-card p { margin: 0; color: var(--muted); font-size: .76rem; }
.book-card footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .75rem; }
.progress-line { height: 5px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; margin-top: 14px; }
.progress-line span { height: 100%; display: block; border-radius: inherit; background: var(--brand); transition: width .3s ease; }
.progress-line.accent span { background: var(--accent); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #e9e9e1; border-radius: 15px; padding: 4px; margin-bottom: 16px; }
.segmented button { min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: .84rem; font-weight: 700; cursor: pointer; }
.segmented button.active { background: white; color: var(--brand); box-shadow: 0 2px 8px rgba(26,47,38,.07); }
.search-field { position: relative; margin-bottom: 14px; }
.search-field svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted-2); width: 19px; }
.search-field input { width: 100%; min-height: 50px; padding: 0 46px; border-radius: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.84); color: var(--ink); }
.search-field input::placeholder { color: var(--muted-2); }
.clear-search { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

.lesson-list { display: grid; gap: 9px; }
.lesson-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 13px; border-radius: 17px; }
.lesson-index { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-soft); color: var(--brand); font-weight: 800; }
.lesson-main { min-width: 0; }
.lesson-main h3 { margin: 0 0 4px; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-meta { color: var(--muted); font-size: .74rem; display: flex; gap: 8px; }
.lesson-row .btn { min-height: 40px; padding: 0 13px; font-size: .78rem; border-radius: 12px; }
.empty-state { padding: 48px 22px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { width: 72px; height: 72px; margin: 0 auto 15px; border-radius: 24px; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); }
.empty-state .empty-icon svg { width: 34px; height: 34px; }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }
.empty-state p { max-width: 300px; margin: 0 auto 18px; font-size: .87rem; }

.study-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 14px; }
.study-top .progress-line { margin: 0; height: 7px; }
.study-counter { text-align: center; color: var(--muted); font-size: .76rem; margin-top: 5px; }
.round-button { width: 44px; height: 44px; border: 1px solid var(--line); background: rgba(255,255,255,.8); border-radius: 14px; display: grid; place-items: center; cursor: pointer; }
.study-card { position: relative; min-height: min(58vh, 480px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 38px 24px 28px; overflow: hidden; cursor: pointer; }
.study-card::before { content: ""; position: absolute; width: 180px; height: 180px; top: -100px; left: -70px; border-radius: 50%; background: var(--brand-soft); opacity: .65; }
.study-card.revealed { justify-content: flex-start; padding-top: 64px; }
.study-card .word-label { position: relative; color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 18px; }
.word-large { position: relative; font-size: clamp(2.25rem, 11vw, 4.2rem); line-height: 1.06; font-weight: 830; letter-spacing: -.055em; overflow-wrap: anywhere; }
.word-audio { position: relative; margin-top: 17px; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; cursor: pointer; }
.word-audio svg { width: 23px; height: 23px; }
.reveal-hint { position: relative; margin-top: 42px; color: var(--muted); font-size: .84rem; display: flex; align-items: center; gap: 7px; }
.answer-panel { position: relative; width: 100%; margin-top: 34px; animation: reveal .25s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.meaning { font-size: clamp(1.35rem, 6vw, 1.9rem); font-weight: 750; line-height: 1.4; letter-spacing: -.025em; }
.word-detail { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 15px; color: var(--muted); font-size: .78rem; }
.tag { padding: 5px 10px; border-radius: 999px; background: var(--surface-soft); }
.memory-tip { margin: 22px auto 0; max-width: 390px; padding: 13px 15px; text-align: left; border-radius: 14px; color: #695024; background: var(--accent-soft); font-size: .82rem; }
.study-actions { margin-top: 14px; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.action-grid .btn { padding: 0 8px; flex-direction: column; min-height: 66px; gap: 2px; }
.action-grid .btn b { font-size: .94rem; }
.action-grid .btn small { opacity: .72; }
.action-again { background: var(--danger-soft); color: var(--danger); }
.action-hard { background: var(--accent-soft); color: #835713; }
.action-good { background: var(--brand-soft); color: var(--brand); }

.quiz-card { min-height: min(58vh, 470px); padding: 30px 22px 22px; display: flex; flex-direction: column; }
.quiz-prompt { text-align: center; margin-bottom: 24px; }
.quiz-prompt small { color: var(--muted); }
.quiz-word { font-size: clamp(2rem, 9vw, 3.5rem); font-weight: 830; letter-spacing: -.05em; margin: 10px 0; overflow-wrap: anywhere; }
.quiz-meaning { font-size: 1.45rem; font-weight: 750; margin: 10px 0; }
.quiz-options { display: grid; gap: 10px; }
.option-btn { min-height: 58px; padding: 11px 15px; text-align: left; border-radius: 15px; border: 1px solid var(--line); background: #fafaf6; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: border .16s ease, background .16s ease; }
.option-btn .option-key { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: white; border: 1px solid var(--line); font-size: .76rem; font-weight: 750; }
.option-btn.correct { border-color: #7eb89b; background: #e4f3eb; }
.option-btn.wrong { border-color: #e2a69d; background: var(--danger-soft); }
.option-btn:disabled { cursor: default; }
.spell-form { display: grid; gap: 11px; margin-top: auto; }
.spell-input { width: 100%; min-height: 58px; border-radius: 15px; border: 2px solid var(--line); background: #fafaf6; padding: 0 16px; font-size: 1.2rem; font-weight: 700; letter-spacing: .02em; }
.spell-input:focus { border-color: var(--brand); outline: none; }
.quiz-feedback { min-height: 27px; margin-top: 12px; text-align: center; font-size: .84rem; font-weight: 700; }
.quiz-feedback.good { color: var(--success); }
.quiz-feedback.bad { color: var(--danger); }

.review-hero { padding: 23px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.review-hero h1 { margin-bottom: 8px; }
.review-hero p { color: var(--muted); margin: 0; font-size: .88rem; }
.review-count { font-size: 3rem; font-weight: 850; line-height: 1; color: var(--brand); letter-spacing: -.07em; }
.review-count small { display: block; text-align: center; font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: 0; margin-top: 5px; }
.mode-list { display: grid; gap: 10px; }
.mode-card { width: 100%; padding: 16px; border: 1px solid var(--line); background: var(--surface); border-radius: 18px; display: grid; grid-template-columns: 48px 1fr auto; gap: 13px; align-items: center; text-align: left; cursor: pointer; }
.mode-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: var(--brand); background: var(--brand-soft); }
.mode-card:nth-child(2) .mode-icon { color: #8d5b13; background: var(--accent-soft); }
.mode-card:nth-child(3) .mode-icon { color: var(--danger); background: var(--danger-soft); }
.mode-card h3 { margin: 0 0 3px; }
.mode-card p { margin: 0; color: var(--muted); font-size: .78rem; }
.mode-card .chevron { color: var(--muted-2); }
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.heat-day { aspect-ratio: 1; border-radius: 7px; background: #e9e9e1; display: grid; place-items: center; color: var(--muted); font-size: .62rem; }
.heat-day.active { background: var(--brand-soft); color: var(--brand); font-weight: 750; }
.heat-day.today { box-shadow: inset 0 0 0 2px var(--accent); }

.profile-card { padding: 22px; display: flex; align-items: center; gap: 15px; }
.avatar { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 21px; color: white; background: linear-gradient(145deg, var(--brand), var(--brand-deep)); font-size: 1.5rem; font-weight: 850; box-shadow: 0 10px 22px rgba(17,95,82,.2); }
.profile-card h2 { margin: 0 0 4px; }
.profile-card p { color: var(--muted); margin: 0; font-size: .82rem; }
.profile-stats { grid-template-columns: repeat(2, 1fr); }
.settings-card { overflow: hidden; }
.setting-row { min-height: 62px; padding: 11px 15px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .setting-copy { min-width: 0; }
.setting-row h3 { margin: 0 0 2px; font-size: .91rem; }
.setting-row p { margin: 0; color: var(--muted); font-size: .74rem; }
.goal-options { display: flex; gap: 5px; }
.goal-options button { min-width: 39px; min-height: 36px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; font-size: .78rem; }
.goal-options button.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 750; }
.about-note { color: var(--muted); font-size: .8rem; margin: 0; }
.disclaimer { margin-top: 20px; color: var(--muted-2); text-align: center; font-size: .7rem; line-height: 1.7; }

.modal-layer { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-end; justify-content: center; padding: 0; background: rgba(14, 25, 20, .46); backdrop-filter: blur(5px); }
.modal-layer.open { display: flex; animation: fade-in .18s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet { width: min(100%, 620px); max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 20px calc(24px + var(--safe-bottom)); animation: sheet-up .24s ease both; }
@keyframes sheet-up { from { transform: translateY(30px); } to { transform: none; } }
.modal-grabber { width: 42px; height: 5px; border-radius: 999px; background: var(--line-strong); margin: 3px auto 18px; }
.modal-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-title h2 { margin: 0; }
.modal-close { width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--surface-soft); display: grid; place-items: center; cursor: pointer; }
.modal-actions { display: grid; gap: 10px; margin-top: 18px; }
.qr-wrap { display: grid; place-items: center; gap: 13px; text-align: center; }
.qr-canvas { width: min(72vw, 290px); height: auto; padding: 12px; border-radius: 18px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.qr-wrap p { color: var(--muted); margin: 0; font-size: .82rem; max-width: 340px; }
.url-box { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-soft); font-size: .75rem; color: var(--muted); word-break: break-all; text-align: center; }
.session-summary { text-align: center; padding: 8px 0 4px; }
.summary-ring { width: 116px; height: 116px; margin: 2px auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 2rem; font-weight: 850; }
.session-summary h2 { margin-bottom: 7px; }
.session-summary p { color: var(--muted); margin-bottom: 0; }
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0; }
.summary-stats div { padding: 13px 8px; border-radius: 14px; background: var(--surface-soft); }
.summary-stats b { display: block; font-size: 1.12rem; }
.summary-stats small { color: var(--muted); }
.toast { position: fixed; z-index: 200; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translate(-50%, 16px); max-width: calc(100% - 40px); padding: 11px 16px; border-radius: 13px; background: #1d2b25; color: white; font-size: .82rem; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 680px) {
  .main { padding-left: 26px; padding-right: 26px; }
  .app-header { padding-left: 26px; padding-right: 26px; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .book-card { min-height: 180px; }
  .modal-layer { align-items: center; padding: 24px; }
  .modal-sheet { border-radius: 26px; padding-bottom: 24px; }
}
@media (max-width: 390px) {
  .main { padding-left: 14px; padding-right: 14px; }
  .app-header { padding-left: 14px; padding-right: 14px; }
  .hero-card { padding: 20px; }
  .hero-copy { max-width: 62%; }
  .progress-ring { --size: 82px; }
  .brand-copy small { display: none; }
  .streak-chip { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* zaytun HSK RTL and bilingual adjustments */
body {
  direction: rtl;
  font-family: "UKIJ Tuz Tom", "UKIJ Tuz", "Noto Naskh Arabic", "Geeza Pro", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
}
button, input, textarea, select { direction: inherit; }
.brand-copy, .hero-copy, .page-head, .setting-copy, .lesson-main, .mode-card, .empty-state, .about-note { text-align: right; }
.word-large, .quiz-word, .pinyin-line, .spell-input, .url-box {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, sans-serif;
}
.word-large { font-weight: 760; }
.pinyin-line { margin-top: 10px; color: var(--brand); font-size: .94rem; font-weight: 650; letter-spacing: .01em; }
.meaning { direction: rtl; line-height: 1.8; }
.alternative-meanings { margin-top: 12px; color: var(--muted); font-size: .82rem; }
.option-btn { text-align: right; }
.option-btn > span:last-child { unicode-bidi: plaintext; }
.quiz-meaning { direction: rtl; }
.search-field input { text-align: right; }
.lesson-index, .stat-card b, .review-count, .due-number, .progress-ring-inner b { direction: ltr; }
.level-switcher { grid-template-columns: repeat(6, minmax(60px, 1fr)); overflow-x: auto; scrollbar-width: none; }
.level-switcher::-webkit-scrollbar { display: none; }
.level-switcher button { padding: 0 7px; white-space: nowrap; }
.level-goals { display: grid; grid-template-columns: repeat(3, 35px); }
.level-goals button { min-width: 34px; }
.book-card { min-height: 168px; }
.book-card h3, .book-card p, .book-card footer { text-align: right; }
.study-card .word-label, .study-counter { direction: rtl; }
.reveal-hint { direction: rtl; }
.memory-tip { direction: rtl; text-align: right; }
.app-header, .bottom-nav { direction: rtl; }
.bottom-nav button { font-family: inherit; }
@media (max-width: 420px) {
  .book-grid { gap: 9px; }
  .book-card { padding: 14px; min-height: 158px; }
  .book-card h3 { font-size: .96rem; }
  .book-card p { font-size: .68rem; line-height: 1.45; }
  .level-switcher button { font-size: .74rem; }
}

/* Account access gate */
body.auth-locked .app-shell { visibility: hidden; }
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 80% 4%, rgba(239,180,92,.34), transparent 28rem),
    radial-gradient(circle at 8% 96%, rgba(22,128,110,.18), transparent 28rem),
    #f4f3ec;
  overflow-y: auto;
  direction: rtl;
}
.access-card {
  width: min(100%, 470px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 26px 70px rgba(20, 49, 39, .14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.access-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.access-logo { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(145deg, var(--brand), var(--brand-deep)); color: white; font-size: 1.35rem; font-weight: 850; box-shadow: 0 10px 24px rgba(15,95,82,.22); }
.access-brand > span:last-child { display: grid; line-height: 1.15; }
.access-brand b { font-size: 1.15rem; letter-spacing: -.03em; }
.access-brand small { color: var(--muted); margin-top: 5px; font-size: .76rem; }
.access-copy h1 { margin: 0 0 9px; font-size: clamp(1.55rem, 7vw, 2.1rem); line-height: 1.35; }
.access-copy p { margin: 0 0 24px; color: var(--muted); font-size: .88rem; }
#accessForm { display: grid; gap: 11px; }
#accessForm label { font-size: .82rem; font-weight: 720; }
#accessCode {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 2px solid var(--line-strong);
  border-radius: 15px;
  background: #fafaf6;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
  direction: ltr;
  text-align: center;
}
#accessCode:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 4px rgba(17,95,82,.10); }
.access-submit { width: 100%; min-height: 56px; margin-top: 3px; }
.access-error { min-height: 26px; color: var(--danger); text-align: center; font-size: .82rem; line-height: 1.55; }
.access-foot { display: grid; gap: 4px; margin-top: 22px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .72rem; line-height: 1.6; }
@media (max-width: 420px) { .access-card { padding: 22px 18px; border-radius: 24px; } }

/* iHSKK-inspired dark learning UI */
:root {
  --bg: #0b0f17;
  --surface: #151d2b;
  --surface-soft: #1c2638;
  --ink: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --line: rgba(148, 163, 184, .15);
  --line-strong: rgba(148, 163, 184, .26);
  --brand: #4a90e2;
  --brand-deep: #2563eb;
  --brand-soft: rgba(74, 144, 226, .16);
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, .14);
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, .14);
  --success: #22c55e;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .18);
  --shadow-md: 0 20px 55px rgba(0, 0, 0, .38);
}
html { background: var(--bg); }
body {
  background:
    radial-gradient(circle at 12% 0%, rgba(74, 144, 226, .15), transparent 30rem),
    radial-gradient(circle at 95% 12%, rgba(34, 197, 94, .11), transparent 27rem),
    linear-gradient(180deg, #0f1419 0%, #0b0f17 48%, #0b0f17 100%);
  color: var(--ink);
}
.app-header {
  background: rgba(11, 15, 23, .88);
  border-bottom-color: rgba(148, 163, 184, .12);
  box-shadow: 0 1px rgba(34, 197, 94, .08), 0 8px 24px rgba(0, 0, 0, .22);
}
.brand-mark {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 9px 24px rgba(34, 197, 94, .28);
}
.brand-copy b { color: #fff; }
.brand-copy small, .page-head p, .due-card p, .setting-row p, .about-note { color: var(--muted); }
.streak-chip, .icon-button {
  background: rgba(21, 29, 43, .8);
  border-color: var(--line);
  color: #dbeafe;
}
.bottom-nav {
  background: rgba(11, 15, 23, .94);
  border-top-color: rgba(148, 163, 184, .14);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .3);
}
.bottom-nav button { color: #64748b; }
.bottom-nav button.active {
  color: #7dd3fc;
  background: rgba(74, 144, 226, .16);
}
.card {
  background: linear-gradient(180deg, rgba(21, 29, 43, .96), rgba(17, 24, 39, .96));
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.hero-card {
  background:
    radial-gradient(circle at 85% 0%, rgba(34, 197, 94, .18), transparent 18rem),
    radial-gradient(circle at 0% 100%, rgba(74, 144, 226, .2), transparent 20rem),
    linear-gradient(145deg, #131c2b, #0f172a 62%, #0b0f17);
  border: 1px solid rgba(148, 163, 184, .16);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .42), 0 0 0 1px rgba(74, 144, 226, .05) inset;
}
.hero-card::before { border-color: rgba(74, 144, 226, .09); }
.hero-card::after { background: rgba(34, 197, 94, .16); }
.hero-copy small, .hero-copy p { color: #a9b6ca; }
.progress-ring { background: conic-gradient(#22c55e var(--progress), rgba(148, 163, 184, .16) 0); }
.progress-ring::before { background: #101827; }
.btn-primary { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; box-shadow: 0 10px 24px rgba(34, 197, 94, .24); }
.btn-brand { background: linear-gradient(135deg, #4a90e2, #2563eb); color: #fff; box-shadow: 0 10px 24px rgba(74, 144, 226, .24); }
.btn-soft { background: var(--brand-soft); color: #93c5fd; }
.btn-outline { background: #111827; color: #e2e8f0; border-color: var(--line-strong); }
.btn-danger { background: var(--danger-soft); color: #fda4af; }
.stat-card, .mode-card, .due-card, .settings-card { background: rgba(21, 29, 43, .9); border-color: var(--line); }
.stat-card b { color: #fff; }
.due-icon, .mode-icon { background: rgba(74, 144, 226, .15); color: #60a5fa; }
.mode-card:nth-child(2) .mode-icon { background: var(--accent-soft); color: #4ade80; }
.mode-card:nth-child(3) .mode-icon { background: var(--danger-soft); color: #fb7185; }
.book-card {
  background:
    radial-gradient(circle at 90% 0%, rgba(74, 144, 226, .2), transparent 10rem),
    linear-gradient(155deg, #172033, #111827);
  border-color: var(--line);
}
.book-card:nth-child(2n) {
  background:
    radial-gradient(circle at 90% 0%, rgba(34, 197, 94, .18), transparent 10rem),
    linear-gradient(155deg, #172033, #111827);
}
.book-badge { background: rgba(74, 144, 226, .18); color: #7dd3fc; }
.book-card:nth-child(2) .book-badge { background: var(--accent-soft); color: #4ade80; }
.book-card h3, .book-card footer { color: #f8fafc; }
.progress-line { background: rgba(148, 163, 184, .14); }
.progress-line span { background: linear-gradient(90deg, #4a90e2, #60a5fa); }
.progress-line.accent span { background: linear-gradient(90deg, #22c55e, #4ade80); }
.segmented { background: #111827; border: 1px solid var(--line); }
.segmented button { color: var(--muted); }
.segmented button.active { background: linear-gradient(135deg, rgba(74,144,226,.25), rgba(34,197,94,.12)); color: #bfdbfe; box-shadow: 0 0 0 1px rgba(74,144,226,.25) inset; }
.search-field input, .spell-input, #accessCode {
  background: #101827;
  border-color: var(--line-strong);
  color: #f8fafc;
}
.search-field input::placeholder, .spell-input::placeholder { color: #64748b; }
.search-field svg, .clear-search { color: #64748b; }
.lesson-row { background: rgba(21, 29, 43, .88); }
.lesson-index { background: rgba(74, 144, 226, .13); color: #7dd3fc; }
.lesson-main h3 { color: #f8fafc; }
.study-card, .quiz-card {
  background:
    radial-gradient(circle at 50% 0%, rgba(74, 144, 226, .12), transparent 20rem),
    linear-gradient(155deg, #151d2b, #0f172a);
  border-color: var(--line);
}
.study-card::before { background: rgba(74, 144, 226, .08); }
.word-large, .quiz-word, .meaning, .quiz-meaning { color: #fff; }
.pinyin-line { color: #60a5fa; }
.word-audio { background: linear-gradient(135deg, #4a90e2, #2563eb); color: #fff; box-shadow: 0 10px 28px rgba(74,144,226,.28); }
.reveal-hint { color: #94a3b8; }
.memory-tip { background: rgba(34, 197, 94, .11); color: #bbf7d0; border: 1px solid rgba(34, 197, 94, .16); }
.action-again { background: var(--danger-soft); color: #fda4af; }
.action-hard { background: rgba(251, 191, 36, .13); color: #fcd34d; }
.action-good { background: var(--accent-soft); color: #86efac; }
.option-btn { background: #111827; border-color: var(--line-strong); color: #e2e8f0; }
.option-btn .option-key { background: #1c2638; border-color: var(--line); color: #cbd5e1; }
.option-btn.correct { background: rgba(34, 197, 94, .16); border-color: #22c55e; }
.option-btn.wrong { background: rgba(244, 63, 94, .14); border-color: #f43f5e; }
.quiz-feedback.good { color: #4ade80; }
.quiz-feedback.bad { color: #fb7185; }
.heat-day { background: #1c2638; color: #64748b; }
.heat-day.active { background: rgba(34, 197, 94, .16); color: #4ade80; }
.heat-day.today { box-shadow: inset 0 0 0 2px #4a90e2; }
.profile-card { background: linear-gradient(145deg, rgba(74,144,226,.12), rgba(21,29,43,.96)); }
.avatar { background: linear-gradient(145deg, #4a90e2, #2563eb); }
.goal-options button { background: #111827; border-color: var(--line-strong); color: #cbd5e1; }
.goal-options button.active { background: var(--brand-soft); color: #93c5fd; border-color: #4a90e2; }
.modal-layer { background: rgba(2, 6, 23, .72); }
.modal-sheet { background: #111827; color: #f8fafc; }
.modal-close { background: #1c2638; color: #cbd5e1; }
.summary-ring { background: rgba(34, 197, 94, .14); color: #4ade80; }
.summary-stats div { background: #1c2638; }
.url-box { background: #1c2638; color: #94a3b8; }
.empty-state { color: var(--muted); }
.empty-state h3 { color: #f8fafc; }
.empty-icon { background: var(--brand-soft); color: #60a5fa; }
.toast { background: #1c2638; border: 1px solid rgba(148,163,184,.18); }
.access-gate {
  background:
    radial-gradient(circle at 80% 4%, rgba(34,197,94,.16), transparent 28rem),
    radial-gradient(circle at 8% 96%, rgba(74,144,226,.16), transparent 28rem),
    #0b0f17;
}
.access-card {
  background: rgba(21,29,43,.94);
  border-color: var(--line);
  box-shadow: 0 26px 70px rgba(0,0,0,.5);
}
.access-logo { background: linear-gradient(145deg, #22c55e, #16a34a); }
.access-copy p, .access-foot { color: var(--muted); }

/* Hero composition inspired by iHSKK */
.hero-highlight { color: #5eea8d; text-shadow: 0 0 24px rgba(34, 197, 94, .18); }
.hero-copy h1 { font-family: Georgia, "Noto Naskh Arabic", "UKIJ Tuz Tom", serif; font-weight: 700; line-height: 1.3; }
.hero-feature-line { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.hero-feature-line span { padding: 5px 9px; border: 1px solid rgba(74,144,226,.22); border-radius: 999px; background: rgba(74,144,226,.08); color: #bfdbfe; font-size: .68rem; white-space: nowrap; }
.hero-orbit { position: relative; flex: 0 0 auto; width: 132px; height: 132px; display: grid; place-items: center; }
.hero-orbit::before, .hero-orbit::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.hero-orbit::before { inset: 0; border: 1px solid rgba(74,144,226,.22); box-shadow: 0 0 34px rgba(74,144,226,.08); }
.hero-orbit::after { inset: 13px; border: 1px dashed rgba(34,197,94,.18); }
.orbit-chip { position: absolute; z-index: 2; padding: 3px 7px; border-radius: 999px; background: #172033; border: 1px solid rgba(148,163,184,.2); color: #93c5fd; font-size: .58rem; font-weight: 800; box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.orbit-one { top: 2px; left: 5px; }
.orbit-two { right: -3px; bottom: 15px; color: #86efac; border-color: rgba(34,197,94,.25); }
@media (max-width: 420px) {
  .hero-feature-line span:nth-child(3) { display: none; }
  .hero-orbit { width: 108px; height: 108px; }
}
