/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg-surface: #14141f;
  --bg-hover: #1e1e2e;
  --text: #e8e8f0;
  --text-dim: #888899;
  --accent: #6c8cff;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --border: #2a2a3a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5a7aee; }
.btn-go { background: #166534; border-color: var(--green); color: var(--green); }
.btn-go:hover { background: #15803d; }
.btn-warn { background: #713f12; border-color: var(--amber); color: var(--amber); }
.btn-warn:hover { background: #854d0e; }
.btn-danger { background: #7f1d1d; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #991b1b; }

/* ===== CONTROL PANEL ===== */
#control-panel {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.cp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.cp-header h1 { font-size: 22px; font-weight: 600; }
.cp-header-actions { display: flex; align-items: center; gap: 8px; }

.total-time {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.total-time.over { color: var(--red); border-color: var(--red); }
.total-time.under { color: var(--green); border-color: var(--green); }

/* State Summary */
.state-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.summary-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.summary-label { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-dim); letter-spacing: 0.5px; }
.summary-value { display: block; font-size: 18px; font-weight: 600; margin-top: 4px; }

/* Transport Controls */
.transport-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-wrap: wrap;
}
.btn-transport { padding: 10px 20px; font-size: 15px; font-weight: 600; }
.btn-adjust { font-weight: 600; font-size: 14px; }
.transport-spacer { flex: 1; }

/* Agenda Editor */
.agenda-editor { margin-top: 16px; }
.agenda-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.agenda-header h2 { font-size: 18px; }

.agenda-list { display: flex; flex-direction: column; gap: 2px; }

.segment-section-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  padding: 12px 8px 4px;
  margin-top: 8px;
}
.segment-section-header:first-child { margin-top: 0; }

.segment-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 80px 120px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: background 0.15s;
}
.segment-row:hover { background: var(--bg-hover); }
.segment-row.active {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}
.segment-row.completed { opacity: 0.5; }

.segment-index {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  font-weight: 600;
}

.segment-row input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
}
.segment-row input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}
.segment-row input[type="number"] {
  width: 70px;
  text-align: center;
  -moz-appearance: textfield;
}
.segment-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.segment-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.segment-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
}
.segment-actions button:hover { background: var(--bg-hover); color: var(--text); }
.segment-actions button.delete-btn:hover { color: var(--red); }

.keyboard-hints {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 10px;
  border-top: 1px solid var(--border);
}

/* ===== THEATRE DISPLAY ===== */
.theatre {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}
.theatre[hidden] { display: none; }

.progress-bar-container {
  height: 6px;
  background: #1a1a2a;
  width: 100%;
  flex-shrink: 0;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.5s linear;
}

.theatre-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3vh 5vw;
  text-align: center;
}

.theatre-topic {
  font-size: clamp(24px, 4vw, 56px);
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 1vh;
}

.theatre-speaker {
  font-size: clamp(48px, 10vw, 140px);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 2vh;
}

.theatre-timer {
  font-size: clamp(80px, 18vw, 260px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--green);
  transition: color 0.3s;
}

.theatre-timer.amber { color: var(--amber); }
.theatre-timer.red { color: var(--red); }
.theatre-timer.overtime {
  color: var(--red);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.theatre-next {
  margin-top: 3vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.next-label {
  font-size: clamp(12px, 1.5vw, 18px);
  color: var(--text-dim);
  letter-spacing: 2px;
  font-weight: 600;
}
.next-info {
  font-size: clamp(16px, 2.5vw, 32px);
  color: var(--text);
  opacity: 0.7;
}

.theatre-pace {
  padding: 12px;
  text-align: center;
  font-size: clamp(14px, 2vw, 22px);
  color: var(--text-dim);
  flex-shrink: 0;
}
.theatre-pace.ahead { color: var(--green); }
.theatre-pace.behind { color: var(--red); }

/* Event Complete */
.theatre-complete {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
}
.theatre-complete[hidden] { display: none; }
.complete-title {
  font-size: clamp(48px, 8vw, 120px);
  font-weight: 700;
  color: var(--green);
  margin-bottom: 3vh;
}
.complete-stats {
  font-size: clamp(20px, 3vw, 40px);
  color: var(--text-dim);
  line-height: 1.8;
  text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .state-summary { grid-template-columns: repeat(2, 1fr); }
  .segment-row { grid-template-columns: 28px 1fr 80px 90px; }
  .segment-row input:nth-child(3) { display: none; } /* hide topic on small */
}
