@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/fraunces-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/fraunces-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/instrument-sans-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Sans";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/instrument-sans-italic.woff2") format("woff2");
}

:root {
  --bg: #f3ede2;
  --surface: #fcfaf5;
  --surface-2: #ebe3d5;
  --ink: #1f1a14;
  --ink-2: #5a5248;
  --muted: #8b8176;
  --line: #e2d9ca;
  --accent: #2b4c9e;
  --accent-ink: #ffffff;
  --accent-deep: #1f3a7a;
  --tint: #dfe6f7;
  --self: #b9502c;
  --self-tint: #f6e3d7;
  --self-ink: #7a3218;
  --coral: #ee7b55;
  --good: #4f7a3a;
  --good-tint: #e4ecd9;
  --veil: rgba(31, 26, 20, 0.36);
  --shadow: 0 18px 50px rgba(31, 26, 20, 0.16);
  --lift: 0 1px 2px rgba(31, 26, 20, 0.06);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --col: 720px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
:root[data-theme="dark"] {
    --bg: #171310;
    --surface: #211c17;
    --surface-2: #2c251e;
    --ink: #f1e9dc;
    --ink-2: #c6bbad;
    --muted: #978b7d;
    --line: #342c24;
    --accent: #93abf0;
    --accent-ink: #0f1a3a;
    --accent-deep: #b9c9f7;
    --tint: #232c47;
    --self: #e08a68;
    --self-tint: #3b2419;
    --self-ink: #f0b79e;
    --coral: #ff9b76;
    --good: #9cbf7c;
    --good-tint: #253320;
    --veil: rgba(0, 0, 0, 0.55);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    --lift: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
    --bg: #171310;
    --surface: #211c17;
    --surface-2: #2c251e;
    --ink: #f1e9dc;
    --ink-2: #c6bbad;
    --muted: #978b7d;
    --line: #342c24;
    --accent: #93abf0;
    --accent-ink: #0f1a3a;
    --accent-deep: #b9c9f7;
    --tint: #232c47;
    --self: #e08a68;
    --self-tint: #3b2419;
    --self-ink: #f0b79e;
    --coral: #ff9b76;
    --good: #9cbf7c;
    --good-tint: #253320;
    --veil: rgba(0, 0, 0, 0.55);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    --lift: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

/* The Italian app: plum where the Spanish app is cobalt, so the two are told apart on a phone. */
html[data-lang="it"] {
  --accent: #6a2c70;
  --accent-ink: #ffffff;
  --accent-deep: #4e1f53;
  --tint: #efe1f0;
}
:root[data-theme="dark"][data-lang="it"] {
    --accent: #d7a6dc;
    --accent-ink: #2a1030;
    --accent-deep: #e8c4ec;
    --tint: #3a2440;
  }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"])[data-lang="it"] {
    --accent: #d7a6dc;
    --accent-ink: #2a1030;
    --accent-deep: #e8c4ec;
    --tint: #3a2440;
  }
}

html[data-lang="nl"] {
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-deep: #9a3412;
  --tint: #fbe4d6;
}
:root[data-theme="dark"][data-lang="nl"] {
    --accent: #fdba8c;
    --accent-ink: #3a1606;
    --accent-deep: #fed7bd;
    --tint: #40261a;
  }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"])[data-lang="nl"] {
    --accent: #fdba8c;
    --accent-ink: #3a1606;
    --accent-deep: #fed7bd;
    --tint: #40261a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
html { height: 100%; -webkit-text-size-adjust: 100%; overscroll-behavior: none; font: -apple-system-body; }
body {
  margin: 0;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.15rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
::selection { background: var(--tint); color: var(--ink); }
#app { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 960px) { body { font-size: 1.05rem; } }
h1, h2, h3, p { margin: 0; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { cursor: default; opacity: 0.45; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea { font: inherit; color: inherit; }
.i { flex: none; }

/* ---------- primitives ---------- */

.serif { font-family: var(--serif); font-optical-sizing: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.cv-mark { display: inline-flex; flex: none; }
.cv-mark .b { fill: var(--accent); }
.cv-mark .d { fill: var(--coral); }
.brand.switch { padding: 6px 10px 6px 6px; margin-left: -6px; border-radius: 14px; gap: 8px; transition: background 0.15s; }
.brand.switch:hover { background: var(--surface-2); }
.brand.switch > .i { color: var(--muted); margin-left: -2px; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
.seg.theme { display: flex; }
.seg.theme button { flex: 1; justify-content: center; }
.menu { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 0 14px; }
.menu .rowitem { color: inherit; text-decoration: none; }
.menu .rowitem .d { color: var(--muted); font-size: 0.95rem; }
.menu .rowitem > .i-check { color: var(--accent); }
.rowitem .ic.lang { background: none; overflow: hidden; }
.rowitem .ic.lang img { width: 44px; height: 44px; border-radius: 13px; }
.wordmark { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); line-height: 1; }
.title { font-family: var(--serif); font-size: 1.85rem; font-weight: 500; letter-spacing: -0.015em; line-height: 1.15; }
.label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 1rem; }
.error { color: var(--self); font-size: 1rem; }
.error:empty { display: none; }
.login .error { min-height: 1.5em; display: block; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink); font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background 0.15s, transform 0.12s var(--ease), box-shadow 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { box-shadow: var(--lift); }
.btn.ghost { background: transparent; color: var(--ink-2); padding: 0 12px; }
.btn.ghost:hover { color: var(--ink); }
.btn.wide { width: 100%; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2); transition: background 0.15s, color 0.15s, transform 0.12s var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn:active { transform: scale(0.94); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field input, .field textarea {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); outline: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px; box-shadow: var(--lift); }
.card > .label { margin-bottom: 8px; }
.card > .rowitem:last-of-type { padding-bottom: 4px; }
.card > .levels { margin-top: 10px; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.seg button, .seg a {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px;
  color: var(--muted); font-size: 1rem; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.seg button.on, .seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--lift); }
.seg a { text-decoration: none; }

.rowitem {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 15px 0; border-top: 1px solid var(--line);
}
.rowitem:first-of-type { border-top: 0; }
.rowitem .ic { width: 44px; height: 44px; border-radius: 13px; background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; flex: none; }
.rowitem .body { flex: 1; min-width: 0; }
.rowitem .t { font-weight: 500; overflow-wrap: anywhere; }
.rowitem .t .tags { white-space: nowrap; }
.rowitem .t .count { margin-left: 8px; font-size: 0.85rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rowitem .t .has { display: inline-flex; margin-left: 6px; vertical-align: -2px; color: var(--muted); }
.rowitem .d { font-size: 1rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
@media (min-width: 720px) { .rowitem .d { -webkit-line-clamp: 1; } }
.rowitem .meta {
  flex: none; align-self: center; font-size: 0.82rem; font-weight: 500; line-height: 1; padding: 6px 10px; border-radius: 999px;
  color: var(--ink-2); background: var(--surface-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rowitem .meta.due { color: var(--accent); background: var(--tint); }
.rowitem .meta.fresh { color: var(--accent); background: transparent; box-shadow: inset 0 0 0 1px var(--tint); }
.rowitem .chev { color: var(--muted); flex: none; }
.rowitem .i-chevron-right { color: var(--muted); transition: transform 0.15s var(--ease), color 0.15s; }
.rowitem:hover .t .name { color: var(--accent); }
.rowitem:hover .i-chevron-right { transform: translateX(2px); color: var(--accent); }

.tag { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- login ---------- */

.login { flex: 1; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); overflow-y: auto; }
.login form, .loginbox { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login form[hidden] { display: none; }
.login .brand { flex-direction: column; gap: 12px; margin-bottom: 24px; }
.login .wordmark { font-size: 2.1rem; }
.login .tagline { font-family: var(--serif); font-style: italic; font-size: 1.1rem; color: var(--muted); margin-top: -6px; }
.login .btn { margin-top: 6px; }
.login .hint { text-align: center; margin-top: -2px; }
.login .userpass { margin-top: 8px; }

/* ---------- home ---------- */

.screen { height: 100%; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.page .inner { width: 100%; max-width: 720px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 52px; }
.topnav { display: none; }
.card, .rowitem, .rowitem .body { min-width: 0; }

.tabbar {
  flex: none; display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; max-width: 120px; padding: 4px 0 2px; border-radius: 14px;
  color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  transition: color 0.15s, background 0.15s;
}
.tabbar a svg { box-sizing: content-box; padding: 4px 18px; border-radius: 999px; transition: background 0.2s var(--ease); }
.tabbar a.on { color: var(--accent); }
.tabbar a.on svg { background: var(--tint); }
.tabbar a:active svg { background: var(--surface-2); }

.tabhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.card.list { padding-top: 6px; padding-bottom: 6px; }
.card.list .rowitem:last-of-type { padding-bottom: 15px; }
.card.list .empty { padding: 12px 0; }
.rowitem .meta.open { color: var(--good); background: var(--good-tint); font-weight: 600; }
.card.list .rowitem { align-items: center; }
.card.list .rowitem .ic { background: var(--surface-2); color: var(--ink-2); }
@media (max-width: 719px) { .card.list .rowitem > .i-chevron-right { display: none; } }
.btn.more { align-self: center; }

.hero { padding-top: 16px; }
.hero .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.btn.start {
  width: 100%; height: auto; min-height: 88px; padding: 18px 18px 18px 24px; border-radius: 20px; justify-content: space-between; gap: 16px;
  white-space: normal; text-align: left; box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.start .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.btn.start .big { font-family: var(--serif); font-size: 1.75rem; font-weight: 500; line-height: 1.05; letter-spacing: -0.01em; }
.btn.start .line { font-size: 0.95rem; opacity: 0.85; overflow-wrap: anywhere; }
.btn.start .go {
  flex: none; width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-ink) 16%, transparent); transition: transform 0.15s var(--ease);
}
.btn.start:hover .go { transform: translateX(2px); }
.btn.start:disabled { opacity: 0.7; }
.hero .or { text-align: center; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 4px; }
.hero .rowitem { padding: 13px 0; }
.hero .head h2 { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.1; }
.hero .rowitem .ic { width: 48px; height: 48px; border-radius: 14px; background: var(--tint); color: var(--accent); transition: background 0.15s, color 0.15s; }
.hero .rowitem .t { font-size: 1.12em; }
.hero .rowitem:disabled .ic { background: var(--surface-2); color: var(--muted); }
.hero .rowitem:disabled { opacity: 1; }
.hero .rowitem:disabled .t { color: var(--ink-2); }
.hero .rowitem:hover:not(:disabled) .ic { background: var(--accent); color: var(--accent-ink); }

.levels { display: flex; flex-direction: column; gap: 12px; }
.level { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 12px; font-size: 1rem; }
.level .name { color: var(--ink-2); }
.level .val { text-align: right; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.track { display: flex; gap: 3px; }
.track i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.track i.on { background: var(--accent); }
.track.set button { flex: 1; padding: 8px 0; border: 0; background: none; cursor: pointer; }
.track.set button i { display: block; height: 6px; border-radius: 3px; background: var(--line); }
.track.set button.on i { background: var(--accent); }
.track.set button:hover i { outline: 1px solid var(--accent); }
.levelhint { margin: 10px 0 0; font-size: 0.85rem; }
.facts { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 1rem; }
.fact { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.fact .n { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.empty { padding: 8px 0 2px; font-size: 1rem; color: var(--muted); }
.homegrid { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 720px) { .homegrid { gap: 24px; } }
@media (min-width: 960px) {
  .page .inner:has(.homegrid) { max-width: 1040px; }
  .homegrid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
}

@media (min-width: 720px) {
  .page .inner { padding: 28px 32px 64px; gap: 24px; }
  .topbar { margin-bottom: 8px; }
  .tabbar { display: none; }
  .topnav { display: flex; gap: 4px; flex: 1; justify-content: center; }
  .topnav a {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px;
    color: var(--muted); text-decoration: none; font-weight: 500; font-size: 1rem; transition: color 0.15s, background 0.15s;
  }
  .topnav a .i { display: none; }
  .topnav a:hover { color: var(--ink); background: var(--surface-2); }
  .topnav a.on { color: var(--ink); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--line); }
  .card { padding: 24px; }
  .hero { padding-top: 20px; }
}

/* ---------- session ---------- */

.chat { height: 100%; display: flex; flex-direction: column; }
.chat-head { flex: none; background: var(--bg); border-bottom: 1px solid var(--line); }
.chat-head .inner { max-width: var(--col); margin: 0 auto; padding: max(4px, env(safe-area-inset-top)) 12px 0; }
.chat-head .bar { display: flex; align-items: center; gap: 4px; height: 56px; }
.chat-head .ttl { flex: 1; min-width: 0; padding-left: 2px; font-family: var(--serif); font-size: 1.2rem; font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .end { flex: none; display: flex; }
.chat-head .lead { flex: none; display: flex; margin-left: -6px; }
.chat-head .end .btn { margin-left: auto; }
.scene {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 0 4px 12px; font-size: 0.95rem; color: var(--muted);
}
.scene span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene .i { color: var(--muted); }
.scene:hover { color: var(--ink-2); }

.log { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.log .inner { max-width: var(--col); margin: 0 auto; padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.m { display: flex; flex-direction: column; align-items: flex-start; max-width: 88%; }
.m.live { animation: enter 0.24s var(--ease); }
.m.user { align-self: flex-end; align-items: flex-end; max-width: 82%; }
.who { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin: 0 0 5px 14px; }
.bubble {
  padding: 11px 16px; border-radius: 20px; border-bottom-left-radius: 6px; line-height: 1.5;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--lift);
}
.m.user .bubble {
  border-radius: 20px; border-bottom-right-radius: 6px; border-color: transparent; box-shadow: none;
  background: var(--accent); color: var(--accent-ink);
}
.bubble .w, .gcard .w, .gtable .f { cursor: pointer; border-radius: 4px; padding: 0 1px; margin: 0 -1px; transition: background 0.12s; }
.bubble .w:hover, .gcard .w:hover, .gtable .f:hover { background: var(--tint); }
.bubble .w:active, .gcard .w:active, .gtable .f:active { background: var(--tint); }
.bubble.veil .text { filter: blur(7px); transition: filter 0.4s; }
.acts { display: flex; gap: 0; margin: 2px 0 0 4px; }
.acts .iconbtn { width: 36px; height: 34px; color: var(--muted); }
.acts .iconbtn svg { width: 18px; height: 18px; }
.m .hint { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0 0 14px; color: var(--ink-2); font-size: 1rem; }
.m .hint svg { flex: none; margin-top: 2px; color: var(--accent); }
.acts .iconbtn:hover { color: var(--ink); }
.acts { opacity: 0.8; }
@media (hover: hover) {
  .acts { opacity: 0.45; transition: opacity 0.15s; }
  .m:hover .acts, .m:focus-within .acts { opacity: 1; }
}
.chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--self-ink); font-size: 0.92rem; font-weight: 500;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.15s;
}
.chip::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--self); }
.chip:hover { border-color: var(--self); }
.chip.lesson::before { display: none; }
.note { align-self: center; text-align: center; font-size: 1rem; color: var(--muted); padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wait { align-self: flex-start; display: flex; gap: 5px; padding: 12px 16px; }
.wait i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.wait i:nth-child(2) { animation-delay: 0.2s; }
.wait i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.compose { flex: none; background: var(--bg); border-top: 1px solid var(--line); }
.compose .inner { max-width: var(--col); margin: 0 auto; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.compose .text { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.compose .tip { flex-basis: 100%; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 0.92rem; color: var(--muted); padding-left: 8px; }
.compose .tip .iconbtn { width: 32px; height: 32px; color: var(--muted); }
.compose textarea {
  flex: 1; min-height: 48px; max-height: 160px; padding: 12px 18px; resize: none;
  border-radius: 24px; border: 1px solid var(--line); background: var(--surface); outline: 0; line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.compose textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }
.compose textarea::placeholder { color: var(--muted); font-family: var(--serif); font-style: italic; }
.send { width: 48px; height: 48px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; transition: transform 0.12s var(--ease); }
.send:active { transform: scale(0.94); }
.compose .voice { display: grid; grid-template-columns: 44px 1fr 44px; align-items: start; padding: 6px 0 2px; }
.compose .voice > .iconbtn { margin-top: 18px; }
.compose .voice .center { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mic {
  width: 80px; height: 80px; border-radius: 999px; display: grid; place-items: center; position: relative;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--lift);
  transition: background 0.2s, transform 0.12s var(--ease);
}
.mic:active { transform: scale(0.95); }
.mic.rec { background: var(--self); color: #fff; }
.mic.rec::before {
  content: ""; position: absolute; inset: -6px; border-radius: 999px; border: 2px solid var(--self); opacity: 0.4;
  animation: pulse 1.6s infinite ease-out;
}
.mic .i-loader-circle { animation: spin 0.9s linear infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.45; } 100% { transform: scale(1.4); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.mic-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-variant-numeric: tabular-nums; }
.compose .ended { text-align: center; font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--muted); padding: 10px 0; }

/* ---------- flashcards ---------- */

.deck { height: 100%; display: flex; flex-direction: column; }
.deck .chat-head .count { width: 72px; text-align: right; padding-right: 6px; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 4px; margin: 0 6px 12px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--accent); transition: width 0.35s var(--ease); }
.stage { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; }
.stage .inner { width: 100%; max-width: 560px; margin: auto; padding: 24px 16px; }
.fcard {
  position: relative; min-height: 320px; padding: 40px 24px 32px; border-radius: 28px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--lift);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  animation: deal 0.28s var(--ease);
}
.fcard .tag.new, .fcard .tag.retry {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; color: var(--accent); background: var(--tint); line-height: 1.2;
}
.fcard .ask { font-family: var(--serif); font-size: 2rem; font-weight: 500; line-height: 1.2; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.fcard .answer {
  width: 100%; margin-top: 14px; padding-top: 22px; border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px; animation: enter 0.24s var(--ease);
}
.fcard .word { font-family: var(--serif); font-size: 2.6rem; font-weight: 500; line-height: 1.1; letter-spacing: -0.015em; color: var(--accent); overflow-wrap: anywhere; }
.fcard.finish { gap: 6px; }
.fcard.finish > .i { color: var(--accent); margin-bottom: 4px; }
.fcard.finish .score { font-family: var(--serif); font-size: 3rem; font-weight: 500; line-height: 1.05; font-variant-numeric: tabular-nums; }
.fcard.finish .goal { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--good); font-weight: 600; }
.fcard.finish .list { align-self: stretch; display: flex; flex-direction: column; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); text-align: left; }
.fcard.finish .list .k { color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.fcard.finish .pair { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.fcard.finish .pair .right { font-weight: 600; color: var(--good); }
.fcard.finish .pair .i { color: var(--good); align-self: center; }
.deck .compose .inner { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.deck .reveal { height: 58px; font-size: 1.1rem; }
.deck .compose .row { display: flex; gap: 10px; justify-content: center; }
.deck .compose .row .btn { flex: 1; max-width: 240px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade {
  height: 62px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--surface-2); color: var(--ink); font-weight: 600; transition: transform 0.12s var(--ease), filter 0.15s;
}
.grade:active { transform: scale(0.96); }
.grade:hover { filter: brightness(0.97); }
.grade.again { background: var(--self-tint); color: var(--self-ink); }
.grade.good { background: var(--accent); color: var(--accent-ink); }
.grade.easy { background: var(--good-tint); color: var(--good); }
.deck .keys { display: none; text-align: center; font-size: 0.8rem; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .deck .keys { display: block; } }
@media (min-width: 720px) {
  .fcard { min-height: 360px; padding: 48px 40px 40px; }
  .fcard .ask { font-size: 2.3rem; }
  .fcard .word { font-size: 3rem; }
  .deck .compose .inner { max-width: 560px; }
}
@keyframes deal { from { opacity: 0; transform: translateY(14px) scale(0.985); } }

.fcard .spoken { display: inline-flex; align-items: center; gap: 4px; }
.fcard .spoken .say { width: 40px; height: 40px; color: var(--accent); }
.fcard .ask.spoken { font-family: var(--serif); }
.fcard .meaning { font-family: var(--serif); font-size: 1.6rem; font-weight: 500; line-height: 1.25; color: var(--accent); }
.fcard .also { margin-top: 8px; font-size: 0.95rem; color: var(--muted); }
.grades { grid-template-columns: repeat(2, 1fr); }
.deck .more-new { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 6px; text-align: center; }
.deck .more-new p { max-width: 36ch; }
.deck .compose .btn.ghost { align-self: center; }

/* ---------- meanings to add ---------- */

.meanings { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.meanings .k { color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.meanings .entry { display: flex; flex-direction: column; gap: 6px; }
.meanings .pos { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.meanings .sense {
  display: grid; grid-template-columns: auto 1fr 28px; align-items: center; gap: 4px 12px; text-align: left;
  padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.meanings .sense:hover { border-color: var(--accent); }
.meanings .sense .es { font-family: var(--serif); font-weight: 500; font-size: 1.05rem; }
.meanings .sense .en { color: var(--ink-2); font-size: 1rem; }
.meanings .sense .state { color: var(--accent); display: grid; place-items: center; }
.meanings .sense.added { background: var(--good-tint); border-color: transparent; opacity: 1; }
.meanings .sense.added .state { color: var(--good); }

/* ---------- sheets ---------- */

.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--veil);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease-out;
}
.sheet .panel {
  width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--surface);
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); border-bottom: 0; box-shadow: var(--shadow); animation: rise 0.26s var(--ease);
}
.sheet .handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.sheet .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin-bottom: 10px; }
.sheet .head h3 { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; overflow-wrap: anywhere; }
.sheet .body { display: flex; flex-direction: column; gap: 14px; }
.sheet .foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.sheet .foot > * { flex: 1 1 auto; }
.sheet .foot > .meanings { flex-basis: 100%; }
@media (max-width: 719px) { .sheet .foot:has(> .btn:nth-of-type(3)) > .btn.primary { flex-basis: 100%; } }
.sheet .kv { display: grid; grid-template-columns: 104px 1fr; gap: 8px 12px; font-size: 1.05rem; }
.sheet .kv .k { color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding-top: 5px; }
.sheet .kv .wrong { text-decoration: line-through; text-decoration-color: var(--self); color: var(--ink-2); }
.sheet .kv .right { font-weight: 600; color: var(--good); }
.sheet .pre { white-space: pre-line; }
.sheet .score { display: flex; align-items: baseline; gap: 10px; font-family: var(--serif); font-size: 2.4rem; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sheet .score .muted { font-family: var(--sans); font-size: 1rem; font-weight: 400; }
.sheet .list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.sheet .list .k { color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.sheet .pair { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 1.05rem; }
.sheet .pair .wrong { text-decoration: line-through; text-decoration-color: var(--self); color: var(--ink-2); }
.sheet .pair .right { font-weight: 600; color: var(--good); }
.sheet .pair .i { color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(28px); } }
@media (min-width: 720px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet .panel { width: 540px; border-radius: 24px; border-bottom: 1px solid var(--line); padding: 20px 28px 28px; animation: pop 0.22s var(--ease); }
  .sheet .handle { display: none; }
  .sheet .foot > .btn { flex: none; }
}
@keyframes pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } }

.lesson { line-height: 1.55; }
.lesson h3 { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; margin: 6px 0 10px; }
.lesson p { margin: 0 0 12px; }
.lesson ul, .lesson ol { margin: 0 0 12px; padding-left: 20px; }
.lesson li { margin-bottom: 6px; }
.lesson em { font-family: var(--serif); font-style: italic; font-size: 1.08em; color: var(--ink); }
.lesson code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.95em; font-family: var(--serif); }
.lesson table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 1rem; }
.lesson th, .lesson td { border-bottom: 1px solid var(--line); padding: 6px 8px 6px 0; text-align: left; vertical-align: top; }
.lesson th { font-weight: 600; color: var(--muted); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- loading ---------- */

.i-loader-circle { animation: spin 0.9s linear infinite; }
.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.pending { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.note.done { flex-direction: row; gap: 8px; color: var(--good); }

/* ---------- grammar cards ---------- */

.contents { display: contents; }
.gcard { gap: 10px; }
.gcard .tag.topic { position: absolute; top: 18px; left: 20px; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard .ask { font-size: 2.2rem; color: var(--ink); }
.gcard .label.tense { font-size: 0.9rem; color: var(--ink-2); }
.gcard .person { font-size: 0.95rem; font-weight: 600; color: var(--accent); background: var(--tint); border-radius: 999px; padding: 3px 12px; }
.gcard .gline { font-family: var(--serif); font-size: 1.7rem; font-weight: 500; line-height: 1.35; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.gcard .hint { color: var(--muted); font-size: 1.05rem; font-family: var(--serif); font-style: italic; }
.slot {
  display: inline-block; min-width: 3.2em; padding: 0 6px; margin: 0 2px; border-bottom: 2px solid var(--accent);
  color: var(--accent); text-align: center; transition: color 0.15s, border-color 0.15s, background 0.15s; border-radius: 4px 4px 0 0;
}
.slot.ok { color: var(--good); border-color: var(--good); background: var(--good-tint); }
.slot.fix { color: var(--self-ink); border-color: var(--self); background: var(--self-tint); }
.gback { width: 100%; margin-top: 8px; padding-top: 16px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 12px; text-align: left; animation: enter 0.24s var(--ease); }
.gback .vrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gback .say { width: 40px; height: 40px; color: var(--accent); flex: none; }
.gback .vbtns { display: flex; gap: 4px; flex: none; }
.fcard .cardask { display: flex; justify-content: center; margin-top: 8px; }
.fcard .ask.num, .fcard .meaning.num { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.fcard .nword { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; line-height: 1.25; color: var(--accent); overflow-wrap: anywhere; }
.fcard .numrows { align-self: stretch; display: flex; flex-direction: column; gap: 6px; }
.fcard .numrow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; text-align: left; animation: enter 0.24s var(--ease); }
.fcard .numrow .num { font-weight: 600; font-variant-numeric: tabular-nums; }
.fcard .numrow.ok > .i { color: var(--good); }
.fcard .numrow.fix > .i { color: var(--self); }
.fcard .numrow .typed { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--self); }
.fcard .say.big { width: 64px; height: 64px; }
.fcard .say.big svg { width: 32px; height: 32px; }
.fcard .cardask .iconbtn { width: 40px; height: 40px; color: var(--accent); }
.verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 1.05rem; font-weight: 600; }
.verdict.ok { color: var(--good); }
.verdict.fix { color: var(--self-ink); }
.verdict strong { font-family: var(--serif); font-size: 1.2rem; color: var(--good); }
.verdict .wrong { font-weight: 400; color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--self); }
.gtable { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.gtable .k, .own .k { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.gtable .k { padding: 8px 12px 6px; background: var(--surface-2); }
.gtable .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 10px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 1rem; }
.gtable .row .p { color: var(--muted); }
.gtable .row .f { font-family: var(--serif); font-weight: 500; }
.gtable .row.on { background: var(--tint); }
.gtable .row.on .f { color: var(--accent); font-weight: 600; }
.gback .note { font-size: 0.95rem; color: var(--ink-2); }
.gback .when { font-size: 0.85rem; color: var(--muted); }
.own { display: flex; flex-direction: column; gap: 4px; }
.own .pair { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.own .wrong { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--self); }
.own .right { color: var(--good); font-weight: 600; }
.own .i { color: var(--muted); }
.btn.small { height: 36px; font-size: 0.95rem; align-self: flex-start; padding: 0 10px; gap: 6px; }
.gentry { display: flex; gap: 8px; }
.ganswer {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  font-family: var(--serif); font-size: 1.25rem; color: var(--ink); outline: 0;
}
.ganswer:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }
.ganswer.right { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-tint); }
.ganswer.wrong, .ganswer.accent { border-color: var(--self); box-shadow: 0 0 0 3px var(--self-tint); }
.ganswer::placeholder { color: var(--muted); font-style: italic; font-size: 1.05rem; }
.gcheck { height: 52px; min-width: 96px; padding: 0 18px; font-size: 1rem; }
.gmic { width: 52px; height: 52px; flex: none; border: 1px solid var(--line); background: var(--surface); }
.gmic.rec { background: var(--self); border-color: var(--self); color: #fff; }
.gmic .i-loader-circle { animation: spin 0.9s linear infinite; }
.chip.added { cursor: default; color: var(--accent); }
.chip.added::before { display: none; }
.chip.added:hover { border-color: var(--line); }
.gtable .end { color: var(--accent); font-weight: 700; }
.gtable .row.on .end { text-decoration: underline; text-underline-offset: 3px; }
.gback .note { text-align: left; }
.gcard .ghint { color: var(--muted); }
.gcard .ghint:hover { color: var(--accent); }
.fcard:has(> .tag.new, > .tag.retry) { padding-top: 56px; }

.startlevel { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.startlevel h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 8px; }
.startlevel .row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.startlevel .row .title { font-weight: 600; }
.startlevel .row .desc { color: var(--ink-2); font-size: 0.95rem; }

.balancebar { margin-top: 16px; }
.balancebar .bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.balancebar .bar span { display: block; height: 100%; background: var(--accent); }
