:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e4e1d9;
  --accent: #022153;
  --accent-soft: #e6ebf5;
  --yellow: #fec434;
  --blue: #2c63c9;
  --red: #c8453b;
  --gold: #b7862a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
/* Mörkt: följer telefonen/datorn om inget valts, eller valt med ◐/☀/☾ (data-theme på <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --panel: #1e2125; --ink: #e8e6e1; --muted: #9aa0a6; --line: #30343a;
    --accent: #6f8fe0; --accent-soft: #1a2540; --blue: #6c9bf0; --red: #e57369; --gold: #d9a94a;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --panel: #1e2125; --ink: #e8e6e1; --muted: #9aa0a6; --line: #30343a;
  --accent: #6f8fe0; --accent-soft: #1a2540; --blue: #6c9bf0; --red: #e57369; --gold: #d9a94a;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.logo { color: var(--accent); }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs a {
  padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted);
  white-space: nowrap; font-size: 14px;
}
.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.device-status { font-size: 14px; color: var(--muted); }
.device-status.on { color: var(--accent); }

.main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; outline: none; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.spacer { flex: 1; }

button, .btn {
  font: inherit; font-size: 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--red); }
button.small { padding: 4px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel);
}
.item-head { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.item-title { font-weight: 600; flex: 1; }
.item-meta { color: var(--muted); font-size: 13px; }
.item-body { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }

.tag {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.tag.test { background: #f7e3e1; color: var(--red); }
.tag.done { background: var(--line); color: var(--muted); }
.tag.other { background: var(--line); color: var(--muted); font-style: italic; }
.tag.late { background: #f5ecd8; color: var(--gold); }
/* Mörkt: följer telefonen/datorn om inget valts, eller valt med ◐/☀/☾ (data-theme på <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag.test { background: #3a2422; }
  :root:not([data-theme="light"]) .tag.late { background: #3a3020; }
}
:root[data-theme="dark"] .tag.test { background: #3a2422; }
:root[data-theme="dark"] .tag.late { background: #3a3020; }


.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.check.done .task { text-decoration: line-through; color: var(--muted); }
.day-head { font-weight: 700; margin: 16px 0 4px; }
.day-head > span:first-child::first-letter { text-transform: uppercase; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td input { padding: 5px 8px; }

.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar2 { fill: var(--blue); opacity: .8; }
.chart .bar-good { fill: #2f9e5a; }
.legend i.good { background: #2f9e5a; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .val { fill: var(--ink, currentColor); font-size: 10px; font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.empty { color: var(--muted); font-style: italic; padding: 8px 0; }

/* Simulator */
.sim { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 16px; }
@media (max-width: 800px) { .sim { grid-template-columns: 1fr; } }
.device {
  background: #111; border-radius: 22px; padding: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.screen {
  background: #0d1b17; color: #e9f5f1; border-radius: 12px; min-height: 320px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden;
}
.screen .state { font-size: 12px; opacity: .7; }
.screen .say { font-size: 19px; line-height: 1.35; }
.screen .card {
  background: #fff; color: #1f2328; border-radius: 10px; padding: 18px; text-align: center;
  font-size: 22px; font-weight: 600;
}
.screen .card .hint { font-size: 13px; font-weight: 400; color: #6b6f76; margin-top: 6px; }
.screen .card.right { outline: 3px solid #5fb39b; }
.screen .card.wrong { outline: 3px solid #e57369; }
.timerbar { height: 10px; background: #263a34; border-radius: 6px; overflow: hidden; }
.timerbar > div { height: 100%; background: linear-gradient(90deg, #5fb39b, #d9a94a, #e57369); transition: width .6s; }
.points-pop {
  position: absolute; right: 14px; top: 12px; background: #d9a94a; color: #111; font-weight: 800;
  border-radius: 999px; padding: 4px 10px; animation: pop 1.8s ease forwards;
}
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 15% { transform: scale(1.15); opacity: 1 } 80% { opacity: 1 } 100% { opacity: 0; transform: translateY(-14px) } }
.thinking::after { content: "…"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2 } }
.hw-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.hw { width: 64px; height: 64px; border-radius: 50%; border: 0; color: #fff; font-weight: 700; font-size: 12px; }
.hw.blue { background: var(--blue); }
.hw.red { background: var(--red); }
.hw:active { transform: scale(.95); }
.sim-input { display: flex; gap: 8px; margin-top: 12px; }
.log {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; height: 380px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.log .in { color: var(--accent); }
.log .out { color: var(--blue); }

.quiz-card {
  text-align: center; font-size: 26px; font-weight: 700; padding: 40px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); margin: 12px 0;
}
.quiz-card .answer { font-size: 20px; font-weight: 500; color: var(--accent); margin-top: 16px; }

.logview {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.5;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; height: calc(100vh - 230px); min-height: 300px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.logline { display: block; }
.logline .t { color: var(--muted); }
.logline .lv { display: inline-block; width: 46px; font-weight: 600; }
.logline .lg { color: var(--muted); }
.logline.DEBUG .lv { color: var(--muted); }
.logline.INFO .lv { color: var(--accent); }
.logline.WARN { background: rgba(183, 134, 42, .08); }
.logline.WARN .lv { color: var(--gold); }
.logline.ERROR { background: rgba(200, 69, 59, .08); }
.logline.ERROR .lv { color: var(--red); }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); max-width: 90vw;
}
.toast.error { background: var(--red); color: #fff; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg) } }

.button-link {
  display: inline-flex; align-items: center; padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 8px; text-decoration: none; font-size: 14px; color: var(--ink); background: var(--panel);
}

/* ---- Mobil (iPhone m.fl.) ---- */
@media (max-width: 680px) {
  .topbar {
    flex-wrap: wrap; gap: 6px 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 6px;
  }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -12px; padding: 0 8px 2px; -webkit-overflow-scrolling: touch; }
  .tabs a { padding: 8px 10px; font-size: 15px; }
  .main { padding: 16px 12px calc(60px + env(safe-area-inset-bottom, 0px)); }
  h1 { font-size: 21px; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .panel { padding: 14px 12px; overflow-x: auto; }
  .row { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .spacer { display: none; }
  /* ≥16px så att Safari inte zoomar in vid inmatning */
  input, select, textarea, button { font-size: 16px; }
  table { font-size: 14px; }
  th, td { padding: 6px 6px; }
  .item-head { flex-wrap: wrap; }
  .item-head .item-meta { flex-basis: 100%; }
  .kpi .value { font-size: 22px; }
  .toasts { left: 12px; right: 12px; transform: none; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

.group-head { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px; }

.student-sel { font: inherit; font-size: 15px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent); font-weight: 600; max-width: 160px; }
.student-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
.code { font: 700 24px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 4px; color: var(--accent); }
@media (max-width: 680px) { .student-sel { order: 2; } }

.mat-thumb { width: 64px; height: 84px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: none; cursor: zoom-in; background: var(--line); }
.mat-text { white-space: pre-wrap; font: 14px/1.45 inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 6px; max-height: 320px; overflow: auto; }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.daybox { display: flex; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 0; cursor: pointer; }
.daybox input { width: 16px; height: 16px; }

code.sa { font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; word-break: break-all; }

.gcal-list { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.gcal-list li { margin: 3px 0; }

.cost-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.cost-card { background: var(--panel, #fff); border: 1px solid var(--line, #e5e7eb); border-radius: 12px; padding: 14px; }
.cost-big { font-size: 26px; font-weight: 700; margin: 4px 0; }
.cost-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin: 8px 0; }
.cost-bar { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; min-width: 4px; background: rgba(127,127,127,.08); border-radius: 3px; overflow: hidden; }
.cost-bar-api { background: var(--blue); }
.cost-bar-sub { background: var(--accent); opacity: .45; }
.cost-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.cost-dot.api { background: var(--blue); } .cost-dot.sub { background: var(--accent); opacity: .45; }

.mode-list { display: grid; gap: 8px; }
.mode-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.mode-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.mode-opt input[type=radio] { width: 18px; height: 18px; flex: 0 0 18px; margin: 2px 0 0; padding: 0; accent-color: var(--accent); }
.mode-opt > div { flex: 1; min-width: 0; }
.mode-opt strong { display: block; color: var(--ink); font-size: 15px; }
.mode-opt.mode-opt { margin: 0; font-size: 14px; color: var(--ink); }

.stage { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; }
.stage-list { display: grid; gap: 6px; }
.stage-item { display: flex; align-items: center; gap: 10px; }
.stage-item img, .stage-doc { width: 44px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: 0 0 auto; }
.stage-doc { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.stage-item .item-meta { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dnd-day { border-top: 1px solid var(--line); padding: 2px 0 6px; }
.dnd-day:first-child { border-top: 0; }
.dnd-day.off .dnd-head > span:first-child { color: var(--muted); }
.dnd-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dnd-head .over { color: var(--red); font-weight: 700; }
.dnd-list { min-height: 8px; }
.dnd-row { border-radius: 8px; }
.dnd-row.dragging { opacity: .4; }
.dnd-main { display: flex; align-items: center; gap: 6px; }
.dnd-handle { cursor: grab; color: var(--muted); font-size: 18px; width: 16px; text-align: center; user-select: none; }
.dnd-handle.off { cursor: default; }
.dnd-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0 8px 22px; }
.dnd-tools[hidden] { display: none; }
.dnd-empty { color: var(--muted); font-size: 13px; padding: 6px 22px; border: 1px dashed transparent; border-radius: 8px; }
.dnd-day:hover .dnd-empty { border-color: var(--line); }
.drop-mark { height: 3px; background: var(--accent); border-radius: 2px; margin: 2px 0 2px 22px; }
button.ghost { background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover { background: var(--accent-soft); }

.dnd-group { font-size: 13px; font-weight: 700; color: var(--c); margin: 6px 0 0 22px; padding-left: 8px; border-left: 3px solid var(--c); }
.dnd-row.in-group .dnd-main > div { border-left: 3px solid var(--c); padding-left: 8px; }

.who-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 12px; margin-bottom: 14px;
  border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--line); font-size: 14px; }

/* Kryssrutor och radioknappar: inte hela bredden, och texten bredvid */
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; flex: 0 0 18px; padding: 0; margin: 0; accent-color: var(--accent); }
label.inline { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; margin: 12px 0 4px; cursor: pointer; }

/* Plan: dagar utan moment ihopslagna */
.empty-run { border-top: 1px solid var(--line); margin-top: 8px; }
.empty-run-btn { background: none; border: 0; color: var(--muted); padding: 10px 0; font-size: 14px; cursor: pointer; width: 100%; text-align: left; }
.empty-run-days { display: none; }
.empty-run.open .empty-run-days, .is-dragging .empty-run-days { display: block; }
.empty-run.open .empty-run-btn { color: var(--ink); }

/* Undermeny i Eleven och System */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.subnav a { padding: 7px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.subnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Översikt: Behöver dig */
.needs { border: 1px solid var(--gold); border-left: 6px solid var(--gold); background: var(--panel); }
.needs h2 { color: var(--gold); }
.needs .check .task { font-weight: 600; color: var(--ink); }
.needs .item-meta { color: var(--muted); }
.needs .check { align-items: center; }
.needs .check .grow, .recent .check .grow { flex: 1; }
.recent .check { padding: 8px 0; }

.brand .logo { width: 32px; height: 32px; object-fit: contain; vertical-align: -9px; border-radius: 7px; }

/* Inloggning till föräldravyn */
.login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-box { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 28px 24px; display: flex; flex-direction: column; gap: 8px; }
.login-box h1 { margin: 4px 0 0; font-size: 24px; }
.login-box label { margin-top: 6px; font-size: 14px; color: var(--muted); }
.login-box button.primary { margin-top: 10px; padding: 12px; font-size: 16px; }
.login-logo { width: 96px; height: 96px; border-radius: 22px; align-self: center; }
.login-msg { color: var(--red); min-height: 1.2em; font-size: 14px; }
.login-msg:empty { min-height: 0; }
.login-ok { color: var(--green, #2e7d4f); font-size: 14px; }
.login-ok:empty { display: none; }
.login { overflow-y: auto; }
.login-box a { color: var(--accent); }
.tag.ok { background: #e3f3e8; color: #23683f; }
:root[data-theme="dark"] .tag.ok { background: #1f3a2a; color: #8fd6a8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag.ok { background: #1f3a2a; color: #8fd6a8; } }

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
.theme-btn { min-width: 36px; }
.login-pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 15px; overflow-x: auto; }

/* Veckorapporten skrivs ut utan meny och knappar */
@media print {
  .topbar, .subnav, .toasts, .report button { display: none !important; }
  .main { padding: 0 !important; }
  .panel { box-shadow: none !important; border: none !important; }
}

/* Frågor per läxa: andel rätt som en liten stapel */
.pct { position: relative; display: inline-block; min-width: 90px; height: 22px; border-radius: 11px; background: rgba(127,127,127,.15); overflow: hidden; vertical-align: middle; }
.pct i { position: absolute; inset: 0 auto 0 0; border-radius: 11px; }
.pct b { position: relative; display: block; text-align: center; font-size: 12px; line-height: 22px; }
.pct.good i { background: rgba(31,157,85,.45); }
.pct.warn i { background: rgba(254,196,52,.55); }
.pct.bad i { background: rgba(214,69,65,.45); }
.hw-filter { max-width: 100%; }
.hw-stats td { vertical-align: middle; }

/* Pass och övningar: listan scrollar om en dag har många */
.panel.recent .list { max-height: 440px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }

/* ---- Admin, finputs ---- */
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices .choice { border-radius: 999px; padding: 6px 14px; background: var(--bg); }
.choices .choice.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.info-btn { border: 0; background: none; padding: 0 4px; color: var(--accent); cursor: pointer; font-size: 15px; }
.info-btn.on { opacity: .6; }
.info-more[hidden] { display: none; }
p.sub { font-size: 14px; }
.set-section { padding: 14px 0; border-top: 1px solid var(--line); }
.set-section:first-child { border-top: 0; padding-top: 0; }
.set-section h3 { margin-bottom: 4px; }
.set-section .sub { margin: 6px 0 0; }
.lead-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lead-row .grow { flex: 1; min-width: 140px; }
.lead-range { display: flex; align-items: center; gap: 6px; }
input.num { width: 64px; text-align: center; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 14px -16px -16px; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius); }
.savebar-msg { flex: 1; }
.savebar.dirty { box-shadow: 0 -6px 18px rgba(0,0,0,.12); }
.savebar.dirty .savebar-msg { color: var(--gold); font-weight: 600; }
.hw-cards { display: none; }
.hw-card { display: grid; gap: 6px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; }
.hw-card-head { display: flex; gap: 6px; align-items: center; }
.hw-card .pct { width: 100%; }
@media (max-width: 680px) {
  table.hw-stats { display: none; }
  .hw-cards { display: grid; gap: 8px; }
  /* Nyckeltalen: en rad som går att svepa i sidled */
  .grid.cols-4.kpis { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -12px; padding: 0 12px 4px; scrollbar-width: none; }
  .grid.cols-4.kpis > .kpi { flex: 0 0 44%; scroll-snap-align: start; }
  .savebar { margin: 14px -12px -14px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* Översikt: meningen överst, provkort, lugnare statistik */
.summary { margin: 6px 0 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); }
.summary-main { font-size: 17px; font-weight: 600; }
.summary-next { margin-top: 4px; color: var(--ink); }
.section-head { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.test-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.test-card { border-left: 5px solid var(--c); display: grid; gap: 10px; }
.test-card-head { display: flex; gap: 10px; align-items: center; }
.test-card-head .grow { flex: 1; min-width: 0; }
.test-card-head .task { font-weight: 700; font-size: 16px; }
.test-ico { font-size: 24px; }
.countdown { font-weight: 700; white-space: nowrap; color: var(--accent); }
.countdown.soon { color: var(--red); }
.progress { height: 8px; border-radius: 4px; background: rgba(127,127,127,.18); overflow: hidden; margin-bottom: 4px; }
.progress i { display: block; height: 100%; background: var(--c, var(--accent)); border-radius: 4px; }
.test-card-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel.quiet { box-shadow: none; }
.panel.quiet h2 { font-size: 15px; color: var(--muted); }
.kpis .kpi { box-shadow: none; }
.item.subj { border-left: 4px solid var(--c); }

/* Läxan: flikar och ⋯-meny */
.hw-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.hw-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 12px; }
.hw-tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.more-wrap { position: relative; }
.more-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 6; display: grid; gap: 4px; min-width: 190px;
  padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.more-menu[hidden] { display: none; }
.more-menu button { text-align: left; border: 0; }

/* Plan: det som ligger efter som en gul list */
.behind-strip { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--gold); background: rgba(183,134,42,.10); }
.behind-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.behind-row .grow { flex: 1; min-width: 160px; color: var(--gold); }
.behind-strip .dnd-list[hidden] { display: none; }
.behind-strip .dnd-list { margin-top: 8px; }

.tabs .ico { display: none; }
/* Mobilen: menyn längst ned med ikoner, som en app */
@media (max-width: 680px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; order: 0; flex-basis: auto;
    justify-content: space-around; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--panel); border-top: 1px solid var(--line); }
  .tabs a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 6px; font-size: 11px; flex: 1; min-width: 0; }
  .tabs a .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabs .ico { display: block; font-size: 20px; line-height: 1.2; }
  .tabs a.active { background: none; }
  .main { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .savebar { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}
.tabs .lbl-short { display: none; }
@media (max-width: 680px) { .tabs a:has(.lbl-short) .lbl { display: none; } .tabs .lbl-short { display: block; } }
.page-warn { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--gold); background: rgba(183,134,42,.10); }
.page-warn strong { color: var(--gold); font-size: 14px; }
.check-mark { flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 4px; border: 1.5px solid var(--muted); display: grid; place-items: center; font-size: 12px; color: #fff; }
.check-mark.on { background: #2f9e6b; border-color: #2f9e6b; }
.tag-link { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.tag-link:hover { filter: brightness(1.15); }

/* Ruta ovanpå sidan (t.ex. svåra just nu från ett provkort) */
.popup-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.popup { width: min(720px, 100%); max-height: 85vh; overflow: auto; margin: 0; }
.popup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.popup .hard-list { margin-top: 4px !important; }

/* Familj och nycklar: fält och knappar på en rad */
.keyrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.keyrow input { flex: 1 1 220px; min-width: 0; }
.keyrow button { flex: 0 0 auto; }

/* Guide */
.guide-sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
.guide-sec > summary { cursor: pointer; padding: 14px 16px; font-weight: 700; font-size: 17px; list-style: none; }
.guide-sec > summary::-webkit-details-marker { display: none; }
.guide-sec > summary::before { content: '▸'; display: inline-block; width: 1.1em; color: var(--muted); transition: transform .15s; }
.guide-sec[open] > summary::before { transform: rotate(90deg); }
.guide-body { padding: 0 18px 14px; line-height: 1.55; }
.guide-steps li { margin: 6px 0; }
.guide-body code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .92em; word-break: break-all; }
.guide-check { list-style: none; padding: 0; margin: 4px 0 0; }
.guide-check li { margin: 8px 0; }
.guide-check li.done { color: var(--muted); }
.guide-tick { display: inline-block; width: 1.3em; font-weight: 700; color: var(--gold); }
.guide-check li.done .guide-tick { color: #2e9b5b; }
.guide-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
.guide-table th, .guide-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.guide-table th { color: var(--muted); font-weight: 600; }
.guide-table code { word-break: normal; white-space: nowrap; }
@media (max-width: 640px) {
  .guide-table, .guide-table tbody, .guide-table tr, .guide-table td { display: block; }
  .guide-table th { display: none; }
  .guide-table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .guide-table td { border: 0; padding: 2px 0; }
  .guide-table td:nth-child(2) { color: var(--muted); font-size: 13px; }
}
