:root {
  --bg-primary: #111111;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --accent: #2c6bed;
  --accent-hover: #1b56d3;
  --border: #333333;
  --sidebar-width: 320px;
  --radius: 4px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* Sidebar Layout */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Sections */
.section {
  margin-bottom: 0.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  cursor: pointer;
  border-radius: var(--radius);
  user-select: none;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.section-header:hover {
  background: #333;
}

.section-content {
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-content.collapsed {
  display: none;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

/* Preview Monitor */
.preview-area {
  flex: 1;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080808;
}

.monitor {
  width: 100%;
  max-width: 1280px;
  aspect-ratio: 16/9;
  background-color: #000;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border: 1px solid #222;
}

.checkerboard {
  background-image: linear-gradient(45deg, #111 25%, transparent 25%),
    linear-gradient(-45deg, #111 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #111 75%),
    linear-gradient(-45deg, transparent 75%, #111 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

#reference-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

/* Bounding Box & Interaction */
.bounding-box {
  position: absolute;
  border: 1px solid var(--accent);
  z-index: 10;
  cursor: move;
  display: flex;
  flex-direction: column;
}

.bounding-box.active {
  outline: 1px solid rgba(44, 107, 237, 0.3);
}

.handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border: 1px solid var(--accent);
  border-radius: 50%;
  z-index: 20;
}

.handle-nw {
  top: -4px;
  left: -4px;
  cursor: nw-resize;
}

.handle-n {
  top: -4px;
  left: calc(50% - 4px);
  cursor: n-resize;
}

.handle-ne {
  top: -4px;
  right: -4px;
  cursor: ne-resize;
}

.handle-w {
  top: calc(50% - 4px);
  left: -4px;
  cursor: w-resize;
}

.handle-e {
  top: calc(50% - 4px);
  right: -4px;
  cursor: e-resize;
}

.handle-sw {
  bottom: -4px;
  left: -4px;
  cursor: sw-resize;
}

.handle-s {
  bottom: -4px;
  left: calc(50% - 4px);
  cursor: s-resize;
}

.handle-se {
  bottom: -4px;
  right: -4px;
  cursor: se-resize;
}

/* Forms & UI Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

input[type="text"],
input[type="number"],
select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  width: 100%;
}

/* Professional number input spinners */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
  padding-right: 1.8rem;
  position: relative;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  width: 1.4rem;
  height: 100%;
  position: absolute;
  right: 0;
  top: 0;
  background: var(--bg-tertiary);
  border-left: 1px solid var(--border);
  cursor: pointer;
  opacity: 1;
  display: block;
}

input[type="number"]:hover {
  border-color: var(--accent);
}

input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(44, 107, 237, 0.2);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="range"] {
  flex: 1;
  height: 4px;
  background: var(--border);
  appearance: none;
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

/* Button Groups */
.btn-group {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.btn-toggle {
  flex: 1;
  padding: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  border-right: 1px solid var(--border);
}

.btn-toggle:last-child {
  border-right: none;
}

.btn-toggle.active {
  background: var(--accent);
  color: white;
}

/* OBS Links Panel */
.obs-links {
  padding: 1rem;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
}

.link-field {
  display: flex;
  gap: 4px;
  margin-top: 0.5rem;
}

.link-field input {
  background: #0d0d0d;
  font-family: monospace;
  font-size: 0.75rem;
  color: #666;
  border: 1px solid #333;
}

.btn-copy {
  padding: 0 0.75rem;
  background: #222;
  border: 1px solid #333;
  color: #eee;
  cursor: pointer;
  font-size: 0.7rem;
}

.btn-copy:hover {
  background: #333;
}

/* Status (Silent) */
#status-badge {
  display: none;
}

/* Sponsors Cards */
.sponsor-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sponsor-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sponsor-card .thumb {
  width: 40px;
  height: 40px;
  background: #000;
  border-radius: 2px;
  object-fit: contain;
}

.sponsor-card .info {
  flex: 1;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-danger {
  color: #ff4d4d;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

/* Grid 3x3 Positon Selector */
.pos-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  width: 60px;
  height: 60px;
}

.pos-dot {
  background: #333;
  border-radius: 2px;
  cursor: pointer;
}

.pos-dot.active {
  background: var(--accent);
}

/* Utils */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.w-full {
  width: 100%;
}

.mt-2 {
  margin-top: 0.5rem;
}

#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
}

.toast {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}