/* TAP on Doge documentation, Bitcoin Universe.
   Light sand base with deep bronze accent; dark warm charcoal with amber. */

:root {
  color-scheme: light dark;

  --bg: #f7f1e4;
  --bg-tint: #f1e8d6;
  --surface: #fffdf9;
  --surface-2: #efe5d3;
  --border: #ddcdb0;
  --border-strong: #c7b18b;
  --text: #241d13;
  --muted: #5c4d3a;
  --accent: #8a4a12;
  --accent-soft: #f6e6d0;
  --accent-ink: #ffffff;
  --ok: #2f5d1f;
  --ok-soft: #e6f0dd;
  --warn: #7a5306;
  --warn-soft: #f8ecd0;
  --bad: #96271b;
  --bad-soft: #f9e3df;
  --doge: #8a4a12;
  --btc: #4a4336;

  --dg-line: #b39463;
  --dg-fill: #f6ecd9;
  --dg-fill-2: #ecdcbe;
  --dg-ink: #241d13;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --shadow: 0 1px 2px rgba(60, 40, 12, .06), 0 8px 22px rgba(60, 40, 12, .06);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: ui-rounded, "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --wrap: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120d;
    --bg-tint: #1b1510;
    --surface: #201a13;
    --surface-2: #2a2219;
    --border: #3d3225;
    --border-strong: #574733;
    --text: #f2e9db;
    --muted: #bba98f;
    --accent: #f0a828;
    --accent-soft: #33260f;
    --accent-ink: #17120d;
    --ok: #9fd07e;
    --ok-soft: #1e2a15;
    --warn: #f0c04a;
    --warn-soft: #2f2610;
    --bad: #f0938a;
    --bad-soft: #331915;
    --doge: #f0a828;
    --btc: #cbbfa8;
    --dg-line: #7d6746;
    --dg-fill: #241d15;
    --dg-fill-2: #2f261b;
    --dg-ink: #f2e9db;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #17120d;
  --bg-tint: #1b1510;
  --surface: #201a13;
  --surface-2: #2a2219;
  --border: #3d3225;
  --border-strong: #574733;
  --text: #f2e9db;
  --muted: #bba98f;
  --accent: #f0a828;
  --accent-soft: #33260f;
  --accent-ink: #17120d;
  --ok: #9fd07e;
  --ok-soft: #1e2a15;
  --warn: #f0c04a;
  --warn-soft: #2f2610;
  --bad: #f0938a;
  --bad-soft: #331915;
  --doge: #f0a828;
  --btc: #cbbfa8;
  --dg-line: #7d6746;
  --dg-fill: #241d15;
  --dg-fill-2: #2f261b;
  --dg-ink: #f2e9db;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 1.1rem + 1.6vw, 2.05rem); font-weight: 750; margin-top: 2.2em; }
h3 { font-size: 1.18rem; font-weight: 700; margin-top: 1.8em; }
h4 { font-size: 1.02rem; font-weight: 700; margin-top: 1.5em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.35em; }
li { margin: .3em 0; }
strong { font-weight: 700; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 18px; border-radius: 0 0 var(--radius) 0; font-weight: 700;
}
.skip:focus { left: 0; }

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

.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.head-row { position: relative; display: flex; align-items: center; gap: 14px; min-height: 62px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 800; color: var(--text); text-decoration: none; font-size: 1.02rem; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 1rem; font-weight: 800; flex: none;
}
.brand small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 2px; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 7px 12px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .93rem; font-weight: 600;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

.head-tools { display: flex; align-items: center; gap: 8px; }
.theme-btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 999px; width: 38px; height: 38px; cursor: pointer; font-size: 1rem;
  display: grid; place-items: center; flex: none;
}
.theme-btn:hover { background: var(--surface-2); }

/* ---------- search ---------- */

/* The dropdown anchors to the header row, not to the input, so it stays on
   screen whether the header sits on one line or wraps the search to the left. */
.search { position: static; }
.search input {
  font: inherit; font-size: .93rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 8px 14px; width: 190px; max-width: 42vw;
}
.search input::placeholder { color: var(--muted); }
.search-results {
  position: absolute; right: 20px; top: calc(100% - 2px); width: min(430px, calc(100% - 40px));
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 62vh; overflow-y: auto; padding: 6px; z-index: 60;
}
.search-results[hidden] { display: none; }
.search-results ol { list-style: none; margin: 0; padding: 0; }
.search-results a { display: block; padding: 9px 11px; border-radius: var(--radius-s); text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a:focus-visible { background: var(--accent-soft); }
.search-results .sr-page { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; }
.search-results .sr-title { display: block; font-weight: 650; }
.search-results .sr-snip { display: block; font-size: .84rem; color: var(--muted); }
.search-empty { padding: 14px 12px; color: var(--muted); font-size: .9rem; }

/* ---------- layout ---------- */

main { display: block; }
.page { padding: 34px 0 60px; }
.page > .wrap > :first-child { margin-top: 0; }

.crumb { font-size: .82rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; font-weight: 700; margin: 0 0 10px; }

.lede { font-size: 1.14rem; color: var(--muted); max-width: 66ch; }

.hero { padding: 44px 0 10px; }
.hero-grid { display: grid; gap: 30px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }

.pillrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 5px 13px; font-size: .84rem; font-weight: 650; color: var(--muted);
}
.pill b { color: var(--text); font-weight: 700; }
.pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; font-weight: 700; text-decoration: none;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--surface); color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); filter: none; }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin: 22px 0; padding: 0; list-style: none; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 20px 18px; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card .tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; color: var(--accent); display: block; margin-bottom: 6px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-l); padding: 24px; box-shadow: var(--shadow); margin: 24px 0;
}
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

.note {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; margin: 20px 0;
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.note.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.note b.lbl { display: block; font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 4px; }

/* ---------- code + tables ---------- */

code, kbd, samp { font-family: var(--font-mono); font-size: .89em; }
:not(pre) > code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: .08em .38em; overflow-wrap: anywhere;
}
kbd {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 5px; padding: .1em .45em; font-size: .82em;
}
pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 1em;
  overflow-x: auto; font-size: .88rem; line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: 1em; }

.scroll-x { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
caption { text-align: left; font-size: .85rem; color: var(--muted); padding: 10px 14px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 700; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.yes { color: var(--ok); font-weight: 700; }
.no { color: var(--bad); font-weight: 700; }
.part { color: var(--warn); font-weight: 700; }

/* ---------- rules ---------- */

.rules { counter-reset: none; list-style: none; padding: 0; margin: 0 0 1.4em; }
.rule {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px;
  padding: 12px 0; border-top: 1px solid var(--border); margin: 0;
}
.rule:last-child { border-bottom: 1px solid var(--border); }
.rule .rid {
  font-family: var(--font-mono); font-size: .8rem; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 10px; height: fit-content; white-space: nowrap;
}
.rule .rtext { margin: 0; }
.rule .rtext > :last-child { margin-bottom: 0; }

/* ---------- diagrams ---------- */

figure { margin: 24px 0; }
figure svg { display: block; width: 100%; height: auto; max-width: 100%; }
figcaption { font-size: .87rem; color: var(--muted); margin-top: 10px; }
.dg-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; overflow-x: auto; }
.dg-wrap svg { min-width: 460px; }

.svg-line { stroke: var(--dg-line); }
.svg-fill { fill: var(--dg-fill); }
.svg-fill-2 { fill: var(--dg-fill-2); }
.svg-ink { fill: var(--dg-ink); }
.svg-muted { fill: var(--muted); }
.svg-accent { fill: var(--accent); }
.svg-accent-s { stroke: var(--accent); }
.svg-btc { fill: var(--btc); }
.svg-btc-s { stroke: var(--btc); }
.svg-none { fill: none; }
text { font-family: var(--font-body); }

/* ---------- tool ---------- */

.tool { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-l); padding: 22px; box-shadow: var(--shadow); margin: 22px 0; }
.tool h3 { margin-top: 0; }
.field { margin: 14px 0; }
.field label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.field .hint { font-size: .85rem; color: var(--muted); margin: 0 0 6px; }
textarea, input[type="text"], input[type="number"], select {
  font-family: var(--font-mono); font-size: .9rem;
  width: 100%; background: var(--bg-tint); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 10px 12px;
}
textarea { min-height: 190px; resize: vertical; line-height: 1.5; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row .field { flex: 1 1 150px; margin: 0; }
button.act {
  font: inherit; font-weight: 700; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 10px 20px;
}
button.act.ghost { background: var(--surface); color: var(--accent); }
button.act:hover { filter: brightness(1.07); }
.chiprow { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.chip { font: inherit; font-size: .82rem; font-weight: 650; cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 5px 12px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

.verdict { border-radius: var(--radius); padding: 14px 16px; margin: 18px 0 0; border: 1px solid var(--border); background: var(--surface-2); }
.verdict.ok { background: var(--ok-soft); border-color: var(--ok); }
.verdict.bad { background: var(--bad-soft); border-color: var(--bad); }
.verdict.warn { background: var(--warn-soft); border-color: var(--warn); }
.verdict h4 { margin: 0 0 6px; }
.findings { list-style: none; padding: 0; margin: 14px 0 0; }
.findings li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.findings li:first-child { border-top: 0; }
.findings .sev { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: 2px 9px; height: fit-content; white-space: nowrap; }
.sev.e { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); }
.sev.w { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.sev.i { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-strong); }

.readout { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 16px 0 0; padding: 0; list-style: none; }
.readout li { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.readout .k { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.readout .v { display: block; font-family: var(--font-mono); font-size: 1.12rem; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }

.bars { margin: 18px 0 0; }
.bar-row { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 12px; align-items: center; margin: 10px 0; }
.bar-row .bl { font-size: .84rem; font-weight: 700; }
.bar-track { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; height: 26px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; display: flex; align-items: center; padding: 0 10px; font-size: .8rem; font-weight: 700; white-space: nowrap; min-width: 4px; }
.bar-fill.doge { background: var(--accent); color: var(--accent-ink); }
.bar-fill.btc { background: var(--btc); color: var(--bg); }
.bar-note { font-size: .84rem; color: var(--muted); margin-left: 6px; }

.nojs { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); margin: 18px 0; }

/* ---------- toc ---------- */

.toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 24px 0; }
.toc h2 { margin: 0 0 8px; font-size: 1rem; }
.toc ol { margin: 0; padding-left: 1.2em; columns: 2; column-gap: 28px; }
@media (max-width: 620px) { .toc ol { columns: 1; } }
.toc li { break-inside: avoid; }

.anchor { color: var(--muted); text-decoration: none; font-weight: 400; opacity: 0; margin-left: .3em; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }

/* ---------- footer ---------- */

.site-foot { border-top: 1px solid var(--border); background: var(--bg-tint); padding: 30px 0 44px; font-size: .89rem; }
.foot-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.foot-grid h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; font-family: var(--font-body); }
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin: 3px 0; }
.meta-list { margin: 0; }
.meta-list div { display: flex; gap: 8px; flex-wrap: wrap; margin: 3px 0; }
.meta-list dt { color: var(--muted); min-width: 108px; }
.meta-list dd { margin: 0; font-weight: 650; }
.foot-bottom { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px 22px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .search input { width: 130px; }
  .search-results { right: 16px; width: calc(100% - 32px); }
  .head-row { min-height: 56px; }
}
