/* langpal — visual system.
 * Warm paper background, one vermilion accent (印泥, seal-paste red), ink-dark text.
 * Chinese display type is large and quiet; English is small and muted so the eye lands
 * on the Mandarin first. Everything is a CSS variable so dark mode is a re-theme, not a fork. */

:root {
  --bg: #f7f6f2; --bg-2: #efede7; --card: #ffffff; --ink: #17171a; --ink-2: #3c3c44; --muted: #767682; --line: #e5e3dc; --line-2: #d9d6cd;
  --accent: #c8402b; --accent-2: #e0563f; --accent-ink: #ffffff; --accent-soft: rgba(200, 64, 43, .10);
  --ok: #1f8a56; --ok-soft: rgba(31, 138, 86, .12); --bad: #c23a2f; --bad-soft: rgba(194, 58, 47, .10); --warn: #b7791a;
  --tutor: #ffffff; --learner: #f1ece4; --speak: #2a63d8; --speak-soft: rgba(42, 99, 216, .12);
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 8px 24px -12px rgba(20, 20, 30, .18);
  --radius: 16px; --radius-s: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114; --bg-2: #16171b; --card: #1b1c21; --ink: #ededf0; --ink-2: #c9c9d1; --muted: #8d8d99; --line: #2a2b32; --line-2: #35363f;
    --accent: #e0563f; --accent-2: #f06a52; --accent-soft: rgba(224, 86, 63, .16);
    --ok: #3cb579; --ok-soft: rgba(60, 181, 121, .16); --bad: #e05a4f; --bad-soft: rgba(224, 90, 79, .16);
    --tutor: #1b1c21; --learner: #26231f; --speak: #6b96f0; --speak-soft: rgba(107, 150, 240, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101114; --bg-2: #16171b; --card: #1b1c21; --ink: #ededf0; --ink-2: #c9c9d1; --muted: #8d8d99; --line: #2a2b32; --line-2: #35363f;
  --accent: #e0563f; --accent-2: #f06a52; --accent-soft: rgba(224, 86, 63, .16);
  --ok: #3cb579; --ok-soft: rgba(60, 181, 121, .16); --bad: #e05a4f; --bad-soft: rgba(224, 90, 79, .16);
  --tutor: #1b1c21; --learner: #26231f; --speak: #6b96f0; --speak-soft: rgba(107, 150, 240, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); height: 100dvh; overflow: hidden;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  display: flex; flex-direction: column;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--speak); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }

/* ---------------- top bar ---------------- */
.topbar { flex: none; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.brand-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--ink-2); font-weight: 600; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .6; }
.crumbs > span:last-child { color: var(--ink); font-weight: 600; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px; letter-spacing: -.5px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.wordmark { font-weight: 700; letter-spacing: -.3px; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); padding: 5px 10px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 3px var(--ok-soft); }
.status.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.status.wait .dot { background: var(--warn); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); transition: background .15s, transform .1s; }
.icon-btn:hover { background: var(--bg-2); }
.icon-btn:active { transform: scale(.96); }

main { flex: 1; min-height: 0; width: 100%; max-width: 860px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }

/* ---------------- buttons ---------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); font-weight: 600; transition: transform .1s, background .15s, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.big { padding: 14px 24px; font-size: 16px; border-radius: 14px; }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }

/* ---------------- setup ---------------- */
.view { animation: rise .3s ease-out; }
.setup { padding: 24px 0 0; display: flex; flex-direction: column; gap: 28px; }
@keyframes rise { from { opacity: 0; } }
.hero h1 { margin: 0 0 10px; font-size: clamp(28px, 4.6vw, 40px); line-height: 1.1; letter-spacing: -.02em; font-weight: 800; }
.hero p { margin: 0; color: var(--muted); font-size: 16px; max-width: 54ch; }

.step { display: flex; flex-direction: column; gap: 12px; }
.step-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.step-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; align-self: center; }
.step-sub { color: var(--muted); font-size: 13px; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); min-width: 86px; text-align: left; transition: border-color .15s, background .15s, transform .1s; }
.pill:hover { border-color: var(--ink-2); }
.pill b { font-size: 15px; font-weight: 700; }
.pill small { font-size: 12px; color: var(--muted); }
.pill.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pill.on small { color: var(--ink-2); }
.tones .pill { flex-direction: row; align-items: center; gap: 8px; min-width: 0; border-radius: 999px; padding: 8px 14px 8px 10px; }
.tones .pill .emo { font-size: 17px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card-btn { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 14px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); text-align: left; box-shadow: var(--shadow); transition: transform .15s, border-color .15s, box-shadow .15s, opacity .2s; }
.card-btn:hover { transform: translateY(-2px); border-color: var(--line-2); }
.card-btn .emo { font-size: 26px; line-height: 1; }
.card-btn .ttl { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.card-btn .role { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.card-btn .lv { position: absolute; top: 12px; right: 12px; font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.card-btn.on { border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent), var(--shadow); }
.card-btn.on::after { content: "✓"; position: absolute; bottom: 12px; right: 12px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; display: grid; place-items: center; }
.card-btn.dim { opacity: .42; }
.card-btn.dim:hover { opacity: .8; }

.custom-row { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 14px; border-radius: 12px; border: 1px dashed var(--line-2); background: var(--bg-2); }
.custom-row:focus-within { border-style: solid; border-color: var(--accent); }
.custom-row .custom-icon { color: var(--muted); }
.custom-row input { flex: 1; border: 0; background: transparent; padding: 10px 6px; font: inherit; color: var(--ink); outline: none; }

.advanced { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.advanced summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; padding: 14px 18px; font-weight: 600; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "›"; display: inline-block; color: var(--muted); transition: transform .15s; font-size: 18px; line-height: 1; align-self: center; }
.advanced[open] summary::before { transform: rotate(90deg); }
.advanced .sum-sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; padding: 4px 18px 18px; }
.grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.grid label.check { flex-direction: row; align-items: center; color: var(--ink); gap: 8px; align-self: end; }
select, .grid input:not([type]) { font: inherit; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--ink); }
.range-row { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.range-row input { flex: 1; accent-color: var(--accent); }
.range-row output { font-variant-numeric: tabular-nums; min-width: 3ch; }

.start-dock { position: sticky; bottom: 0; z-index: 9; margin-top: 8px; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line); }
.start-dock > * { max-width: 820px; margin: 0 auto; }
.start-dock { display: flex; flex-direction: column; }
.start-dock .start-summary { width: 100%; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.start-dock .start-summary b { color: var(--ink); font-weight: 600; }
.start-actions { width: 100%; display: flex; justify-content: flex-end; gap: 10px; align-items: center; }

/* ---------------- lesson ---------------- */
.lesson { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lesson-bar { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lesson-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lesson-row.tools { flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.lesson-ident { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.lesson-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 20px; }
.lesson-title { font-weight: 700; letter-spacing: -.01em; }
.lesson-meta { font-size: 12.5px; color: var(--muted); }
.chip { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.chip:empty { display: none; }
.chip b { color: var(--ok); }
.chip.words-chip b { color: var(--accent); }
.toggles { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; background: var(--card); gap: 2px; }
.toggle { position: relative; }
.toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.toggle span { display: inline-block; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.toggle input:checked + span { background: var(--ink); color: var(--bg); }

.log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 18px; padding: 22px 4px 16px; margin: 0 -4px; }
.msg { display: flex; gap: 12px; max-width: 86%; animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.msg.tutor { align-self: flex-start; }
.msg.learner { align-self: flex-end; flex-direction: row-reverse; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; margin-top: 4px; }
.tutor .avatar { background: var(--accent); color: var(--accent-ink); }
.learner .avatar { background: var(--ink); color: var(--bg); }
.bubble { position: relative; padding: 14px 18px; border-radius: 18px; box-shadow: var(--shadow); min-width: 0; }
.tutor .bubble { background: var(--tutor); border: 1px solid var(--line); border-top-left-radius: 6px; }
.learner .bubble { background: var(--learner); border-top-right-radius: 6px; }
.msg.typing .bubble { display: inline-flex; gap: 5px; padding: 16px 18px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .2s; } .msg.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: -4px -6px 12px; border-radius: 12px; background: var(--speak-soft); color: var(--ink-2); font-size: 14.5px; line-height: 1.45; }
.note::before { content: "EN"; flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--speak); border: 1px solid currentColor; border-radius: 6px; padding: 1px 5px; margin-top: 2px; }
.example { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--ok-soft); border-left: 3px solid var(--ok); }
.example .label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ok); margin-bottom: 2px; }
.example .target { font-size: 22px; }
.target { font-size: 27px; line-height: 1.4; letter-spacing: .01em; font-weight: 500; }
.pinyin { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
.gloss { font-size: 14px; color: var(--muted); margin-top: 6px; }
.tools { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.tools .play { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); font-size: 12.5px; color: var(--ink-2); }
.tools .play:hover { background: var(--bg-2); }
.tools .play svg { width: 14px; height: 14px; }
.tools .ms { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; opacity: .8; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid var(--line-2); color: var(--muted); }

.heard { font-size: 18px; line-height: 1.45; }
.heard small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.intent { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--speak); background: var(--speak-soft); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.assess { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.lights { display: flex; gap: 6px; flex-wrap: wrap; }
.light { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 3px 9px 3px 6px; border-radius: 999px; }
.light.ok { color: var(--ok); background: var(--ok-soft); }
.light.bad { color: var(--bad); background: var(--bad-soft); }
.light svg { width: 13px; height: 13px; }
.errors { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.errors li { padding: 9px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.errors .fix { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.errors .said { text-decoration: line-through; text-decoration-color: var(--bad); color: var(--muted); }
.errors .arrow { color: var(--muted); }
.errors .better { color: var(--ok); font-weight: 600; }
.errors .why { display: block; margin-top: 3px; color: var(--ink-2); font-size: 13.5px; }
.praise { margin-top: 10px; color: var(--ok); font-size: 14px; display: flex; align-items: center; gap: 6px; }

/* ---------------- dock (talk) ---------------- */
.dock { flex: none; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hint { font-size: 13px; color: var(--muted); text-align: center; min-height: 20px; max-width: 60ch; line-height: 1.35; }
.dock-row { width: 100%; max-width: 560px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.dock-side { display: flex; align-items: center; gap: 10px; }
.dock-side.left { justify-content: flex-end; }
.dock-side.right { justify-content: flex-start; }

.talk { border: 0; background: transparent; padding: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.talk-pad { position: relative; width: 104px; height: 104px; display: grid; place-items: center; }
.talk-core { position: relative; z-index: 2; width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 28px -10px var(--accent), inset 0 -3px 0 rgba(0, 0, 0, .18); transition: background .2s, transform .12s, box-shadow .2s; }
.talk:active .talk-core { transform: scale(.95); }
.talk .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
.talk .ico { display: none; }
.talk .ico.mic { display: block; }
.talk-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-weight: 500; }
/* recording */
.talk.recording .talk-core { background: var(--bad); box-shadow: 0 10px 28px -10px var(--bad); }
.talk.recording .ring { border-color: var(--bad); animation: ripple 1.4s ease-out infinite; }
.talk.recording .ring.r2 { animation-delay: .7s; }
@keyframes ripple { 0% { transform: scale(.78); opacity: .7; } 100% { transform: scale(1.25); opacity: 0; } }
/* thinking */
.talk.busy .talk-core { background: var(--ink-2); box-shadow: none; }
.talk.busy .ico.mic { display: none; } .talk.busy .ico.spinner { display: block; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* speaking */
.talk.speaking .talk-core { background: var(--speak); box-shadow: 0 10px 28px -10px var(--speak); }
.talk.speaking .ico.mic { display: none; } .talk.speaking .ico.bars { display: flex; }
.bars { align-items: center; gap: 3px; height: 30px; }
.bars i { width: 4px; border-radius: 2px; background: #fff; height: 30%; animation: bar .9s ease-in-out infinite; }
.bars i:nth-child(1) { animation-delay: 0s; } .bars i:nth-child(2) { animation-delay: .15s; } .bars i:nth-child(3) { animation-delay: .3s; } .bars i:nth-child(4) { animation-delay: .45s; } .bars i:nth-child(5) { animation-delay: .6s; }
@keyframes bar { 0%, 100% { height: 30%; } 50% { height: 100%; } }
/* hands-free armed */
.talk.armed .talk-core { box-shadow: 0 0 0 6px var(--accent-soft), 0 10px 28px -10px var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(14px); }

.typed-row { width: 100%; max-width: 560px; display: flex; gap: 8px; margin-top: 4px; }
.typed-row input { flex: 1; font: inherit; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--ink); }
.typed-row input:focus { outline: none; border-color: var(--accent); }

/* ---------------- small screens ---------------- */
@media (max-width: 640px) {
  main { padding: 0 14px; }
  .topbar { padding: 8px 14px; }
  .hero h1 br { display: none; }
  .grid { grid-template-columns: 1fr; }
  .lesson-row.tools { flex-direction: column; align-items: stretch; }
  .toggles { justify-content: center; }
  .msg { max-width: 96%; }
  .target { font-size: 24px; }
  .dock-row { grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .switch-label { display: none; }
  .talk-pad { width: 92px; height: 92px; } .talk-core { width: 76px; height: 76px; }
  .start-actions { justify-content: stretch; } .start-actions .btn.big { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }


/* ---------------- home ---------------- */
.home { padding: 36px 0 40px; display: flex; flex-direction: column; gap: 22px; }
.section-title { margin: 8px 0 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lang-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.lang-card { display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; color: inherit; }
a.lang-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.lang-card.soon { opacity: .55; box-shadow: none; background: var(--bg-2); }
.lang-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.flag { font-size: 30px; line-height: 1; }
.lang-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.lang-native { color: var(--muted); font-size: 14px; }
.lang-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.lang-stats b { color: var(--ink); font-weight: 700; }
.muted { color: var(--muted); }

/* ---------------- dashboard ---------------- */
.dash { padding: 28px 0 40px; display: flex; flex-direction: column; gap: 22px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dash-head h1, .vocab-head h1 { margin: 0; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.02em; font-weight: 800; }
.dash-native { color: var(--muted); font-size: 14px; }
.dash-actions { display: flex; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.tile-k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile-v { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); }
.recent { display: flex; flex-direction: column; gap: 8px; }
.recent-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); transition: border-color .15s, transform .1s; }
.recent-row:hover { border-color: var(--line-2); transform: translateY(-1px); }
.recent-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.recent-main small { color: var(--muted); font-size: 12.5px; }
.recent-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.recent-go { color: var(--accent); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty a { color: var(--accent); font-weight: 600; }

/* ---------------- words in a line ---------------- */
.w { border-radius: 6px; padding: 0 1px; transition: background .12s; }
.words-on .w { cursor: pointer; }
.words-on .w:hover { background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.words-on .w.new { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 45%, transparent); }
.words-on .w.new:hover { box-shadow: inset 0 -2px 0 var(--accent); }
.tip { position: fixed; z-index: 50; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 13px; box-shadow: 0 8px 24px -8px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 1px; max-width: 260px; }
.tip b { font-size: 16px; }
.tip-r { opacity: .8; }
.tip-g { opacity: .9; }
.new-badge { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }

/* ---------------- the word drawer ---------------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 92vw); z-index: 40; background: var(--card); border-left: 1px solid var(--line); box-shadow: -16px 0 40px -24px rgba(0,0,0,.35); transform: translateX(104%); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.drawer-body h3 { margin: 18px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dw-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dw { font-size: 44px; line-height: 1.2; font-weight: 500; letter-spacing: .02em; }
.dw-r { font-size: 18px; color: var(--ink-2); }
.dw-g { font-size: 16px; color: var(--ink); }
.dw-meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.sent { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sent:last-child { border-bottom: 0; }
.sent-s { font-size: 18px; line-height: 1.4; }
.sent-r { font-size: 13px; color: var(--ink-2); }
.sent-g { font-size: 13px; color: var(--muted); }
.icon-btn.small { width: 30px; height: 30px; flex: none; margin-top: 2px; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.small svg { width: 15px; height: 15px; }
#dw-more { align-self: flex-start; margin-top: 8px; }

/* ---------------- vocabulary page ---------------- */
.vocab { padding: 28px 0 40px; display: flex; flex-direction: column; gap: 18px; }
.vocab-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.vocab-tools { display: flex; gap: 8px; }
.vocab-tools input { font: inherit; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); color: var(--ink); min-width: 240px; }
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.vcard { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-align: left; transition: transform .12s, border-color .15s; }
.vcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.vcard.fresh { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.vw { font-size: 24px; font-weight: 500; }
.vr { font-size: 13px; color: var(--ink-2); }
.vg { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.vmeta { font-size: 11px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .recent-stats { display: none; }
  .crumbs { display: none; }
  .dash-head, .vocab-head { align-items: stretch; flex-direction: column; }
  .vocab-tools input { min-width: 0; flex: 1; }
}

/* ---------------- words the learner said ---------------- */
.words-on .w.said-ok { box-shadow: inset 0 -2px 0 var(--ok); }
.words-on .w.said-bad { box-shadow: inset 0 -2px 0 var(--bad); }
.words-on .w.said-ok:hover { background: var(--ok-soft); }
.words-on .w.said-bad:hover { background: var(--bad-soft); }
.chip.said-chip b { color: var(--ok); }
.said-mark { color: var(--ok); font-style: normal; font-weight: 600; }
.sent.mine .sent-s { color: var(--ok); }

/* ---------------- login (Facebook structure: logo + collage + headline | divider | card; two-row footer) ---------------- */
body.auth .topbar { display: none; }
body.auth, body.auth main { background: var(--card); }
body.auth main { max-width: none; padding: 0; }
body.auth .login { flex: 1; }
.login { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; min-height: 100%; background: var(--card); color: var(--ink); }
.login-left { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 36px 40px 40px; border-right: 1px solid var(--line); min-height: 640px; overflow: hidden; }
.login-logo .mark.big { width: 64px; height: 64px; border-radius: 18px; font-size: 34px; box-shadow: 0 8px 20px -10px var(--accent); }
.login-headline { margin: 0; font-size: clamp(32px, 3.7vw, 56px); line-height: 1.02; letter-spacing: -.03em; font-weight: 800; max-width: 7.2em; position: relative; z-index: 2; }
.login-headline em { font-style: normal; color: var(--accent); }
/* the collage */
.collage { position: absolute; right: 24px; top: 40px; width: 560px; height: 520px; transform: scale(.92); transform-origin: top right; pointer-events: none; }
.ph { position: absolute; margin: 0; overflow: hidden; background: var(--bg-2); box-shadow: 0 24px 50px -24px rgba(0,0,0,.45); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .ph-fallback { display: none; position: absolute; inset: 0; place-items: center; font-size: 72px; color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), #e39a3a); }
.ph.noimg img { display: none; } .ph.noimg .ph-fallback { display: grid; }
.ph-main { left: 230px; top: 20px; width: 300px; height: 420px; border-radius: 26px; border: 8px solid #fff; }
.ph-tea { left: 40px; top: 140px; width: 230px; height: 230px; border-radius: 22px; }
.ph-tag { position: absolute; left: 12px; top: 12px; width: 36px; height: 36px; border-radius: 10px; background: #fff; display: grid; place-items: center; font-size: 18px; }
.ph-round { left: 300px; top: 380px; width: 150px; height: 150px; border-radius: 50%; border: 6px solid var(--accent); }
.ui-card { position: absolute; left: 120px; top: 300px; width: 250px; padding: 14px 16px; border-radius: 20px; background: #fff; box-shadow: 0 24px 50px -24px rgba(0,0,0,.45); color: #17171a; }
.ui-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ui-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.ui-name { font-size: 12px; color: #767682; font-weight: 600; }
.ui-zh { font-size: 20px; font-weight: 500; }
.ui-py { font-size: 12px; color: #3c3c44; margin-top: 2px; }
.ui-lights { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 10px; }
.ui-lights span { font-size: 10.5px; font-weight: 700; color: #1f8a56; background: rgba(31,138,86,.12); padding: 2px 7px; border-radius: 999px; }
.ui-chip { position: absolute; left: 440px; top: 70px; white-space: nowrap; padding: 8px 14px; border-radius: 12px; background: #5b49d6; color: #fff; font-weight: 700; font-size: 15px; box-shadow: 0 14px 30px -16px rgba(0,0,0,.5); }
.ui-emoji { position: absolute; left: 60px; top: 60px; width: 76px; height: 76px; border-radius: 50%; background: #ffd34d; display: grid; place-items: center; font-size: 38px; box-shadow: 0 14px 30px -16px rgba(0,0,0,.5); }
.ui-heart { position: absolute; left: 490px; top: 360px; width: 84px; height: 84px; border-radius: 50%; background: #e2384d; color: #fff; display: grid; place-items: center; font-size: 40px; font-weight: 800; box-shadow: 0 14px 30px -16px rgba(0,0,0,.5); }
/* right column */
.login-right { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login-step { display: flex; flex-direction: column; gap: 14px; }
.login-step h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; font-weight: 700; }
.login-step p { margin: -4px 0 0; font-size: 14px; }
.login-step input { font: inherit; font-size: 17px; padding: 16px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--ink); }
.login-step input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-step .btn.big { justify-content: center; padding: 15px 24px; font-size: 17px; }
.login-step hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.btn.outline { justify-content: center; background: transparent; border: 1.5px solid var(--accent); color: var(--accent); padding: 12px 20px; font-size: 15.5px; }
.btn.outline:hover { background: var(--accent-soft); }
.linkish { background: none; border: 0; color: var(--accent); font-size: 14px; font-weight: 500; padding: 0; align-self: center; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.how { color: var(--muted); font-size: 13.5px; text-align: center; }
.form-error { color: var(--bad); font-size: 13.5px; text-align: center; }
.dev-link { font-size: 13px; color: var(--ink-2); background: var(--speak-soft); border-radius: 10px; padding: 10px 12px; }
.dev-link a { color: var(--speak); font-weight: 600; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; }
.login-brand .mark { width: 22px; height: 22px; border-radius: 6px; font-size: 12px; }
/* footer */
.login-footer { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 22px 40px 28px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.foot-langs, .foot-links { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13.5px; color: var(--muted); justify-content: center; }
.foot-langs .on { color: var(--ink); }
.foot-langs .more, .foot-links a { color: var(--ink-2); }
.foot-links a:hover { text-decoration: underline; }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.who span { max-width: 22vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.level-chip.none { background: var(--bg-2); color: var(--muted); font-weight: 500; }
@media (max-width: 1340px) { .collage { transform: scale(.8); top: 30px; } }
@media (max-width: 1100px) { .collage { transform: scale(.68); } }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-left { border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; padding: 24px 20px; gap: 18px; }
  .collage { position: relative; left: 0; top: 0; transform: none; width: 100%; height: 300px; zoom: .55; }
  .login-headline { font-size: 34px; }
  .login-right { padding: 24px 20px 32px; }
  .login-footer { padding: 18px 20px 24px; }
  .who span { display: none; }
}

/* ---------------- phones ---------------- */
@media (max-width: 640px) {
  /* iOS zooms into any input under 16 px */
  input, select, .typed-row input, .vocab-tools input, .custom-row input { font-size: 16px; }
  .status { display: none; }                       /* the top bar keeps brand, user, theme */
  .drawer { width: 100vw; border-left: 0; }
  .drawer-body { padding: 16px; }
  .dw { font-size: 38px; }
  .msg { max-width: 100%; }
  .bubble { padding: 12px 14px; }
  .target { font-size: 22px; }
  .tools .ms { display: none; }                    /* timings are a developer detail */
  .lesson-row.tools { gap: 8px; }
  .toggles { width: 100%; justify-content: space-between; }
  .toggle span { padding: 6px 9px; font-size: 12px; }
  .dock { padding-top: 6px; }
  .dock-row { gap: 4px; }
  .hint { font-size: 12px; }
  .talk-pad { width: 96px; height: 96px; } .talk-core { width: 80px; height: 80px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile-v { font-size: 26px; }
  .cards { grid-template-columns: 1fr; }
  .card-btn { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .card-btn .emo { font-size: 24px; } .card-btn .lv { top: 10px; } .card-btn .role { display: none; }
  .card-btn.on::after { bottom: auto; top: 50%; transform: translateY(-50%); }
  .pill { min-width: 0; padding: 7px 11px; } .pill small { display: none; } .pills { gap: 6px; }
  .start-dock { padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
  .start-summary { display: none; }
  .vocab-grid { grid-template-columns: 1fr 1fr; }
  .vocab-head > div { min-width: 0; }
  .vocab-tools { flex-wrap: wrap; }
  .vocab-tools input { flex: 1 1 100%; }
  .vocab-tools select { flex: 1 1 40%; }
}
/* sign-in on a phone: the form first, as the Facebook app does; the collage is desktop-only */
@media (max-width: 860px) {
  .login { grid-template-rows: auto auto auto; }
  .login-left { order: 1; padding: 20px 20px 8px; display: flex; flex-direction: row; align-items: center; gap: 14px; border-bottom: 0; }
  .login-logo .mark.big { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; }
  .collage { display: none; }
  .login-headline { font-size: 22px; max-width: none; line-height: 1.15; }
  .login-headline br { display: none; }
  .login-right { order: 2; padding: 12px 20px 24px; align-items: flex-start; }
  .login-footer { order: 3; }
  .foot-langs, .foot-links { gap: 4px 14px; font-size: 12.5px; }
}
