/* ---------------------------------------------------------------------------
   Saccades — therapist console
   Two themes; every colour is a token so the whole app re-skins from here.
--------------------------------------------------------------------------- */

:root,
[data-theme="daylight"] {
  --bg:          #ede8e1;   /* warm sand */
  --surface:     #fcfaf7;   /* ivory panels */
  --surface-alt: #f4efe8;   /* recessed wells */
  --line:        #e2dad0;
  --line-strong: #cfc4b6;
  --ink:         #2b2926;
  --ink-soft:    #6c645a;
  --ink-faint:   #9a9086;
  --accent:      #7a4a63;   /* mulberry */
  --accent-hover:#653c52;
  --accent-ink:  #ffffff;
  --accent-wash: #f0e6eb;
  --live:        #4c7c5b;
  --idle:        #b4a89a;
  --stop:        #6e3232;
  --stop-hover:  #5a2828;
  --shadow-sm:   0 1px 2px rgba(58, 46, 34, .06);
  --shadow-md:   0 2px 6px rgba(58, 46, 34, .07), 0 12px 28px rgba(58, 46, 34, .06);
  --stage-frame: rgba(43, 41, 38, .10);
  --chip-ring:   rgba(30, 26, 22, .22);
}

[data-theme="dusk"] {
  --bg:          #14161a;
  --surface:     #1d2126;
  --surface-alt: #262b31;
  --line:        #323940;
  --line-strong: #4c555d;
  --ink:         #e9ebe8;
  --ink-soft:    #a2abad;
  --ink-faint:   #6f797c;
  --accent:      #a4658a;
  --accent-hover:#b57599;
  --accent-ink:  #ffffff;
  --accent-wash: #2c2430;
  --live:        #6fbf8a;
  --idle:        #5a6469;
  --stop:        #a35a5a;
  --stop-hover:  #b56b6b;
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md:   0 2px 8px rgba(0, 0, 0, .35), 0 14px 34px rgba(0, 0, 0, .3);
  --stage-frame: rgba(255, 255, 255, .09);
  --chip-ring:   rgba(255, 255, 255, .26);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

button { font: inherit; color: inherit; }

.serif {
  font-family: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
}

/* ============================== app shell ==============================
   header  /  text + distress + client view  /  control shelf
------------------------------------------------------------------------ */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 0 20px 18px;
  max-width: 1560px;
  margin: 0 auto;
}

.main {
  display: grid;
  grid-template-columns: minmax(360px, 470px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

/* The Text panel takes the slack and scrolls if it must; the readings stay
   pinned below it, always fully in view during a session. */
.col-msg {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}
.col-msg #msgPanel { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.col-msg #sudsPanel { flex: none; }

.shelf {
  display: grid;
  grid-template-columns: minmax(470px, 1.42fr) minmax(230px, .78fr) minmax(270px, .9fr);
  gap: 12px;
}

/* ------------------------------- header -------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px 2px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.015em;
}
.wordmark .mark { width: 22px; height: 22px; display: block; flex: none; }
.topbar .spacer { flex: 1; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--idle);
  flex: none;
}
.status.on .dot {
  background: var(--live);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 22%, transparent);
}
.status.on { color: var(--ink); }

/* ------------------------------ buttons -------------------------------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-soft); padding: 8px 10px; }
.btn.quiet:hover { color: var(--ink); background: var(--surface); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }

.iconbtn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.iconbtn:hover { background: var(--surface); color: var(--ink); }
.iconbtn svg { width: 19px; height: 19px; }

/* =============================== stage ================================= */
.stage-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
  justify-items: end;   /* the client view sits flush with the right edge */
}

.preview-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  height: 100%;
  width: auto;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--stage-frame);
  background: var(--surface-alt);
}
.stage { position: absolute; inset: 0; }

.stage-caption {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.stage-caption .sep { opacity: .45; }
.stage-area.hidden .preview-wrap { visibility: hidden; }

.stage-tools {
  position: absolute; right: 10px; bottom: 10px;
  display: flex; gap: 6px;
}
.stage-tools .btn {
  backdrop-filter: blur(6px);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

/* ======================== start / hold controls ========================= */
.session-panel { display: flex; flex-direction: column; }
.session-transport {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

.speed {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.speed .label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.speed .readout {
  font-family: "Fraunces", Georgia, serif;
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  min-width: 2.4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1;
  min-width: 80px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface); cursor: pointer;
}

.btn-pause {
  flex: none;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-pause:hover { border-color: var(--line-strong); color: var(--ink); }
.btn-pause[aria-pressed="true"] {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-pause svg { width: 18px; height: 18px; }

.btn-go {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .005em;
  cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: background .15s ease;
}
.btn-go:hover { background: var(--accent-hover); }
.btn-go.running { background: var(--stop); }
.btn-go.running:hover { background: var(--stop-hover); }
.btn-go svg { width: 15px; height: 15px; }

/* =============================== shelf ================================= */
.shelf {
  display: grid;
  grid-template-columns: minmax(470px, 1.42fr) minmax(230px, .78fr) minmax(270px, .9fr);
  gap: 12px;
}

.panel {
  background: var(--surface);
  border-radius: 16px;
  padding: 15px 17px 17px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
  flex-wrap: wrap;
}
.panel-head h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 15.5px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.005em;
}
.panel-head .spacer { flex: 1; }
/* buttons that should wrap as a pair rather than one at a time */
.head-actions { display: flex; gap: 6px; flex: none; align-items: center; }
/* the second row of buttons under the Distress Tracking head */
.suds-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -3px 0 13px;
}
/* a hairline between groups of buttons in a panel head */
.head-sep {
  width: 1px; height: 20px;
  background: var(--line-strong);
  margin: 0 3px;
  flex: none;
}

.sub {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-faint);
  margin: 0 0 8px;
  font-weight: 500;
}
.stack + .stack { margin-top: 15px; }
.stack input[type="range"] { margin-top: 2px; }

/* ---- swatches: colours are circles, backgrounds are squircles ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  width: 38px; height: 38px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  padding: 0;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background-clip: padding-box;
  background-size: cover;
  background-position: center;
  color: var(--ink-soft);
  transition: transform .1s ease, box-shadow .12s ease;
}
.chip:hover { transform: translateY(-1px); color: var(--ink); }
.chip[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
.chip svg { width: 17px; height: 17px; }
.chip .glyph { font-size: 21px; line-height: 1; }

.chip.round { border-radius: 50%; }
.chip.soft  { border-radius: 11px; }
.chip.tool  { background: var(--surface-alt); }

/* Two rows of colours, then a rule, then the tools that are not colours. */
.stimulus-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.chips.gems {
  display: grid;
  grid-template-columns: repeat(10, auto);
  gap: 5px;
  justify-content: start;
  flex: none;
}
.col-sep {
  width: 1px;
  align-self: stretch;
  background: var(--line-strong);
  opacity: .85;
  flex: none;
  margin: 2px 4px;
}
.chips.tools {
  display: grid;
  grid-template-columns: repeat(3, auto);
  align-content: center;
  gap: 6px;
  flex: none;
}

/* Colour choices are cut as diamonds. A rotated square (rather than a
   clip-path) keeps the selection ring following the same shape. */
.chip.gem {
  width: 34px; height: 34px;
  border-radius: 5px;
  transform: rotate(45deg);
  margin: 6px 5px;
  border-color: transparent;
  box-shadow: inset 0 0 0 1px var(--chip-ring);
}
.chip.gem:hover { transform: translate(0, -2px) rotate(45deg); }
.chip.gem > * { transform: rotate(-45deg); }
.chip.gem[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px var(--chip-ring),
              0 0 0 2px var(--surface),
              0 0 0 4px var(--accent);
}
.chips.gems { gap: 5px; padding: 2px 0; }

.chip.locked {
  opacity: .38;
  cursor: default;
}
.chip.locked:hover { transform: none; }
.chip.gem.locked:hover { transform: rotate(45deg); }

.chip .badge {
  position: absolute; right: -3px; top: -5px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 7.5px; font-weight: 700; letter-spacing: .05em;
  padding: 1px 4px; border-radius: 999px;
}

/* ---- segmented controls ------------------------------------------------ */
.segment {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  max-width: 100%;
}
.segment button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s ease, color .14s ease;
}
.segment button:hover { color: var(--ink); }
.segment button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.segment.icons button { width: 44px; height: 36px; }
.segment.icons button svg { width: 21px; height: 21px; }
.segment.text button {
  padding: 0 15px; height: 32px;
  font-size: 13px; font-weight: 500;
}

/* ---- text panel ----------------------------------------------------- */
.msg-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-alt);
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: 17px;
  font-weight: 600;
}
.msg-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.msg-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 7px;
  font-size: 11.5px; color: var(--ink-faint);
}
.msg-meta .count { font-variant-numeric: tabular-nums; }
.msg-meta .count.full { color: var(--accent); }

.panel.disabled { opacity: .45; }
.panel.disabled .msg-input,
.panel.disabled .segment button { pointer-events: none; }
.panel-note {
  font-size: 11.5px;
  color: var(--ink-faint);
  line-height: 1.5;
  margin: 9px 0 0;
}

/* ---- distress readings -------------------------------------------------- */

.suds-list {
  display: flex; flex-wrap: nowrap; gap: 6px;
  min-height: 38px; align-items: center;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  overscroll-behavior-x: contain;
}
.suds-list::-webkit-scrollbar { height: 7px; }
.suds-list::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 999px;
}
.suds-list::-webkit-scrollbar-track { background: transparent; }

/* one trigger's readings from the next */
.suds-divider {
  flex: none;
  width: 2px; height: 26px;
  margin: 0 5px;
  border-radius: 2px;
  background: var(--line-strong);
}
.suds-chip {
  flex: none;
  min-width: 36px; height: 32px; padding: 0 8px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 700;
  color: #16181a;
  box-shadow: inset 0 0 0 1px var(--chip-ring);
  cursor: default;
}
.suds-empty { font-size: 12.5px; color: var(--ink-faint); }

/* ---- drift ------------------------------------------------------------- */
.drift-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.drift-head .sub { margin: 0; }
.drift-rate {
  display: flex; align-items: center; gap: 10px;
  margin-top: 9px;
}
.drift-rate input[type="range"] { height: 3px; }
.drift-rate input[type="range"]::-webkit-slider-thumb { width: 15px; height: 15px; border-width: 2px; }
.drift-rate .tick {
  font-size: 10.5px; color: var(--ink-faint);
  letter-spacing: .05em; white-space: nowrap;
}
.drift-rate.off { opacity: .35; pointer-events: none; }

/* ---- session panel ----------------------------------------------------- */
.stats { display: flex; flex-direction: column; gap: 2px; }
.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.stat:last-child { border-bottom: 0; }
.stat .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint);
}
.stat .v {
  font-family: "Fraunces", Georgia, serif;
  font-size: 25px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat.minor .v { font-size: 14px; font-family: inherit; color: var(--ink-soft); font-weight: 500; }
.session-actions { display: flex; gap: 8px; margin-top: 12px; }

/* switch */
.switch {
  position: relative;
  width: 40px; height: 22px;
  border-radius: 999px;
  border: 0;
  background: var(--line-strong);
  cursor: pointer;
  padding: 0;
  transition: background .18s ease;
  flex: none;
}
.switch[aria-pressed="true"] { background: var(--accent); }
.switch::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .18s ease;
}
.switch[aria-pressed="true"]::after { transform: translateX(18px); }

/* ========================== invite dialog rows ========================= */
.invite-row {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
.invite-row .switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
}
.invite-row .pw-input {
  margin-top: 10px;
  font-size: 15px;
}
.invite-row .email-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}
.invite-row .email-row .pw-input { margin-top: 0; flex: 1; min-width: 0; }
.invite-row .email-row .btn { flex: none; }
.invite-row .panel-note { margin-top: 8px; }
.invite-row .panel-note.warn { color: var(--accent); }

/* ============================ mode chooser ============================= */
/* Shown once on load, before anything else can be touched. Which mode you are
   in changes which affordances make sense, and guessing wrong is worse than
   asking. */
.mode-back {
  position: fixed; inset: 0; z-index: 80;
  display: none;
  align-items: center; justify-content: center;
  padding: 26px;
  background: color-mix(in srgb, var(--bg) 72%, rgba(0,0,0,.6));
  backdrop-filter: blur(4px);
  overflow-y: auto;
}
.mode-back.show { display: flex; }
.mode-card {
  width: min(880px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 30px 32px 32px;
  box-shadow: var(--shadow-lg, 0 24px 70px rgba(0,0,0,.3));
}
.mode-card h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px; font-weight: 600; margin: 0 0 8px;
  letter-spacing: -.012em;
}
.mode-card > p {
  margin: 0 0 22px; font-size: 13.5px; color: var(--ink-faint); line-height: 1.6;
}
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.mode {
  display: flex; flex-direction: column; gap: 8px;
  text-align: left;
  padding: 18px 18px 20px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink);
  font: inherit; cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.mode:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode-name { font-family: "Fraunces", Georgia, serif; font-size: 17px; font-weight: 600; }
.mode-note { font-size: 12.5px; line-height: 1.55; color: var(--ink-faint); }

@media (max-width: 780px) {
  .mode-grid { grid-template-columns: 1fr; }
}

/* =============================== modal ================================= */
.modal-back {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--bg) 55%, rgba(0,0,0,.55));
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  z-index: 60;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  color: var(--ink);
  border-radius: 20px;
  padding: 24px 26px;
  width: min(540px, 100%);
  max-height: 86vh;
  overflow: auto;
  box-shadow: var(--shadow-md);
}
.modal h3 {
  font-family: "Fraunces", Georgia, serif;
  margin: 0 0 8px; font-size: 21px; font-weight: 600;
}
.modal p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin: 0 0 10px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

.link-box {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 11px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  word-break: break-all;
}
.qr {
  display: block; margin: 16px auto 0;
  width: 168px; height: 168px;
  background: #fff; border-radius: 12px; padding: 8px;
}
.qr svg { width: 100%; height: 100%; display: block; }

.ill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; margin-top: 14px; }
.ill-grid button {
  aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface-alt);
  border-radius: 14px; font-size: 27px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ill-grid button:hover { border-color: var(--line-strong); }
.ill-grid button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); border-color: transparent; }

.field { margin-top: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; color: var(--ink-soft); }
.field input[type="text"], .field input[type="url"], .field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-alt); color: var(--ink);
  font: inherit;
}
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; line-height: 1.5; }

/* ============================= responsive ============================== */
@media (max-width: 1080px) {
  .shelf { grid-template-columns: 1fr 1fr; }
  .shelf .panel:first-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .app {
    height: auto;
    min-height: 100%;
    grid-template-rows: auto auto auto;
    padding: 0 12px 16px;
  }
  .main {
    grid-template-columns: 1fr;
    grid-template-areas: "stage" "msg";
  }
  .col-msg { grid-area: msg; overflow: visible; }
  .stage-area { grid-area: stage; min-height: 200px; justify-items: stretch; }
  .shelf { grid-template-columns: 1fr; }
  .shelf .panel:first-child { grid-column: auto; }
  .preview-wrap { width: 100%; height: auto; }
  .topbar { flex-wrap: wrap; }
}

/* The sun/moon themeBtn stays reachable on the "How are you running this
   session?" screen, sitting above its dimmed backdrop in the top right. */
#themeBtn { position: relative; z-index: 90; background: var(--surface); }
