:root {
  --ink: #191919;
  --slate: #262625;
  --cloud: #91918d;
  --ivory: #fafaf7;
  --ivory-2: #f0f0eb;
  --ivory-3: #e5e4df;
  --clay: #d97757;
  --book: #cc785c;
  --kraft: #d4a27f;
  --manilla: #ebdbbc;
  --olive: #788c5d;
  --sky: #61aaf2;
  --error: #bf4d43;
  --sticky-yellow: #f3df8c;
  --sticky-pink: #f2b8a8;
  --sticky-blue: #b9d5ef;
  --sticky-green: #c8d9a8;
  --line: 2.25px solid var(--ink);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Inter Tight", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "DejaVu Sans Mono", monospace;
  --hand: "Caveat", "Comic Neue", cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; overflow: hidden;
  background: var(--ivory); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
kbd { font: 500 12px var(--mono); border: 1.5px solid var(--ink); border-bottom-width: 3px; border-radius: 5px; padding: 1px 6px; background: var(--ivory); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* Polsia feed: drops down over the top of the room (an overlay, so the 3D view never resizes) */
.feed { position: absolute; top: 0; left: 0; right: 0; z-index: 5; background: #000; color: #f2f0e8; font: 12px/1.6 var(--mono); padding: 0 12px; height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; transition: height .28s ease, padding .28s ease; }
.feed[data-open="true"] { height: 102px; padding: 8px 12px 6px; }
.feed ol { list-style: none; margin: 0; padding: 0; }
.feed li { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.feed li.new { animation: type-in .6s steps(30, end); }
.feed li:last-child::after { content: "▍"; color: var(--clay); animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes type-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes blink { 50% { opacity: 0; } }
.statusbar { position: relative; display: flex; justify-content: center; align-items: center; background: var(--clay); color: var(--ink); font: 500 14px/1 var(--sans); padding: 9px 12px; }
body.settled .statusbar { transition: background-color 4s ease-in-out, color 4s ease-in-out; }
.statusbar .headline { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.statusbar .headline span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; flex: none; }
.twirl { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 5px; background: rgba(25,25,25,.08); color: inherit; border: 0; border-radius: 999px; padding: 4px 10px 4px 8px; font: 500 12px var(--mono); cursor: pointer; }
.twirl:hover { background: rgba(25,25,25,.16); }
.twirl .tri { display: inline-block; transition: transform .25s ease; }
.twirl[aria-expanded="true"] .tri { transform: rotate(90deg); }
body[data-status="sleeping"] .statusbar { background: #3c4672; color: var(--ivory); }
body[data-status="on_break"] .statusbar { background: #8fb05a; }
body[data-status="armed"] .statusbar, body[data-status="waiting_model"] .statusbar { background: var(--manilla); }
body[data-status="paused"] .statusbar, body[data-status="offline"] .statusbar { background: var(--ivory-3); }
@keyframes pulse { 50% { opacity: .25; } }

/* The room. Gradients can't transition, so the sky colours are registered custom
   properties that fade on roughly the same clock as the room's lights. */
@property --sky-a { syntax: "<color>"; inherits: false; initial-value: #fffaf0; }
@property --sky-b { syntax: "<color>"; inherits: false; initial-value: #f6e7d2; }
@property --sky-c { syntax: "<color>"; inherits: false; initial-value: #ecd3b6; }
.stage { position: relative; min-height: 0; overflow: hidden;
  --sky-a: #fffaf0; --sky-b: #f6e7d2; --sky-c: #ecd3b6;
  background: radial-gradient(120% 90% at 50% 15%, var(--sky-a) 0%, var(--sky-b) 58%, var(--sky-c) 100%); }
body.settled .stage { transition: --sky-a 5s ease-in-out, --sky-b 5.5s ease-in-out, --sky-c 6s ease-in-out; }
body[data-status="sleeping"] .stage, body[data-status="ended"] .stage { --sky-a: #3c4672; --sky-b: #232a48; --sky-c: #151a30; }
body[data-status="armed"] .stage, body[data-status="waiting_model"] .stage, body[data-status="awaiting_start"] .stage { --sky-a: #fde9d6; --sky-b: #f3cdb0; --sky-c: #e6b296; }
body[data-status="on_break"] .stage { --sky-a: #fbfbe8; --sky-b: #e9f0cf; --sky-c: #d6e4b4; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.stage canvas.hot { cursor: pointer; }
.stage canvas:active { cursor: grabbing; }
body.rewound .stage canvas { filter: sepia(.35) saturate(.85); }

.loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font: italic 18px var(--serif); color: #6d6a62; pointer-events: none; }

.bubble { position: absolute; left: 0; top: 0; max-width: 300px; transform: translate(-50%, -100%); padding: 10px 14px; background: var(--ivory); border: var(--line); border-radius: 16px;
  font: italic 15px/1.35 var(--serif); pointer-events: none; box-shadow: 4px 4px 0 rgba(25,25,25,.12); transition: opacity .3s; }
.bubble::after { content: ""; position: absolute; left: var(--tail, 50%); bottom: -10px; width: 16px; height: 16px; background: var(--ivory); border-right: var(--line); border-bottom: var(--line); transform: translateX(-50%) rotate(45deg); }
.bubble.below { transform: translate(-50%, 0); }
.bubble.below::after { bottom: auto; top: -10px; transform: translateX(-50%) rotate(225deg); }
.tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.helper-tag { position: absolute; transform: translate(-50%, -100%); padding: 2px 8px; background: var(--ivory); border: 1.5px solid var(--ink); border-radius: 999px; font: 600 11px var(--mono); white-space: nowrap; box-shadow: 2px 2px 0 rgba(25,25,25,.12); animation: tag-in .35s ease; }
@keyframes tag-in { from { opacity: 0; transform: translate(-50%, -60%) scale(.6); } }
.bubble::before { content: "thinking"; display: block; font: normal 500 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--clay); margin-bottom: 3px; }
.bubble.fade { opacity: 0; }
.caption { position: absolute; left: 0; top: 0; transform: translate(-50%, 8px); padding: 3px 10px 3px 8px; background: var(--ink); color: var(--ivory); border-radius: 999px; font: 500 11.5px var(--mono); white-space: nowrap; pointer-events: none; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }
.caption::before { content: "● "; color: var(--clay); }
.hover { position: absolute; left: 0; top: 0; transform: translate(14px, 14px); padding: 4px 10px; background: var(--clay); color: var(--ink); border: 1.75px solid var(--ink); font: 500 12px var(--mono); pointer-events: none; white-space: nowrap; }
.stamp { position: absolute; right: 22px; top: 16px; transform: rotate(-6deg); border: 3px double var(--error); color: var(--error); font: 700 12px/1.25 var(--mono); letter-spacing: .14em; text-transform: uppercase; padding: 5px 10px; text-align: center; background: rgba(250,250,247,.7); pointer-events: none; }

/* HUD */
.hud { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 28px; align-items: center; padding: 10px 20px 12px; background: var(--ivory); border-top: var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.wordmark { font: 500 28px/1 var(--serif); letter-spacing: -0.025em; font-variation-settings: "opsz" 72; white-space: nowrap; }
.ii { position: relative; display: inline-block; }
.tittle { position: absolute; left: 50%; top: -.1em; width: .32em; height: .32em; transform: translate(-55%, -20%); transition: transform .6s ease; }
.wordmark:hover .tittle { transform: translate(-55%, -20%) rotate(180deg); }
.by { font: 12px var(--sans); color: #6d6a62; white-space: nowrap; }
/* self-driving jazz is always lowercase, in Recursive with a touch of casual (as on selfdrivingjazz.com) */
.sdj { font-family: "Recursive", var(--sans); font-size: 13.5px; font-weight: 560; font-variation-settings: "CASL" .28, "MONO" .08; letter-spacing: -.04em; text-transform: lowercase;
  color: var(--ink); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: var(--clay); }
.sdj:hover { color: var(--clay); }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1.75px solid var(--ink); border-radius: 999px; padding: 3px 10px; font: 500 12px var(--sans); white-space: nowrap; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cloud); }
body[data-status="running"] .chip-dot { background: var(--clay); animation: pulse 1.4s ease-in-out infinite; }
body[data-status="sleeping"] .chip-dot { background: var(--sky); }
body[data-status="on_break"] .chip-dot { background: #8fb05a; }
.ruler-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label now" "ruler ruler"; gap: 4px 10px; align-items: end; min-width: 0; }
.ruler-label { grid-area: label; font: 11.5px var(--mono); color: #4a4843; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ruler-label b { color: var(--ink); font-weight: 600; }
.ruler-buttons { grid-area: now; display: flex; gap: 6px; }
.ruler-btn { background: var(--ink); color: var(--ivory); border: 0; border-radius: 999px; padding: 3px 12px; font: 500 12px var(--sans); cursor: pointer; white-space: nowrap; }
.ruler-play { background: var(--clay); color: var(--ink); }
.ruler { grid-area: ruler; position: relative; height: 30px; background: var(--kraft); border: var(--line); border-radius: 3px;
  background-image: repeating-linear-gradient(90deg, var(--ink) 0 1.5px, transparent 1.5px 8px), repeating-linear-gradient(90deg, var(--ink) 0 1.5px, transparent 1.5px 40px);
  background-size: 100% 6px, 100% 12px; background-repeat: repeat-x; }
.ruler input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: ew-resize; }
.ruler input::-webkit-slider-runnable-track { height: 100%; background: transparent; }
.ruler input::-moz-range-track { height: 100%; background: transparent; }
.ruler input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 38px; margin-top: -6px; background: var(--clay); border: 2.25px solid var(--ink); border-radius: 3px 3px 8px 8px; }
.ruler input::-moz-range-thumb { width: 12px; height: 34px; background: var(--clay); border: 2.25px solid var(--ink); border-radius: 3px 3px 8px 8px; }
.hud-right { display: flex; align-items: center; gap: 12px; }
.hud-right p { margin: 0; font: 11px/1.35 var(--sans); color: #6d6a62; text-align: right; }
.keys-hint { background: none; border: 0; cursor: pointer; padding: 2px; }

/* Closer look */
.scrim { position: fixed; inset: 0; background: rgba(25,25,25,.22); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100vw); background: var(--ivory); border-left: var(--line); z-index: 21; transform: translateX(102%); transition: transform .25s ease; display: flex; flex-direction: column; outline: none; }
body.panel-open .panel { transform: none; }
body.panel-open .scrim { opacity: 1; pointer-events: auto; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1.5px solid var(--ink); }
.panel-kind { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #6d6a62; }
.panel-close { margin-left: auto; font-size: 18px; padding: 2px 6px; }
.panel-body { flex: 1; overflow-y: auto; padding: 24px 28px 48px; font: 17px/1.55 var(--serif); }
.panel-body h1 { font: 500 30px/1.12 var(--serif); letter-spacing: -0.015em; margin: 0 0 6px; }
.panel-body h2 { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #6d6a62; margin: 28px 0 10px; }
.panel-body p { margin: 0 0 12px; }
.panel-body a.x { color: var(--book); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.meta { font: 12.5px var(--mono); color: #6d6a62; margin-bottom: 18px; }
.dim { color: #8d8a80; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--ivory-3); }
.list > li > a { display: block; }
.list .when, .crumple .when { display: block; font: 11.5px var(--mono); color: #8d8a80; }
.badge { display: inline-block; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 1px 7px; border: 1.25px solid currentColor; border-radius: 999px; margin-left: 6px; vertical-align: 2px; }
.badge.ok { color: var(--olive); } .badge.no { color: var(--error); } .badge.wait { color: var(--clay); } .badge.mute { color: var(--cloud); }
.mini-term { list-style: none; margin: 0; padding: 12px 14px; background: #1f1e1d; color: #aeaba1; border-radius: 8px; font: 12px/1.6 var(--mono); }
.mini-term li { display: grid; grid-template-columns: 18px minmax(0, 1fr); }
.mini-term li::before { content: "●"; color: var(--clay); font-size: .8em; }
.mini-term time { color: #6d6a62; margin-right: 8px; }
.artifact { border: 1.75px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fffef9; }
.artifact-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1.5px solid var(--ink); font: 12px var(--sans); background: var(--ivory-2); }
.artifact-bar .ver { margin-left: auto; display: flex; gap: 6px; align-items: center; font: 12px var(--mono); }
.artifact-bar .ver a { padding: 0 6px; border: 1.25px solid var(--ink); border-radius: 5px; }
.artifact-bar .ver a[aria-disabled="true"] { opacity: .3; pointer-events: none; }
.artifact-body { padding: 22px 24px; white-space: pre-wrap; font: 16.5px/1.6 var(--serif); }
.redact { display: block; height: 13px; background: var(--ink); margin: 0 0 14px; }
.crumple { margin: 0 0 16px; padding: 18px 20px; background: #fffef9; border: 1.75px solid var(--ink); transform: rotate(var(--r, -0.6deg));
  background-image: linear-gradient(115deg, transparent 40%, rgba(25,25,25,.05) 41% 43%, transparent 44%), linear-gradient(20deg, transparent 60%, rgba(25,25,25,.05) 61% 63%, transparent 64%); }
.crumple .when { margin-bottom: 6px; }
.crumple s { text-decoration-color: var(--error); text-decoration-thickness: 2px; }
.crumple .fix { display: block; margin-top: 8px; font: 15px var(--serif); color: var(--olive); }
.thread { display: flex; flex-direction: column; gap: 8px; }
.bub { display: block; max-width: 80%; padding: 8px 12px; border-radius: 14px; font: 15px/1.35 var(--sans); border: 1.25px solid var(--ink); }
.bub.out { align-self: flex-end; background: #f6d3c4; border-bottom-right-radius: 4px; }
.bub.in { align-self: flex-start; background: var(--ivory); border-bottom-left-radius: 4px; }
.bub small { display: block; text-align: right; font-size: 11px; color: #6d6a62; }
.card-pin { padding: 18px; border: 1.75px solid var(--ink); background: #fffef9; font: italic 20px/1.4 var(--serif); }
.receipt-big { font: 13px/1.6 var(--mono); white-space: pre; background: #fffef9; border: 1.75px solid var(--ink); padding: 18px; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); }
.tbl th { text-align: left; font-weight: 500; color: #6d6a62; border-bottom: 1.5px solid var(--ink); padding: 6px 8px 6px 0; }
.tbl td { border-bottom: 1px solid var(--ivory-3); padding: 7px 8px 7px 0; vertical-align: top; }

.shortcuts { position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-1deg); width: min(400px, 92vw); background: var(--sticky-yellow); border: var(--line); padding: 22px 24px; box-shadow: 8px 8px 0 var(--ink); }
.shortcuts h2 { margin: 0 0 12px; font: 700 26px var(--hand); }
.shortcuts dl { margin: 0; display: grid; gap: 6px; }
.shortcuts dl div { display: grid; grid-template-columns: 90px 1fr; }
.shortcuts dd { margin: 0; font: 14px var(--serif); }
.shortcuts p { margin: 14px 0 0; font: italic 14px var(--serif); }

@media (max-width: 860px) {
  .feed { font-size: 11px; }
  .feed[data-open="true"] { height: 84px; }
  .statusbar { font-size: 12.5px; justify-content: flex-end; padding-left: 86px; }
  .hud { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand right" "ruler ruler"; gap: 8px 12px; padding: 8px 12px 10px; }
  .brand { grid-area: brand; gap: 8px; min-width: 0; }
  .by { font-size: 11px; }
  .sdj { font-size: 12.5px; }
  .ruler-wrap { grid-area: ruler; }
  .hud-right { grid-area: right; }
  .hud-right p { display: none; }
  .wordmark { font-size: 24px; }
  .bubble { max-width: 220px; font-size: 13.5px; }
  .panel-body { padding: 20px 18px 40px; }
  .stamp { top: 10px; right: 10px; font-size: 10px; }
}
@media (max-width: 420px) {
  .chip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
