:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --ink: #1f2330;
  --muted: #6b7280;
  --accent: #3369e8;
  --accent-ink: #ffffff;
  --good: #21ba45;
  --warn: #f2c037;
  --line: #e5e7eb;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  font-family: 'Quicksand', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161d;
    --panel: #1d2030;
    --ink: #eef0f5;
    --muted: #9aa0ad;
    --line: #2a2f42;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(135deg, #3369e8, #6a4cff);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.2px; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,0.15);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.4);
}
.brand-sub { font-size: 0.95rem; opacity: 0.85; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 24px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.wheel-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.wheel-stage {
  position: relative;
  width: min(640px, 100%);
  aspect-ratio: 1;
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.18));
}

.pointer {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 36'><polygon points='20,34 4,4 36,4' fill='white' stroke='%231f2330' stroke-width='4' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
  z-index: 3;
}

.hub {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 96px; height: 96px;
  border-radius: 50%;
  background: #fff;
  color: #1f2330;
  border: 4px solid #1f2330;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 2;
  transition: transform 0.15s ease, background 0.15s ease;
}
.hub:hover { transform: translate(-50%, -50%) scale(1.05); background: #fffbe6; }
.hub:active { transform: translate(-50%, -50%) scale(0.97); }
.hub:disabled { cursor: default; opacity: 0.6; }

.result {
  min-height: 2.4rem;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
}
.result .winner-name {
  background: linear-gradient(135deg, #3369e8, #6a4cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.result-actions.hidden { display: none; }
.record-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.record-date input {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.side-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.k-pill {
  font-size: 0.85rem;
  background: rgba(51, 105, 232, 0.12);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}

#k-slider {
  width: 100%;
  accent-color: var(--accent);
}
.k-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}
.explain {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.explain summary { cursor: pointer; }
.explain code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 4px;
}

.speakers {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.speakers th, .speakers td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.speakers th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.speakers tr:last-child td { border-bottom: none; }
.speakers tr.off td { color: var(--muted); text-decoration: line-through; }
.speakers tr.off td:first-child { text-decoration: none; }
.speakers input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}
.bar {
  display: inline-block;
  height: 8px;
  background: linear-gradient(90deg, #3369e8, #6a4cff);
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.friday-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.friday-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.friday-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.friday-table tr:last-child td { border-bottom: none; }
.friday-table .fr-date { font-weight: 600; white-space: nowrap; }

.fr-select {
  width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.fr-select:hover { border-color: var(--accent); }
.fr-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(51, 105, 232, 0.2);
}

.other-dates { margin-top: 12px; }
.other-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.other-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.other-row > span:first-child { font-weight: 600; flex: 1 1 auto; }
.other-row .muted { color: var(--muted); font-size: 0.85rem; }
.h-del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.h-del:hover {
  opacity: 1;
  background: rgba(192, 57, 43, 0.15);
  color: #c0392b;
}
.history.empty { color: var(--muted); font-style: italic; padding: 8px 0; }

button {
  font-family: inherit;
  cursor: pointer;
}
.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(51,105,232,0.3);
}
.primary:hover { filter: brightness(1.07); }
.ghost, .ghost-sm {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 500;
}
.ghost-sm { padding: 4px 10px; font-size: 0.82rem; }
.ghost:hover, .ghost-sm:hover { background: rgba(0,0,0,0.04); }

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  max-width: 420px;
  width: 90%;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog h2 { margin: 0 0 6px; }
dialog .muted { color: var(--muted); font-size: 0.85rem; margin: 0 0 12px; }
#names-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2330;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  font-size: 0.9rem;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { background: #c0392b; }
