/* Klinika & Dom — visual system.
   World: Slovene transit wayfinding. Each book is a line (Klinika cobalt, Dom berry), every entry
   carries a line tile, lists run as a route strip, what comes next reads like a departure board.
   One reversed "sign plate" per screen carries the primary figure. */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* type scale (fixed rem, ~1.18 ratio) */
  --fs-1: 0.75rem;
  --fs-2: 0.875rem;
  --fs-3: 1rem;
  --fs-4: 1.1875rem;
  --fs-5: 1.4375rem;
  --fs-6: 1.75rem;
  --fs-7: 2.25rem;

  /* 4 px grid */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --gutter: 16px;
  --tabbar-h: 64px;
  --maxw: 560px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* light palette */
  --ground: oklch(0.968 0.006 170);
  --surface: oklch(0.995 0.002 170);
  --surface-2: oklch(0.948 0.009 170);
  --surface-3: oklch(0.925 0.011 170);
  --line: oklch(0.885 0.011 170);
  --line-strong: oklch(0.78 0.014 170);
  --ink: oklch(0.23 0.025 168);
  --ink-2: oklch(0.42 0.022 168);
  --ink-3: oklch(0.51 0.018 168);

  --plate: oklch(0.255 0.034 166);
  --plate-2: oklch(0.31 0.036 166);
  --plate-line: oklch(0.38 0.035 166);
  --plate-ink: oklch(0.975 0.008 166);
  --plate-ink-2: oklch(0.82 0.022 166);

  --k: oklch(0.5 0.17 262);
  --k-ink: oklch(0.99 0 0);
  --k-soft: oklch(0.94 0.035 262);
  --d: oklch(0.52 0.19 352);
  --d-ink: oklch(0.99 0 0);
  --d-soft: oklch(0.95 0.03 352);

  --primary: var(--plate);
  --primary-ink: var(--plate-ink);
  --primary-hover: oklch(0.32 0.04 166);

  --pos: oklch(0.47 0.12 155);
  --neg: oklch(0.52 0.19 27);
  --ok: oklch(0.6 0.14 152);
  --warn: oklch(0.75 0.15 78);
  --warn-ink: oklch(0.47 0.11 70);
  --warn-soft: oklch(0.95 0.05 85);
  --over: oklch(0.56 0.2 27);
  --over-soft: oklch(0.95 0.035 27);
  --goal: oklch(0.55 0.1 190);
  --rec: oklch(0.58 0.21 27);

  --chart-rev: #2f5bd3;
  --chart-cost: #c4621a;

  --focus: oklch(0.55 0.17 262);
  --shadow-1: 0 1px 2px oklch(0.2 0.03 166 / 0.06), 0 2px 8px oklch(0.2 0.03 166 / 0.05);
  --shadow-2: 0 4px 12px oklch(0.2 0.03 166 / 0.1), 0 12px 32px oklch(0.2 0.03 166 / 0.12);
  --scrim: oklch(0.2 0.03 166 / 0.45);
  --seg-on: var(--surface);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: oklch(0.175 0.012 168);
    --surface: oklch(0.215 0.014 168);
    --surface-2: oklch(0.25 0.015 168);
    --surface-3: oklch(0.285 0.016 168);
    --line: oklch(0.31 0.016 168);
    --line-strong: oklch(0.42 0.018 168);
    --ink: oklch(0.95 0.008 168);
    --ink-2: oklch(0.79 0.014 168);
    --ink-3: oklch(0.68 0.014 168);
    --plate: oklch(0.255 0.032 166);
    --plate-2: oklch(0.3 0.034 166);
    --plate-line: oklch(0.37 0.034 166);
    --plate-ink: oklch(0.97 0.008 166);
    --plate-ink-2: oklch(0.8 0.02 166);
    --k: oklch(0.72 0.13 262);
    --k-ink: oklch(0.18 0.03 262);
    --k-soft: oklch(0.3 0.06 262);
    --d: oklch(0.74 0.14 352);
    --d-ink: oklch(0.2 0.04 352);
    --d-soft: oklch(0.31 0.06 352);
    --primary: oklch(0.93 0.02 166);
    --primary-ink: oklch(0.2 0.03 166);
    --primary-hover: oklch(0.98 0.01 166);
    --pos: oklch(0.78 0.13 155);
    --neg: oklch(0.74 0.15 27);
    --ok: oklch(0.7 0.14 152);
    --warn: oklch(0.8 0.14 80);
    --warn-ink: oklch(0.84 0.12 82);
    --warn-soft: oklch(0.3 0.05 80);
    --over: oklch(0.66 0.19 27);
    --over-soft: oklch(0.3 0.06 27);
    --goal: oklch(0.72 0.1 190);
    --rec: oklch(0.64 0.2 27);
    --chart-rev: #6f8ee8;
    --chart-cost: #d27a3a;
    --focus: oklch(0.75 0.13 262);
    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-2: 0 8px 28px oklch(0 0 0 / 0.5);
    --scrim: oklch(0 0 0 / 0.6);
    --seg-on: oklch(0.38 0.018 168);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: oklch(0.175 0.012 168);
  --surface: oklch(0.215 0.014 168);
  --surface-2: oklch(0.25 0.015 168);
  --surface-3: oklch(0.285 0.016 168);
  --line: oklch(0.31 0.016 168);
  --line-strong: oklch(0.42 0.018 168);
  --ink: oklch(0.95 0.008 168);
  --ink-2: oklch(0.79 0.014 168);
  --ink-3: oklch(0.68 0.014 168);
  --plate: oklch(0.255 0.032 166);
  --plate-2: oklch(0.3 0.034 166);
  --plate-line: oklch(0.37 0.034 166);
  --plate-ink: oklch(0.97 0.008 166);
  --plate-ink-2: oklch(0.8 0.02 166);
  --k: oklch(0.72 0.13 262);
  --k-ink: oklch(0.18 0.03 262);
  --k-soft: oklch(0.3 0.06 262);
  --d: oklch(0.74 0.14 352);
  --d-ink: oklch(0.2 0.04 352);
  --d-soft: oklch(0.31 0.06 352);
  --primary: oklch(0.93 0.02 166);
  --primary-ink: oklch(0.2 0.03 166);
  --primary-hover: oklch(0.98 0.01 166);
  --pos: oklch(0.78 0.13 155);
  --neg: oklch(0.74 0.15 27);
  --ok: oklch(0.7 0.14 152);
  --warn: oklch(0.8 0.14 80);
  --warn-ink: oklch(0.84 0.12 82);
  --warn-soft: oklch(0.3 0.05 80);
  --over: oklch(0.66 0.19 27);
  --over-soft: oklch(0.3 0.06 27);
  --goal: oklch(0.72 0.1 190);
  --rec: oklch(0.64 0.2 27);
  --chart-rev: #6f8ee8;
  --chart-cost: #d27a3a;
  --focus: oklch(0.75 0.13 262);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-2: 0 8px 28px oklch(0 0 0 / 0.5);
  --scrim: oklch(0 0 0 / 0.6);
    --seg-on: oklch(0.38 0.018 168);
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-3);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
::selection { background: color-mix(in oklch, var(--k) 28%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus-visible { outline: none; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
.icon { flex: none; }
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1, "lnum" 1; white-space: nowrap; }
.is-neg { color: var(--neg); }
.is-pos { color: var(--pos); }
.muted { color: var(--ink-3); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.noscript { padding: var(--s6); }

/* ------------------------------------------------------------------ shell */

.app { min-height: 100dvh; }
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + var(--s3)) var(--gutter) var(--s8);
  outline: none;
}
.app.has-tabs .view { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s8)); }

.banners { position: sticky; top: 0; z-index: 30; }
.banner {
  display: flex; align-items: center; gap: var(--s2);
  padding: calc(env(safe-area-inset-top) * 0 + var(--s2)) var(--gutter);
  font-size: var(--fs-2); line-height: 1.3;
}
.banner-demo { background: var(--warn-soft); color: var(--ink); justify-content: center; border-bottom: 1px solid color-mix(in oklch, var(--warn) 45%, transparent); }
.banner-demo strong { font-weight: 700; }
.banner-offline, .banner-notice { background: var(--plate); color: var(--plate-ink); }
.banner-offline .icon, .banner-notice .icon { color: var(--warn); }
.banner-notice .btn { margin-left: auto; flex: none; color: inherit; }

/* tab bar */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 max(var(--s2), env(safe-area-inset-left)) env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
@media (min-width: 600px) { .tabbar { left: 50%; right: auto; width: var(--maxw); transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; } }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); min-width: 44px;
  color: var(--ink-3); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.01em;
  transition: color 160ms var(--ease);
}
.tab.is-active { color: var(--ink); }
.tab.is-active .tab-icon { position: relative; }
.tab.is-active .tab-icon::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.tab:active { transform: scale(0.96); }
.tab-mic { position: relative; }
.tab-mic .tab-icon {
  display: grid; place-items: center;
  width: 58px; height: 58px; margin-top: -26px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 0 0 5px var(--ground), var(--shadow-2);
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}
.tab-mic.is-active .tab-icon::after { display: none; }
.tab-mic .tab-label { color: var(--ink-2); }
.tab-mic:active .tab-icon { transform: scale(0.94); }

/* screen heads */
.screen-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: 48px; margin-bottom: var(--s3);
}
.screen-title {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-5); line-height: 1.15; font-weight: 750; letter-spacing: -0.015em;
}
.screen-sub { color: var(--ink-2); font-size: var(--fs-2); font-weight: 550; }
.screen-head-back { justify-content: flex-start; gap: var(--s1); margin-left: calc(var(--s2) * -1); }
.screen-head-back .screen-title { font-size: var(--fs-4); }
.screen-body { display: flex; flex-direction: column; gap: var(--s6); }

/* ---------------------------------------------------------- sign plate */

.plate {
  position: relative;
  display: flex; flex-direction: column;
  margin: 0 calc(var(--gutter) * -0.5) var(--s6);
  padding: var(--s2) var(--s4) var(--s4);
  border-radius: var(--r-xl);
  background: var(--plate);
  color: var(--plate-ink);
  box-shadow: var(--shadow-1);
}
:root[data-theme="dark"] .plate { border: 1px solid var(--plate-line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .plate { border: 1px solid var(--plate-line); } }
.screen-body > .plate { margin-bottom: 0; }

.board-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: var(--s3);
  min-height: 72px; padding: var(--s3) 0;
  border-bottom: 1px solid var(--plate-line);
}
.board-row:active { opacity: 0.85; }
.board-text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.board-label { font-size: var(--fs-2); font-weight: 650; color: var(--plate-ink); }
.board-sub { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s2); font-size: var(--fs-1); color: var(--plate-ink-2); }
.board-figure { font-size: var(--fs-6); font-weight: 750; letter-spacing: -0.02em; line-height: 1; }
.plate .is-neg { color: oklch(0.8 0.13 27); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta.is-up { color: oklch(0.85 0.12 155); }
.delta.is-down { color: oklch(0.83 0.11 40); }
.plate .tile { box-shadow: 0 0 0 2px var(--plate); }

.board-mic {
  display: flex; align-items: center; gap: var(--s3);
  margin-top: var(--s4); padding: var(--s2) var(--s4) var(--s2) var(--s2);
  border-radius: 999px;
  background: var(--plate-ink); color: var(--plate);
  transition: transform 160ms var(--ease);
}
.board-mic:active { transform: scale(0.985); }
.board-mic-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--plate); color: var(--plate-ink); flex: none; }
.board-mic-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.board-mic-text strong { font-size: var(--fs-3); font-weight: 750; }
.board-mic-text span { font-size: var(--fs-1); opacity: 0.78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.plate-compact { padding: var(--s4) var(--s4) var(--s1); gap: var(--s3); }
.plate-main { display: flex; flex-direction: column; gap: var(--s1); }
.plate-label { font-size: var(--fs-2); font-weight: 600; color: var(--plate-ink-2); }
.plate-figure { font-size: var(--fs-7); font-weight: 760; letter-spacing: -0.025em; line-height: 1.05; }
.plate-facts { display: flex; flex-direction: column; }
.plate-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); min-height: 40px; padding: var(--s2) 0; border-top: 1px solid var(--plate-line); }
.plate-facts dt { font-size: var(--fs-2); color: var(--plate-ink-2); }
.plate-facts dd { font-size: var(--fs-3); font-weight: 700; }
.plate-bar { display: flex; flex-direction: column; gap: var(--s2); }
.plate-bar .bar { background: var(--plate-2); }
.plate-bar-text { font-size: var(--fs-1); color: var(--plate-ink-2); }

/* ----------------------------------------------------------------- tiles */

.tile {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 9px;
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-K { background: var(--k); color: var(--k-ink); }
.tile-D { background: var(--d); color: var(--d-ink); }
.tile-book { width: 30px; height: 30px; font-size: 0.875rem; border-radius: 8px; }
.screen-title .tile-book { width: 28px; height: 28px; }

/* ----------------------------------------------------------- sections */

.section { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s7); }
.screen-body > .section { margin-bottom: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 32px; }
.section-title { font-size: var(--fs-4); font-weight: 720; letter-spacing: -0.01em; }
.section-note { color: var(--ink-2); font-size: var(--fs-2); }
.section-count { color: var(--ink-3); font-size: var(--fs-2); font-variant-numeric: tabular-nums; }
.link { color: var(--k); font-weight: 650; font-size: var(--fs-2); padding: var(--s2) 0; }
.link-center { text-align: center; display: block; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); }
.panel-title { font-size: var(--fs-3); font-weight: 700; }
.panel-note { color: var(--ink-2); font-size: var(--fs-2); margin-bottom: var(--s3); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }

.callout { margin-bottom: var(--s6); padding: var(--s4); border-radius: var(--r-lg); background: var(--k-soft); }
.callout-title { font-weight: 700; margin-bottom: var(--s1); }
.callout p + p { color: var(--ink-2); font-size: var(--fs-2); }

/* ---------------------------------------------------------- rows */

.rows { display: flex; flex-direction: column; }
.rows.panel { padding: 0 var(--s4); }
.row { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) 0; }
.rows > .row + .row { border-top: 1px solid var(--line); }
.row-line { display: flex; align-items: center; gap: var(--s3); min-height: 28px; }
.row-label { flex: 1; min-width: 0; font-weight: 600; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row-value { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.row-line .row-value { flex-direction: row; align-items: baseline; }
.row-value strong { font-weight: 700; }
.row-meta { color: var(--ink-3); font-size: var(--fs-2); display: flex; align-items: center; gap: var(--s1); }
.row-sub { font-size: var(--fs-1); }
.row-tap { padding: 0; }
.row-btn { display: flex; flex-direction: column; gap: var(--s2); width: 100%; padding: var(--s3) 0; border: 0; background: none; text-align: left; border-radius: var(--r-sm); }
.row-btn:active { background: var(--surface-2); }
.row-btn-grid { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: var(--s3); }
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-goal .row-label { font-weight: 650; }
.row-budget .row-label { font-weight: 600; }
.status-ok { color: var(--ink-3); }
.status-ok .icon { color: var(--ok); }
.status-warn { color: var(--warn-ink); }
.status-over { color: var(--over); font-weight: 600; }

/* bars */
.bar { position: relative; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill {
  position: absolute; inset: 0 auto 0 0; width: calc(var(--f, 0) * 100%);
  border-radius: 99px; background: var(--ok);
  transition: width 400ms var(--ease);
}
.bar-warn .bar-fill { background: var(--warn); }
.bar-over .bar-fill { background: var(--over); }
.bar-goal .bar-fill { background: var(--goal); }
.bar-none .bar-fill { background: var(--ink-3); }

/* --------------------------------------------------------- departures */

.departures { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.departure {
  display: grid; grid-template-columns: 52px 1fr auto auto; align-items: center; column-gap: var(--s3);
  min-height: 64px; padding: var(--s2) var(--s4) var(--s2) 0;
}
.departure + .departure { border-top: 1px solid var(--line); }
.dep-when {
  display: flex; flex-direction: column; align-items: center; justify-content: center; align-self: stretch;
  margin: calc(var(--s2) * -1) 0; border-right: 1px solid var(--line);
  background: var(--surface-2);
}
.dep-days { font-size: var(--fs-4); font-weight: 780; line-height: 1; }
.dep-unit { font-size: 0.6875rem; color: var(--ink-3); font-weight: 600; margin-top: 2px; }
.dep-when.is-soon { background: var(--plate); color: var(--plate-ink); }
.dep-when.is-soon .dep-unit { color: var(--plate-ink-2); }
.dep-when:not(.is-soon) .dep-days:only-child, .dep-when.is-soon .dep-days:only-child { font-size: var(--fs-2); }
.dep-text { display: flex; flex-direction: column; min-width: 0; }
.dep-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-meta { color: var(--ink-3); font-size: var(--fs-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.departure .tile-book { width: 22px; height: 22px; font-size: 0.6875rem; border-radius: 6px; }
.dep-amount { font-weight: 700; text-align: right; min-width: 64px; }

/* --------------------------------------------------------------- note */

.note { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.note-title { font-weight: 700; }
.note-text { color: var(--ink-2); font-size: var(--fs-2); line-height: 1.55; }
.note-more { display: inline-flex; align-items: center; gap: var(--s1); color: var(--k); font-weight: 650; font-size: var(--fs-2); }

/* ---------------------------------------------------- route strip list */

.route { --route: var(--line-strong); position: relative; }
.route-K { --route: var(--k); }
.route-D { --route: var(--d); }
.stop { position: relative; padding-left: 0; }
.stop + .stop { margin-top: var(--s2); }
.stop::before {
  content: ""; position: absolute; left: 16px; top: 22px; bottom: -10px; width: 3px; margin-left: -1.5px;
  background: var(--route); border-radius: 2px; opacity: 0.55;
}
.stop:last-child::before { bottom: 18px; }
.stop-head { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 36px; padding-right: var(--s1); }
.stop-dot {
  position: relative; z-index: 1; flex: none; width: 13px; height: 13px; margin-left: 10px;
  border-radius: 50%; background: var(--ground); border: 3px solid var(--route);
}
.stop-day { flex: 1; font-size: var(--fs-2); font-weight: 720; color: var(--ink-2); }
.stop-sum { font-size: var(--fs-2); color: var(--ink-3); font-weight: 600; }
.stop-sum.is-pos { color: var(--pos); }
.legs { margin-left: 36px; display: flex; flex-direction: column; gap: 6px; }
.leg { position: relative; border-radius: var(--r-md); overflow: hidden; }
.leg-main {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: var(--s3);
  width: 100%; min-height: 58px; padding: var(--s2) var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); text-align: left;
  transform: translateX(var(--dx, 0));
  transition: transform 200ms var(--ease), background 120ms;
  touch-action: pan-y;
}
.leg.dragging .leg-main { transition: none; }
.leg.swiped .leg-main { transform: translateX(-96px); }
.leg-main:active { background: var(--surface-2); }
.leg-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.leg-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 640; }
.leg-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-meta { color: var(--ink-3); font-size: var(--fs-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-amount { font-weight: 700; text-align: right; }
.leg-amount.is-transfer { color: var(--ink-2); }
.leg-delete {
  position: absolute; inset: 0 0 0 auto; width: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding-left: 24px;
  border: 0; background: var(--over); color: oklch(0.99 0 0); font-size: var(--fs-1); font-weight: 700;
}
.flag { display: inline-flex; color: var(--ink-3); }
.flag-pending { color: var(--warn-ink); }

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-weight: 680; font-size: var(--fs-3); line-height: 1.1; text-align: center;
  transition: background 140ms var(--ease), transform 140ms var(--ease), opacity 140ms;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.busy { opacity: 0.75; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--over); color: oklch(0.99 0 0); }
.btn-danger-text { color: var(--over); }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: var(--fs-4); border-radius: var(--r-lg); }
.btn-sm { min-height: 40px; padding: 0 var(--s3); font-size: var(--fs-2); }
.btn-row { display: flex; gap: var(--s2); justify-content: space-between; }
.btn-row > .btn { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; }

/* chips */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 var(--s2); border-radius: 99px; background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-1); font-weight: 650; white-space: nowrap; }
.chip-warn { background: var(--warn-soft); color: var(--warn-ink); }
.chips { display: flex; gap: var(--s1); padding: 3px; border-radius: 99px; background: var(--surface-3); }
.chip-btn { min-height: 36px; padding: 0 var(--s3); border: 0; border-radius: 99px; background: transparent; color: var(--ink-2); font-size: var(--fs-2); font-weight: 650; }
.chip-btn.is-on { background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow-1); }
.filters { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }

/* ------------------------------------------------------------ forms */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-2); font-weight: 650; color: var(--ink-2); }
.field-hint { font-size: var(--fs-1); color: var(--ink-3); }
.field-error { color: var(--over); font-size: var(--fs-2); font-weight: 600; min-height: 0; }
.field-error:empty { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.input, .select {
  width: 100%; min-height: 48px; padding: 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-3); /* >= 16px: no iOS zoom */
  transition: border-color 140ms, box-shadow 140ms;
  caret-color: var(--k);
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:focus, .select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 22%, transparent); outline: none; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
.select-sm { min-height: 40px; width: auto; max-width: 60%; font-size: var(--fs-3); }
.input-lg { min-height: 56px; font-size: var(--fs-4); }
.input-code { letter-spacing: 0.08em; text-transform: uppercase; }
.input-sm { min-height: 44px; text-align: right; }
.input[type="date"], .input[type="month"] { padding-right: var(--s2); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-affix { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; color: var(--ink-3); border-radius: 50%; }
.input-group { display: flex; gap: var(--s2); }
.input-group .input { flex: 1; }
.input-group .btn { flex: none; }
.input-euro { position: relative; width: 116px; flex: none; }
.input-euro .input { padding-right: 28px; }
.input-suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.is-weak .input, .is-weak .select, .is-weak .seg-track { border-color: var(--warn); box-shadow: 0 0 0 3px color-mix(in oklch, var(--warn) 28%, transparent); }
.weak-tag { margin-left: auto; padding: 1px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn-ink); font-size: 0.6875rem; font-weight: 750; }

/* segmented */
.seg { border: 0; padding: 0; margin: 0; min-width: 0; }
.seg-track { display: flex; padding: 3px; gap: 3px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid transparent; }
.seg-input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt {
  flex: 1; display: grid; place-items: center; min-height: 40px; padding: 0 var(--s2);
  border-radius: 9px; font-size: var(--fs-2); font-weight: 650; color: var(--ink-2);
  cursor: pointer; user-select: none; text-align: center; white-space: nowrap;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.seg-input:checked + .seg-opt { background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow-1); }
.seg-input:focus-visible + .seg-opt { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg-book .seg-input:checked + .opt-K { background: var(--k); color: var(--k-ink); }
.seg-book .seg-input:checked + .opt-D { background: var(--d); color: var(--d-ink); }
.seg-sm .seg-opt { min-height: 34px; padding: 0 var(--s3); }

/* switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s1) 0; }
.switch-label { display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.switch-text { font-weight: 650; }
.switch-hint { font-size: var(--fs-1); color: var(--ink-3); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-knob { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background 160ms var(--ease); }
.switch-knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); transition: transform 180ms var(--ease); }
.switch-input:checked + .switch-knob { background: var(--primary); border-color: var(--primary); }
.switch-input:checked + .switch-knob::after { transform: translateX(20px); background: var(--primary-ink); }
.switch-input:focus-visible + .switch-knob { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-input:disabled + .switch-knob { opacity: 0.5; }

.check-row { display: flex; align-items: center; gap: var(--s3); min-height: 48px; font-weight: 600; cursor: pointer; }
.check-input { width: 22px; height: 22px; accent-color: var(--plate); flex: none; }

/* ----------------------------------------------------------- Vnos */

.mic-zone {
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  padding: var(--s6) var(--s4) var(--s5); margin-bottom: var(--s5);
  border-radius: var(--r-xl); background: var(--plate); color: var(--plate-ink);
}
.mic-btn {
  --lvl: 0;
  position: relative; display: grid; place-items: center;
  width: 112px; height: 112px; border-radius: 50%; border: 0;
  background: var(--plate-ink); color: var(--plate);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 160ms var(--ease), background 200ms var(--ease);
}
.mic-btn:active:not(:disabled) { transform: scale(0.96); }
.mic-btn:disabled { opacity: 0.5; }
.mic-glyph { position: relative; z-index: 1; display: grid; place-items: center; }
.mic-ring { position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--plate-line); transition: transform 90ms linear, border-color 200ms; }
.mic-zone[data-state="recording"] .mic-btn { background: var(--rec); color: oklch(0.99 0 0); }
.mic-zone[data-state="recording"] .mic-ring { border-color: var(--rec); transform: scale(calc(1 + var(--lvl) * 0.22)); }
.mic-zone[data-state="transcribing"] .mic-ring { border-color: var(--plate-ink-2); border-top-color: transparent; animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mic-label { margin-top: var(--s4); font-weight: 700; font-size: var(--fs-3); text-align: center; }
.mic-timer { min-height: 1.3em; color: var(--plate-ink-2); font-size: var(--fs-2); }
.mic-timer.is-low { color: var(--danger, #c0392b); font-weight: 650; }
.mic-status { color: oklch(0.86 0.1 80); font-size: var(--fs-2); text-align: center; max-width: 34ch; }
.mic-status:empty { display: none; }
.mic-zone.is-disabled .mic-label { font-weight: 500; color: var(--plate-ink-2); }

.text-entry { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s6); }
.result { scroll-margin-top: var(--s4); }
.result:empty { display: none; }
.result { margin-bottom: var(--s7); }
.transcript { margin-bottom: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); }
.transcript-label { font-size: var(--fs-1); font-weight: 700; color: var(--ink-3); margin-bottom: 2px; }
.transcript-text { font-size: var(--fs-4); font-weight: 560; line-height: 1.35; }
.transcript-text::before { content: "»"; color: var(--ink-3); }
.transcript-text::after { content: "«"; color: var(--ink-3); }

/* editor (confirm card) */
.editor { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.sheet .editor { padding: 0; border: 0; box-shadow: none; background: transparent; }
.editor-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.editor-title { font-size: var(--fs-4); font-weight: 720; margin-right: auto; }
.editor-hint { width: 100%; color: var(--warn-ink); font-size: var(--fs-2); font-weight: 600; }
.field-amount .amount-wrap { position: relative; }
.input-amount { min-height: 64px; padding-right: 48px; font-size: var(--fs-6); font-weight: 750; letter-spacing: -0.02em; }
.amount-cur { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: var(--fs-5); font-weight: 700; color: var(--ink-3); pointer-events: none; }
.field-row-seg { grid-template-columns: 1fr; }
.editor-actions { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s1); }

/* --------------------------------------------------------- month picker */

.month-picker { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.mp-label { min-width: 112px; text-align: center; font-size: var(--fs-2); font-weight: 700; white-space: nowrap; }
.month-picker .icon-btn { width: 40px; height: 40px; }

/* ----------------------------------------------------------- P&L */

.pl { padding: var(--s1) var(--s4); }
.pl-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; }
.pl > .pl-row + .pl-row, .pl > .pl-row + details, .pl > details + .pl-row, .pl > details + details { border-top: 1px solid var(--line); }
.pl-group { display: block; }
.pl-sum { display: flex; align-items: center; gap: var(--s2); min-height: 48px; cursor: pointer; list-style: none; }
.pl-sum::-webkit-details-marker { display: none; }
.pl-label { flex: 1; font-weight: 600; }
.pl-value { font-weight: 680; }
.pl-chev { display: grid; place-items: center; color: var(--ink-3); transition: transform 180ms var(--ease); }
details[open] > .pl-sum .pl-chev { transform: rotate(180deg); }
.pl-lines { padding: 0 0 var(--s3) var(--s3); display: flex; flex-direction: column; gap: 6px; }
.pl-line { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--fs-2); color: var(--ink-2); }
.pl-strong .pl-label, .pl-strong .pl-value { font-weight: 750; }
.pl-strong { background: linear-gradient(var(--surface-2), var(--surface-2)) no-repeat center / calc(100% + 32px) 100%; }
.pl-total { min-height: 60px; }
.pl-total .pl-label { font-weight: 780; font-size: var(--fs-4); }
.pl-total .pl-value { font-weight: 800; font-size: var(--fs-5); letter-spacing: -0.015em; }
.pl > .pl-total { border-top: 2px solid var(--ink) !important; }
.pl-below { display: flex; flex-direction: column; padding-top: var(--s4); padding-bottom: var(--s1); }
.pl-below .panel-note { margin-bottom: var(--s1); }
.pl-below > .pl-row { border-top: 1px solid var(--line); }

/* KPIs */
.kpis { padding: 0 var(--s4); }
.kpi { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 60px; padding: var(--s2) 0; }
.kpi + .kpi { border-top: 1px solid var(--line); }
.kpi dt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kpi-label { font-weight: 650; }
.kpi-hint { font-size: var(--fs-1); color: var(--ink-3); }
.kpi-value { font-size: var(--fs-4); font-weight: 760; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table.panel { padding: 0; border-spacing: 0; overflow: hidden; }
.table th, .table td { padding: var(--s3) var(--s4); text-align: left; font-weight: 500; }
.table thead th { font-size: var(--fs-1); font-weight: 700; color: var(--ink-3); background: var(--surface-2); }
.table tbody th { font-weight: 650; }
.table tbody tr + tr > * { border-top: 1px solid var(--line); }
.table tfoot > tr > * { border-top: 2px solid var(--line-strong); font-weight: 750; }
.table .num { text-align: right; }
.table-compact th, .table-compact td { padding: var(--s2) var(--s2); font-size: var(--fs-2); }

/* chart */
.chart { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-base { stroke: var(--line-strong); stroke-width: 1; }
.chart-tick { fill: var(--ink-3); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.chart-month { fill: var(--ink-3); font-size: 10.5px; font-weight: 600; }
.chart-rev { fill: var(--chart-rev); }
.chart-cost { fill: var(--chart-cost); }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-col .chart-rev, .chart-col .chart-cost { opacity: 0.58; transition: opacity 160ms; }
.chart-col.is-sel .chart-rev, .chart-col.is-sel .chart-cost { opacity: 1; }
.chart-col.is-sel .chart-month { fill: var(--ink); font-weight: 800; }
.chart-col.is-sel .chart-hit { fill: var(--surface-2); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: var(--fs-1); color: var(--ink-2); font-weight: 600; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch-rev { background: var(--chart-rev); }
.swatch-cost { background: var(--chart-cost); }
.chart-readout { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s4); row-gap: var(--s1); padding-top: var(--s3); border-top: 1px solid var(--line); font-size: var(--fs-2); color: var(--ink-2); }
.readout-month { width: 100%; font-weight: 700; color: var(--ink); }
.readout-item { display: inline-flex; align-items: center; gap: 6px; }
.readout-item strong { color: var(--ink); font-weight: 700; }
.chart-table summary { cursor: pointer; font-size: var(--fs-2); font-weight: 650; color: var(--k); padding: var(--s1) 0; }
.chart-table[open] summary { margin-bottom: var(--s2); }

/* ----------------------------------------------------------- Več */

.screen-more > .panel { margin-bottom: var(--s4); }
.nav-list { padding: 0 var(--s4); }
.nav-list > li + li { border-top: 1px solid var(--line); }
.nav-row { display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: var(--s2) 0; }
.nav-row:active { opacity: 0.7; }
.nav-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--ink); flex: none; }
.nav-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.nav-label { font-weight: 680; }
.nav-meta { font-size: var(--fs-2); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-chev { color: var(--ink-3); }
.sync-line, .privacy-line { display: flex; align-items: flex-start; gap: var(--s2); color: var(--ink-3); font-size: var(--fs-2); margin-top: var(--s3); padding: 0 var(--s2); }
.sync-line .icon, .privacy-line .icon { margin-top: 2px; }
.privacy-line { margin-top: var(--s2); }

/* reports */
.report-list { display: flex; flex-direction: column; gap: var(--s3); }
.report-item { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.report-meta { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-2); color: var(--ink-3); }
.report-title { font-size: var(--fs-4); font-weight: 720; }
.report-excerpt { font-size: var(--fs-2); color: var(--ink-2); }
.reader-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); color: var(--ink-3); font-size: var(--fs-2); margin-bottom: var(--s5); }
.prose { max-width: 68ch; font-size: 1.0625rem; line-height: 1.6; }
.prose > * + * { margin-top: var(--s4); }
.prose h2 { font-size: var(--fs-5); line-height: 1.2; font-weight: 760; letter-spacing: -0.015em; margin-top: var(--s7); }
.prose > h2:first-child { margin-top: 0; }
.prose h3 { font-size: var(--fs-4); font-weight: 720; margin-top: var(--s6); }
.prose h4 { font-size: var(--fs-3); font-weight: 720; margin-top: var(--s5); }
.prose strong { font-weight: 720; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: var(--s1); }
.prose li::marker { color: var(--ink-3); }
.prose blockquote { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-2); }
.prose code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); }
.md-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.md-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-2); }
.md-table th, .md-table td { padding: var(--s2) var(--s3); text-align: left; }
.md-table th { background: var(--surface-2); color: var(--ink-3); font-weight: 700; font-size: var(--fs-1); }
.md-table tr + tr td { border-top: 1px solid var(--line); }
.md-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* budgets editor */
.budget-edit .row-edit { flex-direction: row; align-items: center; gap: var(--s3); }
.budget-edit .row-label { flex-direction: column; align-items: flex-start; gap: 0; cursor: pointer; }
.budget-edit .row-meta { font-weight: 500; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding: 0 var(--s1); font-weight: 650; }
.total-line strong { font-size: var(--fs-5); font-weight: 780; }

/* subscriptions */
.sub.is-cancelled .row-btn { opacity: 0.55; }
.subs .row-label { font-weight: 650; }

/* settings */
.screen-settings .panel { display: flex; flex-direction: column; gap: var(--s3); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.panel .setting-row + .setting-row { padding-top: var(--s3); border-top: 1px solid var(--line); }
.setting-text { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-2); color: var(--ink-2); }
.setting-text strong { color: var(--ink); font-size: var(--fs-3); }
.setting-row .btn { flex: none; }
.mini-list { display: flex; flex-direction: column; }
.mini-list > li { display: flex; align-items: center; gap: var(--s3); min-height: 56px; }
.mini-list > li + li { border-top: 1px solid var(--line); }
.mini-text { flex: 1; display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-1); color: var(--ink-3); }
.mini-text strong { font-size: var(--fs-3); color: var(--ink); font-weight: 650; }
.mini-icon, .avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); flex: none; font-weight: 750; }
.avatar { border-radius: 50%; background: var(--plate); color: var(--plate-ink); }

.codes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); counter-reset: c; }
.code { position: relative; padding: var(--s3) var(--s2) var(--s3) 30px; border-radius: var(--r-sm); background: var(--surface-2); font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace; font-size: var(--fs-2); font-weight: 600; letter-spacing: 0.02em; }
.code::before { counter-increment: c; content: counter(c); position: absolute; left: 10px; color: var(--ink-3); font-size: var(--fs-1); }
.big-code { padding: var(--s5) var(--s3); border-radius: var(--r-lg); background: var(--plate); color: var(--plate-ink); text-align: center; font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace; font-size: 2rem; font-weight: 700; letter-spacing: 0.12em; }
.fingerprint { padding: var(--s4); border-radius: var(--r-md); border: 2px dashed var(--line-strong); text-align: center; font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace; font-size: var(--fs-5); font-weight: 700; letter-spacing: 0.06em; }
.pair { display: flex; flex-direction: column; gap: var(--s4); }
.pair-wait { display: flex; align-items: center; gap: var(--s2); justify-content: center; color: var(--ink-2); font-size: var(--fs-2); flex-wrap: wrap; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.pair-request { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: var(--r-md); background: var(--surface-2); }
.done-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: var(--s2) auto 0; border-radius: 50%; background: var(--ok); color: oklch(0.99 0 0); }
.done-title { text-align: center; font-size: var(--fs-5); font-weight: 760; }
.strength { font-size: var(--fs-2); font-weight: 700; color: var(--ink-3); margin-top: calc(var(--s2) * -1); }
.strength:empty { display: none; }
.strength[data-score="0"] { color: var(--ink-3); }
.strength[data-score="1"] { color: var(--over); }
.strength[data-score="2"] { color: var(--warn-ink); }
.strength[data-score="3"], .strength[data-score="4"] { color: var(--pos); }
.warning { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--warn-soft); color: var(--ink); font-size: var(--fs-2); }
.warning .icon { color: var(--warn-ink); margin-top: 1px; }
.warning strong { font-weight: 750; }

/* ------------------------------------------------------------- steps */

.steps { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 0 0 var(--s7); }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.6875rem; font-weight: 650; color: var(--ink-3); }
.step::before { content: ""; position: absolute; top: 7px; left: -50%; right: 50%; height: 3px; background: var(--line); }
.step:first-child::before { display: none; }
.step.is-done::before, .step.is-current::before { background: var(--ink); }
.step-dot { position: relative; z-index: 1; width: 17px; height: 17px; border-radius: 50%; background: var(--ground); border: 3px solid var(--line-strong); }
.step.is-done .step-dot { background: var(--ink); border-color: var(--ink); }
.step.is-current .step-dot { border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in oklch, var(--ink) 14%, transparent); }
.step.is-current { color: var(--ink); }
.sheet .steps { margin-bottom: var(--s2); }

/* --------------------------------------------------------------- auth */

.auth { display: flex; flex-direction: column; min-height: calc(100dvh - var(--s8)); max-width: 440px; margin: 0 auto; padding-top: var(--s4); }
.auth-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s8); }
.auth-name { font-size: var(--fs-4); font-weight: 780; letter-spacing: -0.01em; }
.auth-main { flex: 1; display: flex; flex-direction: column; }
.auth-form { display: flex; flex-direction: column; gap: var(--s4); flex: 1; }
.auth-title { font-size: var(--fs-6); line-height: 1.12; font-weight: 780; letter-spacing: -0.02em; text-wrap: balance; }
.auth-text { color: var(--ink-2); font-size: var(--fs-3); max-width: 46ch; }
.auth-actions { display: flex; flex-direction: column; gap: var(--s2); margin-top: auto; padding-top: var(--s6); }
.auth-points { display: flex; flex-direction: column; gap: var(--s2); }
.auth-points li { display: flex; gap: var(--s2); align-items: center; color: var(--ink-2); }
.auth-points .icon { color: var(--ok); }
.mark-bg { fill: var(--plate); }
.mark-line { stroke: var(--plate-ink); stroke-width: 4; stroke-linecap: round; fill: none; }
.mark-k { fill: #4f7bf0; stroke: var(--plate-ink); stroke-width: 3; }
.mark-d { fill: #e0559a; stroke: var(--plate-ink); stroke-width: 3; }
:root[data-theme="dark"] .mark-bg { stroke: var(--plate-line); stroke-width: 2; }
.loading { display: grid; place-items: center; min-height: 70dvh; }
.loading-mark { animation: breathe 1.6s var(--ease) infinite alternate; }
@keyframes breathe { from { opacity: 0.55; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* -------------------------------------------------------------- empty */

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s5) var(--s4); border-radius: var(--r-lg); border: 1px dashed var(--line-strong); }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); margin-bottom: var(--s1); }
.empty-title { font-weight: 700; }
.empty-text { color: var(--ink-2); font-size: var(--fs-2); max-width: 44ch; }
.empty .btn { margin-top: var(--s2); }

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

.sheet {
  width: 100%; max-width: var(--maxw); max-height: 92dvh;
  margin: auto auto 0; padding: 0 var(--gutter) calc(var(--s6) + env(safe-area-inset-bottom));
  border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-2);
  overflow-y: auto; overscroll-behavior: contain;
  animation: sheet-in 260ms var(--ease);
}
.sheet::backdrop { background: var(--scrim); animation: fade-in 200ms var(--ease); }
.sheet.closing { animation: sheet-out 180ms ease-in forwards; }
.sheet.closing::backdrop { animation: fade-out 180ms ease-in forwards; }
.sheet-tall { min-height: 70dvh; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes sheet-out { to { transform: translateY(48px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-grip { width: 40px; height: 5px; margin: var(--s2) auto 0; border-radius: 99px; background: var(--line-strong); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0 var(--s3); background: var(--surface); }
.sheet-title { font-size: var(--fs-4); font-weight: 740; }
.sheet-close { margin-right: calc(var(--s2) * -1); }
.sheet-body { display: flex; flex-direction: column; gap: var(--s4); }
.sheet-text { color: var(--ink-2); }
@media (min-width: 600px) { .sheet { margin: auto; border-radius: var(--r-xl); } }

/* -------------------------------------------------------------- toasts */

.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3)); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: 0 var(--gutter); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; max-width: 440px; min-height: 52px; padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border-radius: var(--r-md); background: var(--plate); color: var(--plate-ink);
  box-shadow: var(--shadow-2); pointer-events: auto;
  animation: toast-in 220ms var(--ease);
}
.toast.leaving { animation: toast-out 180ms ease-in forwards; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }
.toast-icon { color: var(--ok); display: grid; }
.toast-error .toast-icon { color: oklch(0.78 0.14 27); }
.toast-text { flex: 1; font-size: var(--fs-2); font-weight: 600; padding: var(--s1) 0; }
.toast-action { min-height: 40px; padding: 0 var(--s3); border: 0; border-radius: var(--r-sm); background: var(--plate-2); color: var(--plate-ink); font-weight: 750; font-size: var(--fs-2); }

/* -------------------------------------------------------- small screens */

@media (max-width: 374px) {
  :root { --gutter: 12px; }
  .board-figure { font-size: var(--fs-5); }
  .plate-figure { font-size: var(--fs-6); }
  .mp-label { min-width: 96px; }
  .field-row { grid-template-columns: 1fr; }
}
@media (min-width: 420px) {
  .field-row-seg { grid-template-columns: 1fr 1.3fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .tile, .btn-primary, .plate, .bar-fill { forced-color-adjust: none; }
}

/* pairing comparison */
.compare { display: flex; flex-direction: column; gap: var(--s3); }
.compare-item { display: flex; flex-direction: column; gap: var(--s1); }
.compare-item dt { font-size: var(--fs-2); font-weight: 650; color: var(--ink-2); }
.row-value .muted { margin-left: 0.3em; }
.screen-settings .panel.setting-row { flex-direction: row; align-items: center; }
.screen-settings .panel.setting-row .setting-text { flex: 1; }
