:root {
  --bg: #0a0b0d; --card: #14161a; --card2: #1b1e23; --line: #272b33; --text: #eef0f3; --muted: #9ea4ae;
  --accent: #7fd6c2; --accent-ink: #062520; --good: #8fe0b0; --warn: #ffcf8f; --bad: #ff9a9a; --gold: #f2c86b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar: 68px; --radius: 18px; --ts: 1;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: calc(16px * var(--ts)); line-height: 1.45; }
body { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); overscroll-behavior-y: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 8px; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--accent); }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: 0.86rem; } .tiny { font-size: 0.75rem; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }

.appbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; min-height: calc(env(safe-area-inset-top) + 60px);
  background: rgba(10, 11, 13, 0.9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.appbar h1 { margin: 0; font-size: 1.25rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .back, .appbar .icon { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 14px; border: 0; background: transparent; color: var(--accent); display: grid; place-items: center; font-size: 1.5rem; }
.appbar .back { margin-left: -6px; }
.appbar .icon svg { width: 24px; height: 24px; }

main { padding: 12px 14px 24px; max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.card.tone-good { border-color: #2c4a3a; } .card.tone-warn { border-color: #5a4626; } .card.tone-info { border-color: #234640; } .card.tone-bad { border-color: #5a2c2c; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .spread { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stack > * + * { margin-top: 10px; }

button, .btn { font: inherit; min-height: 48px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
button:active, .btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; } .btn-big { min-height: 60px; font-size: 1.1rem; } .btn-sm { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
button:disabled { opacity: 0.45; }
.opt.right:disabled, .opt.wrong:disabled { opacity: 1; }
.badge[hidden] { display: none !important; }
.banner.compact { padding: 8px 14px; } .banner.compact .count { font-size: 1.25rem; }
input, select, textarea { font: inherit; font-size: max(16px, 1rem); color: var(--text); background: #0e1013; border: 1px solid var(--line); border-radius: 12px; min-height: 48px; padding: 10px 12px; width: 100%; }
textarea { min-height: 150px; line-height: 1.45; resize: vertical; }
input[type=range] { padding: 0; min-height: 44px; accent-color: var(--accent); background: transparent; border: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 0.86rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { min-height: 44px; border: 0; background: transparent; border-radius: 10px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.78rem; color: var(--muted); }
.pill.weak { color: var(--warn); border-color: #5a4626; }

/* Bottom tab bar: fixed, a direct child of body (same iOS fixes as Fuel & Lift) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(14, 15, 18, 0.95); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  transform: translate3d(0, var(--vv-offset, 0px), 0); }
body.typing .tabbar, body.typing .update-banner { visibility: hidden; }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 0.72rem; min-height: 56px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); }
.tabbar .badge { position: absolute; top: 6px; left: 52%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #241800; font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; }
.tabbar[hidden] { display: none; }

/* Banners */
.banner { border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 12px; align-items: center; }
.banner.deadline { background: linear-gradient(135deg, #2b2410, #1b1a12); border: 1px solid #5f4d1c; }
.banner.master { background: #10221f; border: 1px solid #275a50; }
.banner .count { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--gold); min-width: 54px; text-align: center; line-height: 1; }
.banner .count small { display: block; font-family: var(--sans); font-size: 0.65rem; color: var(--muted); font-weight: 500; margin-top: 3px; }

/* Swipeable cards */
.deck { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin: 0 -14px; padding: 2px 14px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.deck::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 20px 18px 16px; min-height: 46vh; display: flex; flex-direction: column; }
.slide.tie { border-color: #275a50; background: #0f1d1a; }
.slide.end { border-color: #3b3320; }
.slide .num { font-size: 0.78rem; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; margin-bottom: 10px; }
.slide .txt { font-size: calc(1.42rem * var(--ts)); line-height: 1.38; flex: 1; }
.slide .txt b, .slide .txt strong { color: var(--accent); font-weight: 700; }
.slide.speaking { outline: 2px solid var(--gold); }
.dots { display: flex; justify-content: center; gap: 5px; margin: 8px 0 12px; flex-wrap: wrap; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #3a3f48; }
.dots i.on { background: var(--accent); width: 18px; border-radius: 4px; }
.read { min-height: 52px; font-weight: 600; }
.read svg, .btn svg, button svg { width: 22px; height: 22px; }

/* Quiz */
.qtext { font-size: calc(1.3rem * var(--ts)); line-height: 1.38; font-family: var(--sans); font-weight: 600; margin: 4px 0 14px; }
.opt { width: 100%; justify-content: flex-start; text-align: left; min-height: 58px; margin-bottom: 10px; font-size: 1.05rem; }
.opt .l { display: inline-grid; place-items: center; min-width: 32px; height: 32px; border-radius: 10px; background: #262a31; font-weight: 700; }
.opt.right { border-color: #3a7a58; background: #123222; } .opt.right .l { background: #2d6b4a; }
.opt.wrong { border-color: #7a3a3a; background: #331616; } .opt.wrong .l { background: #6b2d2d; }
.explain { border-left: 3px solid var(--accent); padding: 8px 12px; background: #0f1a18; border-radius: 0 12px 12px 0; margin: 6px 0 12px; }
.rate3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate3 .got { border-color: #3a7a58; } .rate3 .partly { border-color: #7a6a3a; } .rate3 .missed { border-color: #7a3a3a; }
.score { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.mistake { border-left: 3px solid var(--bad); }
.mistake.partly { border-left-color: var(--warn); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 0.95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* Progress */
.bar { height: 10px; background: #23272e; border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar.weak > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.kpi { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.list-item:last-child { border-bottom: 0; }
.list-item .n { min-width: 34px; height: 34px; border-radius: 10px; background: var(--card2); display: grid; place-items: center; font-weight: 700; font-size: 0.9rem; }
.list-item .n.done { background: #173a2c; color: var(--good); } .list-item .n.today { background: var(--accent); color: var(--accent-ink); }
.list-item.locked { opacity: .55; }

/* Tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; min-height: 112px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.tile svg { width: 28px; height: 28px; color: var(--accent); }
.tile b { font-size: 1.02rem; }

/* Driving mode and dark screen */
.drive { position: fixed; inset: 0; z-index: 70; background: #000; color: #d8dde3; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 16px); }
.drive .now { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 10px; }
.drive .now .lbl { font-size: 1.4rem; color: #8a929c; }
.drive .ctrls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 12px; }
.drive .ctrls button { min-height: 110px; border-radius: 26px; background: #111; border-color: #222; color: #cfd5dc; font-size: 1.2rem; font-weight: 700; }
.drive .ctrls button.play { background: #0f2b25; border-color: #1f5b4f; color: var(--accent); }
.drive .ctrls svg { width: 44px; height: 44px; }
.drive .exit { min-height: 56px; margin-top: 12px; background: #0b0b0b; border-color: #222; color: #8a929c; }

/* Mock interview */
.timer-big { font-family: var(--serif); font-size: 3rem; font-weight: 700; text-align: center; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #ff4d4d; display: inline-block; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.points li { margin: 6px 0; }

.sheet-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet { background: var(--card); width: 100%; max-height: 88vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px); z-index: 90; background: #e6fbf5; color: #062520; padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 92vw; display: flex; align-items: center; gap: 12px; }
.toast .btn-sm { background: #062520; color: #e6fbf5; border-color: #062520; min-height: 36px; }
.update-banner { position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 8px); z-index: 95; }
.update-banner button { width: 100%; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.diary-entry { border-left: 3px solid var(--line); }
.diary-entry.l3 { border-left-color: var(--accent); } .diary-entry.l2 { border-left-color: #7fa6d6; } .diary-entry.l1 { border-left-color: #888; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; color: var(--text); font-size: 1rem; }
.check input { width: 26px; min-height: 26px; height: 26px; accent-color: var(--accent); }
