/* First Phrases — styles. Come Alone family tokens; dark via prefers-color-scheme. */
:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1d1a22;
  --muted: #625d69;
  --line: rgba(29,26,34,.12);
  --accent: #2fb3a6;
  --accent-ink: #10201e;
  --pink: #ff5c8a;
  --pos: #12806a;
  --neg: #c8324f;
  --gold: #b7791f;
  --warn-bg: #fff3d6;
  --warn-ink: #6b4a00;
  --shadow: 0 10px 30px rgba(29,26,34,.08);
  --radius: 20px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131a;
    --surface: #201d27;
    --surface-2: #2a2633;
    --text: #f3f0f7;
    --muted: #a8a2b1;
    --line: rgba(243,240,247,.12);
    --pos: #4fd1b0;
    --neg: #ff7a93;
    --gold: #f2c46d;
    --warn-bg: #3a2f14;
    --warn-ink: #ffd88a;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-weight: 500; background: var(--bg); color: var(--text);
  line-height: 1.45; min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 900; letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 10px; font-weight: 800; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus, h1:focus { outline: none; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; max-width: 720px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 900; font-size: 1.15rem; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; color: var(--accent); flex: 0 0 32px; }
.lang-wrap select { font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; max-width: 46vw; }

/* Main */
.app { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 8px 16px 32px; }
.screen { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { padding: 12px 0 16px; }
.hero h1 { font-size: clamp(2rem, 7vw, 2.8rem); }
.hero p { color: var(--muted); margin-top: 8px; font-size: 1.05rem; }
.how { list-style: none; margin-top: 14px; display: grid; gap: 8px; counter-reset: how; }
.how li { counter-increment: how; display: flex; gap: 10px; align-items: baseline; font-weight: 700; }
.how li::before { content: counter(how); flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 900; font-size: .85rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-top: 12px; }
.panel h2 { font-size: 1.15rem; }
.sec { font-size: 1.15rem; margin: 22px 4px 4px; }
.lead { color: var(--muted); font-size: 1.05rem; font-weight: 700; }
.hint { color: var(--muted); font-size: .92rem; margin-top: 6px; }
.hint.pad { padding: 0 4px; margin: 0 0 8px; }
.center { text-align: center; }
.err { color: var(--neg); font-weight: 800; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 14px; padding: 12px 14px; font-weight: 700; margin-top: 12px; }

/* Language grid */
.langs { list-style: none; display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
@media (min-width: 480px) { .langs { grid-template-columns: 1fr 1fr; } }
.lang-card { display: flex; align-items: center; gap: 12px; text-decoration: none; background: var(--surface-2); border-radius: 16px; padding: 12px 14px; min-height: 64px; border: 2px solid transparent; transition: transform .12s ease; }
.lang-card:active { transform: scale(.98); }
.lang-card.last { border-color: var(--accent); }
.lang-code { flex: 0 0 42px; height: 42px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 900; font-size: .9rem; letter-spacing: .04em; }
.lang-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lang-name { font-weight: 900; font-size: 1.05rem; }
.lang-native { color: var(--muted); font-size: .88rem; }
.lang-seen { font-weight: 800; font-size: .85rem; color: var(--pos); }

/* Decks */
.decks { list-style: none; display: grid; gap: 12px; margin-top: 8px; }
.deck { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.deck-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.deck-top h3 { font-size: 1.1rem; }
.deck-meta { color: var(--muted); font-weight: 700; font-size: .88rem; white-space: nowrap; }
.deck-sub { color: var(--muted); font-size: .88rem; margin-top: 6px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; margin-top: 12px; }
.seg a { flex: 1; border-radius: 11px; padding: 10px 6px; font-weight: 800; color: var(--muted); text-align: center; text-decoration: none; font-size: .95rem; min-height: 44px; display: grid; place-items: center; }
.seg a:hover { color: var(--text); }
.seg .on { background: var(--accent); color: var(--accent-ink); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px;
  padding: 14px 20px; font-weight: 900; font-size: 1.05rem; cursor: pointer; background: var(--surface-2); color: var(--text);
  text-decoration: none; transition: transform .12s ease; min-height: 48px; text-align: center;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; display: flex; }
.btn.big { padding: 16px 22px; font-size: 1.1rem; }
.btn.small { padding: 8px 14px; font-size: .9rem; min-height: 40px; border-radius: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row .btn { flex: 1 1 120px; }
.center-row { justify-content: center; margin-top: 22px; }
.center-row .btn { flex: 0 1 auto; }

/* Screen head */
.g-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.g-head .back { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; }
.g-head h1 { font-size: 1.4rem; flex: 1; overflow-wrap: anywhere; }
.ico { display: inline-grid; place-items: center; }
.ico svg { width: 22px; height: 22px; display: block; }

/* Cards */
.cards { list-style: none; display: grid; gap: 10px; }
.card-item { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.phrase-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.phrase { font-weight: 900; font-size: 1.2rem; line-height: 1.3; overflow-wrap: anywhere; }
.pron { color: var(--muted); font-size: .92rem; margin-top: 4px; font-style: italic; overflow-wrap: anywhere; }
.pron .lbl { font-style: normal; font-weight: 700; }
.meaning { font-weight: 800; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.note { color: var(--muted); font-size: .9rem; margin-top: 4px; padding-left: 10px; border-left: 3px solid var(--accent); }
.note.reg-formal { border-left-color: var(--gold); }
.note.reg-informal { border-left-color: var(--pink); }
.speak { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.speak:hover { background: var(--accent); color: var(--accent-ink); }
.speak.big { width: 52px; height: 52px; }

.counter { text-align: center; color: var(--muted); font-weight: 800; margin: 4px 0 10px; }
.flip-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 26px 20px; min-height: 260px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; gap: 4px; cursor: pointer; user-select: none; }
.flip-card.practice { cursor: default; user-select: text; }
.flip-card .phrase { font-size: clamp(1.4rem, 5.5vw, 1.9rem); }
.flip-card .meaning { font-size: 1.15rem; }
.flip-card .hint { margin-top: 18px; }
.flip-card.flipped { border-color: var(--accent); }
.nav-row .btn { flex: 1 1 90px; }

.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.grade .btn { flex-direction: column; gap: 0; padding: 10px 6px; }
.grade .btn small { font-weight: 700; font-size: .78rem; opacity: .8; }
.grade .again { background: transparent; border: 1px solid var(--neg); color: var(--neg); }
.grade .good { background: var(--accent); color: var(--accent-ink); }
.grade .easy { background: var(--surface-2); }
.done-title { font-size: 1.4rem; margin-bottom: 6px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 20; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Footer */
.foot { max-width: 720px; width: 100%; margin: 0 auto; padding: 20px 16px 36px; color: var(--muted); font-size: .92rem; text-align: center; border-top: 1px solid var(--line); }
.foot-line + .foot-line { margin-top: 8px; }
.foot-line a { color: var(--text); font-weight: 800; }
.foot-line.small { font-size: .85rem; }

@media (prefers-reduced-motion: reduce) { .screen { animation: none; } .btn, .toast, .lang-card { transition: none; } }
