/* Universe Lab — koltondoj.com/universe/ */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
/* Layout: a full-bleed cinematic universe; instruments float at the edges like a spacecraft HUD — left: create, right: one tabbed laboratory panel, bottom-left: the mission log, bottom: time. */
:root {
  color-scheme: dark;
  --void: #03040a;
  --panel: rgba(10, 13, 27, 0.84);
  --line: rgba(150, 170, 255, 0.16);
  --ink: #e9ecff;
  --dim: #8b93b8;
  --star: #ffd27a;
  --orbit: #7fd3ff;
  --good: #6ee7a8; --warn: #ffb45e; --bad: #ff6b81; --ai: #b9a3ff;
  --f-display: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --f-body: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
html, body { height: 100%; }
body { background: var(--void); color: var(--ink); font: 14px/1.45 var(--f-body); overflow: hidden; -webkit-font-smoothing: antialiased; }
#space { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--orbit); outline-offset: 2px; }
.hud { position: fixed; z-index: 5; }
.glass { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

#top { top: calc(10px + env(safe-area-inset-top, 0px)); left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 10px; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { font: 700 15px var(--f-display); letter-spacing: .14em; text-transform: uppercase; padding: 9px 14px; }
.brand b { color: var(--star); }
.mode { display: flex; padding: 3px; gap: 3px; }
.mode button { border: 0; background: transparent; padding: 7px 12px; border-radius: 10px; font: 600 12.5px var(--f-display); letter-spacing: .06em; color: var(--dim); }
.mode button.on { background: rgba(255,210,122,.14); color: var(--star); box-shadow: inset 0 0 0 1px rgba(255,210,122,.45); }
.vis { display: flex; padding: 3px; gap: 3px; margin-left: auto; }
.vis button { border: 0; background: transparent; padding: 7px 10px; border-radius: 10px; font: 600 11.5px var(--f-display); letter-spacing: .05em; color: var(--dim); }
.vis button[aria-pressed="true"] { color: var(--ink); background: rgba(127,211,255,.12); box-shadow: inset 0 0 0 1px rgba(127,211,255,.4); }

#tools { top: 50%; transform: translateY(-50%); left: max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 6px; padding: 8px; }
#tools button { width: 58px; padding: 8px 4px 6px; border-radius: 10px; border: 1px solid transparent; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 4px; font: 600 10.5px var(--f-display); letter-spacing: .05em; color: var(--dim); }
#tools button .ic { width: 20px; height: 20px; border-radius: 50%; }
#tools button:hover { color: var(--ink); }
#tools button.on { border-color: rgba(127,211,255,.6); color: var(--ink); background: rgba(127,211,255,.1); }
.ic.star { background: radial-gradient(circle, #fff6d8, #ffc04d 55%, #ff8a2a); box-shadow: 0 0 12px #ffb040; }
.ic.planet { background: radial-gradient(circle at 35% 35%, #9fe3ff, #2f6fb8 70%); }
.ic.moon { width: 13px !important; height: 13px !important; margin: 3.5px; background: radial-gradient(circle at 35% 35%, #eee, #888 70%); }
.ic.hole { background: radial-gradient(circle, #000 42%, #ffd9a0 48%, #ff7a2a 58%, rgba(120,40,255,.5) 70%, transparent 72%); }
.ic.belt { background: radial-gradient(circle, transparent 40%, #c9b38f 42%, #c9b38f 52%, transparent 54%, transparent 62%, #a89474 64%, transparent 68%); }

#panel { top: calc(64px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); width: 364px; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 11px 2px 10px; font: 600 11px var(--f-display); letter-spacing: .07em; text-transform: uppercase; color: var(--dim); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--star); }
.tab { padding: 14px 16px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 13px; }
.tab[hidden] { display: none; }
.tab h3 { margin: 0; font: 600 16px var(--f-display); letter-spacing: .03em; text-wrap: balance; }
.tab p { margin: 0; color: #c5cbea; }
.lbl { font: 600 10.5px var(--f-display); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.small { font-size: 12.5px; color: var(--dim) !important; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: rgba(255,255,255,.03); border-radius: 999px; padding: 6px 11px; font-size: 12.5px; text-align: left; }
.chip:hover { border-color: rgba(127,211,255,.5); }
.chip.on { border-color: var(--star); background: rgba(255,210,122,.12); color: var(--star); }
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font: 600 12.5px var(--f-display); letter-spacing: .06em; text-transform: uppercase; }
.btn.go { background: var(--star); color: #1a1205; }
.btn.ai { background: linear-gradient(90deg, #8f7bff, #b9a3ff); color: #0d0828; }
.btn.ghost { background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.kv span { color: var(--dim); } .kv b { font: 500 13px var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.slider label { font-size: 13px; color: #c5cbea; }
.slider output { font: 500 12.5px var(--f-mono); color: var(--orbit); }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--star); }
.slider input:disabled { opacity: .35; }
.lock { font-size: 12px; color: var(--warn); }
.eq { padding: 12px 12px 10px; border-radius: 12px; background: rgba(127,211,255,.06); border: 1px solid rgba(127,211,255,.2); font: 500 17px var(--f-mono); text-align: center; }
.eq:empty { display: none; }
.eq .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 4px; }
.eq .frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 4px 2px; }
.eq .frac > span:last-child { padding-top: 2px; }
.eq .tok { color: var(--star); border-bottom: 1px dashed rgba(255,210,122,.6); cursor: pointer; padding: 0 1px; }
.eq .live { display: block; margin-top: 8px; font-size: 12.5px; color: var(--orbit); word-break: break-word; }
.eq small { font-size: 11.5px; color: var(--dim); display: block; margin-top: 4px; font-family: var(--f-body); }
canvas.graph { width: 100%; height: 120px; border-radius: 10px; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
.verdict { border-radius: 12px; padding: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); display: flex; flex-direction: column; gap: 6px; }
.verdict.hit { border-color: rgba(110,231,168,.5); background: rgba(110,231,168,.07); }
.verdict.miss { border-color: rgba(255,180,94,.5); background: rgba(255,180,94,.07); }
.verdict.ai { border-color: rgba(185,163,255,.45); background: rgba(185,163,255,.07); }
.verdict h4 { margin: 0; font: 600 14px var(--f-display); }
.aitext { white-space: pre-wrap; font-size: 13.5px; color: #dcd6ff; }
#wiInput { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.35); }
.steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #c5cbea; }
.steps b { color: var(--ink); }
.tag { display: inline-block; font: 600 10px var(--f-display); letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; }
.tag.real { background: rgba(110,231,168,.14); color: var(--good); }
.tag.hypo { background: rgba(255,180,94,.14); color: var(--warn); }
.tag.no { background: rgba(255,107,129,.14); color: var(--bad); }
.tag.ai { background: rgba(185,163,255,.16); color: var(--ai); }
.chaos { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; }
.chaos b { font: 600 15px var(--f-mono); }
.note { border-left: 2px solid var(--line); padding: 2px 0 2px 10px; font-size: 13px; color: #c5cbea; }
.note time { display: block; font: 500 11px var(--f-mono); color: var(--dim); }

#log { left: max(84px, calc(env(safe-area-inset-left, 0px) + 84px)); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); width: min(420px, 38vw); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.ev { padding: 8px 12px; font-size: 12.5px; border-radius: 10px; background: rgba(8,10,22,.78); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: evin .35s ease-out; }
.ev time { font: 500 11px var(--f-mono); color: var(--star); margin-right: 6px; }
@keyframes evin { from { opacity: 0; transform: translateY(6px); } }

#time { left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: min(760px, calc(100% - 24px)); padding: 10px 14px; display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px 14px; align-items: center; }
#play { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--star); color: #1a1205; font-size: 18px; font-weight: 700; }
.yr { font: 600 20px var(--f-mono); font-variant-numeric: tabular-nums; min-width: 92px; }
.yr small { display: block; font: 600 10px var(--f-display); letter-spacing: .14em; color: var(--dim); text-transform: uppercase; }
#rate { width: 100%; accent-color: var(--orbit); }
.rate-l { display: flex; justify-content: space-between; white-space: nowrap; font: 500 10.5px var(--f-mono); color: var(--dim); }
#scrub { grid-column: 1 / -1; width: 100%; accent-color: var(--dim); }
#toast { left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top, 0px)); padding: 9px 16px; font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: min(560px, 90vw); text-align: center; }
#toast.show { opacity: 1; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.blabel { position: absolute; font: 600 10.5px var(--f-display); letter-spacing: .08em; color: rgba(233,236,255,.75); transform: translate(12px, -50%); white-space: nowrap; text-shadow: 0 1px 4px #000; }
.blabel.sel { color: var(--star); }
.blabel small { color: var(--dim); font-weight: 500; margin-left: 4px; }

/* ---------- shared bits that only phones show ---------- */
.short { display: none; }
#grab, #peek, #fab, #ticker { display: none; }
.tabs .ti { display: none; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#ticker { left: 50%; transform: translate(-50%, -6px); max-width: calc(100% - 32px); padding: 7px 14px; border-radius: 999px; font-size: 12.5px; background: rgba(8,10,22,.84); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ticker.show { opacity: 1; transform: translate(-50%, 0); }
#ticker time { font: 500 11px var(--f-mono); color: var(--star); margin-right: 6px; }
#coach { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100% - 32px)); padding: 22px 20px 18px; z-index: 30; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
#coach[hidden] { display: none; }
#coach h3 { margin: 0; font: 600 18px var(--f-display); letter-spacing: .03em; }
#coach ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
#coach li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; font-size: 14px; color: #c5cbea; }
#coach li b { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(127,211,255,.12); color: var(--orbit); font: 600 16px var(--f-display); }

/* ---------- phones held upright: the lab becomes a bottom sheet ---------- */
@media (max-width: 820px) and (min-height: 521px) {
  :root { --sheet: 138px; --sb: env(safe-area-inset-bottom, 0px); --ease: cubic-bezier(.2,.8,.2,1); }
  .full { display: none; } .short { display: inline; }
  #top { gap: 6px; left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); }
  .brand { font-size: 12px; padding: 9px 11px; letter-spacing: .12em; }
  .mode button { padding: 6px 11px; font-size: 12px; }
  .vis button { padding: 6px 8px; font: 600 11px var(--f-mono); letter-spacing: 0; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: calc(var(--sheet) + var(--sb)); padding-bottom: var(--sb); border-radius: 22px 22px 0 0; border-left: 0; border-right: 0; border-bottom: 0; box-shadow: 0 -14px 44px rgba(0,0,0,.5); transition: height .34s var(--ease); background: rgba(9,12,25,.9); }
  #grab { display: flex; justify-content: center; padding: 9px 0 3px; touch-action: none; cursor: grab; }
  #grab i { width: 42px; height: 5px; border-radius: 3px; background: rgba(200,210,255,.3); }
  #peek { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 0; background: transparent; padding: 2px 18px 9px; text-align: left; touch-action: none; width: 100%; }
  #peekMain { font: 600 15.5px var(--f-display); letter-spacing: .03em; }
  #peekSub { font: 500 12px var(--f-mono); color: var(--orbit); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabs { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 7px; font-size: 9.5px; letter-spacing: .05em; border-bottom: 0; }
  .tabs button.on { color: var(--star); }
  .tabs .ti { display: block; }
  .tab { padding: 16px 18px 28px; }
  #panel[data-snap="peek"] .tab { visibility: hidden; }
  #time { left: max(10px, env(safe-area-inset-left, 0px)); right: calc(max(10px, env(safe-area-inset-right, 0px)) + 64px); width: auto; transform: none; bottom: calc(var(--sheet) + var(--sb) + 10px); grid-template-columns: auto auto 1fr auto; gap: 2px 10px; padding: 7px 10px 5px; border-radius: 18px; transition: bottom .34s var(--ease); }
  #play { width: 40px; height: 40px; font-size: 15px; }
  .yr { font-size: 16px; min-width: 60px; }
  .rate-l span:first-child, .rate-l span:last-child { display: none; }
  .rate-l { justify-content: center; }
  #reset { padding: 8px 10px; font-size: 11px; }
  #fab { display: grid; place-items: center; right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(var(--sheet) + var(--sb) + 10px); width: 56px; height: 56px; border-radius: 50%; border: 0; background: linear-gradient(145deg, #ffe6ad, #ffb547); color: #1a1205; font: 400 32px/1 var(--f-display); box-shadow: 0 10px 28px rgba(255,180,80,.38); transition: bottom .34s var(--ease), transform .25s var(--ease), background .2s; }
  body.tray #fab { transform: rotate(45deg); }
  body.placing #fab { background: var(--orbit); font-size: 22px; box-shadow: 0 10px 28px rgba(127,211,255,.4); }
  #tools { top: auto; left: auto; right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(var(--sheet) + var(--sb) + 76px); transform: translateY(14px) scale(.94); transform-origin: bottom right; flex-direction: column; padding: 6px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease), bottom .34s var(--ease); }
  body.tray #tools { opacity: 1; pointer-events: auto; transform: none; }
  #tools button { width: 58px; padding: 9px 4px 7px; }
  #log { display: none; }
  #ticker { display: block; top: calc(62px + env(safe-area-inset-top, 0px)); }
  #toast { top: auto; bottom: calc(var(--sheet) + var(--sb) + 84px); }
  .blabel { font-size: 9.5px; }
  html.dragging #panel, html.dragging #time, html.dragging #fab, html.dragging #tools, html.dragging #toast { transition: none; }
}

/* ---------- phones turned sideways ---------- */
@media (max-height: 520px) {
  .full { display: none; } .short { display: inline; }
  #top { top: calc(6px + env(safe-area-inset-top, 0px)); }
  .brand { font-size: 11px; padding: 7px 10px; }
  .mode button, .vis button { padding: 5px 9px; font-size: 11px; }
  #tools { padding: 4px; gap: 2px; top: calc(50% + 18px); }
  #tools button { width: 48px; padding: 5px 2px 4px; font-size: 9px; }
  #tools button .ic { width: 16px; height: 16px; }
  #panel { top: calc(48px + env(safe-area-inset-top, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: min(330px, 42vw); }
  .tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 8.5px; }
  .tabs .ti { display: block; width: 16px; height: 16px; }
  .tab { padding: 10px 12px 14px; gap: 10px; }
  #time { left: calc(env(safe-area-inset-left, 0px) + 72px); right: calc(min(330px, 42vw) + 22px + env(safe-area-inset-right, 0px)); width: auto; transform: none; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); padding: 6px 10px 4px; gap: 2px 10px; }
  #play { width: 36px; height: 36px; font-size: 14px; }
  .yr { font-size: 15px; min-width: 56px; }
  .rate-l span:first-child, .rate-l span:last-child { display: none; } .rate-l { justify-content: center; }
  #log { display: none; }
  #ticker { display: block; top: calc(48px + env(safe-area-inset-top, 0px)); left: calc((100% - min(330px, 42vw)) / 2); }
  #toast { top: auto; bottom: 74px; left: calc((100% - min(330px, 42vw)) / 2); }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } .ev { animation: none; } }
a.brand { color: var(--ink); text-decoration: none; }
.namerow { display: flex; gap: 8px; align-items: center; }
.namerow[hidden], #sizeBox[hidden] { display: none; }
#nameIn { flex: 1; min-width: 0; font: 600 17px var(--f-display); letter-spacing: .02em; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
#nameIn:focus { border-color: var(--star); outline: none; background: rgba(255,210,122,.06); }
.pencil { color: var(--dim); font-size: 13px; }
.sitelinks { display: flex; gap: 14px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.sitelinks a { color: var(--orbit); text-decoration: none; }
noscript p { position: fixed; inset: 30% 20px auto; text-align: center; color: var(--dim); }
