/* Structure only. All colour and type come from tokens.css. */

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

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-sunken);
  color: var(--text-primary);
  font: var(--size-300)/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }

.topbar {
  display: flex; align-items: baseline; gap: var(--space-4);
  padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-default);
}
.topbar h1 { margin: 0; font-size: var(--size-600); font-weight: 600; letter-spacing: -0.01em; }
.topbar h1 .logo { display: inline-block; vertical-align: -4px; margin-right: var(--space-2); color: var(--text-primary); }
.topbar h1 .logo svg { width: 22px; height: 23px; display: block; }
.topbar .env {
  font: var(--size-100)/1 var(--font-data);
  padding: var(--space-1) var(--space-2); border-radius: var(--radius);
  background: var(--state-warn-bg); color: var(--state-warn);
}
.topbar .clock { margin-left: auto; color: var(--text-muted); font: var(--size-200)/1 var(--font-data); }

nav.sections { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--space-1); margin: var(--space-4) 0 var(--space-5); overflow: visible; }
nav.sections > a { white-space: nowrap; }
nav.sections > a[target="_blank"]::after { content: " \2197"; color: var(--text-muted); font-size: var(--size-100); }
nav.sections a {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius);
  color: var(--text-secondary); text-decoration: none; font-weight: 500;
}
nav.sections a[aria-current="page"] { background: var(--surface-raised); color: var(--text-primary); box-shadow: var(--shadow); }
nav.sections a[aria-disabled="true"] { color: var(--text-muted); cursor: not-allowed; }
nav.sections a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.panel {
  background: var(--surface-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-4);
}
.panel h2 { margin: 0 0 var(--space-3); font-size: var(--size-300); font-weight: 600; color: var(--text-secondary); }
.panel--wide { grid-column: 1 / -1; }

.metric { font-size: var(--size-900); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.metric small { display: block; font-size: var(--size-200); font-weight: 400; color: var(--text-muted); margin-top: var(--space-1); }

.health { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-3); border-radius: 999px;
  font: 500 var(--size-200)/1.6 var(--font-ui);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip[data-state="green"]   { background: var(--state-ok-bg);   color: var(--state-ok); }
.chip[data-state="amber"]   { background: var(--state-warn-bg); color: var(--state-warn); }
.chip[data-state="red"]     { background: var(--state-bad-bg);  color: var(--state-bad); }
.chip[data-state="unknown"] { background: var(--state-idle-bg); color: var(--state-idle); }
.chip[data-state="info"]    { background: var(--state-info-bg); color: var(--state-info); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-default); vertical-align: top; }
th { font-size: var(--size-200); font-weight: 600; color: var(--text-secondary); }
td { font-size: var(--size-200); }
td.mono, th.mono { font-family: var(--font-data); font-size: var(--size-100); color: var(--text-secondary); }
tbody tr:last-child td { border-bottom: 0; }

.empty { color: var(--text-muted); padding: var(--space-4) 0; }
.empty strong { display: block; color: var(--text-secondary); font-weight: 600; margin-bottom: var(--space-1); }

.banner {
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4); border: 1px solid transparent;
}
.banner[data-severity="critical"] { background: var(--state-bad-bg);  color: var(--state-bad);  border-color: var(--state-bad); }
.banner[data-severity="warn"]     { background: var(--state-warn-bg); color: var(--state-warn); }
.banner h3 { margin: 0 0 var(--space-1); font-size: var(--size-300); }
.banner p  { margin: 0; font-size: var(--size-200); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Forms (login). Structure only; colour from tokens. */
.wrap--narrow { max-width: 560px; }
form label { display: block; font-size: var(--size-200); font-weight: 600; color: var(--text-secondary); margin: var(--space-4) 0 var(--space-1); }
form textarea, form input[type="text"], form input[type="email"] {
  width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-page); color: var(--text-primary); font: var(--size-200)/1.5 var(--font-data);
}
form textarea:focus, form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  margin-top: var(--space-3); padding: var(--space-2) var(--space-4); border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-contrast); font: 600 var(--size-300)/1.5 var(--font-ui); cursor: pointer;
}
button.button--quiet { background: transparent; color: var(--text-secondary); margin: 0; padding: 0; font-weight: 500; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details { margin-top: var(--space-4); color: var(--text-secondary); font-size: var(--size-200); }
details summary { cursor: pointer; font-weight: 600; }
details ol { padding-left: var(--space-5); }
.topbar form { margin-left: auto; display: flex; align-items: baseline; gap: var(--space-3); }
.topbar .who { color: var(--text-muted); font: var(--size-200)/1 var(--font-data); }

/* Section pages, actions, approvals, traces. */
.topbar h1 a { color: inherit; text-decoration: none; }
.panel h3 { margin: var(--space-3) 0 var(--space-1); font-size: var(--size-300); font-weight: 600; }
.panel h4 { margin: var(--space-2) 0 var(--space-1); font-size: var(--size-200); font-weight: 600; color: var(--text-secondary); }
.panel p { margin: 0 0 var(--space-2); }
.panel ul { margin: 0 0 var(--space-2); padding-left: var(--space-5); }
.panel .mono { font-family: var(--font-data); font-size: var(--size-100); color: var(--text-secondary); }
pre { margin: 0 0 var(--space-2); padding: var(--space-3); background: var(--surface-sunken); border-radius: var(--radius); font: var(--size-100)/1.5 var(--font-data); overflow: auto; max-height: 360px; }
code { font: var(--size-100)/1 var(--font-data); background: var(--surface-sunken); padding: 1px 4px; border-radius: 3px; }
details.action { border-top: 1px solid var(--border-default); padding: var(--space-3) 0; }
details.action summary { cursor: pointer; }
details.action form { max-width: 640px; }
form select { padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-page); color: var(--text-primary); font: var(--size-200)/1.5 var(--font-ui); width: 100%; }
form input[type="number"] { padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-page); color: var(--text-primary); font: var(--size-200)/1.5 var(--font-data); width: 100%; }
form label.check { display: flex; gap: var(--space-2); align-items: center; font-weight: 500; color: var(--text-primary); }
form.inline { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
form.inline input[type="text"] { width: auto; flex: 1; }
form.inline button { margin: 0; }
button.button--danger { background: var(--state-bad); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
article.approval, article.event, article.tool { border-top: 1px solid var(--border-default); padding: var(--space-3) 0; }
article.approval:first-of-type, article.event:first-of-type, article.tool:first-of-type { border-top: 0; }
.cols { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.banner[data-severity="info"] { background: var(--state-info-bg); color: var(--state-info); }

/* Guest origins map: brand dark, yellow by volume. */
.map { position: relative; background: var(--brand-dark); border-radius: var(--radius); padding: var(--space-2); margin-bottom: var(--space-3); }
.map svg { width: 100%; height: auto; display: block; }
.map-tip { position: absolute; pointer-events: none; background: rgba(0,0,0,.85); color: #fff; font: var(--size-100)/1.4 var(--font-ui); padding: var(--space-1) var(--space-2); border-radius: 4px; white-space: nowrap; }

/* Sparklines and meters. One series each: line in the chart accent, area a wash, end dot with a surface ring. */
.spark { display: block; overflow: visible; max-width: 100%; height: auto; }
.spark-line { fill: none; stroke: var(--chart-accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--chart-accent); fill-opacity: .10; }
.spark-end { fill: var(--chart-accent); stroke: var(--surface-raised); stroke-width: 2; }
.spark-hit { fill: transparent; }
.spark-hit:hover { fill: var(--chart-accent); fill-opacity: .12; }
.metric .spark { margin-top: var(--space-2); }
.meter { height: 8px; border-radius: 4px; background: var(--meter-track); overflow: hidden; margin: var(--space-1) 0 var(--space-2); }
.meter span { display: block; height: 100%; border-radius: 4px; background: var(--state-ok); }
.meter[data-state="warn"] span { background: var(--state-warn); }
.meter[data-state="bad"] span { background: var(--state-bad); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); font-size: var(--size-200); }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; }

/* Panel families: a different tint per kind of content so the eye can sort the page. */
.panel--log { background: var(--surface-log); border-color: var(--border-log); }
.panel--actions { background: var(--surface-actions); border-color: var(--border-actions); }
.panel--docs { background: var(--surface-docs); border-color: var(--border-docs); }
details.log > summary { list-style: none; cursor: pointer; }
details.log > summary::-webkit-details-marker { display: none; }
details.log > summary h2 { margin: 0; }
details.log > summary h2::before { content: "▸ "; color: var(--text-muted); }
details.log[open] > summary h2::before { content: "▾ "; }
details.log[open] > summary h2 { margin-bottom: var(--space-3); }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { display: grid; grid-template-columns: 96px 150px minmax(0, 1fr) 70px; gap: var(--space-3); align-items: baseline; padding: 3px 0; border-top: 1px solid var(--border-log); font-size: var(--size-200); color: var(--text-secondary); }
.log-list li:first-child { border-top: 0; }
.log-list li::before { display: none; }
.log-list .when { color: var(--text-muted); }
.log-list .who { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-list .what { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-list .what i { font-style: normal; color: var(--text-muted); font-family: var(--font-data); font-size: var(--size-100); }
.log-list li[data-state="red"] .what i.state { color: var(--state-bad); }
.log-list li[data-state="amber"] .what i.state { color: var(--state-warn); }
.log-list li[data-state="red"] .when::before, .log-list li[data-state="amber"] .when::before { content: "●"; margin-right: 4px; color: var(--state-bad); }
.log-list li[data-state="amber"] .when::before { color: var(--state-warn); }
.log-list .trace { text-align: right; }
.bars-h { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(60px, 32%) minmax(40px, 1fr) 62px; gap: var(--space-2); align-items: center; font-size: var(--size-200); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.bar-track { height: 10px; border-radius: 5px; background: var(--meter-track); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--chart-accent); border-radius: 5px; }
.bar-value { text-align: right; color: var(--text-secondary); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.tile { padding: var(--space-3); border-radius: var(--radius); background: var(--surface-sunken); }
.tile h4 { margin: 0 0 var(--space-1); font-size: var(--size-100); color: var(--text-muted); font-weight: 600; }
.tile .big { margin: 0; font: 600 var(--size-600)/1.1 var(--font-ui); letter-spacing: -0.01em; }
.tile small { color: var(--text-muted); font-size: var(--size-100); }

.subnav { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-2) 0; margin: 0 0 var(--space-3); background: var(--surface-sunken); border-bottom: 1px solid var(--border-default); }
.subnav a { padding: 4px var(--space-3); border-radius: 999px; font-size: var(--size-200); color: var(--text-secondary); text-decoration: none; background: var(--surface-raised); }
.subnav a:hover { color: var(--text-primary); }
.gauges + .grid, .gauges + section { margin-top: var(--space-4); }
section[id] { scroll-margin-top: 56px; }
.pubfoot { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border-default); color: var(--text-muted); font-size: var(--size-200); }

/* The playbook on the Monitoring page. */
.playbook { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: var(--space-4); }
.play { padding: var(--space-4); border-radius: var(--radius); background: var(--surface-sunken); border: 1px solid var(--border-default); }
.play[data-status="live"] { border-left: 3px solid var(--state-ok); }
.play[data-status="partly"] { border-left: 3px solid var(--state-warn); }
.play[data-status="planned"] { border-left: 3px solid var(--state-idle); }
.play header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.play h3 { margin: 0 0 var(--space-2); font-size: var(--size-300); }
.play p { margin: 0 0 var(--space-2); font-size: var(--size-200); }
.play .play-live { color: var(--text-primary); font-weight: 600; }
.play .play-watch .mono { margin-left: var(--space-2); }
.play ul { margin: 0 0 var(--space-2); padding-left: var(--space-5); font-size: var(--size-200); color: var(--text-secondary); }
.play ol.flow { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: 6px; }
.play ol.flow li { display: grid; grid-template-columns: 22px 1fr; gap: var(--space-2); align-items: start; font-size: var(--size-200); position: relative; }
.play ol.flow li + li::before { content: ""; position: absolute; left: 10px; top: -8px; height: 8px; border-left: 2px solid var(--border-default); }
.play .step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--chart-accent); color: #111; font: 600 var(--size-100)/1 var(--font-data); }
.play[data-status="planned"] .step { background: var(--state-idle); }
.play .play-esc { color: var(--text-secondary); }
.play .play-built { color: var(--text-muted); }

/* The More menu in the section nav. */
nav.sections details { position: relative; display: block; flex: none; align-self: center; margin: 0; padding: 0; font-size: inherit; line-height: inherit; background: none; border: 0; }
nav.sections details[hidden] { display: none; }
nav.sections summary { list-style: none; cursor: pointer; display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--text-secondary); font-weight: 500; line-height: 1.5; white-space: nowrap; }
nav.sections summary::after { content: " \25BE"; color: var(--text-muted); font-size: var(--size-100); }
nav.sections summary::-webkit-details-marker { display: none; }
nav.sections details[open] summary, nav.sections summary.on { background: var(--surface-raised); color: var(--text-primary); box-shadow: var(--shadow); }
nav.sections .menu { position: absolute; z-index: 20; min-width: 180px; margin-top: 4px; padding: var(--space-2); border-radius: var(--radius); background: var(--surface-raised); box-shadow: var(--shadow); border: 1px solid var(--border-default); display: grid; }
nav.sections .menu a { display: block; }
/* weather and sky on the overview */
.weather .tile[data-state="good"] { box-shadow: inset 3px 0 0 var(--state-ok); }
.weather .tile[data-state="warn"] { box-shadow: inset 3px 0 0 var(--state-warn); }
.weather .tile[data-state="bad"] { box-shadow: inset 3px 0 0 var(--state-bad); }
.wxstrip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin: var(--space-3) 0 var(--space-2); }
.wxstrip span { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; border-radius: 4px; background: var(--surface-sunken); font: var(--size-100)/1.2 var(--font-data); color: var(--text-muted); }
.wxstrip span b { font-weight: 600; color: var(--text-secondary); } .wxstrip span i { font-style: normal; color: var(--text-primary); } .wxstrip span em { font-style: normal; }
.wxstrip span.dark { background: oklch(0.17 0.01 260); } .wxstrip span.wet { background: var(--state-info-bg); } .wxstrip span.bad { background: var(--state-bad-bg); color: var(--state-bad); }
@media (max-width: 720px) { .wxstrip { grid-template-columns: repeat(12, 1fr); } .wxstrip span:nth-child(odd) { display: none; } }

.log-list li { overflow-wrap: anywhere; }

/* A slot for a feed that does not exist yet. Deliberately empty and labelled rather than a
   stand-in image: a placeholder that looks like data is worse than an obvious gap. */
.feedslot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  aspect-ratio: 16 / 7; border: 1px dashed var(--line, rgba(255,255,255,.18)); border-radius: 10px; margin: 0 0 14px;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.022) 0 12px, transparent 12px 24px), #101014; }
.feedslot-mark { font: 500 .78rem/1 var(--mono, ui-monospace, monospace); letter-spacing: .18em; color: #8e8e8e; }
.feedslot-sub { font-size: .8rem; color: #6f6f6f; }

/* The public front opens on an explanation of the place, above the cards. */
.lede {
  background: var(--surface-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--space-5) var(--space-4); margin-bottom: var(--space-4);
}
.lede h2 { margin: 0 0 var(--space-3); font-size: var(--size-600); font-weight: 600; letter-spacing: -0.01em; }
.lede p { margin: 0 0 var(--space-3); max-width: 76ch; font-size: var(--size-300); line-height: 1.62; color: var(--text-secondary); }
.lede p:last-child { margin-bottom: 0; }
/* Two columns once the card is wider than one comfortable measure, so the text fills it
   instead of leaving half the card empty, without letting a line run past 76ch. */
@media (min-width: 1000px) {
  .lede-body { columns: 2; column-gap: var(--space-6); }
  /* Prose flows across the break rather than avoiding it, so neither column is left
     with dead space at the foot. */
  .lede-body p { max-width: none; }
}
.lede strong { color: var(--text-primary); font-weight: 600; }
.lede-foot { font-size: var(--size-200); color: var(--text-muted); border-top: 1px solid var(--border-default); padding-top: var(--space-3); }

/* Phones (16-10-2026): a wide table scrolls sideways inside its panel instead of pushing the page wider. */
@media (max-width: 720px) {
  .panel table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel table th, .panel table td { white-space: nowrap; }
  .panel { min-width: 0; max-width: 100%; }
  .panel svg { max-width: 100%; }
}

/* The public front's story strip (19-10-2026): one tile per thing Grímnir does, with its live figure; each opens its page. */
.story { margin-bottom: var(--space-4); }
.story .tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 0; }
.story a.tile { display: block; color: inherit; text-decoration: none; border: 1px solid transparent; }
.story a.tile:hover { border-color: var(--border-strong); }
.story .tile .big { color: var(--link); }
.story .tile small { display: block; margin-top: var(--space-1); line-height: 1.4; }
/* The live state of a thing (19-10-2026): the Wellness Station free or in use. */
.story .tile[data-state="good"] { box-shadow: inset 3px 0 0 var(--state-ok); }
.story .tile[data-state="busy"] { box-shadow: inset 3px 0 0 var(--state-info); }
