:root{color-scheme:light;box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}html{scroll-padding-top:env(safe-area-inset-top,0px)}body{margin:0;padding:0;font:14px -apple-system,BlinkMacSystemFont,sans-serif;background:#fff;color:#000}img{max-width:100%}[hidden]:not([hidden=until-found i]){display:none!important}

/* Hallmark · macrostructure: custom (bespoke depth): full-bleed live canvas with two floating panels; nearest catalog entry is 21 Component Playground, not used
 * audience: Alex and Perennos Living Systems prospects · use: explore the design on a phone · tone: calm architectural model
 * pre-emit critique (self-score by the drafter, review sits above): P4 H4 E3 S4 R3 V3
 *   E3: realism pass adds many details, a few unverified on a real phone. R3: dense control set. V3: not rotated against any other Hallmark output.
 * tokens: all colours and fonts via :root tokens; scene colours read from the same tokens · contrast: checked by reading, not measured */
:root {
  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --paper: #f3efe4;
  --panel: #faf7ef;
  --ink: #1c1a15;
  --muted: #5a5546;
  --line: #d3cab4;
  --accent: #0a7787;
  --accent-ink: #fbf9f2;
  --hover: #eee8d8;
  --focus: #c21c55;

  --scene-bg: #cddbdc;
  --c-sky: #dfeaf0;
  --c-bounce: #b9a98a;
  --c-sun: #fff1d0;

  --c-bone: #ebe5d4;
  --c-stone: #efe9da;
  --c-aggr: #1b1914;
  --c-ink: #17150f;
  --c-sand: #e4d8b8;
  --c-rock: #8d8470;
  --c-floor: #e9e2d0;
  --c-teal: #12a2b3;
  --c-magenta: #d6235f;
  --c-mango: #f2a21f;
  --c-pit: #f1b3c9;
  --c-pv: #17305c;
  --c-pvline: #8aa6cf;
  --c-cistern: #4aa8d8;
  --c-water: #2a86c0;
  --c-ac: #5b97ea;
  --c-brass: #c8a24a;
  --c-leaf: #8aa08a;
  --c-trunk: #8b7a5c;
  --c-shrub: #4d7547;
  --c-absorber: #121212;
  --c-alum: #aab1b5;
  --c-sea: #1d7f94;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --radius: 10px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 140ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14120d;
    --panel: #211e17;
    --ink: #efe9d9;
    --muted: #b3ab94;
    --line: #3b362a;
    --accent: #4fc3d4;
    --accent-ink: #0f1a1c;
    --hover: #2c281f;
    --focus: #ff7aa6;

    --scene-bg: #0f1619;
    --c-sky: #7f9fb4;
    --c-bounce: #7d6f55;
    --c-sun: #ffe9b8;
    --c-sand: #c9bd9c;
  }
}

:root[data-theme="dark"] {
  --paper: #14120d;
  --panel: #211e17;
  --ink: #efe9d9;
  --muted: #b3ab94;
  --line: #3b362a;
  --accent: #4fc3d4;
  --accent-ink: #0f1a1c;
  --hover: #2c281f;
  --focus: #ff7aa6;

  --scene-bg: #0f1619;
  --c-sky: #7f9fb4;
  --c-bounce: #7d6f55;
  --c-sun: #ffe9b8;
  --c-sand: #c9bd9c;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: clip; }
body {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

#stage { position: absolute; inset: 0; background: var(--scene-bg); }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.fail { position: absolute; left: var(--space-lg); right: var(--space-lg); top: 50%; margin: 0; color: var(--ink); font-size: 15px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* UI wrapper: 16px side gutter, safe-area aware */
.ui {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  column-gap: var(--space-md);
  row-gap: var(--space-sm);
  padding-top: max(var(--space-lg), env(safe-area-inset-top, 0px));
  padding-bottom: max(var(--space-lg), env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.ui > * { pointer-events: auto; min-width: 0; }

.brand { grid-column: 1; grid-row: 1; pointer-events: none; justify-self: start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-sm) var(--space-md); }
.brand h1 {
  margin: 0; font-family: var(--font-display); font-weight: 700; font-style: normal;
  font-size: 40px; line-height: 1; letter-spacing: -0.02em; overflow-wrap: anywhere;
}
.brand p { margin: var(--space-xs) 0 0; max-width: 46ch; font-size: 13px; color: var(--muted); }

.btn {
  font: 600 13px/1 var(--font-body); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 44px; padding: 0 var(--space-lg); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.btn:hover { border-color: var(--muted); }
.btn:active { background: var(--line); }
.btn[aria-pressed="true"], .btn[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:focus-visible, .sw:focus-visible, .rng:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; transition: none; }

#viewBtn { grid-column: 2; grid-row: 1; align-self: start; }

.panel {
  grid-column: 1 / -1; grid-row: 2; justify-self: end; align-self: start;
  width: min(300px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-md);
}
.panel[hidden] { display: none; }
.panel h2, .sun h2 {
  margin: 0 0 var(--space-sm); font-family: var(--font-display); font-weight: 500; font-style: normal;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-md); }
.rows { display: grid; gap: 0; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-md);
  min-height: 44px; padding: 0 var(--space-sm); border-radius: 8px; cursor: pointer;
  transition: background-color var(--dur) var(--ease-out);
}
.row:hover { background: var(--hover); }
.row[hidden] { display: none; }
.row .t { display: block; font-weight: 600; font-size: 14px; }
.row small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.sw {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 48px; height: 28px; border-radius: 14px; position: relative; cursor: pointer;
  background: var(--line); border: 1px solid var(--muted);
  transition: background-color var(--dur) var(--ease-out);
}
.sw::after {
  content: ""; position: absolute; left: 4px; top: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--muted);
  transition: transform var(--dur) var(--ease-out);
}
.sw:checked { background: var(--accent); border-color: var(--accent); }
.sw:checked::after { transform: translateX(20px); border-color: var(--accent-ink); }
.sw:active::after { background: var(--line); }

.sun {
  grid-column: 1 / -1; grid-row: 3; justify-self: start; width: min(560px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
}
.ctl { display: grid; grid-template-columns: 88px minmax(0, 1fr) 120px; align-items: center; column-gap: var(--space-md); min-height: 44px; }
.ctl label { font-weight: 600; font-size: 13px; white-space: nowrap; }
.ctl output { font-variant-numeric: tabular-nums; font-size: 13px; text-align: right; white-space: nowrap; }
.rng { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; }
.rng::-webkit-slider-runnable-track { height: 4px; background: var(--line); border-radius: 2px; }
.rng::-moz-range-track { height: 4px; background: var(--line); border-radius: 2px; }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }
.rng::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }
.rng:active::-webkit-slider-thumb { background: var(--ink); }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-sm); margin-top: var(--space-xs); }
.quick .btn { padding: 0 var(--space-xs); }
.sunhead { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.sunhead h2 { margin: 0; }
#sunBtn { display: none; min-height: 44px; }
#sunBody[hidden] { display: none; }
.loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-sm) var(--space-lg); font-size: 13px; color: var(--muted); pointer-events: none; }
.readout { margin: var(--space-sm) 0 0; font-size: 12px; color: var(--muted); }
.readout b { color: var(--ink); font-weight: 600; }

#labels { position: absolute; inset: 0; overflow: clip; pointer-events: none; }
.lbl {
  position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform;
  font: 600 12px/1.25 var(--font-body); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: var(--space-xs) var(--space-sm);
}
.lbl.wide { white-space: normal; width: 200px; }
.lbl .sub { display: block; font-weight: 400; color: var(--muted); }
.lbl[hidden] { display: none; }

@media (max-width: 719px) {
  .brand h1 { font-size: 34px; }
  .ctl { grid-template-columns: 84px minmax(0, 1fr) 100px; column-gap: var(--space-sm); }
  .ctl output { font-size: 12px; }
  .sun { padding: var(--space-sm) var(--space-md); }
  #sunBtn { display: inline-flex; align-items: center; }
}
@media (min-width: 720px) { #sunBody[hidden] { display: block; } }
@media (min-width: 940px) { .panel { grid-row: 2 / 4; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.brand .back{pointer-events:auto;display:inline-block;margin-top:var(--space-sm);font-size:13px;color:var(--accent);text-decoration:underline;text-underline-offset:2px}
.brand .back:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
