/* Vireys – mobiili ensin. Yksi sarake, alapalkki navigaatiolle, tallennuspalkki Nyt-näkymässä. */

@font-face { font-family: "Figtree"; src: url("/fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #eef2f0;
  --surface: #ffffff;
  --fg: #1b2321;
  --muted: #56635f;
  --line: #d3dbd8;
  --accent: #2c5a54;
  --on-accent: #ffffff;
  --danger: #b4453a;
  /* nelikentän tekstivärit */
  --q-haaste: #b77a12;
  --q-uupumus: #b4453a;
  --q-tylsa: #586a8e;
  --q-vire: #3f7f4c;
  /* kaavioiden merkit (validoitu: järjestys vire, tylsä, haaste, uupumus) */
  --c-vire: #2e8a4e;
  --c-tylsa: #4a64a8;
  --c-haaste: #c27d00;
  --c-uupumus: #c43d3d;
  --c-load: #c05a2c;
  --c-control: #008572;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --tabbar-h: 58px;
  --savebar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111715; --surface: #19211f; --fg: #e4ebe8; --muted: #9aa8a3; --line: #2b3633; --accent: #8cc4ba; --on-accent: #0f1715; --danger: #e47a6d;
    --q-haaste: #e2ab48; --q-uupumus: #e47a6d; --q-tylsa: #97a8cc; --q-vire: #82c08f;
    --c-vire: #3f9a5a; --c-tylsa: #6a82d4; --c-haaste: #b88300; --c-uupumus: #e2576f;
    --c-load: #d06a38; --c-control: #16a08c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111715; --surface: #19211f; --fg: #e4ebe8; --muted: #9aa8a3; --line: #2b3633; --accent: #8cc4ba; --on-accent: #0f1715; --danger: #e47a6d;
  --q-haaste: #e2ab48; --q-uupumus: #e47a6d; --q-tylsa: #97a8cc; --q-vire: #82c08f;
  --c-vire: #3f9a5a; --c-tylsa: #6a82d4; --c-haaste: #b88300; --c-uupumus: #e2576f;
  --c-load: #d06a38; --c-control: #16a08c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 60px; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--fg);
  font-family: var(--body); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
img, svg { display: block; }

/* Yläpalkki */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--gutter-r) 8px var(--gutter-l);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-mark { width: 22px; height: 22px; }
.bm-vire { fill: var(--c-vire); } .bm-haaste { fill: var(--c-haaste); } .bm-tylsa { fill: var(--c-tylsa); } .bm-uupumus { fill: var(--c-uupumus); }
.topbar-end { display: flex; align-items: center; gap: 10px; }
.today { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chip-btn { min-height: 30px; padding: 3px 12px; font-size: 13px; border-radius: 99px; }

/* Näkymät */
main {
  max-width: 640px; margin: 0 auto;
  padding: 4px var(--gutter-r) calc(var(--tabbar-h) + var(--safe-b) + 24px) var(--gutter-l);
}
body[data-view="nyt"] main { padding-bottom: calc(var(--tabbar-h) + var(--savebar-h) + var(--safe-b) + 16px); }
.view { display: grid; gap: 16px; min-width: 0; }
.vhead { display: grid; gap: 4px; }
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: clamp(26px, 7vw, 34px); line-height: 1.08; letter-spacing: -.015em; text-wrap: balance; }
h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 19px; line-height: 1.2; text-wrap: balance; }
h3 { margin: 0; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lede { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
p { margin: 0; }

/* Nelikenttä */
.plot { display: grid; grid-template-columns: 18px minmax(0, 1fr); grid-template-rows: auto 18px; gap: 4px; width: 100%; max-width: 460px; justify-self: center; }
.y-label { writing-mode: vertical-rl; transform: rotate(180deg); display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.x-label { grid-column: 2; display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.axis-name { color: var(--fg); font-weight: 500; text-transform: uppercase; }
.grid {
  position: relative; aspect-ratio: 1; width: 100%;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
  touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.grid:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.q { padding: 10px; display: flex; flex-direction: column; gap: 1px; transition: background-color .25s; }
.q span { font-family: var(--display); font-weight: 700; font-size: clamp(14px, 4vw, 17px); line-height: 1.1; }
.q small { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.q.tr, .q.br { align-items: flex-end; text-align: right; }
.q.bl, .q.br { justify-content: flex-end; }
.q.tl { background: color-mix(in srgb, var(--q-vire) 12%, var(--surface)); color: var(--q-vire); }
.q.tr { background: color-mix(in srgb, var(--q-haaste) 12%, var(--surface)); color: var(--q-haaste); }
.q.bl { background: color-mix(in srgb, var(--q-tylsa) 12%, var(--surface)); color: var(--q-tylsa); }
.q.br { background: color-mix(in srgb, var(--q-uupumus) 12%, var(--surface)); color: var(--q-uupumus); }
.q.tl.on { background: color-mix(in srgb, var(--q-vire) 24%, var(--surface)); }
.q.tr.on { background: color-mix(in srgb, var(--q-haaste) 24%, var(--surface)); }
.q.bl.on { background: color-mix(in srgb, var(--q-tylsa) 24%, var(--surface)); }
.q.br.on { background: color-mix(in srgb, var(--q-uupumus) 24%, var(--surface)); }
.cross-h, .cross-v { position: absolute; background: var(--line); pointer-events: none; }
.cross-h { left: 0; right: 0; top: 50%; height: 1px; }
.cross-v { top: 0; bottom: 0; left: 50%; width: 1px; }
.past { position: absolute; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--fg); transform: translate(-50%, -50%); pointer-events: none; }
.dot {
  position: absolute; width: 28px; height: 28px; border-radius: 50%;
  background: var(--fg); border: 4px solid var(--surface);
  box-shadow: 0 0 0 1px var(--fg), 0 4px 14px color-mix(in srgb, var(--fg) 30%, transparent);
  transform: translate(-50%, -50%); pointer-events: none;
  transition: transform .12s ease-out;
}
.grid.dragging .dot { transform: translate(-50%, -50%) scale(1.15); }
.hint { position: absolute; left: 50%; top: calc(50% + 12px); transform: translateX(-50%); max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 11px; background: var(--surface); color: var(--muted); padding: 3px 8px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; pointer-events: none; }

/* Tulkinta */
.reading { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; min-width: 0; border-top: 5px solid var(--qc, var(--accent)); font-size: 15px; }
.reading .top { display: grid; gap: 4px; }
.reading h2 { font-size: 21px; }
.chip { justify-self: start; font-family: var(--mono); font-size: 12px; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--qc) 16%, var(--surface)); color: var(--qc); font-weight: 500; }
.meta { margin: 0; font-size: 14px; color: var(--muted); }
.reading ul, .qcard ul { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 2px; }
.ask { padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--qc, var(--accent)) 9%, var(--surface)); font-weight: 500; }
.ask b { display: block; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--qc, var(--accent)); margin-bottom: 2px; }

/* Painikkeet */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; font: inherit; font-size: 15px; font-weight: 600; padding: 9px 16px; border-radius: 12px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button.ghost { background: transparent; color: var(--fg); border-color: var(--line); font-weight: 500; }
button.danger { color: var(--danger); }
button.danger-fill { background: var(--danger); border-color: var(--danger); color: var(--surface); }
button.small { min-height: 36px; padding: 5px 12px; font-size: 14px; }
button:disabled { opacity: .35; cursor: default; }
button:active:not(:disabled), .btn:active { transform: scale(.98); }
button:focus-visible, .btn:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }

/* Tallennuspalkki */
.savebar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  padding: 8px var(--gutter-r) 8px var(--gutter-l);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
body:not([data-view="nyt"]) .savebar { display: none; }
.savebar-in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sb-sum, .sheet-sum { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sb-sum strong, .sheet-sum strong { display: block; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sum small, .sheet-sum small { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sum > span { min-width: 0; }
.swatch { flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
#openSave { flex: none; }

/* Alapalkki */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 var(--gutter-r) var(--safe-b) var(--gutter-l);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; touch-action: manipulation; }
.tab > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .ic { display: grid; place-items: center; width: 48px; height: 28px; border-radius: 14px; transition: background-color .2s; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab svg .fill { fill: currentColor; stroke: none; }
.tab[aria-current="page"] { color: var(--fg); }
.tab[aria-current="page"] .ic { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

/* Tallennusarkki */
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh;
  margin: auto auto 0; padding: 0; border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--fg);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
}
.sheet[open] { animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: rgba(8, 14, 12, .5); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet form { display: grid; gap: 14px; padding: 8px var(--gutter-r) calc(14px + var(--safe-b)) var(--gutter-l); }
.handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto; }
.tags { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.tags legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 15px; }
legend small, .note-field small { font-weight: 400; color: var(--muted); }
.tag { position: relative; }
.tag input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tag span { display: inline-flex; align-items: center; min-height: 36px; padding: 5px 13px; border-radius: 99px; border: 1px solid var(--line); font-size: 14px; background: var(--surface); transition: background-color .15s, border-color .15s; }
.tag input:checked + span { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: var(--accent); font-weight: 600; }
.tag input:checked + span::before { content: "✓"; margin-right: 6px; color: var(--accent); }
.tag input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.note-field { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
textarea { width: 100%; font: inherit; font-size: 16px; font-weight: 400; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); resize: vertical; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* Kortit */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.card .btn { justify-self: start; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.note { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* Raportit */
.hist, .report { display: grid; gap: 12px; min-width: 0; }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-self: start; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; max-width: 100%; }
.seg.seg-full { display: grid; justify-self: stretch; }
.seg button { min-height: 38px; padding: 5px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.stepper .step { padding: 0; width: 44px; }
.stepper .step svg { width: 20px; height: 20px; }
.stepper.static .step { visibility: hidden; }
.period { text-align: center; display: grid; min-width: 0; }
.period strong { font-family: var(--display); font-size: 20px; line-height: 1.2; }
.period small { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.alert { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--q-uupumus) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--q-uupumus) 40%, var(--line)); font-size: 14px; line-height: 1.45; }
.alert svg { width: 20px; height: 20px; color: var(--q-uupumus); margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; font-size: 15px; }
.range-empty { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 0; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); line-height: 1.3; }
.stat b { font-family: var(--body); font-weight: 600; font-size: 24px; line-height: 1.2; }
.stat small { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.4em; }

.summary { border-top: 5px solid var(--qc, var(--accent)); font-size: 15px; }
.summary p { line-height: 1.5; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 16px; height: 3px; border-radius: 2px; }
.key-load { background: var(--c-load); }
.key-control { background: var(--c-control); }
.readout { min-height: 2.9em; font-size: 14px; line-height: 1.45; color: var(--fg); }
.readout .rd-date { color: var(--muted); display: block; }
.readout .sw-inline { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 0; vertical-align: -1px; }
.trend { position: relative; min-width: 0; }
.trend svg { width: 100%; height: auto; overflow: visible; touch-action: pan-y; outline: none; }
.trend svg:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 4px; border-radius: 6px; }
.gl { stroke: var(--line); stroke-width: 1; }
.gl.mid { stroke: color-mix(in srgb, var(--muted) 40%, var(--surface)); }
.tick { font-family: var(--mono); font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ln-load { stroke: var(--c-load); }
.ln-control { stroke: var(--c-control); }
.mk { stroke: var(--surface); stroke-width: 2; }
.mk-load { fill: var(--c-load); }
.mk-control { fill: var(--c-control); }
.endlbl { font-family: var(--mono); font-size: 12px; font-weight: 500; fill: var(--fg); }
.ch-line { stroke: var(--muted); stroke-width: 1; }

.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; }
.breakdown th, .breakdown td { padding: 7px 4px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.breakdown thead th { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 0; }
.breakdown th:first-child, .breakdown td:last-child { text-align: left; }
.breakdown thead th:last-child { text-align: left; }
.breakdown tbody th { font-weight: 600; text-align: left; }
.breakdown tbody th small { display: block; font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }
.breakdown td { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.breakdown td:last-child { font-family: var(--body); font-size: 13px; padding-left: 10px; white-space: normal; line-height: 1.3; }
.breakdown thead th:last-child { white-space: normal; padding-left: 10px; }
.qcell { display: inline-flex; align-items: center; gap: 6px; }
.qcell .swatch { width: 10px; height: 10px; }
.breakdown tr.empty td, .breakdown tr.empty th { color: var(--muted); font-weight: 400; }
.breakdown tbody tr:last-child th, .breakdown tbody tr:last-child td { border-bottom: 0; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 9em) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 14px; }
.bar-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label.stack { display: grid; gap: 0; }
.bar-label small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; display: flex; align-items: center; }
.bar { height: 14px; border-radius: 0 4px 4px 0; min-width: 0; }
.bar-val { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 4.5em; }
.bar-single { background: var(--accent); }
.tagwrap { display: grid; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 2px; }

.listcard { gap: 0; }
.listcard summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 28px; }
.listcard summary::-webkit-details-marker { display: none; }
.listcard summary .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.listcard summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.listcard[open] summary::after { transform: rotate(-135deg); }
.listcard[open] summary { margin-bottom: 8px; }
ol#history { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
ol#history li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line); }
ol#history li:last-child { border-bottom: 0; }
ol#history .swatch { margin-top: 6px; }
.h-main { min-width: 0; display: grid; gap: 1px; font-size: 15px; }
.h-main strong { font-weight: 600; }
.h-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.h-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.h-tags span { font-size: 12px; padding: 0 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.h-side { display: grid; justify-items: end; gap: 4px; }
.h-nums { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.del { min-height: 32px; padding: 3px 10px; font-size: 13px; font-weight: 500; background: transparent; color: var(--muted); border-color: var(--line); }
.del.armed { color: var(--danger); border-color: var(--danger); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.clear-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; font-size: 14px; padding-top: 4px; }
#confirm { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }

/* Opas */
.axes { margin: 0; display: grid; gap: 2px 0; font-size: 15px; }
.axes dt { font-weight: 600; }
.axes dd { margin: 0 0 6px; color: var(--muted); }
.qguide { display: grid; gap: 8px; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--qc); border-radius: 12px; font-size: 15px; }
.qcard summary { list-style: none; cursor: pointer; padding: 10px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; align-items: center; min-height: 44px; }
.qcard summary::-webkit-details-marker { display: none; }
.qcard summary strong { font-family: var(--display); font-size: 17px; }
.qcard summary small { grid-column: 1; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.qcard summary::after { content: ""; grid-column: 2; grid-row: 1 / span 2; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.qcard[open] summary::after { transform: rotate(-135deg); }
.qcard .qbody { padding: 0 14px 14px; display: grid; gap: 10px; }
.help { font-size: 15px; }
.call-actions { display: grid; gap: 8px; margin-top: 2px; }
.call-actions .btn { justify-self: stretch; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost-btn { background: transparent; color: var(--fg); border-color: var(--line); }
.alert a { font-weight: 600; white-space: nowrap; }
.ver { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: center; }
/* Ilmoitus */
.toast {
  position: fixed; left: 50%; z-index: 40;
  bottom: calc(var(--tabbar-h) + var(--savebar-h) + var(--safe-b) + 12px);
  transform: translate(-50%, 8px); max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 12px; background: var(--fg); color: var(--bg);
  font-size: 15px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body:not([data-view="nyt"]) .toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
.noscript { padding: 24px; text-align: center; }

@media (min-width: 700px) {
  .reading { padding: 20px; }
  .sheet { border-radius: 20px; margin: auto; }
  .sheet form { padding-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .q, .dot, .tab .ic, .toast, .tag span, .qcard summary::after, .listcard summary::after { transition: none; }
  .sheet[open] { animation: none; }
}
@media (forced-colors: active) {
  .bar, .swatch, .key i { forced-color-adjust: none; }
}
