/* ── Variables ─────────────────────────────────────── */
:root {
  --bg:           #0c0c0c;
  --surface:      #161616;
  --surface-2:    #1e1e1e;
  --border:       #2a2a2a;
  --accent:       #7c3aed;
  --accent-dim:   #6d28d9;
  --accent-light: #a78bfa;
  --text:         #f4f4f5;
  --text-muted:   #71717a;
  --sidebar-w:    220px;
  --header-h:     52px;
  --reel-h:       280px;
  --reel-item-h:  60px;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Light mode overrides ───────────────────────────── */
[data-theme="light"] {
  --bg:        #fafaf9;
  --surface:   #ffffff;
  --surface-2: #f5f5f4;
  --border:    #e7e5e4;
  --text:      #1c1917;
  --text-muted: #a8a29e;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input {
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; outline: none;
}
input:focus { border-color: var(--accent); }
ul { list-style: none; }

/* ── Layout ─────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; z-index: 10;
}
[data-theme="light"] #header { box-shadow: 0 1px 0 rgba(0,0,0,0.04); }
#app { display: flex; flex: 1; overflow: hidden; }
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
#main-panel { flex: 1; overflow-y: auto; padding: 28px 32px; }

/* ── Header ─────────────────────────────────────────────── */
.logo { font-size: 0.95rem; font-weight: 800; letter-spacing: -0.03em; color: var(--accent); }
.user-info { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-muted); }
.btn-logout {
  font-size: 0.8rem; color: var(--text-muted);
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover { color: var(--text); border-color: var(--text-muted); }

.btn-theme {
  color: var(--text-muted); padding: 4px; border-radius: 6px;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.btn-theme:hover { color: var(--text); border-color: var(--text-muted); }

/* Dark mode: show sun (click to go light); light mode: show moon (click to go dark) */
.icon-sun  { display: block; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar-section { padding: 10px; }
.sidebar-label {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); padding: 6px 4px;
}
#new-list-form { display: flex; gap: 6px; margin-bottom: 6px; }
#new-list-input { flex: 1; min-width: 0; font-size: 0.875rem; }
#list-nav { display: flex; flex-direction: column; gap: 1px; }
.list-item {
  display: flex; align-items: center;
  padding: 7px 6px 7px 10px; border-radius: 6px;
  cursor: pointer; gap: 4px; border-left: 2px solid transparent;
}
.list-item:hover { background: var(--surface-2); }
.list-item.active { background: var(--surface-2); border-left-color: var(--accent); }
.list-name { flex: 1; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delete-list {
  opacity: 0; font-size: 0.7rem; color: var(--text-muted);
  padding: 2px 5px; border-radius: 3px; flex-shrink: 0; transition: opacity 0.1s;
}
.list-item:hover .delete-list { opacity: 1; }
.delete-list:hover { color: var(--accent); background: rgba(229,62,62,0.12); }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.trash-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 4px; cursor: pointer;
}
.trash-toggle:hover .sidebar-label { color: var(--text); }
.trash-chevron {
  font-size: 0.75rem; color: var(--text-muted);
  display: inline-block; transition: transform 0.15s;
}
#trash-section.trash-expanded .trash-chevron { transform: rotate(90deg); }
.trash-item {
  display: flex; align-items: center; padding: 5px 6px;
  gap: 6px; font-size: 0.82rem; color: var(--text-muted);
}
.btn-sm {
  font-size: 0.72rem; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 6px; flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ── Main panel ──────────────────────────────────────────── */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 28px;
}
.list-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.03em; }
.toggle-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.875rem; color: var(--text-muted); cursor: pointer; user-select: none;
}

/* ── Reel ────────────────────────────────────────────────── */
.reel-section { display: flex; flex-direction: column; align-items: center; gap: 20px; margin-bottom: 36px; }
.reel {
  position: relative; width: 340px; height: var(--reel-h);
  overflow: hidden; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.03);
}
[data-theme="light"] .reel {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Gradient overlays fade names at top/bottom of viewport */
.reel::before,
.reel::after {
  content: ''; position: absolute; left: 0; right: 0;
  height: calc((var(--reel-h) - var(--reel-item-h)) / 2);
  z-index: 2; pointer-events: none;
}
.reel::before { top: 0;    background: linear-gradient(to bottom, var(--surface), transparent); }
.reel::after  { bottom: 0; background: linear-gradient(to top,   var(--surface), transparent); }

/* Lines frame the center highlight window */
.reel-highlight {
  position: absolute; left: 0; right: 0;
  top: calc((var(--reel-h) - var(--reel-item-h)) / 2);
  height: var(--reel-item-h);
  border-top: 1.5px solid var(--accent-light);
  border-bottom: 1.5px solid var(--accent-light);
  box-shadow:
    0 -1px 8px rgba(167,139,250,0.3),
    0  1px 8px rgba(167,139,250,0.3);
  z-index: 3; pointer-events: none;
}
.reel-track { will-change: transform; }
.reel-item {
  height: var(--reel-item-h);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; padding: 0 16px;
  transition: filter 0.25s ease-out;
}
/* Blur applied during spin; CSS transition removes it when reel snaps */
.reel.is-spinning .reel-item { filter: blur(3px); }

/* Settled state — winner slot enlarges, neighbours recede */
.reel.is-settled .reel-item {
  color: var(--text-muted);
  transition: font-size 0.25s ease, color 0.25s ease;
}
.reel.is-settled .reel-item.is-winner {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em;
  color: var(--text);
  transition: font-size 0.25s ease, color 0.25s ease;
}
.reel.is-settled .reel-highlight {
  box-shadow:
    0 -1px 16px rgba(167,139,250,0.55),
    0  1px 16px rgba(167,139,250,0.55);
}

.btn-spin {
  width: 160px; height: 52px; background: var(--accent); color: #fff;
  font-size: 1rem; font-weight: 700; letter-spacing: 0.1em; border-radius: 8px;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  box-shadow: 0 2px 10px rgba(124,58,237,0.35);
}
.btn-spin:hover:not(:disabled) { background: var(--accent-dim); }
.btn-spin:active:not(:disabled) { transform: scale(0.96); }
.btn-spin:disabled { opacity: 0.4; cursor: not-allowed; }


/* ── Members ─────────────────────────────────────────────── */
.members-section { margin-bottom: 32px; }
.section-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 10px; }
.member-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.member-item {
  display: flex; align-items: center;
  padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
[data-theme="light"] .member-item { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.member-name { flex: 1; font-size: 0.9rem; }
.pick-count { font-size: 0.68rem; color: var(--text-muted); opacity: 0.6; }
.remove-member {
  opacity: 0; font-size: 0.7rem; color: var(--text-muted);
  padding: 2px 6px; border-radius: 3px; transition: opacity 0.1s;
}
.member-item:hover .remove-member { opacity: 1; }
.remove-member:hover { color: var(--accent); }
.add-member-form { display: flex; gap: 8px; }
.add-member-form input { flex: 1; font-size: 0.875rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  padding: 6px 14px; background: var(--accent); color: #fff;
  border-radius: 8px; font-weight: 600; font-size: 0.875rem;
  transition: background 0.15s; flex-shrink: 0;
}
.btn-primary:hover { background: var(--accent-dim); }

/* ── Empty states ────────────────────────────────────────── */
.empty-hint  { color: var(--text-muted); font-size: 0.85rem; padding: 6px 0; }
.empty-state { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); }

/* ── Error toast ─────────────────────────────────────────── */
#error-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #7f1d1d; color: #fecaca;
  padding: 10px 20px; border-radius: 8px; font-size: 0.875rem;
  z-index: 100; transition: transform 0.25s ease;
  pointer-events: none; white-space: nowrap;
}
#error-toast.visible { transform: translateX(-50%) translateY(0); }
