/* Self-hosted, no web fonts: everything must load reliably from mainland China. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --income: #2a78d6;
  --expense: #e34948;
  --net: #1baf7a;
  --good-text: #006300;
  --bad-text: #b3261e;
  --warn-bg: #fff4d6;
  --warn-ink: #5c4300;
  --focus: #2a78d6;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --income: #3987e5;
    --expense: #e66767;
    --net: #199e70;
    --good-text: #3fbf3f;
    --bad-text: #ff8a80;
    --warn-bg: #3a2f10;
    --warn-ink: #f5dc9c;
    --focus: #6da7ec;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #9a9890;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --income: #3987e5;
  --expense: #e66767;
  --net: #199e70;
  --good-text: #3fbf3f;
  --bad-text: #ff8a80;
  --warn-bg: #3a2f10;
  --warn-ink: #f5dc9c;
  --focus: #6da7ec;
}

/* Tokyo Night (https://github.com/tokyo-night/tokyo-night-vscode-theme).
   Text uses the theme's own colours; chart fills use deeper steps of the same hues so
   they pass the colour-blind and contrast checks on this background. */
:root[data-theme="tokyo"] {
  color-scheme: dark;
  --page: #16161e;
  --surface-1: #1a1b26;
  --surface-2: #24283b;
  --text-primary: #c0caf5;
  --text-secondary: #a9b1d6;
  --text-muted: #737aa2;
  --grid: #292e42;
  --axis: #3b4261;
  --border: rgba(169, 177, 214, 0.12);
  --accent: #7aa2f7;
  --accent-ink: #1a1b26;
  --income: #6183e6;
  --expense: #db4b4b;
  --net: #17a589;
  --good-text: #9ece6a;
  --bad-text: #f7768e;
  --warn-bg: #2d2a22;
  --warn-ink: #e0af68;
  --focus: #7dcfff;
}

/* Rosé Pine (https://rosepinetheme.com). Chart fills are deeper steps of iris / love / pine-foam. */
:root[data-theme="rose-pine"] {
  color-scheme: dark;
  --page: #191724;
  --surface-1: #1f1d2e;
  --surface-2: #26233a;
  --text-primary: #e0def4;
  --text-secondary: #b8b4d4;
  --text-muted: #908caa;
  --grid: #2a273f;
  --axis: #403d52;
  --border: rgba(224, 222, 244, 0.1);
  --accent: #ebbcba;
  --accent-ink: #191724;
  --income: #9d80e0;
  --expense: #d45478;
  --net: #2b9fb0;
  --good-text: #9ccfd8;
  --bad-text: #eb6f92;
  --warn-bg: #2a2433;
  --warn-ink: #f6c177;
  --focus: #c4a7e7;
}

/* Dracula (https://draculatheme.com). Net uses cyan, not green: red/green bars are hard to tell apart with colour blindness. */
:root[data-theme="dracula"] {
  color-scheme: dark;
  --page: #21222c;
  --surface-1: #282a36;
  --surface-2: #343746;
  --text-primary: #f8f8f2;
  --text-secondary: #c8cbe0;
  --text-muted: #9aa3cc;
  --grid: #343746;
  --axis: #44475a;
  --border: rgba(248, 248, 242, 0.1);
  --accent: #bd93f9;
  --accent-ink: #282a36;
  --income: #9a6ff0;
  --expense: #e04545;
  --net: #1fa3c0;
  --good-text: #50fa7b;
  --bad-text: #ff5555;
  --warn-bg: #33302a;
  --warn-ink: #f1fa8c;
  --focus: #ff79c6;
}

/* Gruvbox Dark (https://github.com/morhetz/gruvbox). Chart fills use saturated steps of blue / red / aqua. */
:root[data-theme="gruvbox"] {
  color-scheme: dark;
  --page: #1d2021;
  --surface-1: #282828;
  --surface-2: #3c3836;
  --text-primary: #ebdbb2;
  --text-secondary: #d5c4a1;
  --text-muted: #a89984;
  --grid: #3c3836;
  --axis: #504945;
  --border: rgba(235, 219, 178, 0.1);
  --accent: #fabd2f;
  --accent-ink: #282828;
  --income: #458fd0;
  --expense: #dd4a33;
  --net: #35a07a;
  --good-text: #b8bb26;
  --bad-text: #fb4934;
  --warn-bg: #3a3325;
  --warn-ink: #fabd2f;
  --focus: #83a598;
}

/* Catppuccin Latte (https://catppuccin.com). Positive text uses a darker green than the palette's so it stays readable. */
:root[data-theme="latte"] {
  color-scheme: light;
  --page: #e6e9ef;
  --surface-1: #eff1f5;
  --surface-2: #dce0e8;
  --text-primary: #4c4f69;
  --text-secondary: #5c5f77;
  --text-muted: #6c6f85;
  --grid: #ccd0da;
  --axis: #bcc0cc;
  --border: rgba(76, 79, 105, 0.14);
  --accent: #8839ef;
  --accent-ink: #ffffff;
  --income: #1e66f5;
  --expense: #d20f39;
  --net: #40a02b;
  --good-text: #2f7a1f;
  --bad-text: #d20f39;
  --warn-bg: #f6e7c8;
  --warn-ink: #7a4a00;
  --focus: #1e66f5;
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

button, select, input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --- header --------------------------------------------------------------- */

.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  font-weight: 650;
  font-size: 16px;
  margin-right: auto;
  white-space: nowrap;
}

.prefs {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 34px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  white-space: nowrap;
}

.btn:hover { filter: brightness(0.97); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn-danger { color: var(--bad-text); }

.btn-sm { padding: 3px 8px; min-height: 28px; font-size: 13px; }

.sso-link {
  display: inline-block;
  line-height: 0;
  border-radius: 4px;
}

.sso-link img { display: block; max-width: 100%; height: auto; }

.sso-link:hover img { filter: brightness(1.15); }

/* --- segmented controls --------------------------------------------------- */

.controls {
  display: flex;
  gap: 16px 24px;
  flex-wrap: wrap;
  align-items: center;
  margin: 20px 0 16px;
}

.control { display: flex; align-items: center; gap: 8px; }

.sync-status {
  order: 1;             /* sits at the end of the first controls row */
  margin: 0 0 0 auto;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.control-label { color: var(--text-secondary); font-size: 13px; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  min-height: 28px;
}

.seg button[aria-pressed="true"] {
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--border);
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: 999px;
  padding: 2px 10px 2px 2px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}

.chip img, .chip .avatar { width: 24px; height: 24px; border-radius: 999px; }

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--surface-2);
}

.chip.all { padding-left: 10px; }

/* --- cards & tiles -------------------------------------------------------- */

.notice {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 16px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.notice button {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: inherit;
  font-size: 18px;
  line-height: 1;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile, .card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tile { padding: 14px 16px; min-width: 0; }

.tile.hero { grid-column: span 2; }

.tile-label { color: var(--text-secondary); font-size: 13px; }

.tile { container-type: inline-size; }

/* Sized from the tile's own width: full size normally, a little smaller only when a
   long localized value (e.g. "+7,83 млрд") would otherwise not fit. Never clipped. */
.tile-value {
  font-size: clamp(15px, 14.5cqi, 24px);
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
}

/* The unit sits beside the number, smaller and quieter, so long localized
   magnitudes (млрд, Mrd., 亿) never push "ISK" onto its own line. */
.tile-value .unit {
  font-size: 0.55em;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.3em;
}

.tile.hero .tile-value { font-size: clamp(28px, 11.5cqi, 44px); line-height: 1.15; }

.tile-sub { color: var(--text-muted); font-size: 12px; }

.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }

.card { padding: 16px; margin-bottom: 16px; min-width: 0; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title { font-size: 16px; font-weight: 600; margin: 0; }

.card-sub { color: var(--text-secondary); font-size: 13px; margin: 2px 0 0; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.grid-2 > .card { margin-bottom: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }

.stack > .card { margin-bottom: 0; }

.section { margin-bottom: 16px; }

.chart-box { position: relative; height: 300px; }

.chart-box.short { height: 220px; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.key { display: inline-flex; align-items: center; gap: 6px; }

.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.line { height: 2px; width: 14px; border-radius: 1px; }
.sw-income { background: var(--income); }
.sw-expense { background: var(--expense); }
.sw-net { background: var(--net); }

/* --- tables --------------------------------------------------------------- */

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--grid);
  vertical-align: top;
}

tr:last-child td { border-bottom: 0; }

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.muted { color: var(--text-muted); }

.small { font-size: 12px; }

.nowrap { white-space: nowrap; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  margin-left: 6px;
}

.desc { color: var(--text-secondary); overflow-wrap: anywhere; }

/* category bars */
.bar-cell { width: 34%; }

.bar-track {
  display: flex;
  height: 10px;
  align-items: center;
}

.bar-half { flex: 1; display: flex; height: 10px; }
.bar-half.left { justify-content: flex-end; }

.bar {
  height: 10px;
  min-width: 0;
}

.bar.in { background: var(--income); border-radius: 0 4px 4px 0; }
.bar.out { background: var(--expense); border-radius: 4px 0 0 4px; }

.bar-mid { width: 1px; height: 14px; background: var(--axis); margin: 0 1px; }

.pager {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- what changed --------------------------------------------------------- */

.brief .card-head { flex-wrap: wrap; }
.brief-headline { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; }
.brief-headline > span:first-child { font-weight: 600; }
.brief-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--grid);
  font-size: 14px;
}
.brief-row:first-of-type { border-top: 0; }
.brief-arrow { font-size: 11px; text-align: center; }
.brief-text { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; overflow-wrap: anywhere; }
.brief-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.brief-icon { width: 20px; height: 20px; border-radius: 4px; flex: none; }
.brief-value { white-space: nowrap; }
.brief-empty { padding: 4px 0; }
.brief-sub { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--grid); }
.brief-sub + template + .brief-row { border-top: 0; }

/* --- assets --------------------------------------------------------------- */

.nw-lists { margin-top: 4px; }
.list-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px; }
.nw-top-title { margin-top: 20px; }

.rank {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(32px, 1fr) 3.2em auto;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  border-top: 1px solid var(--grid);
  font-size: 13px;
}
.rank-share { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.rank:first-of-type { border-top: 0; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 6px; display: flex; }
.rank-fill { display: block; height: 6px; background: var(--income); border-radius: 0 3px 3px 0; min-width: 2px; }
.rank-fill.is-other { background: var(--axis); }
.rank-value { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

.item-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.item-cell img { width: 24px; height: 24px; border-radius: 4px; flex: none; }


.page-num { min-width: 30px; justify-content: center; font-variant-numeric: tabular-nums; }
.page-num[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.char-status .info { width: 14px; height: 14px; font-size: 9px; }

/* --- characters panel ----------------------------------------------------- */

.char-row:first-of-type { border-top: 0; }

.char-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--grid);
}

.char-row img, .char-row .avatar { width: 40px; height: 40px; border-radius: 8px; }

.avatar {
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-secondary);
}

.char-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.status-bad { color: var(--bad-text); font-size: 12px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }

.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 34px;
  min-width: 0;
}

.admin-tiles { margin-top: 20px; }

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 16px;
  font-size: 13px;
}

.admin-nav a { color: var(--text-secondary); text-decoration: none; }
.char-link { color: var(--accent); text-decoration: none; }
.char-link:hover { text-decoration: underline; }

.seg-link {
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.seg-link[aria-current="page"] {
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--border);
}
.admin-nav a:hover { color: var(--text-primary); text-decoration: underline; }

section[id], div[id] { scroll-margin-top: 72px; }

.spark { display: block; width: 100%; height: 90px; }
.spark rect { fill: var(--income); }
.spark rect:hover { fill: var(--accent); opacity: 0.75; }

.spark-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meter { display: block; width: 100%; height: 8px; margin: 4px 0 14px; }
.meter .track { fill: var(--surface-2); }
.meter .fill { fill: var(--income); }
.meter.hot .fill { fill: var(--expense); }

.badge.neg { color: var(--bad-text); border-color: currentColor; }

.error-list { display: grid; gap: 6px; }
.error-item { border: 1px solid var(--grid); border-radius: 8px; background: var(--surface-1); }
.error-item summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}
.error-item summary::-webkit-details-marker { display: none; }
.error-item[open] summary { border-bottom: 1px solid var(--grid); }
.error-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.error-meta { color: var(--text-muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.error-body { padding: 8px 10px 10px; display: grid; gap: 8px; }
.error-text {
  margin: 0;
  padding: 10px;
  border-radius: 6px;
  background: var(--surface-2);
  font: 12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow: auto;
}
code { font: 12px ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* --- info tooltips -------------------------------------------------------- */

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--axis);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: italic 600 10px/1 Georgia, "Times New Roman", serif;
  cursor: help;
  vertical-align: middle;
  position: relative;
}

/* Bigger touch target than the visible circle. */
.info::after { content: ""; position: absolute; inset: -10px; }

.info:hover, .info[aria-describedby] { color: var(--text-primary); border-color: var(--text-secondary); }

.tile-label, .control-label, .card-title { display: inline-flex; align-items: center; gap: 2px; }

.tip {
  position: fixed;
  z-index: 50;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--grid);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
}

/* --- contact blurb -------------------------------------------------------- */

.contact {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  font-size: 14px;
  color: var(--text-secondary);
}

.landing .contact { margin: 0 0 28px; }

.contact-row { display: flex; align-items: center; gap: 10px; }


.contact img { width: 32px; height: 32px; border-radius: 6px; flex: none; }
.contact p { margin: 0; flex: 1; min-width: 0; }
.contact a { color: var(--accent); text-decoration: none; }
.contact a:hover { text-decoration: underline; }

/* --- landing previews ------------------------------------------------------ */

/* Wider than the landing text column, centred on the page. */
.preview {
  width: min(1040px, calc(100vw - 32px));
  margin: 56px 0 0 50%;
  transform: translateX(-50%);
}
.preview-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview-head h2 { margin: 0; font-size: 26px; }
.preview > p { margin: 6px 0 28px; }
.preview-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 28px;
  align-items: center;
  margin: 0 0 40px;
}
/* Alternate sides; the screenshot always gets the wide column. */
.preview-item:nth-of-type(even) { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.preview-item:nth-of-type(even) figcaption { order: 2; }
.preview-item a { display: block; border-radius: 10px; }
.preview-item a:hover img { border-color: var(--accent); }
.preview-item h3 { margin: 0 0 6px; font-size: 18px; }
.preview-item p { margin: 0; color: var(--text-secondary); }
.preview-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.55);
  background: #121212;
}
.preview-cta { text-align: center; margin: 8px 0 24px; }
@media (max-width: 800px) {
  .preview-item, .preview-item:nth-of-type(even) { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .preview-item:nth-of-type(even) figcaption { order: 0; }
}

/* --- landing -------------------------------------------------------------- */

.landing {
  max-width: 640px;
  margin: 64px auto;
  padding: 0 16px;
}

.landing h1 { font-size: 36px; line-height: 1.15; margin: 0 0 12px; }

.landing p.lead { font-size: 17px; color: var(--text-secondary); }

.landing ul { padding-left: 20px; color: var(--text-secondary); }

.landing li { margin: 6px 0; }

.landing .cta { margin: 28px 0 12px; }

footer {
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px 0 40px;
}

.empty { color: var(--text-muted); padding: 12px 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 800px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tile.hero { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px; }
  .char-row { grid-template-columns: 40px minmax(0, 1fr); }
  .char-actions { grid-column: 1 / -1; justify-content: flex-start; }
  td, th { padding: 6px 5px; }
  table { font-size: 13px; }
  .bar-cell { display: none; }
  .hide-sm { display: none; }
  .sync-status { order: -1; width: 100%; margin: 0; }
  .landing { margin-top: 32px; }
  .landing h1 { font-size: 28px; }
}

/* planner */
.plan-form { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; margin: 4px 0 14px; }
.plan-field { display: grid; gap: 4px; min-width: 0; }
.plan-amount { display: flex; gap: 6px; }
.plan-amount .input[type="number"] { width: 9em; }
.plan-result { border-top: 1px solid var(--grid); padding-top: 12px; display: grid; gap: 6px; }
.plan-result p { margin: 0; }
.plan-headline { font-size: 22px; font-weight: 650; }
.plan-lines { margin: 4px 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.plan-lines .pos { color: var(--good-text, inherit); }
.plan-lines .neg { color: var(--bad-text, inherit); }
.plan-rates { margin-top: 14px; border-top: 1px solid var(--grid); padding-top: 10px; }
.plan-rates-title { margin: 0 0 2px; font-size: 14px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.plan-pace { flex: 1 1 100%; }
.plan-slider { display: flex; align-items: center; gap: 10px; min-height: 34px; flex-wrap: wrap; }
.plan-slider input[type="range"] { flex: 1 1 240px; min-width: 160px; max-width: 520px; accent-color: var(--accent); }
.plan-rate { white-space: nowrap; }
