@font-face {
  font-family: "Inter"; font-weight: 100 900; font-display: swap;
  src: url(/couch/tv-home/web/fonts/inter-latin-wght-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Antonio"; font-weight: 300; font-display: swap;
  src: url(/couch/tv-home/web/fonts/antonio-latin-300.woff2) format("woff2");
}

:root {
  --bg: #0d0e10;
  --stage: #121316;
  --panel: #17181b;
  --raise: #1f2024;
  --line: #2a2c31;
  --line-2: #393b41;
  --text: #ecedf0;
  --text-2: #a4a6ad;
  --text-3: #858890;
  --accent: #6f9bff;
  --accent-ink: #0b1430;
  --warn: #f2b25c;
  --heavy: #ff8a73;
  --ok: #7fd4a0;
  --r: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, sans-serif; font-size: 13px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
::selection { background: rgba(111, 155, 255, 0.35); color: #fff; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; opacity: 0.38; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg { width: 18px; height: 18px; flex: none; }
/* our own line icons; an icon from the icon sets (it says focusable="false") carries its own paint */
svg:not([focusable]) { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg .f { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: var(--r);
  background: var(--raise); box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 550; transition: background 160ms var(--ease), box-shadow 160ms var(--ease);
}
.btn:hover { background: #26282d; box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.wide { width: 100%; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--raise); color: var(--text); }
.btn.primary { background: var(--text); color: #111214; box-shadow: none; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--heavy); }
.btn.armed { background: rgba(255, 138, 115, 0.14); color: var(--heavy); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; color: var(--text-2);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--raise); color: var(--text); }
.link-btn { color: var(--text-2); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); margin-top: 10px; }
.link-btn:hover { color: var(--text); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px; border-radius: 14px;
  background: var(--raise); color: var(--text-3); font-size: 12px; font-weight: 550;
}
.chip.on { color: var(--text); }
.chip svg { width: 16px; height: 16px; }

/* ---------- start screen ---------- */
.start { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.start-inner { width: min(1180px, 100%); }
.start-title { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.08; font-weight: 650; letter-spacing: -0.025em; }
.start-sub { margin-top: 12px; font-size: 15px; color: var(--text-2); max-width: 52ch; }
.purposes { margin-top: 36px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.purpose {
  text-align: left; display: flex; flex-direction: column; border-radius: 12px; padding: 8px 8px 14px;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease), background 260ms var(--ease);
}
.purpose:hover { transform: translateY(-3px); background: #1b1c20; box-shadow: inset 0 0 0 1px var(--line-2), 0 18px 40px rgba(0, 0, 0, 0.35); }
.purpose-shot {
  display: block; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.purpose-shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.purpose-name { margin: 14px 6px 0; font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.purpose-blurb { margin: 4px 6px 0; color: var(--text-2); font-size: 12.5px; }
.start-foot { margin-top: 28px; display: flex; align-items: center; gap: 16px; }
.start-note { color: var(--text-3); font-size: 12.5px; }
@media (max-width: 1000px) { .purposes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .purposes { grid-template-columns: 1fr; } }

/* ---------- editor frame ---------- */
.editor {
  height: 100vh; display: grid;
  grid-template-columns: 216px minmax(0, 1fr) 312px; grid-template-rows: 52px minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "layers stage panel";
}
.bar {
  grid-area: bar; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.bar-left, .bar-mid, .bar-right { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 680; letter-spacing: -0.01em; margin-right: 6px; }
.purpose-pill {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px 0 11px; border-radius: 14px;
  background: var(--raise); color: var(--text-2); font-weight: 550; font-size: 12.5px;
}
.purpose-pill:hover { color: var(--text); }
.purpose-pill svg { width: 15px; height: 15px; }

/* speed meter */
.speed-wrap { position: relative; }
.speed { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; border-radius: var(--r); }
.speed:hover { background: var(--raise); }
.speed-label { color: var(--text-2); font-size: 12px; font-weight: 550; }
.speed-label i { font-style: normal; color: var(--text-3); font-weight: 450; margin-left: 2px; }
.speed-track { width: 84px; height: 6px; border-radius: 3px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.speed-fill { display: block; height: 100%; border-radius: 3px; transition: width 380ms var(--ease), background 380ms var(--ease); }
.speed-word { min-width: 42px; font-weight: 650; font-size: 12.5px; text-align: left; }
.lvl-fast .speed-fill { background: var(--ok); } .lvl-fast .speed-word { color: var(--ok); }
.lvl-ok .speed-fill { background: var(--warn); } .lvl-ok .speed-word { color: var(--warn); }
.lvl-heavy .speed-fill { background: var(--heavy); } .lvl-heavy .speed-word { color: var(--heavy); }
.speed-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 300px; padding: 14px;
  border-radius: 10px; background: #1c1d21; box-shadow: inset 0 0 0 1px var(--line-2), 0 16px 40px rgba(0, 0, 0, 0.5);
}
.speed-head { font-weight: 620; margin-bottom: 10px; }
.speed-list { list-style: none; display: grid; gap: 6px; margin-bottom: 10px; }
.speed-list li { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); }
.speed-list b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* layers */
.layers { grid-area: layers; border-right: 1px solid var(--line); background: var(--panel); padding: 16px 10px; overflow: auto; }
.layers .psec-title { padding: 0 8px; }
.layers-list { display: grid; gap: 1px; margin-top: 8px; }
.layer {
  display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 2px 0 10px; border-radius: 6px;
  color: var(--text-2); cursor: pointer; transition: background 120ms var(--ease), color 120ms var(--ease);
}
.layer:hover { background: var(--raise); color: var(--text); }
.layer.on { background: rgba(111, 155, 255, 0.14); color: var(--text); }
.layer.off .layer-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.layer .icon-btn { width: 26px; height: 26px; opacity: 0; }
.layer:hover .icon-btn, .layer.off .icon-btn, .layer.on .icon-btn { opacity: 1; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layers-hint { margin: 18px 8px 0; color: var(--text-3); font-size: 12px; }

/* stage and the TV */
.stage {
  grid-area: stage; position: relative; display: flex; overflow: auto;
  background: radial-gradient(ellipse at 50% 42%, #1a1b1f 0%, var(--stage) 62%);
}
/* margin auto centres the TV, and still scrolls to every edge when zoomed in past the window */
.stage-inner { margin: auto; padding: 20px; display: flex; flex-direction: column; align-items: center; }
.tv {
  position: relative; border-radius: 6px; background: #000;
  box-shadow: 0 0 0 9px #060607, 0 0 0 10px #2b2c31, 0 30px 70px rgba(0, 0, 0, 0.55), 0 8px 18px rgba(0, 0, 0, 0.4);
}
.screen { position: absolute; inset: 0; overflow: hidden; border-radius: 2px; }
.screen iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; background: #000; }
.screen-wait {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-2);
  background: #0b0b0d; opacity: 0; pointer-events: none; transition: opacity 260ms var(--ease);
}
.screen.loading .screen-wait { opacity: 1; }
.tv-stand { width: 18%; max-width: 170px; height: 20px; margin-top: 9px; position: relative; }
.tv-stand::before { content: ""; position: absolute; left: 50%; top: 0; width: 18px; height: 12px; transform: translateX(-50%); background: linear-gradient(#1e1f23, #141518); }
.tv-stand::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border-radius: 6px 6px 3px 3px; background: #1c1d21; box-shadow: inset 0 1px 0 #2d2e33, 0 10px 24px rgba(0, 0, 0, 0.5); }
.store-note { position: absolute; bottom: 14px; color: var(--warn); font-size: 12.5px; }

/* selection */
.overlay { position: absolute; inset: 0; touch-action: none; }
.hover-box, .sel-box { position: absolute; pointer-events: none; border-radius: 3px; }
.hover-box { box-shadow: 0 0 0 1px rgba(111, 155, 255, 0.7); }
.sel-box { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 1px rgba(0, 0, 0, 0.25) inset; }
.sel-box.is-hidden { box-shadow: 0 0 0 1.5px var(--text-3); background: rgba(0, 0, 0, 0.35); }
/* 16 px handles you can see, and a 32 px area you can catch */
.handle {
  position: absolute; width: 16px; height: 16px; border-radius: 4px; background: #fff; pointer-events: auto;
  box-shadow: 0 0 0 1.5px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.handle::after { content: ""; position: absolute; inset: -8px; }
.h-nw { left: -9px; top: -9px; cursor: nwse-resize; }
.h-se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.h-ne { right: -9px; top: -9px; cursor: nesw-resize; }
.h-sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.sel-tag {
  position: absolute; left: -1px; top: -26px; height: 20px; padding: 0 7px; border-radius: 4px;
  background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 650; line-height: 20px; white-space: nowrap;
}
.guide { position: absolute; pointer-events: none; background: #ff5fa2; }
.gx { top: 0; bottom: 0; width: 1px; }
.gy { left: 0; right: 0; height: 1px; }

/* ---------- side panel ---------- */
.panel { grid-area: panel; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding-bottom: 40px; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 6px; }
.phead-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.psec { padding: 14px 16px 16px; border-bottom: 1px solid var(--line); }
.psec:last-child { border-bottom: 0; }
.psec-title { font-size: 11.5px; font-weight: 600; color: var(--text-3); margin-bottom: 10px; }
.field { margin-top: 12px; }
.field:first-of-type { margin-top: 0; }
.field-label { display: block; color: var(--text-2); font-size: 12px; margin-bottom: 6px; }
.note { margin-top: 10px; color: var(--text-3); font-size: 12px; line-height: 1.5; }

.seg { display: flex; padding: 2px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.seg-btn {
  flex: 1; min-width: 0; height: 28px; padding: 0 6px; border-radius: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 140ms var(--ease), color 140ms var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px rgba(0, 0, 0, 0.3); }

.slider { display: flex; align-items: center; gap: 10px; }
.slider input { flex: 1; min-width: 0; accent-color: var(--accent); height: 18px; }
.slider-val { width: 44px; text-align: right; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }

.num-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.num { display: flex; align-items: center; height: 32px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); padding-left: 9px; }
.num:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.num-label { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.num input { width: 100%; min-width: 0; height: 100%; border: 0; background: none; padding: 0 8px 0 6px; text-align: right; font-variant-numeric: tabular-nums; outline: none; }
.num input::-webkit-inner-spin-button { display: none; }

.select, .words {
  width: 100%; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); border: 0; outline: none;
}
.select { height: 32px; padding: 0 10px; margin-top: 10px; }
.field .select { margin-top: 0; }
.words { padding: 9px 10px; resize: vertical; line-height: 1.45; margin-bottom: 4px; }
.select:focus, .words:focus { box-shadow: inset 0 0 0 1px var(--accent); }
.words::placeholder { color: var(--text-3); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); transition: transform 140ms var(--ease); }
.sw:hover { transform: scale(1.08); }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--accent); }
.sw-pick {
  width: 26px; height: 26px; border: 0; padding: 3px; cursor: pointer; border-radius: 50%;
  background: conic-gradient(#ff6b6b, #ffd166, #7bd88f, #5ec8f2, #8b7bff, #f27bd0, #ff6b6b);
}
.sw-pick::-webkit-color-swatch-wrapper { padding: 0; }
.sw-pick::-webkit-color-swatch { border: 2px solid var(--panel); border-radius: 50%; }

.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.thumb { display: flex; flex-direction: column; gap: 5px; text-align: left; color: var(--text-2); font-size: 12px; border-radius: 6px; padding: 3px 3px 5px; }
.thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; }
.thumb span { padding: 0 2px; }
.thumb:hover { color: var(--text); background: var(--raise); }
.thumb.on { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.thumb.all { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; }
.thumb-stack { position: relative; width: 50%; flex: none; aspect-ratio: 16 / 9; }
.thumb-stack img { position: absolute; width: 86%; height: 86%; aspect-ratio: auto; }
.thumb-stack img:last-child { right: 0; bottom: 0; box-shadow: -3px -3px 0 var(--panel); }
.thumb.all.on .thumb-stack img:last-child, .thumb.all:hover .thumb-stack img:last-child { box-shadow: -3px -3px 0 var(--raise); }
.psec .btn.wide { margin-top: 12px; }

.apps { list-style: none; display: grid; gap: 2px; margin-top: 10px; }
.app-row { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 2px 0 2px; border-radius: 6px; background: transparent; cursor: grab; }
.app-row:hover { background: var(--raise); }
.app-row img, .app-dot { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; flex: none; background: var(--raise); }
.app-row .grip { color: var(--text-3); display: flex; }
.app-row .grip svg { width: 16px; height: 16px; }
.app-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row.dragging { opacity: 0.4; }
.app-row.drop { box-shadow: inset 0 2px 0 var(--accent); }

.soon { margin-top: 10px; padding: 10px 12px; border-radius: var(--r); background: rgba(242, 178, 92, 0.1); color: #f0cf9f; font-size: 12.5px; line-height: 1.5; }
.soon b { color: var(--warn); font-weight: 650; }

/* ---------- v2: tabs, layers, Add, guides, groups ---------- */
.editor { grid-template-columns: 240px minmax(0, 1fr) 320px; }
.bar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.btn.toggle.on { background: rgba(111, 155, 255, 0.16); color: var(--text); }
.tabs { display: flex; gap: 2px; padding: 2px; margin: 0 4px 12px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.tab { flex: 1; height: 30px; border-radius: 6px; color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.tab.on { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.layer-head {
  margin: 12px 8px 4px; padding: 4px 0; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  border-radius: 4px; transition: background 120ms var(--ease);
}
.layer-head:first-child { margin-top: 0; }
.layer-head.drop, .layer.drop { box-shadow: inset 0 2px 0 var(--accent); }
.layer-empty { margin: 0 10px 4px; color: var(--text-3); font-size: 12px; }
.layer.locked .layer-name { color: var(--text-3); }
.layer .icon-btn.keep { opacity: 1; color: var(--text-3); }
.layer.dragging { opacity: 0.4; }
.layer { gap: 0; }
.layer .layer-name { flex: 1; min-width: 0; }
.layer-input { flex: 1; min-width: 0; height: 26px; border: 0; border-radius: 5px; padding: 0 6px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); outline: none; }

#add-pane { padding: 0 4px; }
.add-title { margin: 16px 6px 8px; }
.add-title:first-child { margin-top: 2px; }
.add-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.add-item {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 4px 4px 6px; border-radius: var(--r); min-width: 0;
  background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 12px; font-weight: 550; text-align: left;
  transition: background 140ms var(--ease), color 140ms var(--ease), transform 140ms var(--ease);
}
.add-item:hover { background: #26282d; color: var(--text); }
.add-item:active { transform: scale(0.98); }
.add-ic { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--bg); color: var(--text); }
.add-ic svg { width: 18px; height: 18px; }
#add-pane .select { margin-top: 0; }
#add-pane .note { margin: 8px 6px 0; }

.align-row { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 12px; padding: 2px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.align-row .icon-btn { flex: 1; min-width: 30px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.btn-row:first-of-type { margin-top: 0; }
.psec .btn-row + .btn-row { margin-top: 6px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap .seg-btn { flex: 1 0 30%; }
.num-row.two { grid-template-columns: 1fr 1fr; }
.text-in { margin-top: 0; }
.app-name em { font-style: normal; color: var(--accent); font-size: 11.5px; margin-left: 4px; }

.safe-box { position: absolute; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255, 196, 92, 0.75); border-radius: 2px; }
.safe-box.title { box-shadow: inset 0 0 0 1px rgba(255, 196, 92, 0.35); }
.grid-lines {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.09) 1px, transparent 1px);
}
.group-box { position: absolute; pointer-events: none; border-radius: 4px; box-shadow: 0 0 0 1px rgba(111, 155, 255, 0.55); outline: 1px dashed rgba(111, 155, 255, 0.55); outline-offset: 4px; }
.sel-box.is-locked { box-shadow: 0 0 0 1.5px var(--text-3); }
.drop-zone { position: absolute; pointer-events: none; border-radius: 18px; box-shadow: 0 0 0 2px rgba(111, 155, 255, 0.35); }
.drop-zone.on { box-shadow: 0 0 0 2px var(--accent); background: rgba(111, 155, 255, 0.12); }

@media (max-width: 1366px) {
  #reset span, .toggle span { display: none; }
}
/* ---------- v3 ---------- */
/* panels fold away, and at small widths Layers and Add slide over the canvas */
.editor.no-left { grid-template-columns: 0 minmax(0, 1fr) 320px; }
.editor.no-right { grid-template-columns: 240px minmax(0, 1fr) 0; }
.editor.no-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
.editor.no-left .layers, .editor.no-right .panel { display: none; }
@media (max-width: 1366px) {
  .editor, .editor.no-right { grid-template-columns: 0 minmax(0, 1fr) 288px; }
  .editor.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .editor .layers { display: none; }
  .editor.show-left .layers {
    display: block; position: fixed; left: 0; top: 52px; bottom: 0; width: 264px; z-index: 30;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45);
  }
}
.layers { padding-top: 0; }
.tabs { position: sticky; top: 0; z-index: 2; margin: 0 -10px 12px; padding: 12px 14px 10px; background: var(--panel); border-radius: 0; box-shadow: 0 1px 0 var(--line); }
.tabs .tab { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.tabs .tab.on { background: var(--raise); box-shadow: inset 0 0 0 1px var(--line-2); }
.zoom { display: inline-flex; align-items: center; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.zoom .icon-btn { width: 28px; height: 28px; }
.zoom-val { min-width: 46px; height: 28px; color: var(--text-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.zoom-val:hover { color: var(--text); }
.remote-btn { background: rgba(111, 155, 255, 0.12); color: var(--text); box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.35); }
.remote-btn.on { background: var(--accent); color: var(--accent-ink); }
.remote-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; align-self: stretch; margin-bottom: 14px;
  padding: 8px 8px 8px 14px; border-radius: 10px; background: rgba(111, 155, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.35); color: var(--text);
}
.editor.remote .overlay { pointer-events: none; }
.editor.remote .overlay > * { display: none; }
.editor.remote .tv { box-shadow: 0 0 0 9px #060607, 0 0 0 11px var(--accent), 0 30px 70px rgba(0, 0, 0, 0.55); }

.toast {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20; max-width: min(560px, 90%);
  padding: 10px 16px; border-radius: 10px; background: #26282d; color: var(--text); font-size: 13px;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 14px 30px rgba(0, 0, 0, 0.45);
}
.dialog-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(6, 7, 9, 0.62); }
.dialog { width: min(420px, calc(100% - 32px)); padding: 22px; border-radius: 14px; background: #1b1c20; box-shadow: inset 0 0 0 1px var(--line-2), 0 30px 70px rgba(0, 0, 0, 0.55); }
.dialog h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.dialog p { margin: 8px 0 16px; color: var(--text-2); }
.dialog p b { color: var(--text); font-weight: 600; }

.drop-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none;
  background: rgba(111, 155, 255, 0.22); box-shadow: inset 0 0 0 3px var(--accent); color: #fff; font-size: 15px; font-weight: 650;
  transition: opacity 160ms var(--ease);
}
.stage.dropping .drop-hint { opacity: 1; }

/* a small picture inside a choice */
.seg.pics .seg-btn { height: auto; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pic { width: 48px; height: 28px; stroke: none; }
.pic .pk { fill: #2c3a52; stroke: rgba(255, 255, 255, 0.18); stroke-width: 1; }
.pic .pm { fill: #121a24; stroke: none; }
.pic .pd { fill: rgba(255, 255, 255, 0.9); stroke: rgba(255, 255, 255, 0.9); stroke-width: 1.6; stroke-linejoin: round; }
.layouts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.layout { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 2px; border-radius: var(--r); color: var(--text-2); font-size: 11px; font-weight: 550; text-align: center; line-height: 1.2; }
.layout:hover { background: var(--raise); color: var(--text); }
.layout.on { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }

.warn { margin: 4px 16px 0; padding: 10px 12px; border-radius: var(--r); background: rgba(242, 178, 92, 0.1); box-shadow: inset 0 0 0 1px rgba(242, 178, 92, 0.3); }
.warn-line { color: #f4c98a; font-weight: 600; font-size: 12.5px; }
.warn-line + .warn-line { margin-top: 2px; }
.warn .btn-row { margin-top: 8px; }
/* v9.1: a small amber mark on the selection; the words are in the panel, said once */
.sel-warn {
  position: absolute; left: calc(50% - 9px); bottom: -9px; width: 18px; height: 18px; border-radius: 50%; z-index: 2;
  background: var(--warn); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45); pointer-events: auto;
}
.sel-warn::before { content: "!"; display: block; text-align: center; color: #2a1a02; font-size: 12px; font-weight: 800; line-height: 18px; }
.edge-pin {
  position: absolute; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 6px; border-radius: 13px; z-index: 3;
  background: var(--warn); color: #2a1a02; font-size: 11.5px; font-weight: 700; white-space: nowrap; pointer-events: auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}
.edge-pin svg { width: 16px; height: 16px; stroke-width: 2.2; }
.inplace {
  position: absolute; z-index: 5; margin: -4px 0 0 -6px; padding: 2px 6px; border: 0; border-radius: 4px; resize: none; overflow: hidden;
  background: rgba(10, 12, 18, 0.35); color: #fff; outline: 1.5px solid var(--accent); white-space: pre;
}

.add-prev {
  position: relative; display: block; height: 58px; border-radius: 5px; overflow: hidden;
  background: #222 url(/couch/tv-home/web/backgrounds/scene-night.jpg) center 55%/cover;
}
.add-prev-in { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.2); transform-origin: 50% 50%; color: #fff; font-family: "Inter", sans-serif; pointer-events: none; white-space: nowrap; }
.add-prev-in .cd-text2 { white-space: pre; }
.add-prev .cd-cam-demo { background-image: url(/couch/tv-home/web/backgrounds/scene-water.jpg); }
.add-name { padding: 0 2px; font-size: 11px; line-height: 1.3; min-height: 2.4em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.layer-ic { display: flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px; margin-right: 8px; color: var(--text-3); }
.layer-ic svg { width: 16px; height: 16px; }
.layer-ic img { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; }
.layer.on .layer-ic { color: var(--text); }
.layer-badge { flex: none; margin-right: 4px; padding: 1px 6px; border-radius: 4px; background: var(--raise); color: var(--text-3); font-size: 10.5px; font-weight: 650; }
.layer.off { color: var(--text-3); }
.layer.off .layer-name { text-decoration: none; }
.layer.off .layer-ic { opacity: 0.5; }
.layer { padding-left: 6px; }
.layers-hint { margin-top: 12px; }

.soon-line { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12px; }
.soon-tag { flex: none; padding: 2px 8px; border-radius: 5px; background: rgba(242, 178, 92, 0.14); color: var(--warn); font-size: 11px; font-weight: 700; }

/* the top bar never wraps: labels give way to icons as the window narrows */
.bar, .bar button, .bar .btn, .brand, .purpose-pill { white-space: nowrap; }
.bar-mid { min-width: 0; overflow: hidden; padding: 2px; }
@media (max-width: 1720px) {
  .toggle span, #reset span { display: none; }
}
@media (max-width: 1100px) {
  .remote-btn span, .brand { display: none; }
}

/* ---------- v4 ---------- */
/* the remote preview: its bar floats over the stage (the TV stays put), the side panels rest */
.stage { position: relative; }
.remote-bar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 12; width: min(760px, calc(100% - 24px)); margin: 0; background: #1a2234; box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.45), 0 10px 30px rgba(0, 0, 0, 0.45); }
.editor.remote .layers, .editor.remote .panel { opacity: 0.35; pointer-events: none; filter: saturate(0.6); transition: opacity 200ms var(--ease); }

/* toasts sit over the bottom of the side panel, never over the TV, and go after about 2.5 s */
.toast { position: fixed; left: auto; right: 12px; bottom: 12px; transform: none; width: 296px; max-width: calc(100vw - 24px); z-index: 40; }

/* narrow windows: the drawer sits beside the TV (the TV shrinks to fit), it does not cover it */
@media (max-width: 1366px) {
  .editor.show-left { grid-template-columns: 248px minmax(0, 1fr) 288px; }
  .editor.show-left.no-right { grid-template-columns: 248px minmax(0, 1fr) 0; }
  .editor.show-left .layers { position: static; display: block; width: auto; box-shadow: none; }
}

/* ---------- v5 ---------- */
/* toasts: a thin bar at the top of the stage, clear of every panel control */
.toast { position: absolute; left: 50%; right: auto; top: 10px; bottom: auto; transform: translateX(-50%); width: auto; max-width: min(640px, calc(100% - 24px)); z-index: 14; text-align: center; }
.editor.remote .toast { top: 66px; }
/* one banner over the TV when the demo readings are on, instead of a badge on every card */
.tv { position: relative; }
.demo-banner {
  position: absolute; left: 50%; top: -14px; transform: translate(-50%, -100%); z-index: 3; margin: 0; white-space: nowrap;
  padding: 5px 12px; border-radius: 999px; background: rgba(255, 196, 92, 0.14); color: #ffd58a; font-size: 12px; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 196, 92, 0.4);
}
.stage-inner { padding-top: 34px; }
/* at small widths (1024) the drawer slides over the canvas with a scrim, so the TV keeps its size */
.scrim { position: fixed; inset: 52px 0 0 0; z-index: 29; background: rgba(0, 0, 0, 0.5); }
@media (max-width: 1100px) {
  .editor.show-left, .editor.show-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 288px; }
  .editor.show-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .editor.show-left .layers { display: block; position: fixed; left: 0; top: 52px; bottom: 0; width: 280px; z-index: 30; box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45); }
}

/* Add: two across, each preview the item itself, the whole name */
.add-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
.add-item { padding: 5px 5px 8px; gap: 6px; }
.add-prev { height: auto; min-height: 48px; }
.add-name { font-size: 12px; display: block; min-height: 0; -webkit-line-clamp: unset; overflow: visible; white-space: normal; }
.add-prev .cd-demo { top: 4px; right: 4px; }

/* zones and scene buttons as chips */
.chips-edit { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.chip-ed { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 2px 0 10px; border-radius: 14px; background: var(--raise); font-size: 12.5px; font-weight: 550; }
.chip-x { display: inline-flex; width: 22px; height: 22px; border-radius: 11px; align-items: center; justify-content: center; color: var(--text-3); }
.chip-x:hover { background: #2e3036; color: var(--text); }
.chip-x svg { width: 14px; height: 14px; }
.chip-in { flex: 1; min-width: 90px; height: 28px; border: 0; background: none; outline: none; padding: 0 6px; }
.chip-in::placeholder { color: var(--text-3); }

/* before download */
.dialog.wide { width: min(560px, calc(100% - 32px)); }
.checks-list { display: grid; gap: 6px; margin-bottom: 16px; max-height: 50vh; overflow: auto; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 12px; border-radius: var(--r); background: rgba(242, 178, 92, 0.08); box-shadow: inset 0 0 0 1px rgba(242, 178, 92, 0.25); }
.check-text { color: #f4c98a; font-weight: 550; }

/* panning with space held */
.stage.panning, .stage.panning .overlay { cursor: grab; }

/* the word editor: exactly the words, no padding to make it taller */
.inplace { padding: 0 4px; margin: 0 0 0 -4px; height: auto; background: rgba(10, 12, 18, 0.25); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- v6 ---------- */
/* start: the TV picker, then the preset gallery */
.start-step { display: flex; align-items: center; gap: 10px; margin-top: 34px; font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.start-step span { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 11px; background: var(--raise); color: var(--text-2); font-size: 12px; font-weight: 650; }
.tvpick-row { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.tvpick-row .select { width: min(320px, 100%); }
.tvpick-note { margin-top: 8px; color: var(--text-3); font-size: 12.5px; max-width: 70ch; }
.purposes { margin-top: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.purpose-group { margin: 12px 6px 0; color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.purpose-group + .purpose-name { margin-top: 2px; }
.purpose-from { margin: 8px 6px 0; color: var(--text-3); font-size: 11.5px; line-height: 1.4; }
@media (max-width: 1000px) { .purposes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .purposes { grid-template-columns: 1fr; } }

/* the speed bar: big, with its zones, for the TV picked */
.speed { height: 38px; gap: 12px; }
.speed-label { max-width: 240px; overflow: hidden; }
.speed-track { position: relative; width: 190px; height: 10px; border-radius: 5px; overflow: visible; }
.speed-fill { position: relative; z-index: 1; border-radius: 5px; }
.speed-zones { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.speed-zones i { position: absolute; top: -3px; bottom: -3px; width: 1px; background: rgba(255, 255, 255, 0.35); }
.speed-zones i:nth-child(1) { left: 41.67%; } .speed-zones i:nth-child(2) { left: 62.5%; } .speed-zones i:nth-child(3) { left: 83.33%; background: rgba(255, 138, 115, 0.8); }
.speed-word { min-width: 0; white-space: nowrap; }
.lvl-smooth .speed-fill { background: var(--ok); } .lvl-smooth .speed-word { color: var(--ok); }
.lvl-fine .speed-fill { background: #b6d77a; } .lvl-fine .speed-word { color: #b6d77a; }
.lvl-slow .speed-fill { background: var(--warn); } .lvl-slow .speed-word { color: var(--warn); }
.lvl-tooslow .speed-fill { background: var(--heavy); } .lvl-tooslow .speed-word { color: var(--heavy); }
.speed-delta {
  position: absolute; right: 8px; top: calc(100% + 6px); z-index: 21; padding: 5px 10px; border-radius: 999px;
  background: #1c1d21; box-shadow: inset 0 0 0 1px var(--line-2), 0 8px 20px rgba(0, 0, 0, 0.45);
  color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.speed-pop { width: 340px; }
.speed-change { display: grid; gap: 6px; margin: 4px 0 10px; }
@media (max-width: 1400px) { .speed-track { width: 140px; } }
@media (max-width: 1280px) { .speed-word { max-width: 90px; overflow: hidden; text-overflow: ellipsis; } }

/* the Add panel says what each thing costs on this TV */
.add-item { position: relative; }
.add-item[data-cost]::after { content: attr(data-cost); position: absolute; top: 6px; right: 6px; padding: 1px 5px; border-radius: 6px; background: rgba(13, 14, 16, 0.78); color: var(--text-2); font-size: 10.5px; font-weight: 600; }

/* the widget grid: cells, the ghost of where a widget lands, the size picker */
.grid-cells { position: absolute; inset: 0; pointer-events: none; }
.grid-cells i { position: absolute; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.28); background: rgba(111, 155, 255, 0.04); }
.grid-ghost { position: absolute; pointer-events: none; border-radius: 8px; background: rgba(111, 155, 255, 0.16); box-shadow: inset 0 0 0 2px var(--accent); transition: left 120ms var(--ease), top 120ms var(--ease), width 120ms var(--ease), height 120ms var(--ease); }
.grid-from { position: absolute; pointer-events: none; border-radius: 8px; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5); border: 1px dashed rgba(255, 255, 255, 0.4); }
.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.size-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: var(--r); background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 11.5px; }
.size-btn b { font-weight: 600; }
.size-btn:hover { color: var(--text); background: #26282d; }
.size-btn.on { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); background: #1d2433; }
.size-btn.nofit { opacity: 0.45; }
.size-pic { position: relative; width: 56px; height: 34px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line-2); }
.size-pic i { position: absolute; left: 2px; top: 2px; width: calc((52px / 8) * var(--w)); height: calc((30px / 8) * var(--h)); border-radius: 2px; background: currentColor; opacity: 0.6; }
.grid-hint { min-height: 2.6em; }
.looks { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.look-btn { display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: var(--r); background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 11px; text-align: left; }
.look-btn img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; background: #000; }
.look-btn:hover { color: var(--text); background: #26282d; }
/* the top bar keeps room for the speed bar: its TV name and the remote label give way first */
.bar-right { flex: none; }
@media (max-width: 1700px) { .remote-btn span { display: none; } }
@media (max-width: 1180px) { .speed-track { width: 110px; } .zoom { display: none; } }
/* v7: the speed bar always says which TV and "estimate", down to 1024 wide; other labels give way */
.speed-label { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; }
#speed-tv { display: inline-block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.speed-label i { flex: none; }
@media (max-width: 1440px) { #speed-tv { max-width: 120px; } .speed-track { width: 110px; } .speed { gap: 8px; padding: 0 8px; } }
@media (max-width: 1280px) { #speed-tv { max-width: 90px; } .speed-track { width: 80px; } .speed-word { max-width: 76px; } #export span { display: none; } .bar-sep { display: none; } }
@media (max-width: 1100px) { #speed-tv { max-width: 72px; } .speed-track { width: 60px; } #undo, #redo { display: none; } }
/* v8: the offer to make room, over the top of the stage like the remote bar */
.roombar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 13; width: min(820px, calc(100% - 24px)); display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 18px; border-radius: 12px; background: #2a2416; box-shadow: inset 0 0 0 1px rgba(242, 178, 92, 0.5), 0 10px 30px rgba(0, 0, 0, 0.45); color: var(--text); font-size: 13.5px; line-height: 1.4; }
.roombar[hidden] { display: none; }
.roombar #roombar-msg { flex: 1; }
.roombar-btns { display: flex; gap: 8px; flex: none; }
.roombar-btns .btn[hidden] { display: none; }

/* Send to my TV (send.js): the code, big enough to read across a room, and its QR */
.send-btn { margin-right: 6px; }
.send-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
@media (max-width: 1280px) { .send-btn span { display: none; } }
.send-dialog { width: min(460px, calc(100% - 32px)); }
.send-photo { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 6px; color: var(--text-2); font-size: 13px; line-height: 1.45; cursor: pointer; }
.send-photo[hidden] { display: none; }
.send-photo input { margin-top: 3px; accent-color: var(--accent); }
.send-code-label { margin: 14px 0 0 !important; color: var(--text-2); font-size: 12.5px; }
.send-code { margin: 4px 0 2px !important; font-size: 44px; font-weight: 700; letter-spacing: 0.06em; color: var(--text) !important; font-variant-numeric: tabular-nums; user-select: all; }
.send-qr-row { display: flex; gap: 16px; align-items: center; margin: 14px 0 4px; }
.send-qr { flex: none; width: 148px; height: 148px; border-radius: 10px; overflow: hidden; background: #fff; }
.send-qr svg { display: block; width: 148px !important; height: 148px !important; }
.send-qr svg rect { fill: #fff !important; stroke: none !important; }
.send-qr svg path { fill: #000 !important; stroke: none !important; }
.send-qr-row .note { margin: 0; }
.send-error { margin: 12px 0 0 !important; color: var(--heavy) !important; font-size: 13px; }
.send-error[hidden], #send-ask[hidden], #send-busy[hidden], #send-done[hidden] { display: none; }

/* ---------- search (the Add panel and the control sheet) ---------- */
.search { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; height: 36px; margin: 2px 2px 6px; padding: 0 10px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-3); cursor: text; }
#add-pane .search { margin-top: 0; box-shadow: inset 0 0 0 1px var(--line), 0 6px 10px var(--panel); }
.search:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text-2); }
.search svg { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; color: var(--text); }
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }
.empty-note { margin: 10px 6px; padding: 14px 12px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.add-group[hidden] { display: none; }
.add-item.wide { grid-column: span 3; }
.add-item.wide .add-prev { height: 76px; }
.add-name em { display: block; font-style: normal; color: var(--text-3); font-size: 10.5px; }
.apps-grid { grid-template-columns: repeat(4, 1fr); }
.app-item { align-items: center; text-align: center; padding: 8px 4px 6px; }
.app-item .app-ic { display: flex; width: 40px; height: 40px; border-radius: 10px; overflow: hidden; background: var(--bg); align-items: center; justify-content: center; }
.app-item .app-ic img { width: 100%; height: 100%; object-fit: cover; }
.app-item .add-name { min-height: 0; text-align: center; }
.app-item.is-out .app-ic { box-shadow: 0 0 0 1.5px var(--accent); }
@media (max-width: 1366px) { .add-item.wide { grid-column: span 2; } .apps-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- sections: the controls list, their set sizes ---------- */
.ctl-list { list-style: none; display: grid; gap: 2px; }
.ctl-row { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 2px; border-radius: 6px; cursor: grab; }
.ctl-row:hover { background: var(--raise); }
.ctl-row.on { background: #1d2433; box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.55); }
.ctl-row.dragging { opacity: 0.4; }
.ctl-row.drop { box-shadow: inset 0 2px 0 var(--accent); }
.ctl-row .grip { display: flex; color: var(--text-3); }
.ctl-row .grip svg { width: 16px; height: 16px; }
.ctl-ic { display: flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--bg); color: var(--text); overflow: hidden; }
.ctl-ic svg { width: 16px; height: 16px; }
.ctl-ic img { width: 100%; height: 100%; object-fit: cover; }
.ctl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.ctl-sizes { display: flex; gap: 1px; padding: 2px; border-radius: 7px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.ctl-size { display: flex; align-items: center; justify-content: center; width: 26px; height: 24px; border-radius: 5px; color: var(--text-3); }
.ctl-size:hover { color: var(--text); background: var(--raise); }
.ctl-size.on { color: var(--text); background: var(--raise); box-shadow: inset 0 0 0 1px var(--line-2); }
.ctl-row .icon-btn { width: 26px; height: 26px; color: var(--text-3); }
.ctl-row .icon-btn:hover { color: var(--text); }
/* a control's size as a picture: its share of a 2 by 2 block */
.ctl-pic { position: relative; display: block; width: 16px; height: 16px; border-radius: 3px; box-shadow: inset 0 0 0 1px currentColor; opacity: 0.55; }
.ctl-pic i { position: absolute; left: 2px; top: 2px; width: calc(6px * var(--w)); height: calc(6px * var(--h)); border-radius: 1.5px; background: currentColor; }
.ctl-size.on .ctl-pic, .size-btn.on .ctl-pic { opacity: 1; }
.ctl-big { grid-template-columns: repeat(4, 1fr); }
.ctl-big .ctl-pic { width: 34px; height: 34px; border-radius: 6px; }
.ctl-big .ctl-pic i { left: 3px; top: 3px; width: calc(14px * var(--w)); height: calc(14px * var(--h)); border-radius: 3px; }
.add-ctl { margin-top: 10px; }
.add-ctl svg { width: 16px; height: 16px; }

/* on the TV: a selected section's controls, its empty places, and a control being moved */
.ctl-box { position: absolute; pointer-events: none; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); transition: box-shadow 120ms var(--ease), opacity 120ms var(--ease); }
.ctl-box.on { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 3px rgba(111, 155, 255, 0.25); }
.ctl-box.lifting { opacity: 0.35; }
.ctl-box.target { box-shadow: inset 0 0 0 2px #fff; background: rgba(255, 255, 255, 0.1); }
.ctl-box .handle { pointer-events: auto; }
.ctl-tag { left: 50%; transform: translateX(-50%); top: -26px; }
.ctl-empty { position: absolute; border-radius: 10px; border: 1.5px dashed rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.04); pointer-events: none; }
.ctl-empty.add { display: flex; align-items: center; justify-content: center; pointer-events: auto; color: #fff; cursor: pointer; transition: background 140ms var(--ease), border-color 140ms var(--ease); }
.ctl-empty.add:hover { background: rgba(111, 155, 255, 0.2); border-color: var(--accent); border-style: solid; }
.ctl-empty.add svg { width: 22px; height: 22px; stroke-width: 2; }
.ctl-ghost { background: rgba(111, 155, 255, 0.22); border-radius: 10px; box-shadow: inset 0 0 0 2px var(--accent), 0 10px 24px rgba(0, 0, 0, 0.35); transition: none; }

/* the Add a control sheet */
.sheet-back { align-items: flex-end; }
.dialog.sheet { width: min(680px, calc(100% - 32px)); max-height: min(78vh, 720px); display: flex; flex-direction: column; padding: 16px 18px 18px; margin-bottom: 4vh; border-radius: 16px; animation: sheet-up 260ms var(--ease); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dialog.sheet { animation: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet .search { margin: 0 0 4px; }
.sheet .sheet-room { margin: 6px 2px 4px !important; font-size: 12px; color: var(--text-3) !important; }
.sheet-body { overflow: auto; margin: 4px -4px 0; padding: 0 4px; }
.sheet-body .psec-title { margin: 14px 2px 8px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.sheet-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 6px 10px; border-radius: 12px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 12px; font-weight: 550; text-align: center; transition: background 140ms var(--ease), transform 140ms var(--ease); }
.sheet-item:hover { background: #26282d; color: var(--text); }
.sheet-item:active { transform: scale(0.97); }
.sheet-item.taken { opacity: 0.45; }
.sheet-item em { display: block; font-style: normal; font-size: 10.5px; color: var(--text-3); }
.sheet-prev { position: relative; display: flex; align-items: center; justify-content: center; width: 72px; height: 68px; border-radius: 12px; overflow: hidden; background: #2a2c33 url(/couch/tv-home/web/backgrounds/scene-night.jpg) center/cover; color: #fff; }
.sheet-prev > svg { width: 30px; height: 30px; }
.sheet-prev > img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; }
.sheet-prev.live > .cd-o { position: absolute !important; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.33); transform-origin: 50% 50%; font-family: "Inter", sans-serif; pointer-events: none; }

/* keyboard shortcuts */
.dialog.keys { width: min(520px, calc(100% - 32px)); }
.keys-list { display: grid; grid-template-columns: 1fr auto; gap: 7px 16px; margin: 16px 0 18px; font-size: 13px; }
.keys-list dt { color: var(--text-2); }
.keys-list dd { text-align: right; white-space: nowrap; }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2); color: var(--text); font: 600 11.5px/1.6 "Inter", sans-serif; text-align: center; }
.img-fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--text-3); }
.img-fallback svg { width: 70%; height: 70%; }

/* ---------- a phone (Canva mobile's shape): the TV on top, one sheet of tools under it, three tabs
   at the bottom in thumb reach. The top bar keeps only what a phone needs. ---------- */
.mtabs { display: none; }
@media (max-width: 640px) {
  .editor, .editor.no-left, .editor.no-right, .editor.show-left, .editor.no-left.no-right, .editor.show-left.no-right {
    height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: 48px auto minmax(0, 1fr) calc(58px + env(safe-area-inset-bottom));
    grid-template-areas: "bar" "stage" "sheet" "tabs";
  }
  .bar { gap: 4px; padding: 0 6px 0 8px; }
  .bar-left, .bar-mid, .bar-right { gap: 2px; }
  .brand, #reset, .bar-sep, #t-safe, #t-grid, .zoom, #t-remote, #t-left, #t-right, .speed-label, .speed-word, .speed-delta { display: none !important; }
  .bar-mid { overflow: visible; padding: 0; }
  .purpose-pill { max-width: 128px; height: 30px; padding: 0 6px 0 10px; }
  .purpose-pill span { overflow: hidden; text-overflow: ellipsis; }
  .icon-btn, #undo, #redo { display: inline-flex !important; width: 36px; height: 36px; }
  .speed { gap: 0; padding: 0 6px; height: 36px; }
  .speed-track { width: 40px !important; }
  .speed-pop { position: fixed; left: 8px; right: 8px; top: 52px; width: auto; }
  .send-btn, #export { width: 40px; height: 36px; padding: 0; margin: 0; }
  .send-btn span, #export span { display: none; }
  .stage { grid-area: stage; height: calc((100vw - 24px) * 0.5625 + 40px); overflow: hidden; border-bottom: 1px solid var(--line); }
  .stage-inner { padding: 14px 12px 10px !important; }
  .tv { box-shadow: 0 0 0 4px #060607, 0 0 0 5px #2b2c31, 0 14px 30px rgba(0, 0, 0, 0.5); }
  .tv-stand, .demo-banner { display: none !important; }
  .editor .layers, .editor.show-left .layers, .editor .panel {
    grid-area: sheet; position: static !important; display: none; width: auto !important; border: 0; box-shadow: none !important; overflow: auto;
    overscroll-behavior: contain; padding-bottom: 24px;
  }
  .editor.m-layers .layers, .editor.m-add .layers { display: block !important; }
  .editor.m-edit .panel { display: block !important; }
  .layers .tabs { display: none; }
  .layers { padding: 12px 12px 24px; }
  .mtabs {
    grid-area: tabs; display: flex; padding: 4px 6px env(safe-area-inset-bottom); gap: 4px;
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .mtab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 10px; color: var(--text-3); font-size: 11.5px; font-weight: 600; }
  .mtab svg { width: 22px; height: 22px; }
  .mtab.on { color: var(--text); background: var(--raise); }
  .scrim { display: none !important; }
  /* the bars that float over the stage go to the bottom of the sheet, over the tabs, so the TV stays visible */
  .toast { position: fixed; top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); }
  .roombar { position: fixed; top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 10px; padding: 12px; }
  .roombar-btns { width: 100%; }
  .roombar-btns .btn { flex: 1; height: 40px; }
  .remote-bar { position: fixed; top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); }
  /* thumbs: every control at least 40 px tall, and the side panel's grids one column fewer */
  .seg-btn, .btn.small, .btn { min-height: 40px; }
  .ctl-row { min-height: 48px; }
  .ctl-size { width: 34px; height: 32px; }
  .add-grid { grid-template-columns: repeat(3, 1fr); }
  .apps-grid { grid-template-columns: repeat(4, 1fr); }
  .add-item.wide { grid-column: span 3; }
  .dialog.sheet { width: 100%; max-height: 62dvh; margin: 0; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .sheet-grid { grid-template-columns: repeat(3, 1fr); }
  .search input { font-size: 16px; }
  .panel input, .panel select, .panel textarea { font-size: 16px; }
}
@media (pointer: coarse) {
  .handle { width: 22px; height: 22px; border-radius: 6px; }
  .h-nw { left: -12px; top: -12px; } .h-se { right: -12px; bottom: -12px; } .h-ne { right: -12px; top: -12px; } .h-sw { left: -12px; bottom: -12px; }
  .handle::after { inset: -10px; }
}
.add-group { padding-bottom: 6px; }
.add-group + .add-group { margin-top: 10px; padding-top: 4px; border-top: 1px solid var(--line); }
.add-group .add-title { margin-top: 12px; }
#add-pane .search + .add-group { margin-top: 0; border-top: 0; }
/* round 1: one size control per control, under its row; the size it has now, as a word */
.ctl-sz { display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--text-3); font-size: 11.5px; font-weight: 600; }
.ctl-row.on .ctl-sz { color: var(--text-2); }
.ctl-detail { list-style: none; margin: 2px 0 8px; padding: 12px 12px 14px; border-radius: 10px; background: #1a1f2b; box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.28); }
.ctl-detail .ctl-big { margin-bottom: 4px; }
.ctl-detail .field { margin-top: 12px; }
.ctl-detail .note { margin-top: 8px; }
/* what each widget costs: shown when you point at it, not on every card */
.add-item[data-cost]::after { opacity: 0; transition: opacity 140ms var(--ease); }
.add-item[data-cost]:hover::after, .add-item[data-cost]:focus-visible::after { opacity: 1; }
@media (max-width: 640px) {
  .sizes { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; scroll-snap-type: x proximity; }
  .sizes .size-btn { flex: 0 0 84px; scroll-snap-align: start; }
  .handle { width: 14px; height: 14px; border-radius: 4px; }
  .h-nw { left: -8px; top: -8px; } .h-se { right: -8px; bottom: -8px; } .h-ne { right: -8px; top: -8px; } .h-sw { left: -8px; bottom: -8px; }
  .handle::after { inset: -12px; }
  .sel-tag { height: 18px; line-height: 18px; font-size: 10.5px; top: -20px; }
}
/* Import design (ai-import.js), beside Send to my TV: a word on wide screens, an icon on narrow ones */
@media (max-width: 1720px) { #ai-import-btn span { display: none; } #ai-import-btn { width: 34px; padding: 0; } }
@media (max-width: 640px) { #ai-import-btn { width: 36px; height: 36px; } }
/* icon styles: each drawn as itself (icon-sets.js), a tap to pick */
.icon-styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.icon-style { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 2px 7px; border-radius: var(--r); background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 11px; font-weight: 550; }
.icon-style:hover { color: var(--text); background: #26282d; }
.icon-style.on { color: var(--text); background: #1d2433; box-shadow: inset 0 0 0 1.5px var(--accent); }
.icon-style-pic { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); color: #fff; }
.icon-style.full .icon-style-pic { background: none; }
.icon-style-pic svg { width: 22px; height: 22px; }
.icon-style.full .icon-style-pic svg { width: 34px; height: 34px; }
.apps-note { padding: 8px 10px; border-radius: 8px; background: rgba(111, 155, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(111, 155, 255, 0.22); color: var(--text-2) !important; }
.sheet .apps-note { margin: 0 0 10px !important; }
.app-row.later img { opacity: 0.45; }
.app-row em { font-style: normal; color: var(--text-3); font-size: 11.5px; margin-left: 4px; }
/* the TV model database search (window.TVDB, when loaded) */
.tv-search { margin: 0 0 12px; }
.tv-search .search { height: 44px; }
.tv-results { list-style: none; display: grid; gap: 4px; margin-top: 6px; }
.tv-result { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; padding: 10px 12px; border-radius: 8px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); text-align: left; }
.tv-result:hover { background: #26282d; }
.tv-result b { font-weight: 600; }
.tv-result span { grid-column: 1; color: var(--text-3); font-size: 12px; }
.tv-result em { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; color: var(--text-2); font-size: 12px; font-weight: 600; }
.size-dim { font-style: normal; font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: -3px; }
.size-btn.on .size-dim { color: var(--text-2); }
.thumb-missing { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 16 / 9; border-radius: 4px; background: linear-gradient(160deg, #22252c, #15171b); color: var(--text-3); font-size: 11px; font-weight: 600; }
/* the TV database search: each TV with its OS, speed class and what couch-tv can do on it */
.tv-result { grid-template-columns: 1fr auto; }
.tv-result .tv-os { grid-column: 1; }
.tv-result .tv-speed { grid-column: 2; grid-row: 2; justify-self: end; color: var(--text-3); font-size: 11.5px; font-weight: 600; }
.tv-result .tv-reason { grid-column: 1 / -1; color: var(--text-3); font-size: 11.5px; line-height: 1.45; margin-top: 2px; }
.tv-compat { display: inline-block; padding: 2px 8px; border-radius: 999px; font-style: normal; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.tv-compat.ok { background: rgba(127, 212, 160, 0.16); color: var(--ok); }
.tv-compat.part { background: rgba(242, 178, 92, 0.16); color: var(--warn); }
.tv-compat.no { background: rgba(255, 255, 255, 0.08); color: var(--text-2); }
.tv-result em.tv-compat { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
.tv-hint { margin: 6px 2px 0; }
.tv-compat-line { margin-top: 8px; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.tv-compat-line span { color: var(--text-3); }
.speed-pop .tv-search { margin: 6px 0 8px; }
.speed-pop .tv-results { max-height: 260px; overflow: auto; }
@media (max-width: 1720px) { #share-gallery span { display: none; } #share-gallery { width: 34px; padding: 0; } }
/* phone: Send and Download keep a word under their icon; redo and Import step aside to make room */
@media (max-width: 640px) {
  .send-btn, #export { flex-direction: column; gap: 2px; width: 50px !important; height: 44px !important; padding: 0 !important; }
  .send-btn > span, #export > span { display: block !important; font-size: 10px; font-weight: 650; line-height: 1; }
  .send-btn .long { display: none; }
  .send-btn svg, #export svg { width: 18px; height: 18px; }
  #redo, #ai-import-btn, #share-gallery { display: none !important; }
  .purpose-pill { max-width: 112px; }
}
.tv-picked { display: block; margin-bottom: 4px; color: var(--text); font-weight: 650; }
@media (max-width: 640px) {
  #redo { display: inline-flex !important; }
  .purpose-pill { max-width: 92px; }
  .speed-track { width: 30px !important; }
  /* toasts sit just under the TV, never over the tools in the sheet */
  .toast { position: fixed; top: calc(48px + (100vw - 24px) * 0.5625 + 2px); bottom: auto; max-width: calc(100vw - 24px); font-size: 12.5px; }
}

/* How it works on your TV (tvs/platform-setup.js): right after a TV is picked, and in Send to my TV */
.tv-setup { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); text-align: left; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.tv-setup .su-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tv-setup .su-head b { color: var(--text); font-size: 14.5px; }
.tv-setup .su-status, .tv-setup .su-a { display: inline-block; padding: 1px 8px; border-radius: 999px; font-style: normal; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.tv-setup .ok { background: rgba(127, 212, 160, 0.16); color: var(--ok); }
.tv-setup .part { background: rgba(242, 178, 92, 0.16); color: var(--warn); }
.tv-setup .no { background: rgba(255, 120, 120, 0.14); color: #ff9a9a; }
.tv-setup .su-sum { margin: 6px 0 10px; color: var(--text); }
.tv-setup .su-rows { margin: 0; display: grid; gap: 8px; }
.tv-setup .su-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 10px; }
.tv-setup dt { color: var(--text); font-weight: 650; }
.tv-setup dd { margin: 0; }
.tv-setup .su-know { margin: 10px 0 0; padding-left: 18px; }
.tv-setup .su-fall { margin: 8px 0 0; }
.tv-setup .su-link { display: inline-block; margin-top: 8px; color: var(--accent, #7ab8ff); }
@media (max-width: 640px) { .tv-setup .su-row { grid-template-columns: 1fr; gap: 2px; } }
