:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --border-strong: #d2d7dd;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #1f5eff;
  --accent-soft: #eef3ff;
  --good: #0f9d58;
  --warn: #b26a00;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215;
    --surface: #181b1f;
    --border: #272b31;
    --border-strong: #343a42;
    --text: #e9ecef;
    --muted: #9aa3ad;
    --accent: #6b9bff;
    --accent-soft: #1a2440;
    --good: #4ec98a;
    --warn: #e0a44a;
    --danger: #e0685c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------- brand */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.brand.small h1 { font-size: 16px; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  background: var(--accent); color: #fff;
  border-radius: 9px;
  font-weight: 700; font-size: 14px; letter-spacing: .04em;
}

/* ------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ------------------------------------------------------------ buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit; font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: var(--border-strong); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.error { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }

/* ------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  background: none; border: none; cursor: pointer;
  font: inherit; color: var(--muted);
  padding: 7px 14px; border-radius: 8px;
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

main { max-width: 880px; margin: 0 auto; padding: 28px 24px 12px; }
.panel-head { margin-bottom: 18px; }
.panel-head h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 62ch; }

.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------------------------------------------------------- vote card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.card-note { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.card-meta { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }

.pill {
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--border);
}
.pill.done { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); border-color: transparent; }
.pill.open { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: transparent; }
.pill.mine { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.scale { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.scale button {
  flex: 1 1 0; min-width: 38px;
  padding: 9px 0;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface); color: var(--text);
  font: inherit; font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.scale button:hover { border-color: var(--accent); color: var(--accent); }
.scale button.selected { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.scale-hint { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* -------------------------------------------------------- leaderboard */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.board { width: 100%; border-collapse: collapse; font-size: 14px; }
table.board th, table.board td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.board th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
table.board tr:last-child td { border-bottom: none; }
table.board .num { text-align: right; font-variant-numeric: tabular-nums; }
.col-rank { width: 44px; }
.rank { font-variant-numeric: tabular-nums; color: var(--muted); }
.rank.top { color: var(--accent); font-weight: 700; }
.board-name { font-weight: 600; }
.board-note { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: 2px; }
.avg { font-weight: 700; font-size: 15px; }
.dash { color: var(--muted); }

/* ------------------------------------------------------------ suggest */
.suggest-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.row { display: flex; gap: 10px; }
.row.end { justify-content: flex-end; }

/* ----------------------------------------------------------- password */
.pw-card {
  position: fixed; inset: auto 24px 24px auto;
  width: min(320px, calc(100vw - 48px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  z-index: 20;
}
.pw-card h3 { margin: 0; font-size: 15px; }

.foot {
  max-width: 880px; margin: 0 auto; padding: 20px 24px 40px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 13px;
}

.empty { color: var(--muted); padding: 28px; text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 40;
}

@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .who { margin-left: auto; }
  main { padding: 20px 16px 8px; }
}
