:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --border: #e3e7ed;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --accent-soft: #e8f0fd;
  --ok: #18794e;
  --ok-soft: #e3f5ea;
  --warn: #a35a00;
  --warn-soft: #fdf1df;
  --danger: #c4320a;
  --danger-soft: #fdebe6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12151a;
    --surface: #1b2028;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2c333e;
    --accent: #6c9cf0;
    --accent-text: #0d1420;
    --accent-soft: #1f2c44;
    --ok: #4cc38a;
    --ok-soft: #173326;
    --warn: #f0a742;
    --warn-soft: #3a2a12;
    --danger: #f2765a;
    --danger-soft: #3d1e17;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); background: var(--danger-soft); padding: 0.6rem 0.8rem; border-radius: 8px; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.7rem 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.topbar .who { display: flex; align-items: center; gap: 0.6rem; min-width: 0; font-size: 0.9rem; color: var(--muted); }
.topbar .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }
main.narrow { max-width: 440px; }
.card-page { margin-top: 8vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); margin-bottom: 12px;
}

/* forms */
label { display: block; margin: 0.8rem 0; font-weight: 600; font-size: 0.95rem; }
input, textarea, select {
  display: block; width: 100%; margin-top: 0.35rem;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.7rem;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; border-radius: 8px; padding: 0.6rem 1rem;
  background: var(--accent); color: var(--accent-text);
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary, .button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
button.danger { background: var(--danger-soft); color: var(--danger); }
.block { width: 100%; padding: 0.8rem; font-size: 1.05rem; }
form button[type='submit'] { width: 100%; margin-top: 0.5rem; }

/* pills */
.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.12rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.todo { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }

/* idea list */
.idea-link { display: block; text-decoration: none; color: inherit; }
.idea-link:hover .card { border-color: var(--accent); }
.idea-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.idea-id { font-size: 0.8rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.idea-name { font-size: 1.05rem; font-weight: 700; margin: 0.15rem 0; }
.meta { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; font-size: 0.85rem; color: var(--muted); }

/* name picker */
.names { display: grid; gap: 8px; margin: 1rem 0; }
.name-option {
  display: flex; align-items: center; gap: 0.7rem; margin: 0; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.9rem; cursor: pointer;
}
.name-option input { width: auto; margin: 0; }
.name-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.name-option.taken { opacity: 0.5; cursor: not-allowed; }
.name-option .sub { margin-left: auto; font-size: 0.8rem; color: var(--muted); }

/* vote form */
.problem { white-space: pre-wrap; }
.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0;
  font-weight: 600;
}
.toggle input { width: 1.3rem; height: 1.3rem; margin: 0; flex: none; }
.criterion { padding: 0.75rem 0; border-top: 1px solid var(--border); }
.criterion:first-of-type { border-top: 0; padding-top: 0; }
.criterion-head { display: flex; justify-content: space-between; gap: 0.5rem; font-weight: 600; margin-bottom: 0.5rem; }
.criterion-head .weight { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 0.65rem 0; font-size: 1.05rem;
}
.scale button[aria-pressed='true'] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.scale-hint { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }
.total { display: flex; align-items: baseline; justify-content: space-between; }
.total strong { font-size: 1.6rem; }
.sticky-submit {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 0.75rem 16px calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.sticky-submit > div { max-width: 720px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: 0.75rem; text-decoration: none; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 0.7rem 1rem; border-radius: 10px;
  background: var(--text); color: var(--bg); font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.qr { display: flex; justify-content: center; margin: 1rem 0; }

/* admin */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: var(--surface); color: var(--text); border-color: var(--border); white-space: nowrap; }
.tabs button[aria-selected='true'] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
code { font-size: 0.85em; background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 4px; word-break: break-all; }
.notice { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.card.done { opacity: 0.75; }
