:root {
  --cream: #faf3e0;
  --cream-2: #f5efe6;
  --card: #fffdf7;
  --teal: #0f8b8d;
  --teal-dark: #0a6e70;
  --teal-soft: #2a9d8f;
  --ink: #2b2b2b;
  --muted: #6b6b6b;
  --line: #e6dcc8;
  --danger: #c0564b;
  --shadow: 0 2px 10px rgba(40, 30, 10, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over display rules set in classes below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
}

h1, h2, h3 { font-weight: 700; }
h2 { margin-top: 0; color: var(--teal-dark); }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--teal);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar h1 { margin: 0; font-size: 1.4rem; }
.auth .who { display: inline-flex; align-items: center; gap: 10px; }
#who-name { font-weight: 600; }

/* ---- tabs ---- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 22px 0;
  flex-wrap: wrap;
}
.tab {
  border: none;
  background: var(--cream-2);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.tab.active { background: var(--card); color: var(--teal-dark); font-weight: 600; }

/* ---- panels ---- */
main { padding: 22px; max-width: 920px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.6); color: inherit; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- wheel ---- */
.wheel-wrap { position: relative; width: 420px; max-width: 100%; margin: 10px auto; }
#wheel { width: 100%; height: auto; display: block; }
.wheel-pointer {
  position: absolute;
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
  font-size: 2rem;
  color: var(--teal-dark);
}
.wheel-controls { text-align: center; margin: 12px 0; }
.wheel-result { font-size: 1.3rem; font-weight: 700; color: var(--teal-dark); min-height: 1.5em; }
.recent-spins { margin-top: 20px; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 0.9rem; }
input[type=text], input[type=date], input[type=password], select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 1rem;
  color: var(--ink);
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.slider-row { margin: 16px 0; }
.slider-row label { display: block; font-weight: 600; margin-bottom: 4px; }
.slider-row output { color: var(--teal-dark); }
input[type=range] { width: 100%; accent-color: var(--teal); }

.attendees { border: 1px solid var(--line); border-radius: 8px; margin: 14px 0; }
.attendees legend { font-weight: 600; padding: 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cream-2); padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.inline { display: inline-flex; align-items: center; gap: 6px; }

/* ---- cards ---- */
.cards { display: grid; gap: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; }
.card .meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.score-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: var(--cream-2);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
}
.pill strong { color: var(--teal-dark); }
.pill.total { background: var(--teal); color: #fff; }
.pill.total strong { color: #fff; }
.voter-line { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }

/* ---- tables ---- */
.board-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
table.board { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.board th, table.board td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.board th { background: var(--cream-2); color: var(--teal-dark); }
table.board tr:last-child td { border-bottom: none; }

/* ---- lists / admin ---- */
.admin-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.admin-block h3 { margin-top: 0; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: none; }
#cycle-chosen li { display: flex; align-items: center; justify-content: space-between; }
.respin { padding: 3px 12px; font-size: 0.8rem; }
.add-member { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.badge { font-size: 0.75rem; background: var(--teal-soft); color: #fff; border-radius: 999px; padding: 2px 8px; margin-left: 6px; }

.notice { background: var(--cream-2); border-radius: 8px; padding: 12px; color: var(--muted); }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(40, 30, 10, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  width: min(380px, 92vw); box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.hint { font-size: 0.85rem; color: var(--muted); }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 60; font-size: 0.95rem;
}
.toast.error { background: var(--danger); }
