/* Mingo — solid colors + shadow only, NO gradients. Mobile-first (375px). */
:root {
  --bg: #12121f;
  --surface: #1a1a2e;
  --surface-2: #23233a;
  --surface-3: #2d2d47;
  --border: #33334d;
  --text: #eef0f6;
  --text-dim: #a5a8bd;
  --text-faint: #767a92;
  --accent: #6c8cff;
  --accent-press: #5674ea;
  --en: #6c8cff;
  --zh: #ff7a59;
  --good: #46c98b;
  --bad: #ff5f6d;
  --warn: #f5c451;
  --gold: #f5c451;
  --shadow: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.28);
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.lang-zh { --accent: var(--zh); --accent-press: #e8623f; }

button { font-family: inherit; cursor: pointer; border: none; color: inherit; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn svg { width: 18px; height: 18px; }
.chip svg { width: 16px; height: 16px; margin-right: 2px; }
.row-between > svg { color: var(--text-faint); }
h1,h2,h3,h4 { margin: 0; font-weight: 700; line-height: 1.3; }
p { margin: 0; }

/* ── Layout ───────────────────────────────────────── */
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.screen { display: none; padding: 16px 16px 24px; animation: fade 0.2s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; letter-spacing: -0.02em; }
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.brand-badge {
  width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3);
  display: grid; place-items: center; font-weight: 800; color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Language toggle */
.lang-toggle { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; box-shadow: var(--shadow-sm); }
.lang-toggle button {
  min-height: 34px; padding: 0 14px; border-radius: 999px; background: transparent;
  color: var(--text-dim); font-weight: 700; font-size: 14px; transition: background 0.15s;
}
.lang-toggle button.on { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }

/* Bottom tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(8, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}
#tabbar button {
  min-height: var(--tap); background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--text-faint);
  font-size: 9.5px; font-weight: 600; padding: 4px 0; border-radius: 10px;
}
#tabbar button svg { width: 21px; height: 21px; stroke-width: 2; }
#tabbar button.on { color: var(--accent); }
#tabbar button.on span { color: var(--text); }

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .sub { color: var(--text-dim); font-size: 13px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 4px 10px; }
.section-title:first-child { margin-top: 4px; }

/* Buttons */
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-sm); transition: transform 0.08s, background 0.15s;
}
.btn:active { transform: scale(0.97); background: var(--accent-press); }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: var(--surface-3); color: var(--text); }
.btn.ghost:active { background: var(--surface-2); }
.btn.good { background: var(--good); }
.btn.bad { background: var(--bad); }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 14px; }
.btn:disabled { opacity: 0.45; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.icon-btn {
  min-width: var(--tap); min-height: var(--tap); border-radius: var(--radius-sm);
  background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; }
.note-input { width: 100%; min-height: 44px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); padding: 0 12px; font-size: 14px; }
.note-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.icon-btn svg { width: 22px; height: 22px; stroke-width: 2; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-dim); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--accent); color: #fff; border-color: transparent; }

/* Progress bar */
.bar { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

/* Daily routine list */
.routine { list-style: none; margin: 0; padding: 0; }
.routine li {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border);
}
.routine li:last-child { border-bottom: none; }
.routine .rk { flex: 1; }
.routine .rk b { display: block; font-size: 15px; }
.routine .rk small { color: var(--text-dim); font-size: 12.5px; }
.check {
  min-width: 30px; min-height: 30px; border-radius: 50%; border: 2px solid var(--border);
  background: transparent; display: grid; place-items: center; flex-shrink: 0;
}
.check.done { background: var(--good); border-color: var(--good); }
.check svg { width: 18px; height: 18px; color: #fff; opacity: 0; }
.check.done svg { opacity: 1; }
.go {
  min-width: var(--tap); min-height: var(--tap); border-radius: var(--radius-sm); background: var(--surface-3);
  display: grid; place-items: center; flex-shrink: 0;
}
.go svg { width: 20px; height: 20px; color: var(--text-dim); }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat .l { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.stat .n.gold { color: var(--gold); }
.stat .n.acc { color: var(--accent); }
.stat .n.grn { color: var(--good); }

/* Weekly bar chart */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 8px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .col .v { width: 100%; max-width: 30px; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 3px; transition: height 0.4s; }
.chart .col .v.empty { background: var(--surface-3); }
.chart .col .d { font-size: 11px; color: var(--text-faint); }
.chart .col.today .d { color: var(--accent); font-weight: 700; }

/* Flashcard */
.flash {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  min-height: 240px; padding: 24px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; box-shadow: var(--shadow); gap: 12px; margin-bottom: 16px;
}
.flash .word { font-size: 40px; font-weight: 800; letter-spacing: -0.01em; }
.flash .py { font-size: 20px; color: var(--accent); font-weight: 600; }
.flash .mean { font-size: 20px; font-weight: 600; }
.flash .ex { font-size: 16px; color: var(--text); margin-top: 4px; }
.flash .exko { font-size: 14px; color: var(--text-dim); }
.flash .hint { font-size: 13px; color: var(--text-faint); }
.flash .divider { width: 60%; height: 1px; background: var(--border); margin: 4px 0; }

/* Bubbles (dialogue) */
.bubble { max-width: 82%; padding: 12px 15px; border-radius: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.bubble.a { background: var(--surface-2); border-bottom-left-radius: 5px; }
.bubble.me { background: var(--accent); color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.bubble.me.hidden .txt, .bubble.me.hidden .py { filter: blur(7px); }
.bubble .txt { font-size: 16px; font-weight: 600; }
.bubble .py { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.bubble .ko { font-size: 12.5px; opacity: 0.75; margin-top: 4px; }
.bubble .who { font-size: 11px; opacity: 0.6; margin-bottom: 3px; }

/* Pill labels */
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.lv1 { background: rgba(70,201,139,0.18); color: var(--good); }
.pill.lv2 { background: rgba(245,196,81,0.18); color: var(--warn); }
.pill.lv3 { background: rgba(255,95,109,0.18); color: var(--bad); }
.pill.box { background: var(--surface-3); color: var(--text-dim); }

/* Onboarding */
.ob { padding: 24px 20px calc(40px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.ob h1 { font-size: 30px; margin-bottom: 6px; }
.ob .lead { color: var(--text-dim); font-size: 15px; margin-bottom: 28px; }
.ob .q { font-size: 16px; font-weight: 700; margin: 24px 0 10px; }
.ob input[type=text] {
  width: 100%; min-height: var(--tap); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 0 14px; font-size: 15px;
}
.ob input[type=text]:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* Timer */
.timer-face { font-size: 52px; font-weight: 800; text-align: center; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.block-list { list-style: none; margin: 0; padding: 0; }
.block-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.block-list li:last-child { border-bottom: none; }
.block-list li.on { background: var(--surface-2); margin: 0 -16px; padding: 12px 16px; border-radius: 10px; border-bottom: none; }
.block-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-3); flex-shrink: 0; }
.block-list li.on .block-dot { background: var(--accent); }
.block-list li.done .block-dot { background: var(--good); }

/* Recorder */
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); display: inline-block; margin-right: 6px; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Notes */
.note-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }
.note-item .nt { flex: 1; }
.note-item .nt b { display: block; font-size: 15px; }
.note-item .nt small { color: var(--text-dim); font-size: 12.5px; }

/* Quiz */
.quiz-opt {
  width: 100%; min-height: var(--tap); text-align: left; padding: 12px 14px; margin-bottom: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; font-weight: 600;
}
.quiz-opt.correct { background: var(--good); border-color: transparent; color: #fff; }
.quiz-opt.wrong { background: var(--bad); border-color: transparent; color: #fff; }
.quiz-opt:disabled { opacity: 1; }

/* Misc */
.muted { color: var(--text-dim); }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.badge-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 12px; font-weight: 800; display: inline-grid; place-items: center;
}
textarea {
  width: 100%; min-height: 120px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 12px; font-size: 13px; font-family: ui-monospace, monospace;
  resize: vertical;
}
.empty { text-align: center; color: var(--text-faint); padding: 30px 10px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--surface-3); color: var(--text); padding: 11px 18px; border-radius: 999px; font-size: 14px;
  font-weight: 600; box-shadow: var(--shadow); z-index: 60; opacity: 0; pointer-events: none; transition: opacity 0.2s; white-space: nowrap;
}
.toast.show { opacity: 1; }
.speed-row { display: inline-flex; gap: 6px; }
.speed-row button { min-height: 34px; min-width: 44px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); font-weight: 700; font-size: 13px; }
.speed-row button.on { background: var(--accent); color: #fff; border-color: transparent; }
.week-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.week-row::-webkit-scrollbar { display: none; }
.week-card { flex: 0 0 auto; width: 150px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.week-card.now { border-color: var(--accent); background: var(--surface-3); }
.week-card .wk { font-size: 11px; color: var(--text-faint); font-weight: 700; }
.week-card .th { font-size: 14px; font-weight: 700; margin-top: 3px; }
.week-card .de { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
