:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-panel: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-dim: #666;
  --accent-green: #27ae60;
  --accent-red: #c0392b;
  --accent-yellow: #f1c40f;
  --accent-blue: #3498db;
  --border-color: #2c3e6d;
  --border-radius: 6px;
  --font-ui: -apple-system, 'Segoe UI', system-ui, sans-serif;
  --transition-fast: 150ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-rows: 1fr auto;
  width: 100%; height: 100%;
}

#video-container {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 8px 8px 0;
  border-radius: var(--border-radius);
}

#video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#serial-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-dim);
  font-size: 16px;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

.fullscreen #control-panel { display: none; }
.fullscreen #video-container { margin: 0; border-radius: 0; }

#app.script-open {
  grid-template-columns: 1fr 30%;
}

#app.script-open #script-panel {
  display: flex;
  grid-column: 2;
  grid-row: 1;
}

#app.script-open #control-panel {
  grid-column: 1 / -1;
}

select, input[type="text"] {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 13px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0a0' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  cursor: pointer;
}

select:focus, input[type="text"]:focus {
  border-color: var(--accent-blue);
}

.btn {
  height: 30px;
  padding: 0 14px;
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn:hover { background: var(--border-color); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-danger { background: var(--accent-red); border-color: var(--accent-red); }
.btn-danger:hover { background: #e74c3c; }
.btn-success { background: var(--accent-green); border-color: var(--accent-green); }
.btn-success:hover { background: #2ecc71; }

.status-text {
  font-size: 12px;
  margin-top: 4px;
  transition: color var(--transition-fast);
}

.status-ok { color: var(--accent-green); }
.status-err { color: var(--accent-red); }
.status-warn { color: var(--accent-yellow); }
