/* Future Worlds mobile web app. Same palette as the iOS test app. */
:root {
  --bg: #f2f2f0;
  --panel: #ffffff;
  --ink: #161616;
  --muted: #7a7a76;
  --line: #e2e2de;
  --soft: #f7f7f5;
  --ok: #2f7d4f;
  --warn: #a8650a;
  --bad: #b3261e;
  --accent: #ffd60a;
  --detail: #5ad1ff;
  --object: #ffd60a;
  --glass: rgba(255, 255, 255, 0.88);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --top: env(safe-area-inset-top, 0px);
  --bot: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Helvetica Neue", system-ui, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--ink); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
[hidden] { display: none !important; }

/* ---------- debug strip + drawer ---------- */

#strip {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: calc(var(--top) + 2px) 10px 2px;
  font: 10px/1.3 var(--mono); color: rgba(128, 128, 124, 0.85);
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#strip .bad { color: var(--bad); }
#drawer {
  position: fixed; inset: 0; z-index: 60; background: #0b0b0c; color: #e8e8e4;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--top) + 18px) 14px calc(var(--bot) + 24px);
  font: 11.5px/1.45 var(--mono);
}
#drawer h3 { font: 600 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #8d8d88; margin: 16px 0 6px; }
#drawer .row { display: flex; gap: 8px; flex-wrap: wrap; }
#drawer button { border: 1px solid #333; border-radius: 6px; padding: 6px 10px; color: #e8e8e4; }
#drawer .entry { display: flex; gap: 8px; border-top: 1px solid #1c1c1f; padding: 3px 0; word-break: break-word; }
#drawer .entry .t { color: #6d6d68; flex: none; }
#drawer .entry.err { color: #ff8a80; }
#drawer pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

/* ---------- light pages ---------- */

.page { min-height: 100dvh; padding-bottom: calc(var(--bot) + 32px); }
.bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: grid; grid-template-columns: 76px 1fr 76px; align-items: center;
  padding: calc(var(--top) + 18px) 16px 10px; border-bottom: 1px solid var(--line);
}
.bar .title { text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .right { text-align: right; font-weight: 600; }
.bar .link { text-align: left; }
.pad { padding: 16px; display: grid; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 8px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.btn { background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 8px; padding: 10px 14px; font-weight: 600; text-align: center; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.field { display: grid; gap: 4px; }
.field span { font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--soft); width: 100%;
}
.field textarea { min-height: 76px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 5px 11px; font-size: 14px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale .chip { text-align: center; font-weight: 600; padding: 8px 0; }
.item { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 6px; }

/* recent list */
.list { display: grid; gap: 8px; }
.cap { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 10px; padding: 8px; text-align: left; width: 100%; }
.thumb { width: 52px; height: 52px; border-radius: 6px; background: #000; color: #fff; object-fit: cover; flex: none; display: grid; place-items: center; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; }
.cap .grow { flex: 1; min-width: 0; }
.cap .sub { color: var(--muted); }
.progressbar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progressbar i { display: block; height: 100%; background: var(--ink); }

/* portrait */
.headline { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 0; }
.answer { font: 22px/1.3 Georgia, serif; }
.prompt-card { background: var(--panel); border-radius: 12px; padding: 18px; display: grid; gap: 8px; }
.facet + .facet { border-top: 1px solid var(--line); padding-top: 10px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; }
.sources .thumb { width: 44px; height: 44px; }
.meter { height: 5px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); }
.trait { border-top: 1px solid var(--line); padding-top: 6px; display: grid; gap: 4px; }
.trait .head { display: flex; justify-content: space-between; gap: 8px; }
.switch { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 13px; }

/* join */
.join { display: grid; place-items: center; padding: 24px; }
.join form { width: min(340px, 100%); display: grid; gap: 12px; text-align: center; }
.brand { font-size: 22px; font-weight: 700; }
.join input { border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; background: var(--panel); font-family: var(--mono); font-size: 15px; }

/* ---------- camera ---------- */

.cam { position: fixed; inset: 0; background: #000; color: #fff; overflow: hidden; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.cam .flash.on { opacity: 0.85; transition: none; }
.cam-center { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 32px; text-align: center; }
.cam-center .clock { font: 300 48px var(--mono); }
.cam-center .rec-prompt { font-size: 20px; line-height: 1.35; max-width: 320px; }
.cam-center .hint { color: #888; font-size: 13px; max-width: 300px; }
.cam-center .level { width: 180px; height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden; }
.cam-center .level i { display: block; height: 100%; width: 0; background: #fff; transition: width 0.08s; }
.cam-center .dbg { font: 10.5px var(--mono); color: #666; }
.cam-center .btn { background: #fff; color: #000; border-color: #fff; }
.cam-center .btn.ghost { background: transparent; color: #fff; border-color: #444; }
.topbar {
  position: absolute; left: 14px; right: 14px; top: calc(var(--top) + 20px);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.pill { background: rgba(0,0,0,0.5); color: #fff; padding: 5px 11px; border-radius: 999px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill.mono { font-family: var(--mono); }
.pill.red { background: var(--bad); }
.pill.light { background: var(--glass); color: var(--ink); font-size: 13px; padding: 6px 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.1); }
.cam-prompt { position: absolute; left: 24px; right: 24px; top: calc(var(--top) + 64px); display: flex; justify-content: center; }
.cam-prompt button { background: rgba(0,0,0,0.55); color: #fff; font-size: 17px; line-height: 1.35; padding: 7px 12px; border-radius: 8px; text-align: center; }
.bottombar { position: absolute; left: 0; right: 0; bottom: calc(var(--bot) + 14px); display: grid; justify-items: center; gap: 18px; }
.modes { display: flex; gap: 6px; background: rgba(0,0,0,0.5); border-radius: 999px; padding: 4px; }
.modes button { padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.modes button.on { background: #fff; color: #000; }
.shutter-row { display: flex; align-items: center; justify-content: space-between; align-self: stretch; padding: 0 28px; }
.shutter-row > button:not(.shutter) { width: 72px; font-weight: 600; text-align: left; }
.shutter-row > button:last-child { text-align: right; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.shutter i { width: 62px; height: 62px; border-radius: 50%; background: #fff; transition: all 0.15s; }
.shutter.red i { background: var(--bad); }
.shutter.stop i { width: 30px; height: 30px; border-radius: 6px; background: var(--bad); }

/* ---------- detail ---------- */

.detail { position: fixed; inset: 0; background: var(--soft); overflow: hidden; --lift: 70px; }
.stage { position: absolute; inset: 0; }
.stage .photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.boxes { position: absolute; inset: 0; pointer-events: none; }
.box { position: absolute; border: 2px solid; border-radius: 3px; pointer-events: auto; }
.box.sel { border-width: 3px; }
.box.dim { opacity: 0.25; }
.num { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 5px; color: #000; font-size: 11px; font-weight: 700; flex: none; }
.box .num { position: absolute; top: -2px; left: -2px; }
.audio-ui { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding-bottom: var(--lift); }
.play { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--ink); font-weight: 600; }
.caption { position: absolute; left: 16px; right: 16px; bottom: calc(var(--lift) + 44px); display: flex; justify-content: center; pointer-events: none; }
.caption span { background: rgba(0,0,0,0.65); color: #fff; font-size: 16px; line-height: 1.35; padding: 6px 10px; border-radius: 6px; text-align: center; }
.caption b { color: var(--accent); font: 400 12px var(--mono); margin-right: 4px; }
.aprogress { position: absolute; left: 16px; right: 16px; bottom: calc(var(--lift) + 30px); height: 3px; border-radius: 2px; background: rgba(0,0,0,0.12); }
.aprogress i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 2px; }
.center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.glass { background: var(--glass); border-radius: 20px; padding: 22px 30px; display: grid; justify-items: center; gap: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.12); pointer-events: auto; max-width: 320px; text-align: center; }
.glass .clock { font-size: 52px; font-weight: 300; font-variant-numeric: tabular-nums; line-height: 1.1; }
.steps { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; }
.steps span { display: inline-flex; align-items: center; gap: 5px; }
.steps.small { gap: 4px; margin: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(0,0,0,0.18); flex: none; }
.dot.done { background: var(--ok); } .dot.failed { background: var(--bad); } .dot.running { background: var(--warn); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.dtop { position: absolute; top: calc(var(--top) + 20px); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dtop .status { font-variant-numeric: tabular-nums; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 58dvh; display: flex; flex-direction: column;
  background: #fff; border-radius: 22px 22px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.14);
  padding: 8px 20px 0;
}
.sheet .handle { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px 0 10px; }
.tabs { display: flex; align-self: center; background: var(--soft); border-radius: 999px; padding: 3px; margin-bottom: 12px; flex: none; }
.tabs button { padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.tabs button.on { background: var(--ink); color: #fff; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--bot) + 14px); display: grid; gap: 10px; align-content: start; }
.obs { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 3px 0; width: 100%; }
.obs .sub { color: var(--muted); font-size: 13px; }
.tl { display: flex; gap: 10px; text-align: left; width: 100%; }
.tl .t { color: var(--muted); font: 12px var(--mono); width: 40px; flex: none; padding-top: 2px; }
.dbottom { position: absolute; left: 16px; right: 16px; bottom: calc(var(--bot) + 14px); display: flex; justify-content: center; }
.callout { width: 100%; background: var(--glass); border-radius: 16px; padding: 14px; display: flex; gap: 10px; align-items: flex-start; text-align: left; box-shadow: 0 4px 16px rgba(0,0,0,0.14); }
.callout .x { margin-left: auto; color: var(--muted); font-size: 18px; line-height: 1; }

/* subtle run details inside the sheet */
.dbg { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; display: grid; gap: 4px; font: 11px/1.45 var(--mono); color: var(--muted); }
.dbg .toggle { text-align: left; color: var(--muted); }
.run { display: grid; gap: 2px; }
.run .line { display: flex; justify-content: space-between; gap: 8px; text-align: left; width: 100%; color: var(--ink); }
.run .line .m { color: var(--muted); text-align: right; }
.run pre { background: var(--soft); border-radius: 6px; padding: 8px; margin: 0; font-size: 10.5px; white-space: pre-wrap; word-break: break-word; max-height: 50dvh; overflow: auto; color: var(--ink); }
.dbg .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.dbg .acts button { border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; color: var(--ink); font-family: var(--mono); font-size: 11px; }
.dbg .acts button.armed { background: var(--bad); color: #fff; border-color: var(--bad); }

