/* Tiny Traps: The Perils of Almost - Drylab Stylesheet */

:root {
  --bg-void: #060911;
  --bg-panel: #0d1322;
  --bg-panel-2: #121a2e;
  --bg-ctrl: #17213a;
  --border-dim: rgba(130, 170, 255, 0.16);
  --border-hi: rgba(110, 210, 255, 0.45);
  --txt-main: #e8eefc;
  --txt-muted: #93a4c7;
  --txt-dim: #6c7ea3;
  --accent-cyan: #38e2ff;
  --accent-gold: #ffbe4f;
  --accent-mag: #ff4d8d;
  --accent-grn: #3ee69a;
  --accent-vio: #a57bff;
  --radius-sm: 6px;
  --radius-md: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  color: var(--txt-main);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #10182b 0%, #0a101d 100%);
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.brand h1 span {
  font-weight: 400;
  color: var(--accent-cyan);
}

.brand .credit {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--txt-muted);
}

.brand .credit strong {
  color: #d6e2ff;
  font-weight: 600;
}

.global-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fold-ctrl {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: var(--bg-ctrl);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--txt-muted);
}

.fold-ctrl input[type="range"] {
  width: 78px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.fold-ctrl output {
  min-width: 24px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
  font-weight: 600;
}

.tool-btn,
.mini-btn {
  appearance: none;
  border: 1px solid var(--border-dim);
  background: var(--bg-ctrl);
  color: var(--txt-main);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-btn:hover,
.mini-btn:hover {
  background: #202e50;
  border-color: var(--border-hi);
}

.tool-btn.active {
  background: rgba(56, 226, 255, 0.14);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(56, 226, 255, 0.18);
}

.tool-btn.audio-btn.active {
  background: rgba(62, 230, 154, 0.15);
  border-color: var(--accent-grn);
  color: var(--accent-grn);
  box-shadow: 0 0 12px rgba(62, 230, 154, 0.22);
}

.mini-btn {
  padding: 3px 9px;
  font-size: 11px;
}

/* 9-Tab Navigation Ribbon */
.tab-nav {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
  padding: 7px 12px;
  background: #090e1a;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}

.tab-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  color: var(--txt-muted);
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  background: #141e35;
  color: var(--txt-main);
  border-color: rgba(130, 180, 255, 0.35);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(56, 226, 255, 0.18), rgba(165, 123, 255, 0.16));
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--accent-cyan);
}

.tab-num {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.04em;
}

.tab-btn.active .tab-num {
  color: var(--accent-cyan);
}

.tab-lbl {
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Main Split Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* 3D Kaleidoscope Stage */
.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 48%, #101a33 0%, #070b15 62%, #04060c 100%);
  overflow: hidden;
  border-right: 1px solid var(--border-dim);
}

#stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#stage-canvas:active {
  cursor: grabbing;
}

.hud-top,
.hud-bottom {
  position: absolute;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud-top {
  top: 12px;
}

.hud-bottom {
  bottom: 12px;
  align-items: flex-end;
}

.hud-badge {
  background: rgba(10, 16, 30, 0.82);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-cyan);
  backdrop-filter: blur(6px);
}

.hud-eq {
  background: rgba(10, 16, 30, 0.78);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-gold);
  backdrop-filter: blur(6px);
}

.hud-hint {
  background: rgba(8, 12, 22, 0.72);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 11px;
  color: var(--txt-muted);
}

.scope-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  background: rgba(8, 12, 22, 0.84);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
}

.scope-lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--accent-grn);
}

#scope-canvas {
  display: block;
  width: 160px;
  height: 36px;
  background: #04070f;
  border-radius: 4px;
  border: 1px solid rgba(62, 230, 154, 0.25);
}

/* Right Inspector Column */
.inspector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #0a0f1d;
  overflow-y: auto;
  min-height: 0;
}

.inspector::-webkit-scrollbar {
  width: 7px;
}

.inspector::-webkit-scrollbar-track {
  background: #080c16;
}

.inspector::-webkit-scrollbar-thumb {
  background: #223052;
  border-radius: 4px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 11px 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.panel h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--txt-muted);
}

.panel-head h3 {
  margin: 0;
}

.muted {
  margin: 0 0 9px;
  font-size: 12.5px;
  color: var(--txt-muted);
}

/* Status Pills */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-hi);
  background: rgba(56, 226, 255, 0.14);
  color: var(--accent-cyan);
  white-space: nowrap;
}

.pill.ok {
  border-color: var(--accent-grn);
  background: rgba(62, 230, 154, 0.14);
  color: var(--accent-grn);
}

.pill.warn {
  border-color: var(--accent-gold);
  background: rgba(255, 190, 79, 0.15);
  color: var(--accent-gold);
}

.pill.trap {
  border-color: var(--accent-mag);
  background: rgba(255, 77, 141, 0.16);
  color: var(--accent-mag);
}

.pill.open {
  border-color: var(--accent-vio);
  background: rgba(165, 123, 255, 0.16);
  color: var(--accent-vio);
}

/* Preset Buttons */
.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  appearance: none;
  flex: 1 1 auto;
  min-width: 96px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
  background: var(--bg-ctrl);
  color: var(--txt-main);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--border-hi);
  background: #1f2d4f;
}

.preset-btn.active {
  border-color: var(--accent-gold);
  background: rgba(255, 190, 79, 0.16);
  color: var(--accent-gold);
}

.preset-btn.trap-btn.active {
  border-color: var(--accent-mag);
  background: rgba(255, 77, 141, 0.18);
  color: #ff80ae;
}

/* Controls Host */
.controls-host {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ctrl-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctrl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.ctrl-lbl {
  color: var(--txt-main);
  font-weight: 500;
}

.ctrl-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-cyan);
  font-weight: 600;
}

.ctrl-range {
  width: 100%;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.ctrl-select {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-ctrl);
  color: var(--txt-main);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
}

.ctrl-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
}

.ctrl-toggle input {
  accent-color: var(--accent-cyan);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.ctrl-btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ctrl-action {
  appearance: none;
  flex: 1 1 auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hi);
  background: rgba(56, 226, 255, 0.12);
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ctrl-action:hover {
  background: rgba(56, 226, 255, 0.22);
}

/* Telemetry Readouts */
.tele-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tele-item {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-width: 0;
}

.tele-item.span-2 {
  grid-column: 1 / -1;
}

.tele-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--txt-dim);
  margin-bottom: 2px;
}

.tele-v {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--txt-main);
  word-break: break-word;
}

.tele-v.ok { color: var(--accent-grn); }
.tele-v.warn { color: var(--accent-gold); }
.tele-v.trap { color: var(--accent-mag); }
.tele-v.open { color: var(--accent-vio); }

.tele-mono {
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.35;
  color: #cfe3ff;
  background: #070b15;
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 6px 7px;
  word-break: break-all;
  max-height: 130px;
  overflow-y: auto;
}

/* Sonic Twin Panel */
.card-sonic {
  border-color: rgba(62, 230, 154, 0.26);
  background: linear-gradient(180deg, rgba(16, 32, 34, 0.55) 0%, var(--bg-panel) 100%);
}

.sonic-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-grn);
  margin-bottom: 4px;
}

.sonic-desc {
  margin: 0;
  font-size: 12px;
  color: #c2d4e8;
}

/* Viewpoint Essay Drawer */
.card-essay summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-gold);
  user-select: none;
}

.card-essay h4 {
  margin: 9px 0 6px;
  font-size: 13.5px;
  color: #ffffff;
}

.essay-body p {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: #c3d0ea;
  line-height: 1.5;
}

.essay-body p:last-child {
  margin-bottom: 0;
}

.essay-body code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-cyan);
  background: rgba(56, 226, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .tab-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr) 350px;
  }
}

@media (max-width: 820px) {
  html,
  body {
    overflow: auto;
  }
  #app-shell {
    height: auto;
    min-height: 100vh;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .stage-wrap {
    height: 56vh;
    min-height: 360px;
    border-right: none;
    border-bottom: 1px solid var(--border-dim);
  }
}
