/* Poradek — design system: calm neutrals and two colours with one job each.
   Blue = act (buttons, hints). Coral (the logo's dot) = what's new or chosen (new-word dot, selected word, streak).
   Red is only for errors. Generous spacing, one main action per screen. */
:root {
  --bg: #f7f6f3;          --surface: #ffffff;     --sunken: #f1efea;
  --fg: #1b1c1f;          --muted: #6d6f76;       --faint: #a3a5ab;
  --line: #e7e4dd;        --line-strong: #d9d5cc;
  --accent: #2753d6;      --accent-ink: #ffffff;  --accent-soft: #e8edfc;
  --hl: #ffe3e1;          --hl-ink: #1b1c1f;      --mark: #2753d6;   --new: #f0545a;
  --flame: #f0545a;       --ok: #2f8a4a;          --warn: #c99a1f;  --err: #c4352b;
  --r-lg: 18px; --r-md: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 4px 16px rgba(20, 20, 30, .04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;        --surface: #1b1c20;     --sunken: #222328;
    --fg: #ecedef;        --muted: #9b9da4;       --faint: #6c6e75;
    --line: #2b2c31;      --line-strong: #393a40;
    --accent: #7d9bff;    --accent-ink: #0d1020;  --accent-soft: #232a43;
    --hl: #4a2629;        --hl-ink: #ffeceb;      --mark: #9db3ff;   --new: #ff7b7f;   --flame: #ff7b7f;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--fg); overflow-x: hidden; }
body { font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
h1, h2, p { margin: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 46px; padding: 0 1.1rem;
  border-radius: var(--r-md); border: 1px solid transparent; font-weight: 600; font-size: .98rem; letter-spacing: -.005em; background: none; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(39, 83, 214, .25); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { border-color: var(--line-strong); color: var(--fg); background: var(--surface); }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }
.btn-icon { width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; color: var(--fg); }
.btn-icon:active { background: var(--sunken); }
.btn-round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; }
.btn-round:active { background: var(--sunken); }
.btn-round.accent { color: var(--accent); }
.btn-round.danger { color: var(--err); }
/* speaker: accent while it speaks; a turtle while it speaks slowly (tap again for slower) */
.btn-round .ic.alt { display: none; width: 22px; height: 22px; }
.btn-round.speaking { color: var(--accent); background: var(--accent-soft); }
.btn-round.slow .ic:not(.alt) { display: none; }
.btn-round.slow .ic.alt { display: block; }

/* ---------- top bar + tabs (bottom on phones) ---------- */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
/* (no backdrop-filter here: it would trap the fixed bottom tab bar inside the header) */
.bar-in { max-width: 760px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: .25rem; padding: 0 .75rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: -.01em; font-size: 1.05rem; padding-left: .25rem; }
.brand img { border-radius: 7px; }
#title { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.grow { flex: 1; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; transform: translateZ(0); display: flex; justify-content: space-around;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tab { flex: 1; max-width: 160px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: .72rem; font-weight: 600; letter-spacing: .01em; }
.tab .ic { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }
@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .tabs { position: static; transform: none; height: auto; padding: 0; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; gap: .25rem; margin-left: .5rem; }
  .tab { flex-direction: row; gap: .45rem; font-size: .9rem; padding: .5rem .8rem; border-radius: 999px; max-width: none; }
  .tab .ic { width: 18px; height: 18px; }
  .tab.active { background: var(--accent-soft); }
}

main { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }
/* views switch instantly: the bar and tabs never move, only the content changes */
.contents { display: contents; }
.section { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1.9rem .25rem .7rem; }
.status { min-height: 1.3em; font-size: .9rem; color: var(--muted); margin-top: .6rem; }
.status.err { color: var(--err); }

/* ---------- home ---------- */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem 1.25rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.hello { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.streak { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .95rem; margin-top: .3rem; }
.streak .ic { color: var(--faint); width: 18px; height: 18px; }
.streak.on .ic { color: var(--flame); fill: color-mix(in srgb, var(--flame) 22%, transparent); }
.streak.on { color: var(--fg); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: 1.1rem; }
.stat { background: var(--sunken); border-radius: var(--r-md); padding: .7rem .75rem; }
.stat b { display: block; font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); line-height: 1.25; display: block; }
.pages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.page { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: .9rem .6rem .9rem 1rem; display: flex; align-items: center; gap: .5rem; cursor: pointer; box-shadow: var(--shadow); }
.page:active { background: var(--sunken); }
.page-main { flex: 1; min-width: 0; }
.page-title { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-preview { color: var(--muted); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }
.page-meta { color: var(--faint); font-size: .8rem; margin-top: .3rem; }
.page .btn-icon { color: var(--faint); }
/* first visit: a short line, and the app itself as the example */
.intro { margin: .1rem 0 1.1rem; }
.intro-title { font-size: 1.65rem; line-height: 1.15; font-weight: 750; letter-spacing: -.03em; }
/* the slogan in your language and in the one you learn, rolling down towards you in turn */
.flip { display: grid; perspective: 900px; }
.flip > span { grid-area: 1 / 1; backface-visibility: hidden; transform-origin: 50% 0; opacity: 0; transform: rotateX(75deg);
  transition: transform .75s cubic-bezier(.2, .8, .2, 1), opacity .45s ease; }
.flip > span.on { opacity: 1; transform: none; }
.flip > span.out { opacity: 0; transform-origin: 50% 100%; transform: rotateX(-75deg) translateY(.15em); }
.flip > span:nth-child(2) { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .flip > span { transition: none; } }
.intro-sub { margin-top: .35rem; color: var(--muted); font-size: 1rem; }
.intro-demo { margin-top: 1rem; pointer-events: none; user-select: none; }
.intro-demo .sent { padding-bottom: .8rem; }
.intro-demo .info { margin-top: .6rem; }
.intro-signin { margin-top: 1rem; text-align: center; color: var(--muted); font-size: .95rem; }
.intro-signin a { color: var(--accent); font-weight: 650; text-decoration: none; }
.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty-mark { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 1rem; }
.empty-mark .ic { width: 28px; height: 28px; }
.empty-title { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.empty-body { color: var(--muted); margin-top: .4rem; max-width: 30rem; margin-left: auto; margin-right: auto; }

/* ---------- editor ---------- */
.field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-weight: 600; font-size: .92rem; margin: 0 .1rem .45rem; }
.field + .field-label, .area + .field-label { margin-top: 1.25rem; }
.field { width: 100%; height: 50px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); padding: 0 1rem;
  font-size: 1.05rem; font-weight: 600; box-shadow: var(--shadow); text-overflow: ellipsis; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--faint); font-weight: 400; }
.field-label .muted { font-weight: 400; font-size: .85rem; }
.area { width: 100%; resize: vertical; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); padding: .9rem 1rem;
  font-size: 1.05rem; line-height: 1.65; box-shadow: var(--shadow); }
.area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.area::placeholder { color: var(--faint); }
.own { margin-top: 1rem; }
.own summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; list-style: none; padding: .5rem .1rem; display: inline-block; }
.own summary::-webkit-details-marker { display: none; }
.own[open] summary { margin-bottom: .3rem; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .75rem; }
.actions .btn.primary { min-width: 9rem; }
@media (max-width: 759px) { .actions .btn { flex: 1; } }

/* ---------- reader ---------- */
.toggles { display: flex; gap: .5rem; margin-bottom: .9rem; }
/* Hints / translation stay in reach while reading: on phones a small floating pair above the tab bar (where the thumb is,
   away from the camera and status bar); on wide screens a strip pinned under the header. */
@media (max-width: 759px) {
  #view-reader .toggles { position: fixed; right: 12px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); z-index: 9; margin: 0;
    gap: 4px; padding: 4px; border-radius: 999px; border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 4px 18px rgba(20, 20, 30, .12); }
  #view-reader .toggles .chip { height: 32px; padding: 0 .7rem; font-size: .78rem; border: 0; }
  #view-reader .toggles .chip .ic { display: none; }   /* on = filled; no room for ticks */
  #view-reader .toggles .chip:not([aria-pressed="true"]) { background: transparent; }
  #view-reader { padding-bottom: 64px; }   /* the last sentence and "More" are never under them */
  body:has(#view-reader:not([hidden])) #toast { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 68px); }
}
@media (min-width: 760px) {
  #view-reader .toggles { position: sticky; top: 57px; z-index: 5; margin: 0 0 .9rem; padding: .55rem 0; background: var(--bg); }
}
.chip { display: inline-flex; align-items: center; gap: .35rem; height: 36px; padding: 0 .85rem 0 .7rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--muted); font-size: .88rem; font-weight: 600; }
.chip .ic { width: 16px; height: 16px; opacity: 0; transition: opacity .15s; margin-right: -.2rem; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip[aria-pressed="true"] .ic { opacity: 1; margin-right: 0; }
.progress { display: flex; align-items: center; gap: .75rem; margin: 0 0 1rem; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.track { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.track i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .35s ease; }

#reader { display: grid; gap: .75rem; }
.sent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem 1rem .95rem 1.15rem; box-shadow: var(--shadow); }
.sent.gen { border-style: dashed; box-shadow: none; position: relative; }

.pl { display: flex; align-items: flex-start; gap: .5rem; }
.pl-text { flex: 1; min-width: 0; font-size: 1.32rem; line-height: 2.45; font-weight: 550; letter-spacing: -.01em; }
.acts { display: flex; gap: 0; margin-right: -.5rem; }

.src-row { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; padding-top: .45rem; border-top: 1px solid var(--line); min-height: 44px; }
.src { flex: 1; min-width: 0; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.triage { display: flex; margin-left: auto; margin-right: -.5rem; }
.triage .ic { width: 19px; height: 19px; }
.hide-src .src { display: none; }
@media (min-width: 760px) {   /* side by side: your language left, the one you learn right */
  .sent { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); grid-template-areas: "src pl" "info info"; column-gap: 1.4rem; }
  .sent .pl { grid-area: pl; } .sent .info { grid-area: info; }
  .sent .src-row { grid-area: src; margin: 0; padding: .5rem 1.3rem 0 0; border: 0; border-right: 1px solid var(--line); flex-direction: column; align-items: stretch; }
  .sent .src { font-size: 1.02rem; }
  .sent .triage { margin: auto 0 0 -.5rem; }
  .hide-src .sent { grid-template-columns: 1fr; grid-template-areas: "pl" "info"; }
  .sent.pending .src { order: -1; }
}
.w { cursor: pointer; border-radius: 7px; padding: 0 3px; display: inline-block; line-height: 1.22; text-align: center; vertical-align: top; transition: background .12s; }
.w .wt { display: inline-block; position: relative; }   /* as wide as the word (its hint may be wider) */
.w { position: relative; }
.w::before { content: ""; position: absolute; inset: -6px -3px; }   /* easier to hit than the letters alone */
.w.multi .wt { box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--accent) 28%, transparent); }
.w .gl { display: block; font-size: .64rem; font-weight: 500; letter-spacing: 0; line-height: 1.25; color: var(--accent); max-width: 9.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.no-hints .w .gl { display: none; }
.w.sel { background: var(--hl); color: var(--hl-ink); }
.w.sel .gl { color: color-mix(in srgb, var(--hl-ink) 70%, transparent); }
.pn { display: inline; line-height: 1.22; margin-left: 1px; }
.wg { display: inline-block; white-space: nowrap; vertical-align: top; }
.nw { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.nw.sel { background: var(--hl); color: var(--hl-ink); }

.info { margin-top: .8rem; padding: .85rem .9rem .85rem 1rem; border-radius: var(--r-md); background: var(--sunken); }
.info-top { display: flex; align-items: center; gap: .75rem; }
.pairs { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .2rem 1.2rem; align-items: baseline; }
.pairs .n { font-size: 1.12rem; }
.pairs .t { font-size: 1.32rem; font-weight: 700; letter-spacing: -.01em; }
.pairs .dict { font-size: .98rem; font-weight: 400; color: var(--muted); padding-top: .3rem; border-top: 1px solid var(--line-strong); }
.pairs .t.dict { font-size: 1.02rem; font-weight: 600; }
.pairs .n.both { grid-row: span 2; align-self: center; }   /* one meaning for both lines */
.pairs .t.dict { grid-column: 2; }
.pairs .form { grid-column: 2; font-size: .85rem; color: var(--muted); margin-top: .1rem; }   /* "object form": under the words it describes */
.pairs mark { background: none; color: var(--mark); font-weight: 800; }
.note { margin-top: .55rem; font-size: .85rem; color: var(--muted); }
#view-settings > .note { margin: .55rem .25rem 0; }

.sent.pending .pl-text { padding: .5rem 0 .3rem; line-height: 1; }
.skeleton { display: block; height: 1.05rem; width: 82%; border-radius: 6px; margin: .3rem 0 .6rem;
  background: linear-gradient(90deg, var(--line) 0%, var(--sunken) 50%, var(--line) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton.short { width: 48%; }
.skeleton.inline { display: inline-block; width: 6rem; height: .95rem; margin: 0; vertical-align: middle; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sent.glossing .pl-text::after { content: ""; display: block; height: 3px; width: 55%; border-radius: 2px; margin: -.1rem 0 .3rem;
  background: linear-gradient(90deg, var(--line) 0%, var(--accent) 50%, var(--line) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; opacity: .45; }
.sent.failed { border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
@media (prefers-reduced-motion: reduce) { .skeleton, .sent.glossing .pl-text::after { animation: none; } }
/* new word in a suggested sentence: a small notification dot on the word's corner (not its hint's); tapping it pops it */
.w.fresh .wt::after { content: ""; position: absolute; top: -5px; right: -3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--new); box-shadow: 0 0 0 2px var(--surface); }
.w.fresh.sel .wt::after { box-shadow: 0 0 0 2px var(--hl); }
.w.fresh.seen .wt::after { animation: pop .32s ease-out forwards; }
@keyframes pop { 0% { transform: scale(1); opacity: 1; } 35% { transform: scale(1.7); opacity: .9; } 100% { transform: scale(0); opacity: 0; } }
.new-key { margin-left: auto; display: inline-flex; align-items: center; gap: .35rem; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }
.new-key .ic { width: 15px; height: 15px; color: var(--accent); stroke-width: 2.4; }
.new-key.done { color: var(--fg); animation: settle .4s ease-out; }
@keyframes settle { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.fresh-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
/* home: this week */
.week { display: flex; gap: .55rem; margin-top: .75rem; }
.day { display: flex; flex-direction: column; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 600; color: var(--faint); width: 1.6rem; }
.day i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.day.on i { background: var(--flame); }
.day.today i { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--faint); }
.day.today { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .w.fresh.seen .wt::after, .new-key.done { animation: none; opacity: 0; } .new-key.done { opacity: 1; } }
.gen-head { display: flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1rem .25rem 0; }
.more { margin-top: 1.25rem; }
#moreBtn.busy { opacity: .7; }

/* ---------- words ---------- */
.search { display: flex; align-items: center; gap: .55rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 0 .9rem; box-shadow: var(--shadow); }
.search .ic { color: var(--faint); }
.search input { flex: 1; border: 0; background: none; height: 46px; outline: none; font-size: 1rem; min-width: 0; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.count { font-size: .82rem; color: var(--muted); margin: .9rem .25rem .35rem; min-height: 1.2em; }
.word-head, .glossary li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: .9rem; align-items: center; }
.word-head { padding: .2rem calc(.5rem + 1px) .4rem calc(1rem + 1px);   /* = the rows' padding + the list's border, so the columns line up */
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.glossary { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.glossary li { padding: .45rem .5rem .45rem 1rem; border-top: 1px solid var(--line); cursor: pointer; min-height: 56px; }
.glossary li:first-child { border-top: 0; }
.glossary .r b { font-weight: 650; }
.glossary li > .l small, .glossary li > .r small { display: block; color: var(--faint); font-size: .82rem; font-weight: 400; margin-top: .1rem; }
/* the example uses the row's own columns (same width, same edges), so both languages stay in their column */
.glossary .ex { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; column-gap: .9rem; align-items: start;
  background: var(--sunken); border-radius: var(--r-sm); padding: .6rem .4rem .6rem .6rem; margin: .1rem -.4rem .45rem -.6rem; font-size: .95rem; }
.glossary .ex .r { grid-column: 2 / -1; }
.glossary .ex[hidden] { display: none; }
.glossary .ex .l { color: var(--muted); }

/* ---------- settings ---------- */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.row-item { display: flex; align-items: center; gap: .8rem; padding: .95rem 1rem; line-height: 1.45; }
.row-item + .row-item, .group > div + div { border-top: 1px solid var(--line); }
.row-item.col { flex-direction: column; align-items: stretch; gap: .7rem; }
.row-head { display: flex; align-items: center; gap: .8rem; font-weight: 600; }
.row-label { flex: 1; font-weight: 600; }
.lead { color: var(--muted); }
select { border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); padding: .55rem .7rem; font-size: .95rem; max-width: 100%; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); flex: none; margin: 0 5px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot.off { background: var(--warn); }
.ver { text-align: center; color: var(--faint); font-size: .78rem; margin: 2rem 0 .5rem; }

/* ---------- words: groups ---------- */
.glossary li.wgroup { display: flex; justify-content: space-between; min-height: 0; padding: .9rem 1rem .4rem; cursor: default; background: var(--bg);
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.glossary li.wgroup span { font-weight: 600; color: var(--faint); letter-spacing: 0; }
.glossary li.wgroup + li { border-top: 0; }
.link { border: 0; background: none; padding: .35rem 0 0; color: var(--accent); font-weight: 600; font-size: .92rem; text-align: left; }
.info .link { margin-top: .5rem; }

/* ---------- all forms (sheet) ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(10, 12, 18, .45); animation: fadein .2s ease-out; }
.sheet-card:focus { outline: none; }
.sheet-card { position: relative; width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); animation: rise .24s ease-out; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 760px) { .sheet { align-items: center; } .sheet-card { border-radius: var(--r-lg); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet-back, .sheet-card { animation: none; } }
body.sheet-open { position: fixed; left: 0; right: 0; overflow: hidden; }   /* nothing scrolls behind an open sheet */
.sheet-body { overscroll-behavior: contain; }
.sheet-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1rem .75rem 1.25rem; border-bottom: 1px solid var(--line); }
.sheet-name { flex: 1; min-width: 0; }
.sheet-name h2 { font-size: 1.45rem; letter-spacing: -.02em; }
.sheet-name p { font-size: .95rem; }
.sheet-body { overflow-y: auto; padding: .5rem 1.25rem 1.5rem; -webkit-overflow-scrolling: touch; }
.sheet-loading { padding: 1rem 0; }
.sheet-foot { display: flex; gap: .6rem; padding: .8rem 1.25rem 1rem; border-top: 1px solid var(--line); }
.sheet-foot .btn { flex: 1; white-space: nowrap; padding: 0 .8rem; }
.chips.chosen { padding-bottom: .8rem; margin-bottom: .8rem; border-bottom: 1px solid var(--line); }
.sheet-body > .chips:first-child { margin-top: .9rem; }
.wchip.pick { padding: .55rem .8rem; }
.wchip.pick b { font-size: 1.02rem; }
.fmeta { color: var(--muted); font-size: .9rem; margin-top: .6rem; }
.fnote { margin-top: .6rem; font-size: .95rem; line-height: 1.5; background: var(--sunken); border-radius: var(--r-sm); padding: .65rem .8rem; }
.fs { margin-top: 1.1rem; }
.fs h3 { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .35rem; }
.fr { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .75rem; padding: .42rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.fr.three { grid-template-columns: 5.4rem minmax(0, 1fr) minmax(0, 1fr); column-gap: .6rem; }
.fr.head { grid-template-columns: 5.4rem minmax(0, 1fr) minmax(0, 1fr); column-gap: .6rem; border-top: 0; padding-bottom: .3rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.fr .p { color: var(--muted); font-size: .9rem; }
.fr .p.case b { display: block; color: var(--fg); font-weight: 600; font-size: .92rem; }
.fr .p.case small { display: block; font-size: .8rem; color: var(--faint); margin-top: .05rem; }
.fr.three { align-items: start; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.tag { font-size: .82rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.keyforms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .8rem; }
.keyforms div { background: var(--sunken); border-radius: var(--r-sm); padding: .55rem .65rem; }
.keyforms b { display: block; font-size: 1.05rem; }
.keyforms small { display: block; font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.points { margin: .8rem 0 0; padding: .6rem .8rem .6rem 1.9rem; background: var(--sunken); border-radius: var(--r-sm); font-size: .95rem; line-height: 1.45; }
.points li + li { margin-top: .4rem; }
.points li::marker { color: var(--faint); }
.fr .f { font-weight: 600; font-size: 1.05rem; }
.fx { padding: .45rem 0; border-top: 1px solid var(--line); }
.fx .muted { font-size: .92rem; }

/* ---------- batches of suggestions ---------- */
button.gen-head { width: 100%; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; color: var(--muted); }
.gen-head .batch-info { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
button.gen-head:not(.open) { padding: .55rem .25rem; border-top: 1px solid var(--line); margin-top: .5rem; }

/* ---------- words chosen for the next sentences ---------- */
.practice { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .7rem; }
.practice-label { font-size: .82rem; color: var(--muted); margin-right: .2rem; }
.pchip { display: inline-flex; align-items: center; gap: .3rem; height: 32px; padding: 0 .55rem 0 .75rem; border-radius: 999px; border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .9rem; }
.pchip .ic { width: 14px; height: 14px; stroke-width: 2.2; }

/* ---------- words page: how the language works, everyday words ---------- */
.section.first { margin-top: .2rem; }
.basics { display: flex; gap: .5rem; overflow-x: auto; padding: 0 .1rem .3rem; margin: 0 -.1rem 1rem; scrollbar-width: none; }
.basics::-webkit-scrollbar { display: none; }
.tchip { flex: none; max-width: 15rem; padding: .6rem .85rem; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); text-align: left; font-weight: 600; font-size: .9rem; line-height: 1.3; box-shadow: var(--shadow); }
.everyday { margin-bottom: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.everyday summary { cursor: pointer; list-style: none; padding: .9rem 1rem; font-weight: 650; display: flex; justify-content: space-between; }
.everyday summary::-webkit-details-marker { display: none; }
.everyday summary::after { content: "›"; color: var(--faint); transition: transform .2s; }
.everyday[open] summary::after { transform: rotate(90deg); }
#everyday { padding: 0 1rem 1rem; }
.hint { font-size: .88rem; margin-bottom: .4rem; }
.eg h3 { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: .9rem 0 .45rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.wchip { display: inline-flex; flex-direction: column; align-items: flex-start; padding: .4rem .7rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); line-height: 1.25; }
.wchip b { font-weight: 650; }
.wchip span { font-size: .78rem; color: var(--muted); }
.wchip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; }
.wchip[aria-pressed="true"] b { color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 0 1.1rem; grid-column: 1 / -1; }
/* buttons inside the word box and the Words list: one clear style, a full finger size */
.pills { display: flex; flex-wrap: wrap; gap: .5rem; grid-column: 1 / -1; margin-top: .7rem; }
.pill { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 1rem 0 .85rem; border-radius: 999px; border: 0;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: .95rem; }
.pill .ic { width: 18px; height: 18px; }
.pill:active { filter: brightness(.95); transform: scale(.98); }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.pill.wide { justify-content: center; width: 100%; padding: 0 1rem; text-decoration: none; }
.pill.quiet { background: transparent; color: var(--muted); margin-left: auto; padding: 0 .4rem; white-space: nowrap; flex-shrink: 0; }
#account .who { display: flex; flex-direction: column; min-width: 0; }
#account .who b, #account .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account .who small { color: var(--muted); }

/* ---------- a suggestion: blue edge = swipe right to add it, red edge = swipe left to remove it ---------- */
.swipe { position: relative; border-radius: var(--r-lg); }
.swipe-act { position: absolute; inset: 0; border-radius: var(--r-lg); display: flex; align-items: center; gap: .45rem; padding: 0 1.4rem;
  color: #fff; font-weight: 650; font-size: .95rem; opacity: 0; transition: opacity .15s; }
.swipe-act .ic { width: 20px; height: 20px; transition: transform .15s; }
.swipe-act.keep { background: var(--accent); justify-content: flex-start; }
.swipe-act.del { background: var(--err); justify-content: flex-end; }
.swipe.to-keep .swipe-act.keep, .swipe.to-del .swipe-act.del { opacity: .55; }
.swipe.armed .swipe-act { opacity: 1; }
.swipe.armed .swipe-act .ic { transform: scale(1.15); }
.sent.gen { touch-action: pan-y; position: relative; z-index: 1; transition: transform .2s ease; }
/* A quiet hint of the gesture: the card's middle line runs on a little at each end, softly coloured
   (left blue: swipe right to add; right red: swipe left to remove). Level with the line, so the card stays calm. */
.sent.gen .src-row { position: relative; }
.sent.gen .src-row::before, .sent.gen .src-row::after { content: ''; position: absolute; top: -1px; width: 7px; height: 1px; border-radius: 1px; }
.sent.gen .src-row::before { left: calc(4px - 1.15rem); background: color-mix(in srgb, var(--accent) 45%, transparent); }
.sent.gen .src-row::after { right: calc(4px - 1rem); background: color-mix(in srgb, var(--err) 40%, transparent); }
@media (min-width: 760px) {   /* side by side there is no middle line: the same dashes, halfway down the card's edges */
  .sent.gen .src-row::before, .sent.gen .src-row::after { content: none; }
  .sent.gen::before, .sent.gen::after { content: ''; position: absolute; top: 50%; width: 7px; height: 1px; }
  .sent.gen::before { left: 4px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
  .sent.gen::after { right: 4px; background: color-mix(in srgb, var(--err) 40%, transparent); }
}
.sent.gen.dragging { transition: none; }
/* shown once: the card leans right (add), then left (remove) */
.swipe.peek .sent { animation: peek 1.5s ease-in-out; }
.swipe.peek .swipe-act.keep { animation: show-keep 1.5s ease-in-out; }
.swipe.peek .swipe-act.del { animation: show-del 1.5s ease-in-out; }
@keyframes peek { 0%, 100% { transform: none; } 22%, 34% { transform: translateX(96px); } 66%, 78% { transform: translateX(-96px); } }
@keyframes show-keep { 0%, 50%, 100% { opacity: 0; } 22%, 34% { opacity: .8; } }
@keyframes show-del { 0%, 50%, 100% { opacity: 0; } 66%, 78% { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .swipe.peek .sent, .swipe.peek .swipe-act { animation: none; } .sent.gen { transition: none; } }
/* the gesture replaces buttons; they are still there for keyboards and screen readers (shown when focused) */
.triage { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.triage:focus-within { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }

/* ---------- older suggestions: one quiet line ---------- */
button.earlier { display: flex; align-items: center; justify-content: center; gap: .3rem; width: 100%; min-height: 44px; margin-top: .4rem;
  border: 0; background: none; color: var(--muted); font-size: .9rem; font-weight: 600; }
button.earlier .ic { width: 16px; height: 16px; transform: rotate(-90deg); transition: transform .2s; }
button.earlier.open .ic { transform: rotate(90deg); }

/* ---------- rule cards: pattern (bold) · meaning (quiet) · example (accent) ---------- */
.rules { margin-top: .4rem; }
.rl { padding: .7rem 0; border-top: 1px solid var(--line); line-height: 1.4; }
.rl:first-child { border-top: 0; }
.rl b { font-size: 1.08rem; font-weight: 700; margin-right: .5rem; }
.rl span { color: var(--muted); }
.rl span.solo { color: var(--fg); }
.rl em { display: block; font-style: normal; color: var(--accent); margin-top: .25rem; font-weight: 500; }

/* ---------- cases table: whole words; wide tables scroll sideways with the case names pinned ---------- */
.tscroll { overflow-x: auto; margin: 1.1rem 0 0; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
table.cases { border-collapse: collapse; min-width: 100%; }
table.cases th, table.cases td { text-align: left; vertical-align: top; padding: .5rem 1.1rem .5rem 0; border-top: 1px solid var(--line); }
table.cases thead th { border-top: 0; padding-bottom: .35rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
table.cases td { white-space: nowrap; font-weight: 600; font-size: 1.05rem; }
table.cases th.case { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 5.6rem; padding-right: .9rem; font-weight: 400; }
table.cases th.case + td { padding-left: .9rem; border-left: 1px solid var(--line); }   /* the line the rest slides under */
table.cases thead th:nth-child(2) { padding-left: .9rem; }
table.cases th.case b { display: block; font-weight: 600; font-size: .92rem; }
table.cases th.case small { display: block; font-size: .8rem; color: var(--faint); margin-top: .05rem; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%); z-index: 30;
  background: var(--fg); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; font-size: .92rem; font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  max-width: calc(100vw - 2rem); text-align: center; animation: toast-in .2s ease-out; display: flex; align-items: center; gap: .9rem; justify-content: center; }
#toast[hidden] { display: none; }
.toast-act { border: 0; background: none; color: var(--accent-soft); font-weight: 700; padding: .2rem .1rem; text-transform: uppercase; font-size: .85rem; letter-spacing: .04em; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { #toast { animation: none; } }
@media (min-width: 760px) { #toast { bottom: 1.5rem; } }
html { overflow-anchor: none; }   /* like iPhone Safari: the app keeps your place itself (keepPlace) */

/* ---------- feedback: five stars, an optional note, Send ---------- */
.stars { display: flex; gap: .15rem; margin: -.3rem 0 0 -.45rem; }
.stars button { width: 46px; height: 46px; border: 0; background: none; display: grid; place-items: center; color: var(--line-strong); border-radius: 12px; }
.stars .ic { width: 30px; height: 30px; stroke-width: 1.5; transition: transform .12s, color .12s, fill .12s; }
.stars button.on { color: #f2b01e; }
.stars button.on .ic { fill: currentColor; }
.stars button:active .ic { transform: scale(.88); }
.fb-note { width: 100%; min-height: 3.2rem; resize: vertical; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  padding: .7rem .9rem; font: inherit; line-height: 1.45; }
.fb-note:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#fbSend { align-self: flex-start; min-width: 7rem; }
#fbSend:disabled { opacity: .45; }
.fb-status { font-size: .92rem; color: var(--ok); margin-top: -.2rem; }
.fb-status:empty { display: none; }
.fb-status.err { color: var(--err); }
.info .pills:not(:empty) { margin-top: .5rem; }
