/* ============================================================
   kinkbox — boxy brutalist theme
   one design language (angled cuts + neon), every component
   gets its own geometry. no generic cards.
   ============================================================ */
* { box-sizing: border-box; }
:root {
  --bg: #0a0812;
  --bg2: #0f0b1a;
  --panel: #151021;
  --panel2: #1d1631;
  --line: #2c2148;
  --line-hot: #4a3580;
  --text: #efeaff;
  --muted: #9a8fc0;
  --accent: #ff4d8d;
  --accent2: #7b5cff;
  --ok: #34ffb0;
  --warn: #ffd23f;
  --cool: #3ec6ff;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100dvh; background-image: radial-gradient(1200px 500px at 70% -10%, #1a1030 0%, transparent 60%); }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-hot); border: 2px solid var(--bg); border-radius: 0; }
::-webkit-scrollbar-track { background: var(--bg2); }

/* ---------------- buttons: notched slabs (unique: corner-cut) ---------------- */
.btn {
  --cut: 10px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line-hot);
  border-left: 4px solid var(--accent2);
  padding: 10px 18px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.btn:hover { background: #251b40; border-left-color: var(--accent); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-left: 4px solid #ffffff55;
  box-shadow: 0 0 24px #ff4d8d44;
}
.btn.big { padding: 14px 22px; font-size: 0.9rem; }

/* ---------------- topbar: logo slab + status rail (unique) ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--bg) 82%, transparent);
}
.topbar::after { /* neon rail under the header */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2) 40%, transparent 90%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 24px 50%);
}
.topbar h1 {
  margin: 0; font-size: 1.05rem; letter-spacing: 0.22em; text-transform: uppercase; font-family: var(--mono);
  background: var(--panel2); padding: 10px 18px 10px 14px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  border-left: 5px solid var(--accent);
  position: relative;
}
.topbar h1::before { /* pulsing LED */
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 10px;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
  animation: led 2.4s infinite;
}
@keyframes led { 0%, 88% { opacity: 1; } 92%, 100% { opacity: 0.25; } }

/* ---------------- tabs: ticket stubs (unique: angled parallelograms) ---------------- */
.tabs { display: flex; gap: 10px; padding: 2px 16px 14px; align-items: flex-end; }
.tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: 10px 20px; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; font-family: var(--mono);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  position: relative;
}
.tab.active {
  color: var(--bg); background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 700; padding-bottom: 13px; border: none;
  box-shadow: 0 4px 18px #ff4d8d55;
}
.tab.active::after { /* pointer notch below active tab */
  content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px; background: var(--accent2);
}

/* ---------------- search: reticle command bar (unique: targeting corners) ---------------- */
.searchbar {
  display: flex; gap: 10px; padding: 4px 16px 12px; position: relative;
}
.searchbar::before, .searchbar::after {
  content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--accent2); pointer-events: none;
}
.searchbar::before { left: 8px; top: -2px; border-right: none; border-bottom: none; }
.searchbar::after { right: 8px; bottom: -2px; border-left: none; border-top: none; }
.searchbar input[type="search"] {
  flex: 1; min-width: 0;
  background: var(--bg2); color: var(--text);
  border: none; border-bottom: 2px solid var(--line-hot);
  padding: 12px 14px; outline: none; font-family: var(--mono);
}
.searchbar input[type="search"]:focus { border-bottom-color: var(--accent); box-shadow: 0 8px 20px -14px var(--accent); }
.searchbar input[type="search"]::placeholder { color: #5e5486; }
.searchbar select {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: 0 8px; outline: none; font-size: 0.75rem; font-family: var(--mono); text-transform: uppercase;
}

/* ---------------- chips: hex tags, hand-placed (unique: alternating tilt) ---------------- */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 2px 20px 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line);
  padding: 7px 16px; font-size: 0.75rem; font-family: var(--mono); letter-spacing: 0.08em;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.chip:nth-child(odd) { transform: rotate(-1.2deg); }
.chip:nth-child(even) { transform: rotate(1deg); }
.chip:hover { color: var(--text); border-color: var(--line-hot); }
.chip.active { background: #2a1530; color: var(--accent); border-color: var(--accent); }

/* ---------------- grid: masonry, no cards — varied tiles (unique) ---------------- */
#grid { columns: 160px 4; column-gap: 10px; padding: 4px 16px 12px; }
.card {
  position: relative; display: block; width: 100%; margin: 0 0 10px;
  break-inside: avoid; overflow: hidden; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  filter: saturate(0.85);
  transition: filter 0.15s, border-color 0.15s, transform 0.15s;
}
/* varied tile heights so the masonry feels organic, not card-like */
.card:nth-child(5n+1) { aspect-ratio: 3/4; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%); }
.card:nth-child(5n+2) { aspect-ratio: 1/1; clip-path: polygon(14px 0, 100% 0, 100% 100%, 0 100%, 0 14px); }
.card:nth-child(5n+3) { aspect-ratio: 4/5; }
.card:nth-child(5n+4) { aspect-ratio: 2/3; clip-path: polygon(0 0, 100% 0, 100% 100%, 14px 100%, 0 calc(100% - 14px)); }
.card:nth-child(5n)   { aspect-ratio: 3/4.4; }
.card:hover { filter: saturate(1.15); border-color: var(--accent); transform: translateY(-2px); }
/* selection = viewfinder corner brackets, not an outline */
.card.selected { border-color: transparent; filter: saturate(1.2); }
.card.selected::before, .card.selected::after {
  content: ""; position: absolute; width: 22px; height: 22px; border: 3px solid var(--accent); z-index: 2;
}
.card.selected::before { left: 3px; top: 3px; border-right: none; border-bottom: none; }
.card.selected::after { right: 3px; bottom: 3px; border-left: none; border-top: none; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* meta: every tile gets a different overlay treatment */
.card .meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 8px 6px;
  background: linear-gradient(transparent, rgba(5,3,10,0.92));
  font-size: 0.68rem; font-family: var(--mono); color: #cfc6ee;
  display: flex; justify-content: space-between; gap: 4px;
}
.card:nth-child(2n) .meta { flex-direction: column-reverse; align-items: flex-start; gap: 2px; }
.card .dur { background: var(--accent); color: #fff; padding: 2px 7px; font-weight: 700; clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.card .user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- status: terminal line (unique: blinking block cursor) ---------------- */
.status { text-align: left; padding: 2px 20px 8px; color: var(--muted); font-size: 0.78rem; font-family: var(--mono); }
.status::before { content: "// "; color: var(--accent2); }
.status:not(:empty)::after { content: "▮"; color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- pager: heavy arrows + notched counter (unique) ---------------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 0 28px; }
#page-label {
  min-width: 64px; text-align: center; font-family: var(--mono); font-size: 1rem;
  background: var(--panel2); border: 1px solid var(--line-hot); padding: 8px 0;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%);
}
.pager .btn { --cut: 8px; }

/* ============================================================
   SESSION VIEW
   ============================================================ */

/* ---------------- breath core: hollow reactor ring (unique) ---------------- */
.breath-wrap { display: flex; justify-content: center; padding: 10px 0 2px; }
.breath-ball {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, #2a1230 55%, transparent 56%);
  border: 2px solid var(--accent);
  box-shadow: 0 0 22px #ff4d8d66, inset 0 0 18px #ff4d8d44;
  color: #fff; font-size: 0.68rem; font-family: var(--mono); letter-spacing: 0.14em; text-transform: uppercase; text-align: center;
  transition: transform 1s ease-in-out; transform: scale(0.75);
  position: relative;
}
.breath-ball::before { /* inner satellite dot */
  content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent); top: 6px; left: 50%; transform: translateX(-50%);
}
.breath-ball.cool {
  border-color: var(--cool);
  background: radial-gradient(circle at 50% 50%, #0f2438 55%, transparent 56%);
  box-shadow: 0 0 22px #3ec6ff55, inset 0 0 18px #3ec6ff33;
}
.breath-ball.cool::before { background: var(--cool); box-shadow: 0 0 12px var(--cool); }

/* ---------------- phase label: big display type (unique) ---------------- */
#phase-label {
  font-size: 1.5rem; margin: 0; text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800;
  font-family: var(--mono);
}
#phase-label.build { color: var(--accent); text-shadow: 0 0 18px #ff4d8d88; }
#phase-label.edge { color: var(--warn); text-shadow: 0 0 18px #ffd23f88; }
#phase-label.cool { color: var(--cool); text-shadow: 0 0 18px #3ec6ff88; }
#phase-label.finale { color: var(--ok); text-shadow: 0 0 22px #34ffb0aa; }

.clock { font-family: var(--mono); color: var(--muted); font-size: 1rem; border-bottom: 2px solid var(--line-hot); padding-bottom: 2px; }

/* ---------------- stage: viewfinder frame (unique: corner brackets + scanlines) ---------------- */
.stage {
  margin: 12px 16px; background: #000; aspect-ratio: 16/10;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
}
.stage::before, .stage::after {
  content: ""; position: absolute; width: 26px; height: 26px; border: 3px solid var(--accent2); z-index: 2; pointer-events: none;
}
.stage::before { left: 0; top: 0; border-right: none; border-bottom: none; }
.stage::after { right: 0; bottom: 0; border-left: none; border-top: none; }
.stage > * { z-index: 1; }
.stage video, .stage img { max-width: 100%; max-height: 100%; }
.stage .scan { /* scanline sweep */
  position: absolute; left: 0; right: 0; top: -30%; height: 26%; z-index: 2; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, #7b5cff14 50%, transparent 100%);
  animation: scan 6s linear infinite;
}
@keyframes scan { 0% { top: -30%; } 100% { top: 105%; } }
.stage .hint { padding: 14px; color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }

/* ---------------- progress: segmented tick bar (unique) ---------------- */
.progress { height: 16px; background: var(--bg2); border: 1px solid var(--line); position: relative; overflow: hidden; margin: 4px 16px 14px; }
#phase-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 16px #ff4d8d77;
  transition: width 0.3s linear;
}
.progress::after { /* tick segments carved on top */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--bg) calc(10% - 2px) 10%);
  pointer-events: none;
}

/* ---------------- controls: pods + toggles (unique: each control its own pod) ---------------- */
.coach { padding: 0 16px 30px; }
.coach-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.ctl {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 12px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
.ctl label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.72rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.1em; }
.ctl input[type="number"] {
  width: 58px; background: var(--bg2); color: var(--text); border: none; border-bottom: 2px solid var(--accent2);
  padding: 6px 4px; text-align: center; font-family: var(--mono); font-size: 1rem; outline: none;
  appearance: textfield; -moz-appearance: textfield;
}
.ctl input[type="number"]::-webkit-outer-spin-button, .ctl input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.ctl input[type="number"]:focus { border-bottom-color: var(--accent); }

/* checkbox -> neon toggle ramp */
.ctl input[type="checkbox"] {
  appearance: none; width: 36px; height: 18px; margin: 0; position: relative; cursor: pointer;
  background: var(--bg2); border: 1px solid var(--line-hot);
}
.ctl input[type="checkbox"]::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px;
  background: var(--muted); transition: all 0.15s;
}
.ctl input[type="checkbox"]:checked { border-color: var(--accent); background: #2a1530; }
.ctl input[type="checkbox"]:checked::after { left: 20px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* stop = hazard kill-switch (unique: striped edge) */
#btn-stop { border-left: 4px solid transparent; background-image: repeating-linear-gradient(45deg, #1d1631 0 8px, #241a3d 8px 16px); }
#btn-stop:not(:disabled) { border-left-color: var(--warn); box-shadow: inset 0 -3px 0 #ffd23f55; }

/* finale = burst outline (unique: double border glow) */
#btn-finale { background: transparent; color: var(--ok); border: 1px solid var(--ok); border-left: 4px solid var(--ok); box-shadow: 0 0 14px #34ffb033; }
#btn-finale:not(:disabled):hover { background: #34ffb018; box-shadow: 0 0 22px #34ffb055; }

.hint { color: var(--muted); font-size: 0.78rem; font-family: var(--mono); }

/* ============================================================
   PLAYER DIALOG: monitor frame (unique: chrome bar + scanlines)
   ============================================================ */
dialog#player-dialog {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line-hot);
  max-width: min(92vw, 720px); width: 92vw; padding: 0 0 12px;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
dialog#player-dialog::backdrop { background: rgba(4,2,8,0.9); }
.dlg-chrome {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--panel2); font-family: var(--mono); font-size: 0.72rem;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: led 1.6s infinite; }
.dlg-chrome .spacer { flex: 1; }
dialog#player-dialog video { width: 100%; max-height: 70vh; display: block; background: #000; }
dialog#player-dialog img { width: 100%; max-height: 70vh; object-fit: contain; display: block; background: #000; }
dialog#player-dialog iframe { width: 100%; height: 380px; border: 0; display: block; background: #000; }
#player-caption { padding: 8px 14px 0; margin: 0; }
dialog#player-dialog .btn, dialog#player-dialog #btn-use { margin: 12px 14px 0; }
