/* [Model: Sonnet 5.5] LinguaReactor phone screen. Own styles only. */
:root {
  --bg: #FBFBFA;
  --surface: #FFFFFF;
  --line: #EAEAEA;
  --text: #1F2328;
  --muted: #6B6F76;
  --accent: #2457D6;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EEFC;
  --ok: #346538;
  --ok-soft: #EDF3EC;
  --bad: #9F2F2D;
  --bad-soft: #FDEBEC;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
  --font: -apple-system, "Noto Sans KR", system-ui, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1A1C1F;
    --line: #2B2E33;
    --text: #E8E9EB;
    --muted: #9A9EA6;
    --accent: #7FA2F5;
    --accent-ink: #0B1220;
    --accent-soft: #1E2A44;
    --ok: #9CCB9F;
    --ok-soft: #1D2A1E;
    --bad: #F0A3A1;
    --bad-soft: #351E1E;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.clip-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* shell */
/* [Model: Gemini 3.8 Flash] Fixed inset viewport to ensure tabbar never scrolls off-screen */
#root { display: flex; flex-direction: column; position: fixed; inset: 0; width: 100%; height: 100dvh; height: 100vh; overflow: hidden; }
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 4px) 8px 4px 16px; min-height: 56px; flex: none; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.icon-btn { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; color: var(--text); }
.icon-btn:active, .btn:active, .tab:active { opacity: .6; }
main { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 16px; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.tabbar { flex: none; position: relative; z-index: 10; display: flex; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); border-top: 1px solid var(--line); background: var(--surface); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 16px; min-height: 48px; }
.tab.on { color: var(--accent); font-weight: 600; }

/* buttons, fields */
.btn { min-height: 48px; padding: 0 20px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { min-height: 56px; width: 100%; font-size: 18px; }
.btn[disabled] { opacity: .45; }
input[type=text], input[type=url], select, textarea { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { min-height: 96px; resize: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }

/* video tab */
.url-form { display: flex; flex-direction: column; gap: 8px; }
.due-strip { min-height: 48px; padding: 0 16px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 600; text-align: left; display: flex; align-items: center; justify-content: space-between; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.rec-list { display: flex; flex-direction: column; gap: 16px; }
.rec { text-align: left; display: block; width: 100%; }
.rec img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--line); display: block; }
.rec b { display: block; margin-top: 8px; font-weight: 600; line-height: 1.4; }
.rec small { color: var(--muted); font-size: 16px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

/* lists */
.section-title { font-size: 16px; color: var(--muted); font-weight: 600; margin: 8px 0 0; }
.list { display: flex; flex-direction: column; }
.row { display: block; width: 100%; text-align: left; min-height: 64px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row .r1 { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.row .r1 b { font-size: 18px; font-weight: 600; }
.row .r1 span { color: var(--muted); min-width: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.review-start { display: flex; flex-direction: column; gap: 8px; }
.review-start p { margin: 0; text-align: center; }

/* pages */
.page { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); }
.page-top { display: flex; align-items: center; gap: 4px; padding: calc(var(--safe-t) + 4px) 16px 4px 8px; min-height: 56px; }
.page-top h2 { margin: 0; font-size: 18px; font-weight: 600; }
.page-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }

/* player */
.vid { width: 100%; aspect-ratio: 16 / 9; background: #000; flex: none; }
.vid iframe, .vid #yt { width: 100%; height: 100%; display: block; }
.cue-box { flex: none; padding: 12px 16px 8px; min-height: 120px; border-bottom: 1px solid var(--line); }
.cue-text { margin: 0; font-size: 22px; line-height: 44px; font-weight: 600; letter-spacing: -0.01em; }
.cue-text .w { padding: 0 2px; border-radius: 4px; }
.cue-text .w:active { background: var(--accent-soft); }
.cue-tr { margin: 0; color: var(--muted); font-size: 16px; }
.lines { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.line { display: block; width: 100%; text-align: left; min-height: 48px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.line.on { background: var(--accent-soft); }
.line small { display: block; color: var(--muted); font-size: 16px; }
.ctrl { flex: none; display: flex; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: var(--safe-b); }
.ctrl button { flex: 1; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 14px; }
.ctrl button:active { background: var(--accent-soft); }
/* [Model: Gemini 4 Argon] Active toggle state for 1-touch sentence auto-pause */
.ctrl button.on { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.ctrl .speed { font-weight: 700; font-size: 18px; line-height: 24px; }

/* sheet */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 16px 16px 0 0; border-top: 1px solid var(--line); max-height: 80dvh; display: flex; flex-direction: column; padding-bottom: var(--safe-b); transition: transform .2s ease-out; }
.sheet.drag { transition: none; }
.grab { height: 28px; display: grid; place-items: center; flex: none; touch-action: none; }
.grab i { width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet-body { padding: 0 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
/* [Model: Gemini 3.8 Flash] Rich Dictionary Sheet Styles */
.sw { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sw h3 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.ipa { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); }
.pos-badge { background: var(--line); color: var(--accent); font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.cefr-badge { background: #2563eb; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.mean { font-size: 22px; font-weight: 700; line-height: 1.35; margin: 2px 0 6px; color: var(--text); }
.dict-sec-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 6px 0 4px; }
.dict-meanings-box { display: flex; flex-direction: column; gap: 4px; background: rgba(0,0,0,0.02); border-radius: 8px; padding: 8px 10px; }
.dict-pos-group { display: flex; align-items: baseline; gap: 8px; font-size: 14px; line-height: 1.4; }
.dict-pos-tag { background: var(--line); color: var(--accent); font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
.dict-pos-meanings { color: var(--text); }
.dict-examples-box { display: flex; flex-direction: column; gap: 6px; }
.dict-context-box { display: flex; flex-direction: column; gap: 6px; }
.dict-ex-item { background: rgba(0,0,0,0.03); border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 0 8px 8px 0; font-size: 13px; }
.dict-ex-item.is-context { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.06); }
.dict-ex-src { font-weight: 600; color: var(--text); line-height: 1.4; }
.dict-ex-dst { color: var(--muted); margin-top: 3px; line-height: 1.4; }
.lr-hl { background: rgba(250, 204, 21, 0.45); color: inherit; padding: 1px 3px; border-radius: 3px; font-weight: 700; }
.dict-loading-bar { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 6px 0; }
.ex { margin: 0; color: var(--muted); }
.ex b { color: var(--text); font-weight: 600; }
.link { min-height: 44px; min-width: 44px; padding: 0 8px; color: var(--accent); text-decoration: underline; align-self: center; }

/* detail / stages */
.d-mean { font-size: 24px; font-weight: 700; margin: 0; }
.stage { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; }
.stage .chk { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.stage.done .chk { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.stage .chk .ic { width: 16px; height: 16px; }
.stage .nm { flex: 1; font-weight: 600; }
.stage .cnt { color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cloze { font-size: 20px; line-height: 1.5; margin: 0; }
.res { padding: 12px 16px; border-radius: 8px; font-weight: 600; }
.res.ok { background: var(--ok-soft); color: var(--ok); }
.res.bad { background: var(--bad-soft); color: var(--bad); }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }
.clip-vid { width: 100%; aspect-ratio: 16 / 9; background: #000; }
.clip-vid iframe { width: 100%; height: 100%; }
.danger { color: var(--bad); border-color: var(--bad-soft); }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.set-row.col { flex-direction: column; align-items: stretch; }
.switch { width: 56px; height: 44px; border-radius: 22px; background: var(--line); position: relative; flex: none; }
.switch i { position: absolute; top: 6px; left: 6px; width: 32px; height: 32px; border-radius: 16px; background: #fff; transition: transform .15s; }
.switch[aria-checked=true] { background: var(--accent); }
.switch[aria-checked=true] i { transform: translateX(12px); }

/* toast */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 60; padding: 12px 16px; border-radius: 8px; background: #1F2328; color: #fff; text-align: center; pointer-events: none; }
@media (prefers-color-scheme: dark) { .toast { background: #E8E9EB; color: #111214; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* access code / offline blockers */
.block { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
.block-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.block-box h2 { margin: 0; font-size: 24px; }
.big-input { width: 100%; height: 56px; text-align: center; font-size: 24px; letter-spacing: .2em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.err { margin: 0; color: var(--bad); }
.login-gis { min-height: 44px; display: flex; justify-content: center; }
.account-line { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-pic { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.account-id { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

/* [Model: Gemini 4 Argon] First-time onboarding wizard & interactive tutorial */
.ob-screen { position: fixed; inset: 0; z-index: 80; background: rgba(17, 18, 20, .55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); }
.ob-card { width: 100%; max-width: 440px; max-height: 90dvh; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; box-shadow: 0 16px 40px rgba(0, 0, 0, .18); }
.ob-top { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.ob-step { font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 12px; border-radius: 99px; }
.ob-title { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.3; letter-spacing: -0.02em; }
.ob-sub { margin: 0; font-size: 15px; line-height: 1.45; }
.ob-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.ob-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ob-grid > :last-child:nth-child(odd) { grid-column: span 2; }
.ob-opt { min-height: 52px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; font-weight: 600; transition: border-color .15s, background .15s; }
.ob-opt small { color: var(--muted); font-weight: 400; font-size: 13px; }
.ob-opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ob-opt.on small { color: var(--accent); }
.ob-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.tut-vis { border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--line); padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.tut-vis .tut-badge { display: inline-block; align-self: center; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.tut-vis .tut-demo { font-size: 18px; font-weight: 700; color: var(--text); }
.tut-vis .tut-hint { font-size: 14px; color: var(--muted); }
.tut-dots { display: flex; justify-content: center; gap: 6px; padding: 4px 0; }
.tut-dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--line); transition: width .15s, background .15s; }
.tut-dots i.on { width: 22px; background: var(--accent); }

/* [Model: Sonnet 5.5] generated 1-tap search chips (were inline-styled, 32px high) */
.search-quick-tags { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.search-quick-tags::-webkit-scrollbar { display: none; }
/* [Model: Sonnet 5.5] page rows must not shrink below their content: the Settings cookie box overlapped the Save and Tutorial buttons */
.page-body > * { flex-shrink: 0; }
/* [Model: Sonnet 5.5] onboarding grid: 1fr columns grew to the longest label (Japonais, Ukrainien ...) and the card scrolled sideways, clipping the first letters */
.ob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ob-opt { min-width: 0; flex-wrap: wrap; }
.ob-opt span { min-width: 0; overflow-wrap: anywhere; }
/* [Model: Sonnet 5.5] Korean subtitles broke inside a word ("채 / 널에"); keep-all breaks only at spaces */
.cue-text:lang(ko), .line:lang(ko), #lines:lang(ko) .line { word-break: keep-all; overflow-wrap: break-word; }

/* [Model: Gemini 3.8 Flash] Anki SRS 4-Rating Buttons & Duolingo Streak / Quest Bar */
.anki-box { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 10px; }
.anki-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.anki-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 6px 4px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; transition: transform .1s, background .15s; }
.anki-btn:active { transform: scale(0.97); }
.anki-btn .anki-lbl { font-weight: 700; font-size: 14px; }
.anki-btn .anki-iv { font-size: 11px; font-weight: 600; opacity: 0.85; margin-top: 2px; }

.anki-btn.again { border-color: rgba(220, 38, 38, 0.4); background: rgba(220, 38, 38, 0.08); color: #dc2626; }
.anki-btn.hard { border-color: rgba(217, 119, 6, 0.4); background: rgba(217, 119, 6, 0.08); color: #d97706; }
.anki-btn.good { border-color: rgba(22, 163, 74, 0.4); background: rgba(22, 163, 74, 0.08); color: #16a34a; }
.anki-btn.easy { border-color: rgba(37, 99, 235, 0.4); background: rgba(37, 99, 235, 0.08); color: #2563eb; }

.streak-strip { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; }
.streak-item { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
.streak-icon { font-size: 18px; }
.quest-info { font-size: 13px; font-weight: 600; color: var(--muted); }
.quest-bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; width: 100%; }
.quest-bar i { display: block; height: 100%; background: #f97316; transition: width .3s; }
