/* Field Journal: a traveler's dot-grid notebook. Ballpoint blue, a subtle highlighter, masking-tape card labels.
   One flourish per surface: a card gets tape or ruled lines, never both, and fields stay plain.
   Tokens live in variables.css. The living spec is /ui-library: change it when you change a component here. */

/* Base. Element rules use :where() so any component or tachyons class wins over them. */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 18px; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
[hidden] { display: none !important; }

body {
  display: flex; flex-direction: column; min-height: 100vh; margin: 0;
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-read);
  font-optical-sizing: auto;
  background: var(--paper-dots), var(--paper);
  /* Inherited, so every underline (links, terms, utilities) clears descenders. */
  text-underline-offset: .3em;
  text-decoration-skip-ink: auto;
}

:focus-visible { outline: var(--focus); outline-offset: 2px; }
::selection { background: var(--mark); }

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

:where(h1, h2, h3, h4, h5, h6) { font-family: var(--font-read); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; color: var(--ink); text-wrap: balance; }
:where(h1) { font-size: 2.2rem; margin: 0 0 var(--s4); }
:where(h2) { font-size: 1.6rem; margin: var(--s6) 0 var(--s4); }
:where(h3) { font-size: 1.2rem; margin: var(--s5) 0 var(--s2); }
:where(h4, h5, h6) { font-size: 1rem; margin: var(--s4) 0 var(--s2); }
:where(p) { margin: 0 0 var(--s3); overflow-wrap: break-word; }
:where(hr) { margin: var(--s5) 0; border: 0; border-top: 1px solid var(--rule); }
:where(img) { max-width: 100%; }
:where(code, kbd, samp, pre) { font-family: var(--font-data); font-size: .88em; }
:where(label) { font-family: var(--font-ui); }
:where(button, input, select, textarea, optgroup) { font: inherit; margin: 0; }
:where(small) { font-size: 80%; }
:where(sub, sup) { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
:where(sub) { bottom: -.25em; }
:where(sup) { top: -.5em; }
:where(fieldset) { min-width: 0; margin: 0; padding: 0; border: 0; }
:where(legend) { padding: 0; }
:where(dialog) { color: var(--ink); }

/* Layout. A view's top-level <main> is the page column; .page does the same for nested layouts. */
body > main, .page { flex: 1 0 auto; width: min(100% - 2 * var(--gutter), var(--page-width)); margin: 0 auto; padding: var(--s6) 0 var(--s7); }
.is-narrow-page { --page-width: 560px; }
body:has(> main.is-wide-page), .is-wide-page { --page-width: 1280px; }

.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack.is-tight { gap: var(--s2); }
.stack.is-loose { gap: var(--s6); }
/* Marketing pages: each section gets a full breath of paper. */
.stack.is-sections { gap: calc(var(--s7) + var(--s5) + var(--s1)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.cluster.is-tight { gap: var(--s2); }
.cluster.is-spread { justify-content: space-between; }
:where(.stack, .cluster) > :where(*) { margin-top: 0; margin-bottom: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--s5); align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: var(--s5) var(--s6); }

/* Type */
.display { font-family: var(--font-read); font-weight: 600; font-size: clamp(2.4rem, 5.5vw, 3.4rem); line-height: 1.05; letter-spacing: -.025em; }
h1.display { margin: 0 0 var(--s3); }
.lede { font-size: 1.2rem; line-height: 1.5; font-style: italic; color: var(--ink-soft); max-width: 40rem; text-wrap: pretty; }
.label { display: block; margin: 0 0 var(--s2); font: var(--label-font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.hint { font: 400 .8rem/1.5 var(--font-ui); color: var(--ink-soft); margin: 0; }
:where(p).hint { margin-top: var(--s1); }
.hint .ph, .label .ph { vertical-align: -.1em; }
.hint > .ph:first-child, .label > .ph:first-child { margin-right: var(--s1); }
.font-ui { font-family: var(--font-ui); }
.ink-soft { color: var(--ink-soft); }
.data { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: .88em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.hint.data { font-size: .72rem; }
.kbd { display: inline-block; padding: 0 .4em; margin: 0 .1em; font: 500 .72rem/1.6 var(--font-data); border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: var(--radius); background: var(--surface); color: var(--ink-soft); }
.trail { font: 400 .8rem/1.5 var(--font-ui); color: var(--ink-soft); }
.trail .ph { font-size: .7em; opacity: .6; }
.term { text-decoration: underline dotted var(--ink-soft); cursor: help; }

/* Highlighter: a soft marker swipe with ragged ends. Text color never changes. */
.mark { color: inherit; background: linear-gradient(100deg, transparent 0, var(--mark) .25em, var(--mark) calc(100% - .3em), transparent 100%); padding: .02em .15em; margin: 0 -.08em; border-radius: .5em .2em .6em .25em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

.prose { max-width: var(--measure); font-size: 1.05rem; line-height: 1.7; }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--s4); }
.prose li + li { margin-top: var(--s1); }
.prose h2 { font-size: 1.4rem; margin: var(--s6) 0 var(--s3); }
.prose h3 { font-size: 1.15rem; margin: var(--s5) 0 var(--s2); }
.prose img { display: block; height: auto; margin: var(--s5) 0; border-radius: var(--radius); }
.prose > :last-child { margin-bottom: 0; }
/* A card is already a column, so its text fills it. */
.card .prose { max-width: none; }
.prose blockquote { margin: var(--s5) 0; padding: var(--s3) var(--s4); background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: var(--radius); font-style: italic; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose blockquote cite { display: block; margin-top: var(--s2); font: normal 400 .8rem var(--font-ui); color: var(--ink-soft); }
.prose blockquote cite::before { content: "— "; }

.roll { display: inline-flex; align-items: center; gap: var(--s2); padding: 0 var(--s2); border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); font: 500 .8rem/1.8 var(--font-ui); white-space: nowrap; vertical-align: .05em; cursor: help; }
.roll-result { font: 400 .85rem/1.5 var(--font-ui); animation: ds-result-in 1.2s ease-out both; }
@keyframes ds-result-in { from { opacity: 0; } to { opacity: 1; } }
.roll-result.is-success { color: var(--success); }
.roll-result.is-failure { color: var(--danger); }

/* Illustration: fineliner and wash, straight on the paper. */
.sketch { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }
.logo-mark { display: inline-block; flex: none; width: 40px; height: 40px; background: url(/images/logo-trans_300.webp) center / cover no-repeat; }
.logo-mark.is-large { width: 100px; height: 100px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .sketch { mix-blend-mode: screen; filter: invert(.9) hue-rotate(180deg); }
  :root:not([data-theme=light]) .logo-mark { filter: invert(.9); }
}
:root[data-theme=dark] .sketch { mix-blend-mode: screen; filter: invert(.9) hue-rotate(180deg); }
:root[data-theme=dark] .logo-mark { filter: invert(.9); }

/* Buttons are ink outlines; primary is filled ballpoint blue. */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s4);
  font: 600 .85rem/1 var(--font-ui); color: var(--ink); background: var(--surface); text-decoration: none; white-space: nowrap;
  border: var(--border-w) solid var(--ink); border-radius: var(--radius-control);
  cursor: pointer; transition: background-color .12s, border-color .12s, transform .12s;
}
.button:hover { color: var(--ink); background: var(--sunk); }
.button:not(.is-quiet):not([disabled]):active { transform: translateY(1px); }
.button.is-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.is-primary:hover { color: var(--accent-ink); filter: brightness(1.15); }
.button.is-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.button.is-danger:hover { color: var(--danger-ink); filter: brightness(1.08); }
.button.is-quiet { background: transparent; border-color: transparent; color: var(--ink-soft); }
.button.is-quiet:hover { color: var(--ink); background: var(--sunk); }
.button.is-small { min-height: 32px; padding: 0 var(--s3); font-size: .78rem; }
.button.is-large { min-height: 48px; padding: 0 var(--s5); font-size: .95rem; }
.button.is-icon { padding: 0; width: 40px; }
.button.is-icon.is-small { width: 32px; }
.button.is-wide { width: 100%; }
.button .ph { font-size: 1.15em; }
.button .kbd { margin-left: var(--s1); border-color: currentColor; background: transparent; color: inherit; opacity: .85; font-size: .65rem; }
.button.has-cost { padding-right: 0; overflow: hidden; }
.button-cost { display: inline-flex; align-items: center; gap: var(--s1); align-self: stretch; margin-left: var(--s2); padding: 0 var(--s3); border-left: 1px solid currentColor; font-weight: 500; opacity: .85; }
.button[disabled], .button[aria-disabled=true] { cursor: not-allowed; opacity: .45; filter: grayscale(.4); }
:is(.button.is-primary, .button.is-danger):is([disabled], [aria-disabled=true]):not(.is-loading) { opacity: 1; filter: none; color: var(--ink-soft); background: var(--sunk); border-color: var(--rule-strong); }
.disabled-reason { display: inline-flex; border-radius: var(--radius-control); cursor: help; }
.disabled-reason .button { pointer-events: none; }
.button.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.button.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1em; height: 1em; border: 2px solid var(--ink); border-right-color: transparent; border-radius: 50%; animation: ds-spin .7s linear infinite; }
.button.is-primary.is-loading::after { border-color: var(--accent-ink); border-right-color: transparent; }
.button.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
form.button_to { display: inline-flex; margin: 0; }
@keyframes ds-spin { to { transform: rotate(360deg); } }

.button-group { display: inline-flex; }
.button-group.is-wide { display: flex; }
.button-group.is-wide > .button { flex: 1; }
.button-group .button { border-radius: 0; }
.button-group .button + .button, .button-group form + form .button { margin-left: calc(-1 * var(--border-w)); }
.button-group > .button:first-child, .button-group > form:first-child .button { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.button-group > .button:last-child, .button-group > form:last-child .button { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.button-group .button:is([aria-pressed=true], [aria-current], :has(input:checked)) { background: var(--ink); border-color: var(--ink); color: var(--surface); position: relative; z-index: 1; }
.button-group .button input { position: absolute; opacity: 0; pointer-events: none; }
.button-group .button:has(input:focus-visible) { outline: var(--focus); outline-offset: 2px; }
.button-group .button:has(input:disabled) { cursor: not-allowed; color: var(--ink-soft); background: var(--sunk); }
.button-group .button:has(input:disabled:checked) { color: var(--ink-soft); background: var(--rule); border-color: var(--rule-strong); }

/* Every field is the same plain box. Bare form fields get the same look so Rails helpers need no class. */
.field { display: flex; flex-direction: column; }
.field .label { margin-bottom: var(--s2); }
:is(.input, :where(input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=tel], input[type=date], input[type=time], input[type=datetime-local], input[type=month], select, textarea)) {
  display: block; width: 100%; min-height: 40px; padding: var(--s1) var(--s3);
  font: 400 .9rem/1.5 var(--font-ui); color: var(--ink);
  background: var(--surface); border: var(--border-w) solid var(--rule-strong); border-radius: var(--radius-control); appearance: none;
}
:is(select.input, :where(select)) { appearance: none; padding-right: var(--s6); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235f6470' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right var(--s3) center / .75rem; }
:is(select.input, :where(select)):disabled { background-color: var(--sunk); }
:is(.input, :where(input, select, textarea))::placeholder { color: var(--ink-soft); opacity: .75; }
:is(.input, :where(input, select, textarea)):hover { border-color: var(--ink-soft); }
:is(.input, :where(input, select, textarea)):focus-visible { border-color: var(--accent); outline: var(--focus); outline-offset: 0; }
:is(.input, :where(input, select, textarea)):disabled { color: var(--ink-soft); background: var(--sunk); border-color: var(--rule); cursor: not-allowed; }
.input.data { font-family: var(--font-data); font-size: .85rem; }
.field.is-invalid .input, .field_with_errors :where(input, select, textarea) { border-color: var(--danger); }
.field.is-invalid .label, .field_with_errors .label { color: var(--danger); }
.field_with_errors { display: contents; }
.field-error { display: flex; align-items: center; gap: var(--s1); margin: var(--s1) 0 0; font: 500 .8rem/1.4 var(--font-ui); color: var(--danger); }
.field-meta { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }

/* Long writing is story text, so it uses the reading face. */
:is(textarea.input, :where(textarea)) { resize: vertical; font: 400 1rem/1.6 var(--font-read); padding: var(--s2) var(--s3); }

.check { display: flex; align-items: center; gap: var(--s2); font: 400 .9rem var(--font-ui); color: var(--ink); cursor: pointer; }
.check input, .choice input, :where(input[type=checkbox], input[type=radio]) { accent-color: var(--ink); flex: none; width: 18px; height: 18px; margin: 0; }
.check.is-disabled { color: var(--ink-soft); cursor: help; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--s2); }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s1); height: 100%; padding: var(--s4) var(--s5) var(--s3); text-align: center; font: 400 .85rem/1.3 var(--font-ui); border: var(--border-w) solid var(--rule-strong); border-radius: var(--radius-control); background: var(--surface); transition: border-color .12s, background-color .12s; }
.choice-body .ph { font-size: 1.6rem; color: var(--ink-soft); }
.choice:hover .choice-body { border-color: var(--ink-soft); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:checked + .choice-body .ph { color: var(--accent); }
/* A corner mark tells a pick-one choice (round) from a pick-many choice (square). */
.choice-body::after { content: ""; position: absolute; top: var(--s2); right: var(--s2); display: grid; place-items: center; width: 16px; height: 16px; font: 700 11px/1 var(--font-ui); color: var(--accent-ink); border: var(--border-w) solid var(--rule-strong); border-radius: 50%; background: var(--surface); }
.choice input[type=checkbox] + .choice-body::after { border-radius: 3px; }
.choice input[type=radio]:checked + .choice-body::after { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
.choice input[type=checkbox]:checked + .choice-body::after { content: "✓"; border-color: var(--accent); background: var(--accent); }
.choice input:focus-visible + .choice-body { outline: var(--focus); outline-offset: 2px; }
.choice input:disabled + .choice-body { opacity: .5; cursor: not-allowed; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.switch { position: relative; display: inline-block; flex: none; width: 44px; height: 24px; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--rule-strong); transition: background-color .15s; }
.switch-track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: var(--focus); outline-offset: 2px; }

/* A single-field form attaches its button to the field. */
.input-group { position: relative; display: flex; align-items: stretch; }
.input-group .input, .input-group > :where(input, select) { flex: 1; min-width: 0; border-right: 0; border-radius: var(--radius-control) 0 0 var(--radius-control); }
.input-group .button { border-radius: 0 var(--radius-control) var(--radius-control) 0; min-height: 0; }
.input-group .button + .button { margin-left: calc(-1 * var(--border-w)); border-radius: 0; }
.input-group .button + .button:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.input-group-icon { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); color: var(--ink-soft); pointer-events: none; z-index: 1; }
.input-group-icon + .input { padding-left: calc(var(--s3) * 2 + 1em); }
.input-group-clear { position: absolute; right: 96px; top: 50%; transform: translateY(-50%); min-height: 0; width: 28px; height: 28px; z-index: 1; }
.input-group.is-small { max-width: 320px; }
.input-group.is-small .input { min-height: 32px; font-size: .85rem; }
.input-group.is-small .button { font-size: .78rem; padding: 0 var(--s3); }

/* Long writing uses a composer: a plain sheet above, help/count/submit in the footer bar. */
.composer-box { background: var(--surface); border: var(--border-w) solid var(--rule-strong); border-radius: var(--radius-control); }
.composer-box:focus-within { outline: var(--focus); outline-offset: 0; border-color: var(--accent); }
.composer-box textarea.input, .composer-box > textarea { min-height: calc(1.6rem * 5.5); padding: var(--s3) var(--s4); border: 0; border-radius: var(--radius-control) var(--radius-control) 0 0; }
.composer-box textarea.input:focus-visible, .composer-box > textarea:focus-visible { outline: none; }
.composer-bar { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-top: 1px solid var(--rule); }
.composer-bar > .data, .composer-bar > .is-end { margin-left: auto; }

/* Cards are loose sheets. A titled card gets a masking-tape label. */
.card { --card-pad: var(--s5); position: relative; padding: var(--card-pad); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.card > :last-child:not(.card-footer) { margin-bottom: 0; }
/* The tape rises above the card, so a titled card keeps a clear gap from what sits above it. */
.card.is-tabbed { margin-top: var(--s6); padding-top: var(--s6); }
.card-tab {
  position: absolute; top: 0; left: var(--s4); transform: translateY(-62%) rotate(-1.6deg);
  display: inline-flex; align-items: center; gap: var(--s2); max-width: calc(100% - 2 * var(--s4));
  margin: 0; padding: var(--s2) var(--s5) var(--s1);
  font: 700 1.1rem/1.1 var(--font-hand); letter-spacing: 0; color: var(--tape-ink); background: var(--tape);
  clip-path: polygon(2% 0, 98% 4%, 100% 30%, 97% 55%, 100% 100%, 3% 96%, 0 70%, 3% 45%, 0 12%);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-grid > .card:nth-child(even) .card-tab, .tier-grid > .card:nth-child(even) .card-tab { transform: translateY(-62%) rotate(1.2deg); }
.card-tab .ph { flex: none; font-size: 1.15em; }
.card-tab a { color: inherit; text-decoration: none; }
.card-tab-count { padding: 0 var(--s2); border-radius: var(--radius); background: var(--tape-chip); font: 500 .75rem var(--font-data); }
.card.is-accent .card-tab { background: var(--accent); color: var(--accent-ink); }
.card-tab-actions { position: absolute; top: 0; right: var(--s4); transform: translateY(-50%); display: flex; overflow: hidden; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.card-tab-actions .button { border-radius: 0; min-height: 30px; }
.card-tab-actions .button + .button, .card-tab-actions > * + * .button { border-left: 1px solid var(--rule); }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: var(--s4) calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad)); padding: var(--s2) var(--card-pad); border-top: 1px dashed var(--dash); }
.stack > .card-footer { margin-top: 0; }

.inset { padding: var(--s3) var(--s4); background: var(--sunk); border-radius: var(--radius); line-height: 1.6; overflow-wrap: break-word; }
.inset > :last-child { margin-bottom: 0; }

/* Callouts: a sticky note for notes, an index card for examples. */
.callout { display: flex; gap: var(--s3); margin: 0; padding: var(--s3) var(--s4); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); font: 400 .95rem/1.55 var(--font-read); }
.callout > .ph { flex: none; margin-top: .2em; font-size: 1.15rem; color: var(--callout, var(--ink-soft)); }
.callout > div { min-width: 0; flex: 1; }
.callout > div > :last-child { margin-bottom: 0; }
.callout.is-note { --callout: var(--accent); background: var(--note); transform: rotate(-.4deg); }
.callout.is-example { font-style: italic; line-height: 1.6em; border-top: 3px solid var(--margin-line); background: var(--surface) linear-gradient(transparent calc(1.6em - 1px), var(--line) calc(1.6em - 1px)) 0 var(--s3) / 100% 1.6em; }
.callout.is-warning { --callout: var(--warning); box-shadow: inset 4px 0 0 var(--callout), var(--shadow-card); }
.callout.is-danger { --callout: var(--danger); box-shadow: inset 4px 0 0 var(--callout), var(--shadow-card); }
.callout.is-success { --callout: var(--success); box-shadow: inset 4px 0 0 var(--callout), var(--shadow-card); }
/* Inside a card a callout lies flat, so shadows never stack. */
.card .callout:not(.is-note, .is-example) { background: var(--sunk); box-shadow: none; }
.card .callout:is(.is-warning, .is-danger, .is-success) { box-shadow: inset 4px 0 0 var(--callout); }
.card .callout:is(.is-note, .is-example) { box-shadow: none; }
.card .tile { box-shadow: none; }
.card .tile:hover { box-shadow: var(--shadow-card); }

.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s6) var(--s4); text-align: center; border: var(--border-w) dashed var(--dash); border-radius: var(--radius); }
.empty > .ph { font-size: 2rem; color: var(--ink-soft); margin-bottom: var(--s2); }
.empty > p { margin: 0; }
.empty > .button, .empty > .cluster { margin-top: var(--s3); }

/* One show/hide pattern: native details with a turning caret. */
.disclosure > summary { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) 0; list-style: none; cursor: pointer; font: 600 .9rem/1.4 var(--font-ui); color: var(--ink); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: ""; flex: none; width: .45em; height: .45em; margin: 0 .3em 0 .15em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; opacity: .6; }
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure > summary:hover { color: var(--accent); }
.disclosure > summary .hint { font-weight: 400; }
.disclosure > summary > .is-end { margin-left: auto; }
.disclosure-body { padding: var(--s2) 0 var(--s4) calc(.9em + var(--s2)); display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); }
.disclosure-body > * { margin: 0; }
.disclosure-body > :where(.field, .form-grid, .stack, .card, .inset, .callout, .table-wrap, form, p, ul, ol) { align-self: stretch; }
.disclosure-list > .disclosure + .disclosure { border-top: 1px solid var(--rule); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.timeline li { display: grid; grid-template-columns: 4rem 1fr; gap: var(--s3); font-size: .95rem; }
.timeline li > .hint:first-child { padding-top: .2em; }
.timeline.is-dated li { grid-template-columns: 7rem 1fr; }

/* Tags, avatars, stats */
.tag { display: inline-flex; align-items: center; gap: var(--s1); padding: 0 var(--s2); font: 500 .74rem/1.5 var(--font-ui); white-space: nowrap; vertical-align: .1em; color: var(--ink-soft); border: 1px solid var(--rule-strong); border-radius: var(--radius); text-decoration: none; }
.tag.is-accent { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.tag.is-success { color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.tag.is-warning { color: var(--warning-text); background: color-mix(in srgb, var(--warning) 14%, transparent); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.tag.is-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: 50%; background: var(--surface); border: var(--border-w) solid var(--ink); color: var(--ink); font: 600 .75rem var(--font-ui); text-transform: uppercase; text-decoration: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.is-small { width: 28px; height: 28px; font-size: .6rem; }
.avatar.is-large { width: 56px; height: 56px; font-size: .95rem; }
.avatar.is-faded { opacity: .4; border-style: dashed; cursor: help; }
.avatar .ph { font-size: 1.2em; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--paper); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.avatar.is-ready { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.avatar-stack .avatar.is-ready + .avatar { margin-left: 2px; }

.count { display: inline-flex; align-items: center; gap: var(--s1); font: 400 .85rem var(--font-ui); color: var(--ink-soft); }
.count .ph { color: var(--accent); }
.count .data, .count .num { color: var(--ink); font-weight: 600; }

.stat-block { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s4); }
.stat { display: flex; flex-direction: column; align-items: center; padding: var(--s3) 0; background: var(--surface); border: var(--border-w) solid var(--rule-strong); border-radius: 10px 16px 12px 18px / 16px 10px 18px 12px; }
.stat .label { margin: 0; }
.stat-score { font-size: 1.4rem; font-weight: 600; line-height: 1.3; }
.stat-mod { font-size: .75rem; color: var(--ink-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
.stat-grid > .card { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3) var(--s4); color: var(--ink); text-decoration: none; }
.stat-grid .label { margin: 0; }

.meter { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s3); }
.meter:not(:has(> :nth-child(3))) { grid-template-columns: auto 1fr; }
.meter .label { margin: 0; }
.meter-track { height: 10px; background: var(--sunk); border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent); }

/* Lists and tables */
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); font: 400 .85rem/1.45 var(--font-ui); }
.facts li { display: flex; gap: var(--s2); }
.facts .ph { flex: none; margin-top: .15em; color: var(--accent); }
.rows, .people { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--s2) var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--rule); }
.rows li.is-disabled { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.people li { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) 0; }
.people li + li { border-top: 1px solid var(--rule); }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s2) var(--s4); align-items: center; margin: 0; }
.kv dt, .kv dd { margin: 0; }
.kv dd { overflow-wrap: anywhere; }
.kv.is-stacked { grid-template-columns: minmax(0, 1fr); gap: var(--s1); align-items: start; }
.kv.is-stacked dt:not(:first-child) { margin-top: var(--s3); }
.label.is-quiet, .kv.is-stacked dt { font: 500 .85rem/1.4 var(--font-ui); letter-spacing: normal; text-transform: none; }
.color-dot { display: inline-block; flex: 0 0 10px; width: 10px; height: 10px; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent); }
.track { display: inline-flex; gap: var(--s1); vertical-align: middle; }
.track span { flex: none; width: 14px; height: 14px; border: var(--border-w) solid var(--ink); border-radius: 50%; }
.track.is-boxes span { border-radius: 1px; }
.track span.is-filled { background: var(--ink); }

.table-wrap { overflow-x: auto; background: linear-gradient(to right, var(--surface) 30%, transparent) left / 32px 100% no-repeat local, linear-gradient(to left, var(--surface) 30%, transparent) right / 32px 100% no-repeat local, radial-gradient(farthest-side at 0 50%, var(--rule-strong), transparent) left / 10px 100% no-repeat scroll, radial-gradient(farthest-side at 100% 50%, var(--rule-strong), transparent) right / 10px 100% no-repeat scroll, var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); }
/* A table inside a card runs edge to edge, so the card is its only frame. */
.card .table-wrap { margin-inline: calc(-1 * var(--card-pad)); border-width: 1px 0; border-radius: 0; box-shadow: none; }
.card > .table-wrap:last-child, .card > :last-child > .table-wrap:last-child { margin-bottom: calc(-1 * var(--card-pad)); border-bottom: 0; }
.card.is-tabbed:has(> .card-tab + .table-wrap) { padding-top: var(--s5); }
.card .table :is(th, td):first-child { padding-left: var(--card-pad); }
.card .table :is(th, td):last-child { padding-right: var(--card-pad); }
.table { width: 100%; border-collapse: collapse; font: 400 .9rem/1.4 var(--font-ui); }
.table th { text-align: left; padding: var(--s2) var(--s4); font: var(--label-font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); background: var(--surface); border-bottom: 1px solid var(--rule-strong); }
.table th a { text-decoration: none; display: inline-flex; gap: var(--s1); align-items: center; }
.table th a[aria-sort] { color: var(--ink); }
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--accent-soft); }
.table .num { text-align: right; }
.table td.data, .table td > .data { white-space: nowrap; }
.table tfoot td { border-top: 1px solid var(--rule-strong); }
.table .disclosure > summary { padding: 0; }
.table.is-compact th, .table.is-compact td { padding: var(--s1) var(--s3); }

/* Navigation: the current place gets a ballpoint underline. */
.appbar { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; padding: var(--s2) var(--s3); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); font: 500 .85rem var(--font-ui); }
.appbar a { display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); text-decoration: none; color: var(--ink-soft); border-radius: var(--radius); }
.appbar a:hover { color: var(--ink); background: var(--sunk); }
.appbar a[aria-current=page] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.appbar-brand { display: inline-flex; align-items: center; gap: var(--s2); margin-right: var(--s3); font: 600 1.1rem var(--font-read); }
.appbar-spacer { flex: 1; }

.tabs { display: flex; gap: var(--s1); flex-wrap: wrap; border-bottom: 1px solid var(--rule); }
.tab { display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); margin-bottom: -1px; font: 500 .85rem var(--font-ui); text-decoration: none; color: var(--ink-soft); background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab[aria-current], .tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font: 400 .8rem var(--font-ui); color: var(--ink-soft); }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a + a::before, .breadcrumbs a + span::before { content: "/"; margin-right: var(--s2); opacity: .5; }
.breadcrumbs [aria-current] { color: var(--ink); font-weight: 600; }
.pagination { display: flex; flex-wrap: wrap; gap: var(--s1); }
.pagination .button[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); }
.steps li { display: flex; gap: var(--s3); align-items: flex-start; font: 400 .9rem/1.4 var(--font-ui); }
.step-mark { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: var(--border-w) solid var(--ink); font: 600 .95rem/1 var(--font-read); color: var(--ink); background: var(--surface); }
.steps li.is-done .step-mark { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.steps li[aria-current] .step-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps li:not(.is-done):not([aria-current]) { color: var(--ink-soft); }
.steps.is-guide li:not(.is-done) { color: var(--ink); }

/* Feedback */
.flash { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s4); font: 500 .9rem/1.4 var(--font-ui); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--success); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.flash > .ph { font-size: 1.2rem; color: var(--success); }
.flash > span { flex: 1; }
.flash.is-danger { border-left-color: var(--danger); }
.flash.is-danger > .ph { color: var(--danger); }
.flash-stack { position: fixed; z-index: 50; top: calc(56px + var(--s3)); right: var(--s4); display: grid; gap: var(--s2); width: min(100% - 2 * var(--s4), 420px); }
.flash-stack .flash { box-shadow: var(--shadow-float); animation: ds-flash-out .4s ease-in 6s forwards; }
.flash-stack .flash:hover { animation-play-state: paused; }
@keyframes ds-flash-out { to { opacity: 0; transform: translateY(-6px); visibility: hidden; } }

.skeleton { display: block; height: .9em; border-radius: var(--radius); background: linear-gradient(90deg, var(--sunk) 0%, var(--rule) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: ds-shimmer 1.4s ease-in-out infinite; }
.skeleton.is-title { height: 1.4em; width: 55%; }
.skeleton.is-short { width: 40%; }
@keyframes ds-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.spinner { display: inline-flex; align-items: center; gap: var(--s2); font: 400 .9rem var(--font-ui); color: var(--ink-soft); }
.spinner .ph { font-size: 1.3rem; color: var(--accent); animation: ds-spin 1s linear infinite; }

.modal { width: min(100% - 2 * var(--s4), 560px); max-height: calc(100vh - 2 * var(--s5)); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius); box-shadow: var(--shadow-float); }
.modal.is-narrow { width: min(100% - 2 * var(--s4), 420px); }
.modal.is-wide { width: min(100% - 2 * var(--s4), 800px); }
.modal::backdrop { background: var(--backdrop); }
.modal-inner { --card-pad: var(--s5); padding: var(--card-pad); display: flex; flex-direction: column; gap: var(--s3); }
.modal-inner > * { margin: 0; }
/* A dialog that holds a form ends in the same card footer as a form card. */
.modal-inner > .card-footer { margin: var(--s2) calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad)); }
.modal h2 { margin: 0; font-size: 1.35rem; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }

/* Collections */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--s4); }
.tile { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); text-decoration: none; transition: transform .15s, box-shadow .15s; }
.tile:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.tile-title { display: flex; align-items: center; gap: var(--s2); font: 600 1.1rem/1.25 var(--font-read); }
.tile-title .ph-arrow-right { margin-left: auto; color: var(--ink-soft); transition: transform .15s; }
.tile:hover .tile-title .ph-arrow-right { transform: translateX(3px); color: var(--accent); }
.tile-summary { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 4; -webkit-box-orient: vertical; font-size: .9rem; color: var(--ink-soft); line-height: 1.45; }
.tile .cluster { margin-top: auto; gap: var(--s2); }
.tile.is-new { background: transparent; border: var(--border-w) dashed var(--dash); box-shadow: none; }

.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--s6) var(--s4); padding-top: var(--s5); }
.cover { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); width: 100%; padding: var(--s5) var(--s3) var(--s3); text-align: left; text-decoration: none; color: var(--ink); font: inherit; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.cover:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.cover-art { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
.cover-art.is-photo { object-fit: cover; border-radius: var(--radius); }
.cover-badge { position: absolute; top: calc(var(--s5) + var(--s2)); right: calc(var(--s3) + var(--s2)); }
.cover-badge .tag:not(.is-accent), .tag.cover-badge:not(.is-accent) { background: var(--surface); }
.cover-title { position: absolute; top: 0; left: var(--s3); max-width: calc(100% - 2 * var(--s3)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 1.05rem/1.1 var(--font-hand); padding: var(--s2) var(--s4) var(--s1); background: var(--tape); color: var(--tape-ink); transform: translateY(-62%) rotate(-1.6deg); clip-path: polygon(2% 0, 98% 4%, 100% 30%, 97% 55%, 100% 100%, 3% 96%, 0 70%, 3% 45%, 0 12%); }
.cover-grid > :nth-child(even) .cover-title { transform: translateY(-62%) rotate(1.2deg); }
.cover-summary { font: 400 .8rem/1.4 var(--font-ui); color: var(--ink-soft); }
.cover.is-loading { cursor: wait; }
.cover.is-loading .cover-art { opacity: .4; }
.cover-grid > form { display: flex; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips > .label { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: var(--s1); padding: var(--s1) var(--s3); font: 500 .8rem/1.3 var(--font-ui); color: var(--ink); background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius-control); cursor: pointer; text-decoration: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked), .chip[aria-pressed=true], .chip[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip:has(input:checked)::before, .chip[aria-pressed=true]::before { content: "✓"; font-weight: 700; }
.chip:has(input:focus-visible) { outline: var(--focus); outline-offset: 2px; }
.chip.is-removable { cursor: default; padding-right: var(--s1); background: var(--accent-soft); border-color: transparent; }
.chip.is-removable button, .chip.is-removable a { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: var(--ink-soft); cursor: pointer; }
.chip.is-removable button:hover, .chip.is-removable a:hover { background: var(--sunk); color: var(--ink); }

.story-list { list-style: none; margin: 0; padding: 0; }
.story-list li { display: grid; grid-template-columns: 2rem 1fr auto; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
.story-list li:last-child { border-bottom: 0; }
.story-list li > .data { color: var(--ink-soft); }
.story-list li[aria-current] > .data { color: var(--accent); font-weight: 600; }
.story-list li:not(.is-done):not([aria-current]) { color: var(--ink-soft); }

.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 30%); gap: var(--s4); overflow-x: auto; padding-bottom: var(--s3); scroll-snap-type: x mandatory; }
.gallery figure { margin: 0; padding: var(--s2); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); scroll-snap-align: start; }
.gallery .sketch { aspect-ratio: 4 / 3; object-fit: contain; }

/* AI and generation */
.generating { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); font: italic 400 1rem var(--font-read); color: var(--ink-soft); border: var(--border-w) dashed var(--dash); border-radius: var(--radius); }
.generating .ph { color: var(--accent); font-size: 1.2rem; animation: ds-write 1.2s ease-in-out infinite; }
.generating-bar { flex: 1; min-width: 60px; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent) 0 0 / 40% 100% no-repeat, var(--rule); animation: ds-sweep 1.6s ease-in-out infinite; }
@keyframes ds-write { 50% { transform: translate(3px, -2px) rotate(-8deg); } }
@keyframes ds-sweep { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

.thread { display: flex; flex-direction: column; gap: var(--s3); max-width: 40rem; }
.message { align-self: flex-start; max-width: 90%; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); font-size: .95rem; overflow-wrap: break-word; }
.message > :last-child { margin-bottom: 0; }
.message.is-user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.message.is-thinking { display: inline-flex; align-items: center; gap: var(--s2); box-shadow: none; }
.tool-call { margin-bottom: var(--s2); padding: 0 var(--s2); background: var(--sunk); border-radius: var(--radius); }
.tool-call > summary { font-size: .78rem; font-weight: 500; color: var(--ink-soft); }
.thinking { display: inline-flex; gap: 3px; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ds-blink 1.2s infinite; }
.thinking span:nth-child(2) { animation-delay: .2s; }
.thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes ds-blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* Tokens and upgrades */
.tier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--s4); align-items: stretch; }
.tier { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s6); }
.tier > :where(h2, h3):not(.card-tab) { margin: 0; }
.tier > .button, .tier > form { margin-top: auto; }
.tier-price { display: flex; align-items: baseline; gap: var(--s1); margin: 0; }
.tier-price .num { font: 600 1.8rem/1 var(--font-ui); letter-spacing: -.02em; color: var(--ink); }
.tier.is-tabbed { padding-top: var(--s5); }
.tier.is-featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-card); animation: ds-featured-border 3s ease-in-out infinite; }
@keyframes ds-featured-border { 50% { border-color: var(--rule-strong); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-card); } }
a.tier { color: var(--ink); text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.tier:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
a.tier.is-featured:hover { box-shadow: 0 0 0 1px var(--accent), var(--shadow-lift); }
.delta { padding: 0 var(--s1); border-radius: var(--radius); font-size: .75rem; animation: ds-delta 2.4s ease-out forwards; }
.delta.is-up { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.delta.is-down { color: var(--ink-soft); background: var(--sunk); }
@keyframes ds-delta { 0% { opacity: 0; transform: translateY(4px); } 15%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.field.is-locked .label { color: var(--ink-soft); }

/* Sheets and tools */
.dice-result { display: flex; align-items: baseline; gap: var(--s3); margin: 0 0 var(--s3); }
.dice-result > .data:first-child { font-size: 2.6rem; font-weight: 600; line-height: 1; }
.dice-result:has(> .dice-result-empty) { align-items: center; }
.dice-result-empty { font-size: 2rem; color: var(--ink-soft); }
.dice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--s1); }
.dice-history { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); margin: var(--s3) 0 0; padding: var(--s3) 0 0; border-top: 1px dashed var(--dash); color: var(--ink-soft); }
.dice-history li + li::before { content: "·"; margin-right: var(--s3); opacity: .5; }

.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; border-color: color-mix(in srgb, var(--danger) 45%, transparent); box-shadow: inset 4px 0 0 var(--danger), var(--shadow-card); }

/* Panels and banners */
.banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); font: 500 .85rem/1.4 var(--font-ui); background: var(--note); border-bottom: 1px solid var(--rule-strong); }
.banner > span:first-of-type { flex: 1; }
.banner > .ph { font-size: 1.1rem; }
.banner.is-status { justify-content: center; background: var(--ink); color: var(--paper); border: 0; }
.banner.is-status > span { flex: none; }
.banner.is-status .spinner .ph { color: var(--paper); }
.drawer { display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--rule-strong); box-shadow: -12px 0 24px -18px rgba(0, 0, 0, .4); }
.drawer.is-floating { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(100%, 420px); }
.drawer-header, .drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); }
.drawer-header { border-bottom: 1px solid var(--rule); font: 600 .95rem var(--font-ui); }
.drawer-body { flex: 1; padding: var(--s4); overflow-y: auto; }
.drawer-footer { justify-content: flex-end; border-top: 1px solid var(--rule); }
.drawer-footer.is-stacked { flex-direction: column; align-items: stretch; gap: var(--s2); }
.drawer-footer.is-stacked > .button.is-quiet { align-self: flex-start; }
.drawer-header.has-tabs { align-items: flex-end; padding-top: var(--s1); padding-bottom: 0; }
.drawer-header.has-tabs > .tabs { flex-wrap: nowrap; border-bottom: 0; }
.drawer-header.has-tabs > .button { margin-bottom: var(--s1); }
.drawer-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-width: 0; padding: var(--s1) var(--s3); border-bottom: 1px solid var(--rule); }

/* Landing */
.hero { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1.2fr); gap: var(--s6); align-items: center; }
.hero-art { max-height: 380px; width: auto; justify-self: center; }
@media (min-width: 641px) { .hero:has(> .hero-art.is-wide) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); } }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s5); margin-top: var(--s6); }
.feature-grid article > .ph { font-size: 1.6rem; color: var(--accent); }
.feature-grid h3 { margin: var(--s2) 0 var(--s1); }
.cta-band { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s6); padding: var(--s5); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.cta-band > * { margin: 0; }
.stack > .cta-band, .stack > .feature-grid { margin-top: 0; }
.quote-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--s4); }
.quote-card { margin: 0; padding: var(--s4); font-style: italic; line-height: 1.5; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.quote-card::before { content: "“"; }
.quote-card::after { content: "”"; }
.marquee { overflow: hidden; padding-block: var(--s5) var(--s2); mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); }
.marquee-track { display: flex; gap: var(--s4); width: max-content; animation: marquee-scroll 60s linear infinite; }
.marquee:hover .marquee-track, .marquee:focus-within .marquee-track { animation-play-state: paused; }
.marquee .quote-card { flex: none; width: 280px; }
.marquee.is-covers .cover { flex: none; width: 240px; }
@keyframes marquee-scroll { to { transform: translateX(calc(-50% - var(--s2))); } }
.zine-promo { position: fixed; z-index: 40; right: var(--s5); bottom: var(--s4); width: 130px; transform: translateY(calc(100% + var(--s6))) rotate(4deg); transition: transform .6s cubic-bezier(.2, .9, .3, 1.15); }
.zine-promo.is-shown { transform: rotate(4deg); }
.zine-promo a { display: grid; gap: var(--s1); text-decoration: none; color: var(--ink); font: 700 .85rem/1.2 var(--font-hand); text-align: center; }
.zine-promo img { width: 100%; height: auto; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .22)); transition: transform .2s; }
.zine-promo a:hover img, .zine-promo a:focus-visible img { transform: translateY(calc(-1 * var(--s2))) rotate(-2deg); }
.zine-promo a:hover span { text-decoration: underline; }
.zine-promo-close { position: absolute; z-index: 1; top: 0; right: calc(-1 * var(--s2)); display: grid; place-items: center; width: 24px; height: 24px; padding: 0; min-height: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 50%; color: var(--ink); cursor: pointer; }
.site-footer { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s4); margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--rule); font: 400 .8rem/1.4 var(--font-ui); }
.site-footer > div { display: flex; flex-direction: column; gap: var(--s2); }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* App shell */
.site-nav { position: sticky; top: 0; z-index: 30; background: var(--paper-dots), color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); }
.site-nav-inner { display: flex; align-items: stretch; gap: var(--s1); width: min(100% - 2 * var(--gutter), var(--page-width)); min-height: 56px; margin: 0 auto; font: 500 .85rem var(--font-ui); }
.site-nav-inner > * { align-self: center; }
/* A nav link runs the full bar height, so the current place underlines the nav's own bottom rule. */
.site-nav-inner > a:not(.button) { align-self: stretch; display: inline-flex; align-items: center; gap: var(--s2); margin-bottom: -1px; padding: 0 var(--s3); color: var(--ink-soft); text-decoration: none; border-bottom: 2px solid transparent; }
.site-nav-inner > a:not(.button):hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.site-nav-inner > a[aria-current=page] { color: var(--ink); border-bottom-color: var(--accent); }
.site-nav .site-nav-brand { padding: 0; margin-right: auto; }
.site-nav .site-nav-brand:hover { border-bottom-color: transparent; }
.site-nav .count { color: var(--ink-soft); }
.site-nav .count:hover { color: var(--ink); }
.site-shell-footer { width: min(100% - 2 * var(--gutter), var(--page-width)); margin: 0 auto; padding-bottom: var(--s5); }
.site-shell-footer .site-footer { margin-top: 0; }
.site-shell-footer .site-footer strong { font-weight: 600; color: var(--ink); }
.site-copyright { margin: var(--s5) 0 0; text-align: center; font: 400 .75rem var(--font-ui); color: var(--ink-soft); }
.page-banner { width: min(100% - 2 * var(--gutter), var(--page-width)); margin: var(--s4) auto 0; border: 1px solid var(--rule-strong); border-radius: var(--radius); }
body.development { box-shadow: inset 0 0 0 3px var(--warning); }

/* Tooltips: one style, theme ds. */
.tippy-box[data-theme~=ds] { background: var(--ink); color: var(--paper); font: 500 .78rem/1.4 var(--font-ui); border-radius: var(--radius); }
.tippy-box[data-theme~=ds] > .tippy-content { padding: var(--s1) var(--s3); }
.tippy-box[data-theme~=ds][data-placement^=top] > .tippy-arrow::before { border-top-color: var(--ink); }
.tippy-box[data-theme~=ds][data-placement^=bottom] > .tippy-arrow::before { border-bottom-color: var(--ink); }
.tippy-box[data-theme~=ds][data-placement^=left] > .tippy-arrow::before { border-left-color: var(--ink); }
.tippy-box[data-theme~=ds][data-placement^=right] > .tippy-arrow::before { border-right-color: var(--ink); }
.tippy-box { overflow-wrap: break-word; }

@media (max-width: 640px) {
  .quote-grid > :nth-child(n+4) { display: none; }
  .table :is(th, td) { padding: var(--s2); overflow-wrap: anywhere; }
  .table.is-compact :is(th, td) { padding: var(--s2); }
  body > main, .page { padding-top: var(--s5); }
  .stack.is-sections { gap: calc(var(--s7) + var(--s3)); }
  .hero { grid-template-columns: 1fr; }
  .hero-art { max-height: 240px; }
  .gallery { grid-auto-columns: 75%; }
  .stat-block { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card { --card-pad: var(--s4); }
  .card.is-tabbed { padding-top: var(--s6); }
  .card-tab-actions .button { font-size: 0; gap: 0; }
  .card-tab-actions .button .ph { font-size: 1rem; }
  .composer-bar { flex-wrap: wrap; }
  .site-nav-inner { gap: 0; }
  .site-nav-inner > a:not(.button) { padding: 0 var(--s2); }
  .site-nav .is-wide-only { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton, .spinner .ph, .button.is-loading::after, .generating .ph, .generating-bar, .thinking span, .delta, .flash-stack .flash, .marquee-track, .roll-result, .tier.is-featured { animation: none; }
  .zine-promo, .zine-promo img { transition: none; }
  .marquee { overflow-x: auto; mask-image: none; }
}
