:root {
  --bg-deep: #10131a;
  --bg-panel: #171b24;
  --bg-card: #1f2533;
  --border-subtle: rgba(188, 165, 255, 0.16);
  --text-main: #f2f4fa;
  --text-muted: #9da6bd;
  --accent: #b784ff;
  --accent-strong: #9353f5;
  --teal: #3ad1c3;
  --rose: #ff5b8b;
  --sidebar-width: 340px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background: var(--bg-deep);
}

/* OBS Mode: pure transparent output */
html.obs-mode,
body.obs-mode {
  background: transparent !important;
}

body.obs-mode .sidebar,
body.obs-mode .stage-topbar,
body.obs-mode .pip-wrap,
body.obs-mode .toast-banner {
  display: none !important;
}

body.obs-mode .studio-shell {
  grid-template-columns: 1fr !important;
}

body.obs-mode .stage-wrap {
  background: transparent !important;
}

.studio-shell {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  width: 100vw;
  height: 100vh;
}

.studio-shell.sidebar-hidden {
  grid-template-columns: 1fr;
}

.studio-shell.sidebar-hidden .sidebar {
  display: none;
}

.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-wrap.bg-studio {
  background: radial-gradient(circle at 50% 42%, #292f42 0%, #161923 65%, #0e1017 100%);
}

.stage-wrap.bg-checker {
  background-color: #20242d;
  background-image:
    linear-gradient(45deg, #2a303c 25%, transparent 25%),
    linear-gradient(-45deg, #2a303c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a303c 75%),
    linear-gradient(-45deg, transparent 75%, #2a303c 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

.stage-wrap.bg-green {
  background: #00ff00;
}

.stage-wrap.bg-magenta {
  background: #ff00ff;
}

.stage-topbar {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.stage-topbar > * {
  pointer-events: auto;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(18, 21, 30, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  font-size: 12.5px;
  font-weight: 500;
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.dot-live.ok {
  background: var(--teal);
  box-shadow: 0 0 8px rgba(58, 209, 195, 0.9);
}

.fps-pill {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(183, 132, 255, 0.16);
  color: #dcc3ff;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.canvas-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

#vtuber-canvas,
#fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#fx-canvas {
  pointer-events: none;
}

.pip-wrap {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 176px;
  height: 132px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: rgba(12, 14, 20, 0.86);
  z-index: 15;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.pip-wrap.hidden {
  display: none;
}

#webcam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#webcam-video.unmirrored {
  transform: none;
}

.pip-label {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
}

.toast-banner {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(23, 27, 36, 0.94);
  border: 1px solid var(--accent);
  font-size: 13px;
  z-index: 30;
  pointer-events: none;
}

.toast-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Sidebar */
.sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, #d6b6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.panel h2 {
  margin: 0 0 2px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ccb6f7;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.seg-btn {
  border: 1px solid var(--border-subtle);
  background: rgba(16, 19, 26, 0.6);
  color: var(--text-muted);
  padding: 8px 6px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: linear-gradient(135deg, rgba(147, 83, 245, 0.35), rgba(58, 209, 195, 0.22));
  border-color: var(--accent);
  color: #ffffff;
}

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

.field-row label {
  font-size: 12px;
  color: var(--text-muted);
}

select {
  background: #141821;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
}

.toggle-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chk {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  cursor: pointer;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.btn {
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-main);
  background: rgba(28, 33, 46, 0.85);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  background: rgba(45, 50, 70, 0.95);
}

.btn-primary,
.btn-accent {
  background: linear-gradient(135deg, var(--accent-strong), #6e45e2);
  border-color: rgba(210, 178, 255, 0.45);
}

.btn-primary:hover,
.btn-accent:hover {
  background: linear-gradient(135deg, #a168fa, #7d55ec);
}

.full-width {
  width: 100%;
}

.hotkey-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.hk-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  text-align: left;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: #151923;
  color: var(--text-main);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hk-btn:hover {
  border-color: var(--accent);
}

.hk-btn.active {
  background: rgba(147, 83, 245, 0.25);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(183, 132, 255, 0.35);
}

.hk-btn kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 11px;
  font-weight: 700;
  color: #e4d2ff;
}

.obs-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 7px;
  background: #131720;
  border: 1px dashed rgba(58, 209, 195, 0.45);
}

.obs-label {
  font-size: 11px;
  color: var(--teal);
  font-weight: 600;
}

#obs-url-code {
  font-family: Consolas, monospace;
  font-size: 11.5px;
  color: #dbeafe;
  word-break: break-all;
}
