/* G-OS v2 — "The House". ASPECTSS is the building, GOV.UK is the interior.
   The warm-dark/Irlen rails are the CONSTRAINT this works inside (v3.4):
   never white-on-black, never pure black, tint remembered, colour = signal.

   Sensory zoning: each room carries its own light temperature via --room-glow,
   running warm (action end) to dusk (quiet end) — the interface equivalent of
   Mostafa's high-stimulus -> low-stimulus gradient. */

:root {
  --ink: #f6ead9;
  --ink-soft: #c9b8b0;
  --ink-faint: #94818a;
  --bg: #171126;
  --bg-warm: #2b1a1e;
  --panel: #221a31;
  --panel-2: #2c2140;
  --line: #3a2d4e;
  --wall: #55406b;
  --red: #ff8d7e;
  --amber: #ffc76b;
  --green: #7fe0b0;
  --accent: #ffb46b;
  --ember: #ff7e5f;
  --rose: #e879a6;
  --dusk: #9aa5d8;
  --focus: #ffc76b;          /* GOV.UK-grade focus, tuned ember */
  --tint: transparent;
  --radius: 16px;
  --step: 1.05rem;
  --room-glow: rgba(255, 126, 95, .07);
}

html[data-tint="none"]  { --tint: transparent; }
html[data-tint="warm"]  { --tint: rgba(232, 168, 92, .06); }
html[data-tint="rose"]  { --tint: rgba(228, 130, 150, .08); }
html[data-tint="peach"] { --tint: rgba(240, 150, 100, .09); }
html[data-tint="sage"]  { --tint: rgba(120, 190, 150, .07); }
html[data-tint="blue"]  { --tint: rgba(120, 160, 220, .09); }

html[data-size="s"]  { --step: .92rem; }
html[data-size="m"]  { --step: 1.05rem; }
html[data-size="l"]  { --step: 1.25rem; }
html[data-size="xl"] { --step: 1.5rem; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--room-glow), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, #1d1430 55%, var(--bg-warm) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font: var(--step)/1.65 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .012em;
  word-spacing: .06em;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  padding-bottom: calc(4.6rem + env(safe-area-inset-bottom));
  transition: background .8s ease;
}

/* Irlen wash above everything, clicks pass through. */
body::after {
  content: "";
  position: fixed; inset: 0;
  background: var(--tint);
  pointer-events: none;
  z-index: 99;
}

.defs { position: absolute; width: 0; height: 0; }
.ico, .glyph {
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.ico { width: 1.35em; height: 1.35em; display: block; }

/* GOV.UK-grade focus: thick, unmissable, never removed. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- header */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .7rem;
  padding: calc(.55rem + env(safe-area-inset-top)) .9rem .55rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.crumb { flex: 1; min-width: 0; }
.crumb-word {
  font-size: .95em; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; white-space: nowrap;
  background: linear-gradient(90deg, var(--amber), var(--ember) 55%, var(--rose));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.controls { display: flex; gap: .35rem; }
.ctl {
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-soft); border-radius: 12px;
  min-width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center;
  font: inherit; font-size: .9em; cursor: pointer;
}
.ctl:active { background: var(--panel-2); }
.ctl.home { color: var(--accent); border-color: var(--wall); }

/* --------------------------------------------------------------- the estate */
/* The whole ecosystem as a WORLD. Layers move at different depths under the
   pointer — a place you look into, not a page you scroll past. */
.estate-wrap { position: relative; overflow: hidden; border-radius: 20px; }
.estate { width: 100%; height: auto; display: block; touch-action: pan-y; }
.estate .layer { transition: transform .18s ease-out; will-change: transform; }
.estate text { pointer-events: none; }
.estate .plot { cursor: pointer; }
.estate .plot:hover .glow, .estate .plot:focus .glow { opacity: .5; }
.estate .glow { opacity: 0; transition: opacity .3s ease; }
.estate .label {
  fill: var(--ink-faint); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; font-weight: 600;
}
.estate .plot[data-tone="red"] .label { fill: var(--red); }
.star { fill: #cbb89a; animation: twinkle 4s ease-in-out infinite; }
.star.s2 { animation-delay: -1.3s; } .star.s3 { animation-delay: -2.6s; }
@keyframes twinkle { 50% { opacity: .15; } }
.estate-caption { text-align: center; font-size: .8em; color: var(--ink-faint); margin: .5rem 0 0; }

/* The Office: the staff as characters. */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .7rem; }
.member {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem .9rem .9rem; text-align: center; position: relative;
}
.member .portrait {
  width: 4.2rem; height: 4.2rem; margin: 0 auto .6rem; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #35284e, var(--bg));
  border: 1.5px solid var(--wall); color: var(--accent);
  box-shadow: 0 0 18px -6px var(--ember), inset 0 0 12px -6px var(--rose);
}
.member .portrait .ico { width: 1.9rem; height: 1.9rem; }
.member h2 { margin: 0; font-size: 1.05em; }
.member .role { margin: .15rem 0 .5rem; font-size: .68em; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); }
.member .charter { margin: 0; font-size: .8em; color: var(--ink-soft); }
.member .new {
  position: absolute; top: .6rem; right: .6rem;
  font-size: .6em; font-weight: 700; letter-spacing: .1em;
  background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green);
  padding: .2em .55em; border-radius: 6px; text-transform: uppercase;
}

/* The Workshop: the kanban wall. */
.kanban { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: .8rem; scroll-snap-type: x proximity; }
.kcol {
  flex: 0 0 78%; max-width: 20rem; scroll-snap-align: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem;
}
.kcol h2 {
  margin: 0 0 .6rem; font-size: .78em; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); display: flex; justify-content: space-between; align-items: center;
}
.kcol h2 .chip {
  background: var(--panel-2); color: var(--accent); border-radius: 999px;
  padding: .1em .6em; font-size: .95em;
}
.kcard {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .7rem; margin: .45rem 0; font-size: .88em; line-height: 1.45;
}
.kmore { font-size: .74em; color: var(--ink-faint); text-align: center; margin: .4rem 0 0; }

/* The Gate: staged security as a path. */
.gstages { display: grid; gap: .6rem; margin: .8rem 0; }
.gstage {
  display: grid; grid-template-columns: 2.4rem 1fr; gap: .7rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .9rem;
}
.gstage .n {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--wall); color: var(--ink-faint); font-weight: 700;
}
.gstage[data-on="true"] { border-left: 4px solid var(--green); }
.gstage[data-on="true"] .n { border-color: var(--green); color: var(--green); }
.gstage h2 { margin: 0; font-size: .95em; }
.gstage p { margin: .15rem 0 0; font-size: .8em; color: var(--ink-soft); }

/* ---------------------------------------------------------------- the plan */
.stage { max-width: 46rem; margin: 0 auto; padding: .5rem .9rem 1rem; }

.plan-wrap { position: relative; }
.plan { width: 100%; height: auto; display: block; }

.plan .outline { stroke: var(--wall); stroke-width: 2.5; fill: none; }
.plan .ground  { stroke: var(--line); stroke-width: 2; }

.room {
  cursor: pointer;
}
.room .shell {
  fill: var(--panel);
  stroke: var(--wall); stroke-width: 1.8;
  transition: fill .25s ease;
}
.room:active .shell, .room:hover .shell { fill: var(--panel-2); }
.room .glyph { color: var(--ink-soft); }
.room .name {
  fill: var(--ink-faint); font-size: 10.5px;
  letter-spacing: .18em; text-transform: uppercase; font-weight: 600;
}
.room .lamp { fill: var(--ink-faint); }
.room[data-tone="red"]   .lamp { fill: var(--red); }
.room[data-tone="amber"] .lamp { fill: var(--amber); }
.room[data-tone="green"] .lamp { fill: var(--green); }
.room[data-tone="red"]   .glyph { color: var(--red); }
.room[data-tone="amber"] .glyph { color: var(--amber); }
.room[data-tone="dusk"]  .shell { fill: #1f2440; stroke: #454f7d; }
.room[data-tone="dusk"]  .glyph { color: var(--dusk); }
.room[data-tone="dusk"]  .name  { fill: #6e7898; }
.room .count {
  fill: var(--bg); font-size: 10px; font-weight: 700;
}
.room .lamp-ring { fill: none; stroke-width: 0; }
.room[data-tone="red"] .lamp-ring {
  stroke: var(--red); stroke-width: 1.5; opacity: .6;
  animation: lampring 2s ease-out infinite;
}
@keyframes lampring {
  from { transform: scale(1); opacity: .6; }
  to   { transform: scale(2.2); opacity: 0; }
}
.room .lamp-ring { transform-origin: center; transform-box: fill-box; }

/* Rooms breathe, staggered — the house is alive, gently. */
.room .body { transform-origin: center; transform-box: fill-box; }
@keyframes breathe { 50% { transform: scale(1.012); } }
.room .body { animation: breathe 7s ease-in-out infinite; }
.room:nth-of-type(2n) .body { animation-delay: -2.3s; }
.room:nth-of-type(3n) .body { animation-delay: -4.1s; }

/* Chimney smoke = heartbeat. Red glow = a shift died. */
.smoke { fill: var(--ink-faint); opacity: 0; }
.plan[data-chimney="smoke"] .smoke { animation: puff 5s ease-out infinite; }
.plan[data-chimney="smoke"] .smoke.s2 { animation-delay: 1.6s; }
.plan[data-chimney="smoke"] .smoke.s3 { animation-delay: 3.2s; }
@keyframes puff {
  0%   { opacity: 0; transform: translateY(0) scale(.6); }
  20%  { opacity: .5; }
  100% { opacity: 0; transform: translateY(-26px) scale(1.5); }
}
.smoke { transform-box: fill-box; transform-origin: center; }
.plan[data-chimney="red"] .chimney-cap { fill: var(--red); }
.plan[data-chimney="red"] .chimney-glow {
  fill: var(--red); opacity: .35;
  animation: glow 1.8s ease-in-out infinite;
}
@keyframes glow { 50% { opacity: .1; } }
.chimney-glow { opacity: 0; }

.plan-caption {
  text-align: center; font-size: .8em; color: var(--ink-faint);
  margin: .4rem 0 0;
}

/* ------------------------------------------------------- room transitions */
/* ASPECTSS transitions: you walk, you don't teleport. */
.view { animation: arrive .35s ease both; }
@keyframes arrive {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.view.leave { animation: depart .22s ease both; }
@keyframes depart {
  to { opacity: 0; transform: translateY(-8px) scale(.99); }
}

/* ---------------------------------------------------------------- cards */
.room-head {
  display: flex; align-items: center; gap: .7rem;
  margin: .5rem 0 .9rem;
}
.room-head .glyph { width: 2rem; height: 2rem; color: var(--accent); flex: none; }
.room-head h1 {
  margin: 0; font-size: 1.35em; font-weight: 700; letter-spacing: .02em;
}
.room-head .sub { margin: .1rem 0 0; font-size: .78em; color: var(--ink-faint); }

.card {
  display: grid; grid-template-columns: 2.6rem 1fr;
  gap: .1rem .85rem; align-items: start;
  background: linear-gradient(160deg, var(--panel-2) 0%, var(--panel) 70%);
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem .95rem;
  margin: .6rem 0;
  box-shadow: 0 8px 24px -18px rgba(255, 126, 95, .35);
}
.card[data-tone="red"]   { border-left-color: var(--red); }
.card[data-tone="amber"] { border-left-color: var(--amber); }
.card[data-tone="green"] { border-left-color: var(--green); }
.card .glyph { width: 2.3rem; height: 2.3rem; grid-row: 1 / span 3; color: var(--ink-faint); }
.card[data-tone="red"] .glyph   { color: var(--red); }
.card[data-tone="amber"] .glyph { color: var(--amber); }
.card[data-tone="green"] .glyph { color: var(--green); }
.card h2 { margin: 0; font-size: 1em; font-weight: 600; line-height: 1.5; }
.card .src { margin: .35rem 0 0; font-size: .72em; color: var(--ink-faint); }
.card .more {
  margin: .55rem 0 0; font-size: .9em; color: var(--ink-soft);
  border-top: 1px dashed var(--line); padding-top: .55rem;
}
.card button.expand {
  appearance: none; background: none; border: 0;
  color: var(--accent); font: inherit; font-size: .8em;
  padding: .35rem 0 0; cursor: pointer; text-align: left;
}
.card button.say {
  appearance: none; background: none; border: 0;
  color: var(--ink-faint); padding: .2rem; cursor: pointer;
  grid-column: 2; justify-self: end; margin-top: -1.9rem;
}

/* GOV.UK-style status tags for the You room. */
.tag {
  display: inline-block; font-size: .68em; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: .18em .6em; border-radius: 6px; margin-bottom: .35rem;
}
.tag.red   { background: color-mix(in srgb, var(--red) 22%, transparent);   color: var(--red); }
.tag.amber { background: color-mix(in srgb, var(--amber) 20%, transparent); color: var(--amber); }
.tag.grey  { background: var(--panel-2); color: var(--ink-soft); }

/* One thing at a time (You room): the deck. */
.deck-nav {
  display: flex; align-items: center; gap: .8rem; margin: .8rem 0;
}
.deck-nav .btn { flex: 1; justify-content: center; }
.deck-dots { display: flex; gap: .32rem; justify-content: center; margin: .2rem 0 .6rem; flex-wrap: wrap; }
.deck-dots i {
  width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--line);
}
.deck-dots i.red { background: var(--red); }
.deck-dots i.amber { background: var(--amber); }
.deck-dots i.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.deck-count { text-align: center; font-size: .78em; color: var(--ink-faint); margin: 0; }

/* -------------------------------------------------------- compose + search */
.compose textarea {
  width: 100%; min-height: 8.5rem;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; font: inherit; resize: vertical;
}
.row { display: flex; gap: .5rem; margin: .65rem 0; flex-wrap: wrap; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--ink); border-radius: 999px;
  padding: .7rem 1.15rem; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
}
.btn.primary {
  background: linear-gradient(120deg, var(--amber), var(--ember));
  color: #2b130e; border-color: transparent; font-weight: 700;
  box-shadow: 0 6px 20px -8px var(--ember);
}
.btn.rec { color: var(--red); border-color: var(--red); }
.btn.ghost { background: none; }
.note { font-size: .84em; color: var(--ink-faint); margin: .4rem 0; }

.search input {
  width: 100%; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .95rem 1.05rem; font: inherit;
}
.hit { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.hit b { color: var(--accent); font-weight: 600; }
.hit p { margin: .25rem 0 0; font-size: .88em; color: var(--ink-soft); }
.hit .path { font-size: .72em; color: var(--ink-faint); }

/* --------------------------------------------------------- the quiet room */
/* ASPECTSS escape space: no data, no words, one slow shape, one door out. */
.quiet {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    radial-gradient(90% 70% at 50% 30%, #262c4d 0%, #1a1d33 55%, #120d1e 100%);
  animation: arrive .8s ease both;
}
body[data-quiet="1"] .corridor,
body[data-quiet="1"] .bar .controls #sizeBtn,
body[data-quiet="1"] .bar .controls #tintBtn { visibility: hidden; }

.quiet .breath {
  width: min(52vw, 15rem); height: min(52vw, 15rem);
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, #a8b4dd22, #8f9bc411 60%, transparent 72%);
  border: 1.5px solid #4a5578;
  animation: breathcycle 11s ease-in-out infinite;
}
@keyframes breathcycle {
  0%   { transform: scale(.78); opacity: .75; }
  36%  { transform: scale(1);   opacity: 1;   }  /* in, 4s   */
  63%  { transform: scale(1);   opacity: 1;   }  /* hold, 3s */
  100% { transform: scale(.78); opacity: .75; }  /* out, 4s  */
}
.quiet .door {
  position: absolute; bottom: calc(2rem + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  color: #6e7898; background: none; border: 1px solid #39415c;
  border-radius: 999px; padding: .6rem 1.3rem; font: inherit; cursor: pointer;
}

/* ------------------------------------------------------------ the corridor */
/* Persistent mini-plan. You are always somewhere; the somewhere is drawn. */
.corridor {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: flex; justify-content: center; gap: .45rem;
  padding: .55rem .8rem calc(.7rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.corridor .cell {
  appearance: none; border: 1.5px solid var(--wall); background: var(--panel);
  width: 2.7rem; height: 2.3rem; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-faint); position: relative;
}
.corridor .cell .ico { width: 1.05em; height: 1.05em; }
.corridor .cell[aria-current="true"] {
  border-color: var(--accent); color: var(--accent);
  background: var(--panel-2);
}
.corridor .cell .dot {
  position: absolute; top: .22rem; right: .22rem;
  width: .42rem; height: .42rem; border-radius: 50%;
}
.corridor .cell .dot.red   { background: var(--red); }
.corridor .cell .dot.amber { background: var(--amber); }
.corridor .cell.quiet { border-color: #39415c; color: var(--dusk); background: #232838; }

/* ---------------------------------------------------------------- sheet */
.sheet {
  position: fixed; inset: auto 0 0 0; z-index: 100;
  background: var(--panel-2); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
}
.sheet[hidden] { display: none; }
.sheet-title { margin: 0 0 .8rem; font-size: .92em; color: var(--ink-soft); }
.swatches { display: flex; gap: .6rem; flex-wrap: wrap; }
.sw { width: 3.2rem; height: 3.2rem; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; }
.sw[aria-pressed="true"] { border-color: var(--accent); }
.close {
  margin-top: 1rem; width: 100%; padding: .8rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; cursor: pointer;
}

.foot-note {
  padding: .8rem 0 0; font-size: .74em; color: var(--ink-faint); text-align: center;
}

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


/* ------------------------------------------------------ living-OS buildings */
.panelbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6rem; margin: .4rem 0 .8rem;
}
.panelbox svg { width: 100%; height: auto; display: block; }
.panelbox.sky { background: radial-gradient(120% 140% at 50% 0%, #1d2240 0%, var(--panel) 75%); }

/* Engine wire */
.wire { stroke: var(--wall); stroke-width: 2; fill: none; }
.wire.flow {
  stroke: var(--amber); stroke-width: 1.4; stroke-dasharray: 4 14; opacity: .8;
  animation: flow 2.4s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -18; } }
.enode .ering { fill: none; stroke: var(--wall); stroke-width: 1.6; }
.enode .ecore { fill: var(--panel-2); stroke: var(--ink-faint); stroke-width: 1.6; }
.enode[data-state="green"] .ecore { fill: color-mix(in srgb, var(--green) 30%, var(--panel-2)); stroke: var(--green); }
.enode[data-state="red"] .ecore { fill: color-mix(in srgb, var(--red) 26%, var(--panel-2)); stroke: var(--red); }
.enode[data-state="red"] .ering { stroke: var(--red); animation: lampring 2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.eat { fill: var(--ink-soft); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; }
.ename { fill: var(--ink-faint); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; }

/* Observatory sky */
.bandlab { fill: var(--ink-faint); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; }
.bandline { stroke: var(--line); stroke-width: 1; }
.istar { cursor: pointer; }
.istar.b0 { fill: var(--green); }
.istar.b1 { fill: var(--amber); }
.istar.b2 { fill: var(--rose); opacity: .9; }
.istar.b3 { fill: #cbb89a; opacity: .75; }
.istar.b4 { fill: var(--dusk); opacity: .6; }
.istar:hover, .istar:focus { stroke: var(--ink); stroke-width: 1.5; }

/* Money bars */
.btrack { fill: var(--panel-2); stroke: var(--line); }
.bfill.now { fill: var(--ember); opacity: .85; }
.bfill.floor { fill: var(--green); opacity: .8; }
.bmark { stroke: var(--amber); stroke-width: 1.6; stroke-dasharray: 3 3; }
.blab { fill: var(--ink-soft); font-size: 10.5px; letter-spacing: .06em; }
.blab.em { fill: var(--amber); font-size: 9.5px; }

/* Windmill sails turn — the engine is alive even from the lawn. */
.sails { animation: mill 14s linear infinite; }
@keyframes mill { to { transform: translate(40px, 168px) rotate(360deg); } }
.sails { transform: translate(40px, 168px); }
@media (prefers-reduced-motion: reduce) { .sails, .wire.flow { animation: none !important; } }
