/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #21262d;
  --border:       #30363d;
  --accent:       #58a6ff;
  --accent-dim:   #1f6feb;
  --danger:       #f85149;
  --danger-dim:   #7d2626;
  --success:      #3fb950;
  --warning:      #d29922;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-subtle:  #484f58;
  --radius:       14px;
  --radius-sm:    8px;
  --transition:   0.15s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

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

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); display: block; margin-bottom: 6px; }

/* ── Layout helpers ─────────────────────────────────────────────────────────── */
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.row    { display: flex; align-items: center; gap: 10px; }
.gap-sm { gap: 6px; }
.w-full { width: 100%; }

/* ── Form fields ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }

input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition);
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-subtle); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  -webkit-user-select: none; user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--accent);    color: #000; }
.btn-primary:hover:not(:disabled) { background: #79c0ff; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger   { background: var(--danger);    color: #fff; }
.btn-danger:hover:not(:disabled) { background: #ff6b6b; }

.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }

.btn-full { width: 100%; }

.btn-xl {
  padding: 22px;
  font-size: 1.2rem;
  border-radius: var(--radius);
  flex: 1;
}

.btn-icon {
  padding: 10px 14px;
  font-size: 1.1rem;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.btn-icon:hover { background: var(--border); color: var(--text); }

/* ── Error / status messages ────────────────────────────────────────────────── */
.error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.9rem;
}

/* ── Status dot ─────────────────────────────────────────────────────────────── */
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-green  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-yellow { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.dot-red    { background: var(--danger);  box-shadow: 0 0 6px var(--danger);  }

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

/* ── Join page ──────────────────────────────────────────────────────────────── */
.join-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.join-card {
  width: 100%;
  max-width: 420px;
}

.join-card .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

.join-card h1 {
  margin-bottom: 28px;
  font-size: 1.5rem;
}

/* ── Control page ───────────────────────────────────────────────────────────── */
.control-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* Header */
.ctrl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 8px;
}

.ctrl-header .room-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.ctrl-header .user-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.ctrl-header .header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Slide counter */
.slide-counter {
  text-align: center;
  margin-bottom: 28px;
}

.slide-counter .current {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.slide-counter .total {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Nav buttons */
.nav-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

/* Jump section */
.jump-section {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.jump-section input {
  width: 80px;
  flex-shrink: 0;
  text-align: center;
  padding: 12px 10px;
}

.jump-section label {
  margin-bottom: 0;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Black screen button */
.blackscreen-btn {
  width: 100%;
  margin-bottom: 20px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.blackscreen-btn.active {
  background: #1a1a1a;
  border-color: var(--text-subtle);
  color: var(--text-muted);
}

/* Timer section */
.timer-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.timer-display {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.timer-controls { display: flex; gap: 10px; }

/* Notes section */
.notes-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.notes-header {
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.notes-header:hover { color: var(--text); }
.notes-header .arrow { transition: transform var(--transition); }
.notes-section.open .notes-header .arrow { transform: rotate(180deg); }

.notes-body {
  display: none;
  padding: 18px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
}

.notes-section.open .notes-body { display: block; }
.notes-empty { color: var(--text-subtle); font-style: italic; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 20px 22px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 { font-size: 1.05rem; }

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px 22px;
}

.log-list { list-style: none; }

.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.log-item:last-child { border-bottom: none; }

.log-time { color: var(--text-subtle); white-space: nowrap; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.log-user { color: var(--accent); font-weight: 600; }
.log-action { color: var(--text-muted); }

.log-empty {
  text-align: center;
  color: var(--text-subtle);
  padding: 30px 0;
  font-style: italic;
}

/* ── Connection status banner ───────────────────────────────────────────────── */
.conn-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--warning);
  color: #000;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px;
  z-index: 200;
  display: none;
}

.conn-banner.show { display: block; }

/* ── Scrollbar styling ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
