:root {
  --ink: #e8e3d8;
  --dim: #9c968a;
  --bg: #14161c;
  --panel: #1b1e26;
  --line: #2b303b;
  --vg-blue: #4a63a8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #1d212b 0%, var(--bg) 70%);
  color: var(--ink);
  font: 15px/1.6 ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  min-height: 100%;
  display: flex;
  gap: 40px;
  align-items: center;
  justify-content: center;
  padding: 32px;
  flex-wrap: wrap;
}

/* the painting sits in something that reads as a frame, not a video player */
.frame {
  position: relative;
  padding: 14px;
  border-radius: 3px;
  background: linear-gradient(150deg, #6b5330, #3a2c18 45%, #7d6238);
  box-shadow: 0 30px 70px rgba(0,0,0,.65), 0 2px 0 rgba(255,255,255,.08) inset;
  line-height: 0;
}
.stack { position: relative; line-height: 0; }
#stage {
  display: block;
  width: min(46vw, 560px);
  height: auto;
  aspect-ratio: 4 / 5;
  background: #0b0d11;
}
/* annotation overlay: its own DOM canvas, because the WebGL one is fully
   redrawn every frame and anything painted into it would vanish */
#anno {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  cursor: crosshair;
  /* Hidden until annotation mode is on. It is a second 1024x1280 canvas sitting
     on the painting, and while it is in the layer tree the compositor blends and
     rescales it on every frame -- for a surface that is empty almost all of the
     time. On integrated graphics that is not free. */
  display: none;
}
#anno.on { pointer-events: auto; display: block; }
@media (max-width: 900px) {
  #stage { width: min(88vw, 460px); }
  .wrap { padding: 18px; gap: 22px; }
}

.annoBtns { display: flex; gap: 6px; margin: 10px 0 8px; flex-wrap: wrap; }
.annoBtns button, #bases button {
  padding: 4px 10px; font-size: 12px; background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 5px; cursor: pointer;
}
.annoBtns button:hover, #bases button:hover { color: var(--ink); border-color: var(--dim); }
.annoBtns button.primary { color: var(--ink); border-color: var(--vg-blue); }
#annoNote, #sayText, #chatText {
  width: 100%; padding: 5px 8px; font-size: 12px; font-family: inherit;
  background: #12141a; color: var(--ink);
  border: 1px solid var(--line); border-radius: 5px;
}
#annoOut { font-family: ui-monospace, monospace; word-break: break-all; }

#boot {
  position: absolute; inset: 14px;
  display: grid; place-items: center;
  background: #0b0d11; color: var(--dim);
  font-size: 14px; line-height: 1.4;
  transition: opacity .5s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }

.hud { width: min(400px, 92vw); }
.hud h1 { font-size: 21px; font-weight: 600; margin: 0 0 2px; letter-spacing: .01em; }
.hud h1 span { font-size: 12px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.lede { color: var(--dim); margin: 0 0 20px; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 16px; }
dt { color: var(--dim); font-size: 13px; }
dd { margin: 0; font-variant-numeric: tabular-nums; }
#conn.ok { color: #7fbf7f; }
#conn.bad { color: #d08a5a; }

label { display: block; color: var(--dim); font-size: 14px; margin: 6px 0; cursor: pointer; }
label input { accent-color: var(--vg-blue); margin-right: 8px; }

.slider { margin: 14px 0 4px; }
.slider label { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 6px; }
.slider output { color: var(--ink); font-variant-numeric: tabular-nums; }
.slider input[type=range] { width: 100%; accent-color: var(--vg-blue); }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--dim); line-height: 1.5; }
.hint b { color: var(--ink); font-variant-numeric: tabular-nums; }

.panel {
  margin: 16px 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.panel > summary { cursor: pointer; color: var(--dim); font-size: 13px; user-select: none; }
.panel > summary::marker { color: var(--line); }
.basis { margin: 8px 0 2px; }
.basis label {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 2px; font-size: 12px; font-family: ui-monospace, monospace;
}
.basis output { color: var(--ink); font-variant-numeric: tabular-nums; }
.basis input[type=range] { width: 100%; accent-color: var(--vg-blue); margin: 0; }
#bases button {
  margin-top: 10px; padding: 4px 10px; font-size: 12px;
  background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 5px; cursor: pointer;
}
#bases button:hover { color: var(--ink); border-color: var(--dim); }

.note {
  margin-top: 20px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel);
  font-size: 13px; color: var(--dim);
}
.note p { margin: 0 0 10px; }
.note p:last-child { margin-bottom: 0; }
.note b { color: var(--ink); font-weight: 600; }
.note i { color: var(--ink); font-style: normal; }

#chatLog {
  max-height: 190px; overflow-y: auto; margin: 10px 0 0;
  font-size: 12px; line-height: 1.55;
}
#chatLog p { margin: 0 0 5px; }
#chatLog .u { color: var(--dim); }
#chatLog .v { color: var(--ink); }
#chatLog .v span {
  color: var(--dim); font-size: 11px; margin-left: 6px;
  font-family: ui-monospace, monospace;
}
