/* Aether — Uncomplex visual language: calm, monochrome, precise. Colour is
   reserved for state, focus and data. */
:root {
  --bg: #f6f6f3; --panel: #ffffff; --ink: #16171a; --muted: #5d6068; --line: #d9d9d4; --soft: #ecece8;
  --accent: #a2620a; --accent-ink: #ffffff; --ok: #1f7a4d; --warn: #a15c00; --bad: #b3261e; --focus: #0b57d0;
  --viz1: #0e7490; --viz2: #be123c; --viz3: #7c3aed; --viz4: #a16207; --viz5: #1f7a4d;
  --radius: 4px; --gap: 12px; --bar: 52px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111214; --panel: #18191c; --ink: #ecece8; --muted: #a3a6ad; --line: #2e3035; --soft: #1f2125;
  --accent: #e0a43a; --accent-ink: #16171a; --ok: #58c08a; --warn: #e0a43a; --bad: #f28b82; --focus: #8ab4f8;
  --viz1: #4cc3d9; --viz2: #ff6b8b; --viz3: #b39dff; --viz4: #f2c14e; --viz5: #6bd6a0;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #111214; --panel: #18191c; --ink: #ecece8; --muted: #a3a6ad; --line: #2e3035; --soft: #1f2125;
    --accent: #e0a43a; --accent-ink: #16171a; --ok: #58c08a; --warn: #e0a43a; --bad: #f28b82; --focus: #8ab4f8;
    --viz1: #4cc3d9; --viz2: #ff6b8b; --viz3: #b39dff; --viz4: #f2c14e; --viz5: #6bd6a0;
    color-scheme: dark;
  }
}
:root[data-contrast="high"] { --muted: var(--ink); --line: var(--ink); }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 0.9375rem; line-height: 1.45; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
h1, h2, h3, h4 { font-weight: 600; margin: 0; line-height: 1.25; }
h2 { font-size: 1.25rem; } h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p { margin: 0 0 0.6em; } small, .muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.boot { padding: 20vh 24px; text-align: center; color: var(--muted); }

button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.45em 0.9em; min-height: 2.25rem; cursor: pointer; touch-action: manipulation; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
button.hero { font-size: 1.05rem; padding: 0.7em 1.6em; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.quiet { border-color: transparent; background: none; }
button.toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
/* State is never signalled by colour alone: pressed toggles also gain a mark. */
button.toggle[aria-pressed="true"]::before { content: "✓ "; }
select, input[type="text"], input[type="number"], input[type="search"], textarea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.35em 0.5em; min-height: 2.25rem; max-width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--ink); min-height: 1.75rem; margin: 0; }
input.num { width: 5.2em; text-align: right; }
a { color: inherit; }

#app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "head head head" "nav main side" "foot foot foot"; }
#app > header { grid-area: head; display: flex; align-items: center; gap: 8px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.brand { font-weight: 700; letter-spacing: 0.32em; font-size: 0.95rem; margin-right: 8px; }
.project-name { flex: 1 1 auto; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.busy { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
#app > nav { grid-area: nav; border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 8px 0; width: 10.5rem; }
#app > nav button { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 0.55em 16px; border-left: 3px solid transparent; }
#app > nav button[aria-current="page"] { border-left-color: var(--accent); background: var(--soft); font-weight: 600; }
#app > nav small { display: block; font-weight: 400; }
#workspace { grid-area: main; overflow: auto; padding: 20px; min-width: 0; }
#inspector { grid-area: side; border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; width: 19rem; padding: 16px; }
#app[data-nav="closed"] > nav, #app[data-side="closed"] > #inspector, #app[data-full="true"] > nav, #app[data-full="true"] > #inspector, #app[data-full="true"] > header { display: none; }
#app > footer { grid-area: foot; border-top: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; gap: 10px; padding: 6px 12px; padding-bottom: max(6px, env(safe-area-inset-bottom)); min-width: 0; }
.transport-btn { min-width: 2.75rem; min-height: 2.75rem; font-size: 1.05rem; padding: 0; }
.timeline { flex: 1 1 12rem; height: 2.75rem; min-width: 60px; cursor: pointer; touch-action: none; border: 1px solid var(--line); border-radius: var(--radius); display: block; }
.readout { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.85rem; }
.readout b { font-weight: 600; }
.meter { width: 64px; height: 2.25rem; display: block; }
footer input.volume { width: 6rem; flex: 0 0 6rem; }

.ws-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 16px; }
.ws-head p { color: var(--muted); margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 24px; align-items: start; }
.group { margin: 0 0 20px; }
.group > h3, .group > summary { margin-bottom: 8px; }
details.group > summary { cursor: pointer; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.field { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; margin-bottom: 6px; }
.field > label { color: var(--ink); overflow-wrap: anywhere; }
.field > select, .field > input[type="text"] { grid-column: 2 / -1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list > li { border-bottom: 1px solid var(--line); padding: 8px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list > li > .grow { flex: 1 1 12rem; min-width: 0; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 0 0.6em; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.viz { width: 100%; display: block; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); touch-action: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 0.875rem; margin: 0 0 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.finding { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin-bottom: 12px; }
.finding h4 { font-size: 0.9rem; } .finding p { font-size: 0.85rem; margin: 2px 0; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: right; }
.note { font-size: 0.85rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; margin: 8px 0 16px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--ink); font-weight: 600; }

dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 20px; width: min(36rem, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog-body { margin: 12px 0 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toasts { position: fixed; right: 12px; bottom: calc(var(--bar) + 20px); display: grid; gap: 8px; z-index: 50; max-width: min(26rem, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); font-size: 0.9rem; }
.toast.error { background: var(--bad); color: #fff; }

/* Progressive disclosure: one interface, three depths. */
:root[data-mode="explorer"] .composer, :root[data-mode="explorer"] .architect, :root[data-mode="composer"] .architect { display: none !important; }

@media (max-width: 1100px) { #inspector { width: 16rem; } }
@media (max-width: 860px) {
  /* Phones and narrow tablets: navigation becomes a scrolling strip, the inspector a sheet below the workspace. */
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; grid-template-areas: "head" "nav" "main" "side" "foot"; }
  #app > nav { width: auto; display: flex; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  #app > nav button { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 0.7em 14px; }
  #app > nav button[aria-current="page"] { border-bottom-color: var(--accent); }
  #app > nav small { display: none; }
  #inspector { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 38dvh; }
  #workspace { padding: 14px; }
  .hide-narrow { display: none !important; }
  #app > header { gap: 2px; padding-left: 6px; padding-right: 6px; }
  #app > header button { padding-left: 0.5em; padding-right: 0.5em; }
  .brand { letter-spacing: 0.18em; margin-right: 2px; }
  .busy { display: none; }
  .field { grid-template-columns: minmax(0, 1fr) auto; }
  .field > label { grid-column: 1 / -1; }
  .field > select, .field > input[type="text"] { grid-column: 1 / -1; }
  #app > footer { flex-wrap: wrap; }
  .timeline { order: -1; flex-basis: 100%; }
}
@media (max-height: 520px) and (orientation: landscape) { #app > nav small { display: none; } #workspace { padding: 10px 14px; } }
@media (prefers-reduced-motion: no-preference) { :root:not([data-motion="reduced"]) button { transition: border-color 0.12s, background-color 0.12s; } }
@media (forced-colors: active) { button.toggle[aria-pressed="true"] { border: 3px solid; } }
