:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #141414;
  --muted: #5f5f59;
  --line: #e2e2dc;
  --accent: #0a7d4f;
  --accent-soft: #e3f3eb;
  --down: #b3261e;
  --down-soft: #fbe9e7;
  --chip: #efefea;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1011;
    --surface: #18191b;
    --text: #ededea;
    --muted: #a3a39d;
    --line: #2a2b2e;
    --accent: #3ddc97;
    --accent-soft: #143326;
    --down: #ff8a80;
    --down-soft: #3a1a18;
    --chip: #232427;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Header */
.site-header { padding: 22px 0 6px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 18px; text-decoration: none; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 18px; font-size: 15px; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }

/* Hero */
.hero { padding: 36px 0 24px; }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.08; letter-spacing: -.035em; margin: 0 0 14px; font-weight: 800; }
.lede { font-size: 18px; color: var(--muted); max-width: 660px; margin: 0; }
.meta { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); }
.meta b { color: var(--text); font-weight: 600; }
.pill { background: var(--chip); padding: 4px 10px; border-radius: 999px; }

/* Calculator */
.calc {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px;
}
.calc label { font-weight: 700; font-size: 16px; }
.money { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 0 12px; }
.money span { color: var(--muted); font-weight: 600; }
.money input {
  font: inherit; font-size: 20px; font-weight: 700; width: 120px; border: 0; background: transparent; color: var(--text);
  padding: 8px 6px;
}
.money input:focus { outline: none; }
.money:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.calc small { color: var(--muted); font-size: 13px; flex-basis: 100%; }
.calc small a { color: var(--muted); }

/* Controls */
.controls {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 12px 0; border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
}
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .toggle {
  font: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
}
.seg button[aria-pressed="true"], .toggle[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.field { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.field.push { margin-left: auto; }
select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.count { font-size: 13px; color: var(--muted); padding: 16px 0 8px; margin: 0; }

/* Card list */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1.4fr 1fr 1.3fr auto; gap: 16px; align-items: center; padding: 18px 20px;
}
.card[hidden] { display: none; }
.rank { font-size: 12px; color: var(--muted); font-weight: 600; }
.card h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 2px 0 6px; line-height: 1.25; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 12px; background: var(--chip); color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.tag.self { background: var(--accent-soft); color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.base { font-size: 32px; font-weight: 800; color: var(--accent); letter-spacing: -.03em; line-height: 1.1; }
.base.zero { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); }
.max { font-size: 20px; font-weight: 700; line-height: 1.2; }
.req { font-size: 13px; color: var(--muted); margin-top: 2px; font-weight: 400; }
.visit {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: var(--text); color: var(--bg); text-decoration: none;
  font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: 10px;
}
.visit:hover { opacity: .85; }
.estimate {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: -4px;
}
.estimate b { font-size: 18px; color: var(--accent); }
.estimate.none { background: var(--chip); color: var(--muted); }
.estimate .plan { color: var(--muted); }
.card details { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; margin-top: -4px; }
summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 500; }
dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; margin: 12px 0 4px; font-size: 14px; }
dt { font-size: 12px; color: var(--muted); font-weight: 600; }
dd { margin: 0; }
.checked { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; list-style: none; }

/* Article pages */
.crumbs { font-size: 13px; color: var(--muted); padding: 24px 0 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; }
.crumbs a { color: var(--muted); }
.article { max-width: 700px; padding: 20px 0 0; }
.article h1 { font-size: clamp(28px, 4.5vw, 40px); }
.article h2 { font-size: 24px; letter-spacing: -.02em; margin: 36px 0 10px; line-height: 1.2; }
.article h3 { font-size: 18px; margin: 26px 0 8px; }
.article p, .article li { font-size: 17px; }
.article a { color: var(--accent); }
.article .byline { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.callout { background: var(--accent-soft); border-radius: 12px; padding: 14px 18px; margin: 20px 0; }
.callout p { margin: 0; }
.table-wrap { overflow-x: auto; margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--surface); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--chip); }
.guide-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.guide-list a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; text-decoration: none; color: var(--text); }
.guide-list a:hover { border-color: var(--muted); }
.guide-list h2 { margin: 0 0 4px; font-size: 19px; }
.guide-list p { margin: 0; color: var(--muted); font-size: 15px; }

/* Change log */
.log { list-style: none; padding: 0; margin: 20px 0 0; border-left: 2px solid var(--line); }
.log li { position: relative; padding: 0 0 26px 22px; }
.log li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.log time { font-size: 13px; color: var(--muted); font-weight: 600; }
.log h2 { font-size: 18px; margin: 2px 0 4px; }
.log p { margin: 0; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 5px; background: var(--chip); color: var(--muted); margin-left: 6px; vertical-align: 2px; }
.badge.up { background: var(--accent-soft); color: var(--accent); }
.badge.down { background: var(--down-soft); color: var(--down); }

/* Footer */
.site-footer { margin-top: 56px; border-top: 1px solid var(--line); padding: 36px 0 56px; color: var(--muted); font-size: 14px; }
.site-footer h2 { color: var(--text); font-size: 16px; margin: 0 0 8px; letter-spacing: -.01em; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 28px; }
.site-footer p { margin: 0 0 10px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.fine { margin-top: 28px; font-size: 12px; }

@media (max-width: 760px) {
  .card { grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px; }
  .card .ident, .card .cta { grid-column: 1 / -1; }
  .visit { width: 100%; justify-content: center; }
  .field.push { margin-left: 0; }
  .controls { position: static; }
  .nav { gap: 14px; font-size: 14px; }
}

/* Cookie consent */
.consent {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  padding: 0 16px 16px; pointer-events: none;
}
.consent[hidden] { display: none; }
.consent-inner {
  pointer-events: auto; max-width: 720px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; align-items: center;
  font-size: 14px;
}
.consent-inner p { margin: 0; color: var(--muted); }
.consent-inner .consent-title { color: var(--text); font-weight: 700; font-size: 15px; grid-column: 1; }
.consent-inner #consent-text { grid-column: 1; }
.consent-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 8px; }
.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--text); background: var(--surface); color: var(--text);
  padding: 9px 18px; border-radius: 10px; min-width: 92px;
}
.btn[data-consent="granted"] { background: var(--text); color: var(--bg); }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
@media (max-width: 600px) {
  .consent-inner { grid-template-columns: 1fr; }
  .consent-actions { grid-column: 1; grid-row: auto; margin-top: 10px; }
  .btn { flex: 1; }
}
