/* Svenska — single stylesheet. Calm, book-like. */

:root {
  --bg: #faf7f2;
  --bg-raised: #ffffff;
  --ink: #2b2620;
  --ink-soft: #6b6357;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #2da44e;
  --warn: #bf8700;
  --err: #cf222e;
  --almost: #bf8700;
  --line: #e6ded2;
  --new-word: #fff3c4;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 46rem;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 38, 32, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a17;
    --bg-raised: #262220;
    --ink: #e8e2d9;
    --ink-soft: #a89f92;
    --accent: #6ca4f8;
    --accent-ink: #10233f;
    --line: #3a342e;
    --new-word: #4a3f1d;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}
main { max-width: var(--maxw); margin: 0 auto; padding: 1.2rem 1rem 4rem; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
img { max-width: 100%; }
.muted { color: var(--ink-soft); }
.mt { margin-top: 1rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

/* topbar */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg-raised); }
.nav {
  max-width: 62rem; margin: 0 auto; padding: .5rem 1rem;
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
}
.nav a { color: var(--ink); text-decoration: none; padding: .25rem 0; }
.nav a.active { color: var(--accent); font-weight: 600; }
.nav .brand { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--accent); }
.nav .spacer { flex: 1; }
.admin-link { color: var(--warn) !important; }
.inline-form { display: inline; }

.flash { max-width: var(--maxw); margin: .8rem auto 0; padding: .5rem .9rem; border-radius: var(--radius); }
.flash.ok { background: color-mix(in srgb, var(--ok) 12%, var(--bg-raised)); color: var(--ok); }
.flash.err { background: color-mix(in srgb, var(--err) 12%, var(--bg-raised)); color: var(--err); }

/* buttons & forms */
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: var(--radius); padding: .55rem 1.1rem;
  font-size: 1rem; cursor: pointer; text-decoration: none; font-family: var(--sans);
}
.btn:hover { filter: brightness(1.08); }
.btn.small { padding: .3rem .7rem; font-size: .9rem; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--err); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linklike {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font: inherit; padding: 0; text-decoration: underline;
}
.danger-text { color: var(--err); }
label { display: block; margin: .8rem 0 .25rem; font-weight: 600; font-size: .92rem; }
.check-label { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; max-width: 28rem; padding: .5rem .6rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-raised); color: var(--ink);
}
textarea { max-width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .choice:focus-visible, .tile:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
form button[type=submit] { margin-top: .9rem; }
.form-error { color: var(--err); white-space: pre-wrap; }

/* auth cards, settings */
.auth-card, .settings-card {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.4rem; margin: 1rem 0;
  box-shadow: var(--shadow); max-width: 30rem;
}
.settings-card.danger { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.auth-alt { font-size: .92rem; }

/* hero */
.hero { padding-top: 2.5rem; }
.hero h1 { font-family: var(--serif); font-size: 2.4rem; }
.lede { font-size: 1.15rem; }
.feature-list { padding-left: 1.2rem; }
.feature-list li { margin: .6rem 0; }

/* dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .8rem; margin: 1rem 0; }
.stat-card {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem; text-decoration: none; color: var(--ink); display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.stat-card.highlight { border-color: var(--accent); }
.stat-card.warn { border-color: var(--warn); }
.stat-card.error { border-color: var(--err); }
.stat-num { font-size: 1.7rem; font-weight: 700; font-family: var(--serif); }
.stat-label { color: var(--ink-soft); font-size: .88rem; }
.daily-goal { margin: 1rem 0; }
.chapter-card {
  display: flex; gap: 1rem; align-items: center; background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.chapter-card img { width: 7rem; border-radius: 8px; }
.ch-num { display: block; color: var(--ink-soft); font-size: .85rem; }
.ch-title { font-family: var(--serif); font-size: 1.25rem; }
.ch-note { display: block; color: var(--accent); font-size: .9rem; }
.placement-offer { margin-top: 1.4rem; }

/* progress bars */
.progress { background: var(--line); border-radius: 99px; height: .5rem; overflow: hidden; }
.progress-bar { background: var(--accent); height: 100%; border-radius: 99px; transition: width .3s; }
.strength-bar { background: var(--line); border-radius: 99px; height: .45rem; width: 6rem; overflow: hidden; }
.strength-bar > div { background: var(--ok); height: 100%; }

/* chapter list */
.unit { margin: 1.4rem 0; }
.level-tag {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  font-size: .72rem; font-weight: 700; border-radius: 5px; padding: .1rem .4rem;
  vertical-align: middle; margin-right: .3rem;
}
.chapter-list { list-style: none; padding: 0; }
.chapter-list li { border-bottom: 1px solid var(--line); }
.ch-item { display: flex; gap: .8rem; align-items: baseline; padding: .55rem .3rem; text-decoration: none; color: var(--ink); }
.ch-item:hover { background: var(--bg-raised); }
.ch-n { color: var(--ink-soft); min-width: 1.6rem; text-align: right; }
.chapter-list li.current .ch-item { font-weight: 700; color: var(--accent); }
.chapter-list li.locked .ch-item { color: var(--ink-soft); }
.check { color: var(--ok); margin-left: auto; }
.lock { margin-left: auto; }

/* ---- reader: the book page ---- */
.reader-head h1 { font-family: var(--serif); font-size: 2.1rem; margin: .2rem 0 .6rem; }
.ch-meta { color: var(--ink-soft); font-size: .9rem; margin-bottom: 0; }
.reader-controls { display: flex; gap: 1rem; align-items: center; margin: .6rem 0 1rem; }
.speed-label { display: inline-flex; gap: .4rem; align-items: center; margin: 0; font-weight: 400; font-size: .9rem; }
.speed-label select { width: auto; }
.intro-image { border-radius: var(--radius); box-shadow: var(--shadow); margin: .4rem 0 1rem; }

.reader-body {
  font-family: var(--serif); font-size: 1.22rem; line-height: 1.75;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem clamp(1.2rem, 5vw, 3rem); box-shadow: var(--shadow);
}
.reader-para { margin: 0 0 1.1rem; }
.reader-heading { font-size: 1.35rem; margin: 1.4rem 0 .6rem; }
.reader-figure { margin: 1.4rem 0; text-align: center; }
.reader-figure img { border-radius: 8px; max-height: 22rem; }

.sentence { position: relative; }
.sentence.playing { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 4px; }
.sent-play {
  background: none; border: none; color: var(--ink-soft); cursor: pointer;
  font-size: .75em; padding: 0 .15em; vertical-align: super; opacity: .55;
}
.sent-play:hover { opacity: 1; color: var(--accent); }

.w { cursor: pointer; border-radius: 3px; }
.w:hover, .w:focus-visible { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.new-word { background: var(--new-word); box-shadow: 0 1px 0 var(--warn); }

.margin-gloss {
  display: block; float: right; clear: right; width: 11rem; margin-right: -12.2rem;
  font-family: var(--sans); font-size: .82rem; color: var(--ink-soft);
  border-left: 2px solid var(--line); padding-left: .6rem; line-height: 1.35;
}
@media (max-width: 74rem) {
  .margin-gloss {
    float: none; width: auto; margin: 0 0 .2rem; display: block;
    border-left: 2px solid var(--line);
  }
}

/* word popover */
.popover {
  position: absolute; z-index: 30; max-width: 22rem;
}
.word-card {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 1rem 1.1rem; font-family: var(--sans);
  font-size: .95rem; line-height: 1.45;
}
.word-card-head { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.word-card h3 { margin: 0; font-family: var(--serif); font-size: 1.3rem; }
.word-class { color: var(--ink-soft); font-size: .82rem; }
.word-img { width: 9rem; border-radius: 8px; margin: .4rem 0; display: block; }
.sv-gloss { font-style: italic; margin: .3rem 0; }
.en-gloss { color: var(--ink-soft); margin: .2rem 0; }
.forms-table { border-collapse: collapse; margin: .4rem 0; }
.forms-table td { padding: .1rem .55rem .1rem 0; }
.forms-table .tag { color: var(--ink-soft); font-size: .8rem; }
.word-meta { font-size: .85rem; color: var(--ink-soft); }
.in-deck { color: var(--ok); font-size: .9rem; }
.in-deck-dot { color: var(--ok); font-size: .7rem; }

.audio-btn {
  background: none; border: 1px solid var(--line); border-radius: 99px;
  cursor: pointer; font-size: 1rem; padding: .15rem .5rem; color: var(--ink);
}
.audio-btn:hover { border-color: var(--accent); }
.audio-btn.small { font-size: .85rem; padding: .05rem .4rem; }
.audio-btn.big { font-size: 2.2rem; padding: .6rem 1.2rem; display: block; margin: .5rem auto; }

/* new words + interlude sections */
.new-words, .grammar-interlude, .pensum {
  margin-top: 1.6rem; background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.4rem; box-shadow: var(--shadow);
}
.new-word-list { list-style: none; padding: 0; columns: 2; }
.new-word-list li { margin: .3rem 0; break-inside: avoid; }
@media (max-width: 40rem) { .new-word-list { columns: 1; } }

/* pensum */
.pensum-list li { margin: .8rem 0; }
.pensum-prompt { font-family: var(--serif); font-size: 1.08rem; font-weight: 400; }
.pensum-review { list-style: none; padding: 0; }
.pensum-review li { padding: .45rem .6rem; border-radius: 8px; margin: .3rem 0; display: flex; gap: .7rem; flex-wrap: wrap; }
.pensum-review li.ok { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.pensum-review li.almost { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.pensum-review li.wrong { background: color-mix(in srgb, var(--err) 10%, transparent); }
.pr-given { font-weight: 600; }
.pr-note { color: var(--ink-soft); }
.fb-correct-text { color: var(--ok); font-weight: 600; }
.fb-wrong-text { color: var(--err); }

.reader-nav { display: flex; justify-content: space-between; margin-top: 1.4rem; }

/* ---- exercises ---- */
.exercise {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; margin: 1rem 0; box-shadow: var(--shadow); text-align: center;
}
.exercise .progress { margin-bottom: 1rem; }
.ex-prompt { font-family: var(--serif); font-size: 1.8rem; margin: .4rem 0; }
.ex-prompt.big { font-size: 2rem; }
.ex-sentence { font-family: var(--serif); font-size: 1.35rem; }
.ex-instr { color: var(--ink-soft); }
.ex-hint { color: var(--ink-soft); font-size: .92rem; }
.ex-image { max-height: 14rem; border-radius: var(--radius); }
.ex-hint-img { max-height: 10rem; border-radius: var(--radius); opacity: .95; }
.ex-count { color: var(--ink-soft); font-size: .85rem; }

.choice-grid { display: grid; gap: .7rem; margin: 1rem auto; max-width: 30rem; }
.choice-grid.images { grid-template-columns: 1fr 1fr; }
.choice-grid.words { grid-template-columns: 1fr; }
@media (min-width: 34rem) { .choice-grid.words { grid-template-columns: 1fr 1fr; } }
.choice {
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--bg);
  cursor: pointer; padding: .6rem; font: inherit; color: var(--ink); min-height: 3rem;
}
.choice:hover { border-color: var(--accent); }
.choice img { border-radius: 6px; display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.word-choice { font-size: 1.15rem; font-family: var(--serif); }

.cloze { font-family: var(--serif); font-size: 1.4rem; }
.cloze-input {
  display: inline-block; width: 9ch; max-width: 40vw; text-align: center;
  font: inherit; border: none; border-bottom: 2px solid var(--accent);
  border-radius: 0; background: transparent; padding: 0 .2rem;
}
.text-input { max-width: 26rem; font-size: 1.1rem; text-align: center; }

/* assembly tiles */
.assembly-target {
  min-height: 3.2rem; border: 2px dashed var(--line); border-radius: var(--radius);
  padding: .5rem; margin-bottom: .8rem; display: flex; flex-wrap: wrap; gap: .45rem;
  justify-content: center; align-items: center;
}
.assembly-tiles { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; }
.tile {
  font-family: var(--serif); font-size: 1.15rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .8rem;
  cursor: pointer; color: var(--ink); min-height: 44px;
}
.tile:hover { border-color: var(--accent); }
.assembly-target .tile { background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }

/* feedback */
.feedback-panel { border-width: 2px; }
.fb-correct { border-color: var(--ok); }
.fb-almost { border-color: var(--warn); }
.fb-wrong { border-color: var(--err); }
.fb-title { font-size: 1.3rem; font-weight: 700; margin: .2rem 0; }
.fb-correct .fb-title { color: var(--ok); }
.fb-almost .fb-title { color: var(--warn); }
.fb-wrong .fb-title { color: var(--err); }
.fb-expected { font-size: 1.15rem; }
.fb-next { margin-top: 1rem; }

/* grammar */
.grammar-page h1 { font-family: var(--serif); }
.grammar-examples-sv {
  font-family: var(--serif); font-size: 1.25rem; background: var(--bg-raised);
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  padding: .9rem 1.2rem; margin: 1rem 0;
}
.grammar-english { margin: 1.2rem 0; }
.grammar-english summary { cursor: pointer; color: var(--accent); }
.example-sentences { list-style: none; padding: 0; }
.example-sentences li { margin: .5rem 0; font-size: 1.05rem; }
.margin-note { display: block; color: var(--ink-soft); font-size: .85rem; }
.grammar-ref { list-style: none; padding: 0; }
.grammar-ref li { border-bottom: 1px solid var(--line); padding: .5rem .2rem; }
.grammar-ref li.locked { color: var(--ink-soft); }
.drill-preview li { margin: .25rem 0; }

/* tables */
.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; align-items: center; }
.filter-bar input[type=search], .filter-bar input[type=text] { max-width: 18rem; }
.filter-bar select { width: auto; }
.filter-bar .btn { margin: 0; }
.words-table, .admin-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.words-table th, .words-table td, .admin-table th, .admin-table td {
  text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.admin-table tr.error td { background: color-mix(in srgb, var(--err) 7%, transparent); }
.admin-table tr.warning td { background: color-mix(in srgb, var(--warn) 8%, transparent); }
.status-published { color: var(--ok); }
.status-draft { color: var(--warn); }
.status-missing { color: var(--err); }
.status-generated { color: var(--warn); }
.status-approved { color: var(--ok); }
.error-count { color: var(--err); font-weight: 600; }
.warn-count { color: var(--warn); }
.ok-mark { color: var(--ok); }
.media-thumb { width: 5.5rem; border-radius: 6px; }
.prompt-cell { max-width: 24rem; font-size: .85rem; color: var(--ink-soft); }
.admin-badge {
  background: var(--warn); color: #fff; display: inline-block;
  font-size: .72rem; border-radius: 4px; padding: .05rem .4rem;
}
.admin-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0; }
.admin-actions { display: flex; gap: .7rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.yaml-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; line-height: 1.45; }
.issue-list ul { padding-left: 1.2rem; }
.issue-list .error { color: var(--err); }
.issue-list .warning { color: var(--warn); }

/* dictionary */
.dict-layout { display: grid; gap: 1.4rem; grid-template-columns: 1fr; }
@media (min-width: 52rem) { .dict-layout { grid-template-columns: minmax(14rem, 1fr) 1.4fr; } }
.dict-results { list-style: none; padding: 0; }
.dict-results li { border-bottom: 1px solid var(--line); }
.dict-results a { display: block; padding: .5rem .2rem; text-decoration: none; color: var(--ink); }
.dict-results a:hover { background: var(--bg-raised); }
.dict-card .word-card { box-shadow: var(--shadow); }

/* touch targets on small screens */
@media (max-width: 40rem) {
  html { font-size: 16.5px; }
  .reader-body { padding: 1.3rem 1rem; font-size: 1.18rem; }
  .sent-play { font-size: 1em; padding: .2em .3em; }
}

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