/* Components. Surfaces: page --bg, raised --raised (cards, dialogs), sunk --sunk (wells, inputs, tracks).
   Lines survive only where they carry information: table rules, field bottoms, diffs, a proposal's edge. */

/* cards, panels, wells */
.card { background: var(--raised); border-radius: var(--r-md); padding: var(--s4) var(--s5); }
.card .card, .card .op, .card .comment { background: var(--sunk); }
.card > h2, .card > h3 { margin-bottom: var(--s2); }
.tile { display: flex; flex-direction: column; gap: var(--s1); text-decoration: none; }
.tile:hover { background: var(--sunk); }
.estimate { padding: var(--s2) var(--s3); background: var(--sunk); border-radius: var(--r-md); }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s5); background: var(--sunk); border-radius: var(--r-md); color: var(--muted); }
.empty h2 { color: var(--ink); }
.proposal { border-left: 3px solid var(--ai); border-radius: 0 var(--r-md) var(--r-md) 0; }
.comment { padding: var(--s3); border-radius: var(--r-md); background: var(--raised); }
.reply { margin-left: var(--s4); }
.op { list-style: none; padding: var(--s3); border-radius: var(--r-md); display: flex; flex-direction: column; gap: var(--s1); }
blockquote.quote { margin: 0; padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--sunk); color: var(--muted); font-style: italic; }
blockquote.quote.missing { background: var(--bad-tint); color: var(--bad); }
.tail { max-height: 10rem; overflow: auto; background: var(--sunk); padding: var(--s2); border-radius: var(--r-md); white-space: pre-wrap; margin: 0; }
.map-item { padding: var(--s3) 0; }
.source-text { white-space: pre-wrap; }
.excerpt { color: var(--muted); }
mark { background: var(--warn-tint); color: var(--ink); border-radius: 2px; padding: 0 .1em; }

/* chips and badges: tonal pills, no border */
.chip, .badge { display: inline-block; padding: .1rem .6rem; border-radius: var(--r-pill); background: var(--sunk); color: var(--ink); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.draft, .badge.class-minor { background: var(--sunk); color: var(--muted); }
.badge.approved, .badge.run-finished, .badge.step-done, .badge.intent-done, .badge.delivery-ingested, .badge.publish-ready { background: var(--ok-tint); color: var(--ok); }
.badge.locked, .badge.lock-director-canon { background: var(--sunk); color: var(--ink); font-weight: 700; }
.badge.omitted { background: var(--sunk); color: var(--muted); text-decoration: line-through; }
.badge.lock-human-owned { background: var(--sunk); color: var(--ink); }
.badge.lock-ai-draft, .badge.run-running, .badge.step-running, .badge.intent-running, .badge.delivery-sent, .badge.class-voice { background: var(--ai-tint); color: var(--ai); }
.badge.warn, .badge.stale, .badge.run-awaiting_gate, .badge.step-queued, .badge.publish-held, .badge.class-material { background: var(--warn-tint); color: var(--warn); }
.badge.run-failed, .badge.step-failed, .badge.publish-refused { background: var(--bad-tint); color: var(--bad); }
.badge.run-cancelled, .badge.step-cancelled, .badge.intent-abandoned, .badge.delivery-skipped, .badge.publish-unchanged { background: var(--sunk); color: var(--muted); }

/* notices: tonal fill, a leading bold word */
.notice { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--sunk); }
.notice > strong:first-child { margin-right: var(--s2); }
.notice.warn { background: var(--warn-tint); }
.notice.bad { background: var(--bad-tint); color: var(--bad); }
.notice.ok { background: var(--ok-tint); }
.flash { margin-bottom: var(--s4); max-width: none; }

/* tables: no outer box, rows ruled */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem var(--s3); border-bottom: 1px solid var(--hair); vertical-align: top; }
th { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tbody tr:hover { background: var(--sunk); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.arc th, table.arc td { white-space: nowrap; }
.knowledge th.rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.knowledge td.mark { text-align: center; color: var(--ok); font-weight: 700; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: 0; }
dl.facts dt { color: var(--muted); font-weight: 600; }
dl.facts dd { margin: 0; }

/* tabs: a sunk track with the current item raised */
.tabs { display: flex; align-self: flex-start; gap: var(--s1); padding: var(--s1); max-width: 100%; overflow-x: auto; background: var(--sunk); border-radius: var(--r-pill); }
.tabs a { padding: .35rem var(--s4); border-radius: var(--r-pill); text-decoration: none; color: var(--muted); white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--raised); color: var(--ink); font-weight: 650; }

/* floating layers: dialogs, toasts, the command bar */
dialog { border: 0; border-radius: var(--r-lg); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-float); max-width: min(38rem, calc(100vw - 2rem)); width: 100%; padding: var(--s5); }
dialog::backdrop { background: var(--scrim); }
dialog .row:last-child { justify-content: flex-end; }
dialog.avvia, dialog.soft { max-width: min(46rem, calc(100vw - 2rem)); }
dialog.avvia { max-height: calc(100vh - 2rem); overflow-y: auto; }
dialog.avvia textarea { min-height: 3.5rem; }
.dialog-actions { position: sticky; bottom: calc(-1 * var(--s5)); margin: 0 calc(-1 * var(--s5)) calc(-1 * var(--s5)); padding: var(--s3) var(--s5); background: var(--raised); }
.toast { position: fixed; bottom: var(--s4); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: var(--s3) var(--s4); border-radius: var(--r-md); box-shadow: var(--shadow-float); z-index: 20; }
.toast.error { background: var(--bad); color: var(--raised); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } @keyframes rise { from { opacity: 0; transform: translate(-50%, .5rem); } } }
dialog.palette { top: 12dvh; margin-inline: auto; padding: 0; max-width: min(40rem, calc(100vw - 2rem)); overflow: hidden; }
.palette input[role="combobox"] { width: 100%; padding: var(--s4) var(--s5); font-size: 1.1rem; border-radius: 0; }
.palette [role="listbox"] { list-style: none; margin: 0; padding: var(--s2); max-height: 50dvh; overflow-y: auto; }
.palette [role="option"] { display: flex; gap: var(--s3); justify-content: space-between; padding: var(--s2) var(--s3); border-radius: var(--r-sm); cursor: pointer; }
.palette [role="option"] > :nth-child(2) { margin-inline-start: auto; }
.palette [role="option"] .price { margin: 0; border-radius: var(--r-sm); }
.palette [role="option"][aria-selected="true"] { background: var(--sunk); font-weight: 650; box-shadow: inset .2rem 0 0 var(--action); }
.palette :focus-visible { outline-offset: -2px; }

/* bars are SVG (a CSP without style-src refuses style attributes); the class picks the fill */
svg.bar { display: block; width: 100%; height: .5rem; border-radius: var(--r-pill); background: var(--sunk); }
.bar rect { fill: var(--mark, var(--ink)); }
.bar .range { --mark: var(--faint); }
.bar .human, .swatch.human { --mark: var(--muted); }
.bar .edited, .swatch.edited { --mark: var(--edited); }
.bar .ai, .swatch.ai { --mark: var(--ai); }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--mark); }
.runtime { display: inline-flex; flex-direction: column; gap: .2rem; min-width: 8rem; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.ladder li { display: grid; grid-template-columns: 2.6rem 1fr auto 7rem; gap: var(--s3); align-items: center; }
.ladder .step { font-family: var(--script); font-weight: 700; color: var(--muted); }
.ladder li.done .step { color: var(--ok); }
@media (max-width: 36rem) { .ladder li { grid-template-columns: 2.2rem 1fr auto; } .ladder svg.bar { display: none; } }

/* authorship and diffs: no tint is a person; violet is the AI; teal is AI text a person edited */
.legend span { padding: 0 .35rem; border-radius: 3px; font-size: .8rem; }
ins, .d-insert { background: var(--ins); text-decoration: none; }
del, .d-delete { background: var(--del); }
.d-delete { text-decoration: line-through; }
.d-equal { background: none; }
.by-ai { background: var(--ai-tint); }
.by-edited { background: var(--edited-tint); }
.by-human { background: transparent; }
.diff { white-space: pre-wrap; font-family: var(--script); line-height: 1.6; background: var(--sunk); padding: var(--s4); border-radius: var(--r-md); }

/* the shape of an object's page: verbs, the next-step hint, the status line, the coherence panel */
.verbs { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.ask-split { display: inline-flex; }
.ask-split > .menu-pop { display: flex; }
.ask-split > [data-avvia] { border-radius: var(--r-md) 0 0 var(--r-md); }
.ask-split > .menu-pop > summary { display: flex; align-items: center; padding-inline: .6rem; border-radius: 0 var(--r-md) var(--r-md) 0; border-left: 1px solid color-mix(in srgb, var(--ai) 30%, transparent); }
.ask-split > .menu-pop > summary::before { content: none; }
.verbs [aria-current] { text-decoration: underline 2px; text-underline-offset: 4px; }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; justify-content: space-between; }
.scene-steps { display: flex; gap: var(--s2); }
.scene-steps > * { min-height: 2rem; padding-block: .25rem; white-space: nowrap; }
.hint { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; padding: var(--s2) var(--s4); background: var(--sunk); border-radius: var(--r-md); font-size: .875rem; }
.hint > :last-child:not(:first-child) { margin-left: auto; }
.status-line { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; color: var(--muted); }
.status-line > * + *:not(.badge):not(.chip)::before { content: "·"; margin-right: var(--s2); }
.coherence { display: flex; flex-direction: column; gap: var(--s2); }
.coherence .issue { padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--sunk); font-size: .875rem; }
.coherence .issue.warn { background: var(--warn-tint); }
.coherence details.changed { padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--warn-tint); font-size: .875rem; }
.coherence details.changed > summary { cursor: pointer; font-weight: 600; }
.coherence details.changed > * + * { margin-block: var(--s2) 0; }
.coherence .issue.bad { background: var(--bad-tint); }

/* the price of a button: a shaded segment flush with its end edge, tinted by the button's own colour */
.price {
  display: inline-flex; align-items: center; align-self: stretch; margin-block: -.4rem; margin-inline: .35rem -.95rem;
  padding-inline: .6rem; border-radius: 0 var(--r-md) var(--r-md) 0; background: color-mix(in srgb, currentColor 12%, transparent);
  border-inline-start: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap;
}
.price[aria-busy="true"] { opacity: .6; min-width: 4.5ch; justify-content: center; }
.ask-split > [data-avvia] .price { border-radius: 0; }
.menu-pop .pop > a:has(.price) { display: flex; gap: var(--s3); }
.menu-pop .pop .price { margin: 0 0 0 auto; border-radius: var(--r-sm); }
.menu-pop.spend > .pop { left: auto; right: 0; min-width: 14rem; }
@media (max-width: 40rem) { .menu-pop.spend > .pop { right: var(--s4); } }
.spend dd { font-variant-numeric: tabular-nums; text-align: right; }
