/* CRT STUDIO — terminal aesthetic */
@font-face { font-family: "Aptos Mono"; font-style: normal; font-weight: 400; src: local("Aptos Mono"), local("AptosMono"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 500; font-display: swap; src: url("/crt/fonts/jetbrains-mono-latin.woff2") format("woff2"); }

:root {
  --paper: #0a0c0a;
  --panel: #0e110e;
  --panel2: #121612;
  --line: #1e241e;
  --ink: #c8d2c6;
  --dim: #899585;
  --faint: #596956;
  --accent: #90f910;
  --accent-dim: #4a7d08;
  --danger: #ff5544;
  --mono: "Cascadia Mono", "Consolas", "JetBrains Mono", "Courier New", monospace;
}

:root[data-theme="light"] {
  --paper: #efe8d9; --panel: #e7dfcd; --panel2: #ded5c0; --line: #c4bba7;
  --ink: #080808; --dim: #575347; --faint: #756f61; --accent: #436b00; --accent-dim: #5c790d;
}

#look-controls .ctl-section { border: 0; padding: 0; }

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 232px 1fr 268px;
  height: 100vh;
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ---------- left rail ---------- */
#rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--accent);
  white-space: nowrap;
}
.brand-mark { letter-spacing: 0; }
.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 1px;
  margin-top: 2px;
}

.rail-block { display: flex; flex-direction: column; gap: 8px; }

.block-title {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

/* dropzone */
#dropzone {
  border: 1px dashed var(--faint);
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  color: var(--dim);
  transition: border-color .15s, color .15s, background .15s;
}
#dropzone:hover, #dropzone:focus-visible {
  border-color: var(--accent);
  color: var(--ink);
  outline: none;
}
#dropzone.armed { border-color: var(--accent); background: #14200a; color: var(--accent); }
.dz-icon { font-size: 18px; line-height: 1; margin-bottom: 6px; }
.dz-text span { font-size: 10px; color: var(--faint); }

.source-info { display: flex; flex-direction: column; gap: 3px; }
.src-row { display: flex; gap: 6px; font-size: 11px; }
.src-row .k { color: var(--faint); width: 34px; flex: none; }
.src-row .v { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#src-dim { white-space: normal; line-height: 1.5; }

/* buttons */
.btn {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 6px 10px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: border-color .12s, color .12s, background .12s;
}
.btn:hover { border-color: var(--accent-dim); color: var(--accent); }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; }
.btn.icon { width: 28px; padding: 5px 0; text-align: center; }
.btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); }
.btn:disabled { opacity: .4; cursor: default; }
.btn .hint { color: var(--faint); letter-spacing: 0; }
.btn.rec { color: var(--danger); border-color: #3a1512; }
.btn.rec:hover { border-color: var(--danger); }
.btn.rec.recording { background: #2a0f0c; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* transport */
.transport { display: flex; align-items: center; gap: 4px; }
.transport .time { margin-left: auto; font-size: 10px; color: var(--dim); white-space: nowrap; }
#seek { width: 100%; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  background: var(--ink);
  border: 1px solid var(--paper);
  margin-top: -4px;
}
input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent); }

/* presets */
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.preset-btn {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 6px 4px;
  cursor: pointer;
  text-align: center;
  letter-spacing: .5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preset-btn:hover { border-color: var(--accent-dim); color: var(--accent); }
.preset-btn.active { border-color: var(--accent); color: var(--accent); }
.preset-btn.user { border-style: dashed; }
.preset-btn .del {
  float: right; color: var(--faint); padding: 0 2px;
}
.preset-btn .del:hover { color: var(--danger); }
.preset-actions { display: flex; gap: 4px; }
.preset-actions .btn { flex: 1; padding: 5px 4px; font-size: 10px; }

/* export */
.export-grid { display: flex; flex-direction: column; gap: 6px; }
label { display: flex; flex-direction: column; gap: 3px; color: var(--dim); font-size: 10px; letter-spacing: 1px; }
label.chk { flex-direction: row; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 0; color: var(--ink); cursor: pointer; }
select, input[type="number"] {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 4px 6px;
  width: 100%;
}
select:focus, input:focus { outline: 1px solid var(--accent-dim); }
input[type="checkbox"] { accent-color: var(--accent); }
.export-actions { margin-top: 2px; }
.export-video { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.export-video .row { display: flex; gap: 6px; align-items: center; }
.export-video .row.small { font-size: 10px; }
.export-video label { flex-direction: row; align-items: center; gap: 4px; }
.export-video input[type="number"] { width: 56px; }
.hint { color: var(--faint); font-size: 10px; letter-spacing: 0; }
#rec-hint { margin-left: auto; }

/* keys */
.keys-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 10px;
  font-size: 10px;
  color: var(--dim);
}
.keys-grid b { color: var(--ink); font-weight: normal; }

/* ---------- stage ---------- */
#stage {
  position: relative;
  overflow: hidden;
  background: #050605;
  display: flex;
}
#view {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
#empty-state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; padding: 24px; }
#empty-state h1 { font-size: 20px; color: var(--ink); font-weight: normal; margin-bottom: 16px; }
#empty-state p { color: var(--dim); line-height: 1.8; margin-bottom: 12px; }
#view { background: repeating-conic-gradient(#101510 0% 25%, #080b08 0% 50%) 0 0 / 20px 20px; }
.preset-btn { white-space: normal; min-height: 32px; }
button:focus-visible, summary:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
#preset-dialog { margin: auto; width: min(360px, 90vw); padding: 24px; background: var(--panel); color: var(--ink); border: 1px solid var(--accent-dim); }
#preset-dialog::backdrop { background: #000a; }
#preset-form { display: grid; gap: 14px; }
#preset-form h2 { font-size: 16px; font-weight: normal; }
#preset-name { width: 100%; padding: 8px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); font: inherit; }

#drop-overlay {
  position: absolute; inset: 0;
  background: rgba(5, 8, 5, .8);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 30;
}
.drop-frame {
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-size: 22px;
  letter-spacing: 6px;
  padding: 48px 72px;
}

#gl-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  color: var(--dim);
  z-index: 40;
}
#gl-error h2 { color: var(--danger); letter-spacing: 4px; margin-bottom: 10px; }

#focus-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
#btn-focus-exit { position: absolute; top: 12px; right: 14px; pointer-events: auto; }
#focus-transport { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: #0e110eee; padding: 10px 14px; border: 1px solid var(--line); pointer-events: auto; width: min(460px, 90%); }
#focus-seek { flex: 1; min-width: 60px; }
#focus-time { white-space: nowrap; font-size: 11px; }

#rec-indicator {
  position: absolute;
  top: 14px; left: 16px;
  z-index: 20;
  color: var(--danger);
  font-size: 12px;
  letter-spacing: 2px;
  display: flex; align-items: center; gap: 8px;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s infinite;
}

#toast {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel2);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 8px 16px;
  font-size: 11px;
  letter-spacing: 1px;
  z-index: 50;
  white-space: nowrap;
}

/* ---------- right panel ---------- */
#panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

#controls { padding: 12px 14px 30px; display: flex; flex-direction: column; gap: 2px; }

.ctl-section { border-bottom: 1px solid var(--line); padding: 6px 0 10px; }
.ctl-section > summary {
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--dim);
  list-style: none;
  user-select: none;
  padding: 4px 0;
}
.ctl-section > summary::before { content: "▸ "; color: var(--faint); }
.ctl-section[open] > summary::before { content: "▾ "; }
.ctl-section > summary:hover { color: var(--ink); }

.ctl { margin-top: 8px; }
.ctl-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; color: var(--ink);
}
.ctl-val { color: var(--dim); font-size: 10px; }
.ctl input[type="range"] { width: 100%; }
.ctl-row { display: flex; gap: 8px; }
.ctl-row .ctl { flex: 1; }
.ctl-sep { height: 8px; }
.ctl-inline { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; }
.ctl-inline select { flex: 1; width: auto; }
.ctl-inline input[type="color"] {
  width: 26px; height: 20px; padding: 0; border: 1px solid var(--line);
  background: none; cursor: pointer;
}
.ctl-btns { display: flex; gap: 4px; margin-top: 8px; }
.ctl-btns .btn { flex: 1; font-size: 10px; padding: 5px 2px; }

/* ---------- focus mode ---------- */
body.focus #rail, body.focus #panel { display: none; }
body.focus #app { grid-template-columns: 0 1fr 0; }
body.focus #stage { grid-column: 2; }
body.focus #rail, body.focus #panel { border: none; overflow: hidden; }

/* compact */
@media (max-width: 1100px) {
  #app { grid-template-columns: 200px 1fr 240px; }
}
@media (max-width: 760px) {
  #app > *, .rail-block, .source-info, .src-row { min-width: 0; }
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; grid-template-columns: minmax(0, 1fr); }
  #stage { grid-row: 1; height: 55vh; min-height: 260px; }
  #rail, #panel { overflow: visible; }
  #rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand, .keys { grid-column: 1 / -1; }
  body.focus #app { height: 100vh; grid-template-columns: 1fr; }
  body.focus #stage { grid-column: 1; height: 100vh; }
}

/* OpenBored integration: exports remain visible while browsing the controls. */
.back-board { color: var(--dim); font-size: 11px; text-decoration: none; }
.no-js { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; gap: 20px; background: var(--paper); padding: 30px; text-align: center; }
.no-js a { color: var(--accent); }
.back-board:hover { color: var(--accent); }
.quick-export { position: sticky; top: -14px; z-index: 10; background: var(--panel); padding: 10px 0; border-bottom: 1px solid var(--line); }
.export-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.export-buttons .btn { padding: 9px 2px; letter-spacing: 0; font-size: 11px; }
.quick-export p { margin-top: 8px; line-height: 1.4; }
#rail { gap: 14px; }
#toast { white-space: normal; max-width: calc(100% - 24px); width: max-content; text-align: center; line-height: 1.5; }
@media (max-width: 760px) {
  .back-board, .quick-export { grid-column: 1 / -1; }
  .quick-export { position: static; }
  #rail { padding-bottom: 16px; }
  .export-buttons .btn { font-size: 13px; }
}
