/* ============================================================
   SKED — app.css
   Themes: light (default) · dark · auto · experimental
   ============================================================ */

/* ---------- 1. Light (default) ---------- */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-raised: #ffffff;
  --border: #dfe7f2;
  --border-strong: #cbd6e5;
  --text: #111936;
  --text-2: #667085;
  --text-3: #8a94a6;
  --brand: #3157e7;
  --brand-strong: #2446ce;
  --brand-dim: rgba(49, 87, 231, 0.12);
  --ok: #16a163;
  --warn: #d88916;
  --err: #db4056;
  --vote-yes: #e9f8ee;
  --vote-yes-text: #087443;
  --vote-maybe: #fff7df;
  --vote-maybe-text: #b26200;
  --vote-no: #fff0f2;
  --vote-no-text: #c72e44;
  --vote-unknown: #f2f5f9;
  --vote-unknown-text: #7b8496;
  --result: #eef2ff;
  --result-text: #34408a;
  --r: 18px;
  --r-sm: 10px;
  --shadow: 0 12px 30px rgba(17, 25, 54, 0.08), 0 2px 6px rgba(17, 25, 54, 0.04);
  --shadow-subtle: 0 1px 2px rgba(17, 25, 54, 0.05);
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --sidebar-width: 244px;
  --font: Inter, ui-sans-serif, system-ui, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

/* ---------- 2. Auto dark (system) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="experimental"]) {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-alt: #1c2128;
    --border: #30363d;
    --text: #c9d1d9;
    --text-2: #7d8590;
    --brand: #58a6ff;
    --brand-dim: rgba(88, 166, 255, 0.15);
    --ok: #3fb950;
    --warn: #d29922;
    --err: #f85149;
    --vote-yes: #1a3826;
    --vote-yes-text: #3fb950;
    --vote-maybe: #36290e;
    --vote-maybe-text: #d29922;
    --vote-no: #3d1c1c;
    --vote-no-text: #f85149;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
    --topbar-bg: rgba(22, 27, 34, 0.92);
  }
}

/* ---------- 3. Explicit dark ---------- */
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c2128;
  --border: #30363d;
  --text: #c9d1d9;
  --text-2: #7d8590;
  --brand: #58a6ff;
  --brand-dim: rgba(88, 166, 255, 0.15);
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --vote-yes: #1a3826;
  --vote-yes-text: #3fb950;
  --vote-maybe: #36290e;
  --vote-maybe-text: #d29922;
  --vote-no: #3d1c1c;
  --vote-no-text: #f85149;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  --topbar-bg: rgba(22, 27, 34, 0.92);
}

/* ---------- 4. Experimental (Neo-brutalist / Starface-inspired) ---------- */
[data-theme="experimental"] {
  --bg: #050505;
  --surface: #0a0a0a;
  --surface-alt: #141414;
  --border: #fefe00;
  --text: #f5f5f5;
  --text-2: #888888;
  --brand: #fefe00;
  --brand-dim: rgba(254, 254, 0, 0.12);
  --ok: #00ff88;
  --warn: #ff9900;
  --err: #ff2255;
  --vote-yes: #fefe00;
  --vote-yes-text: #000000;
  --vote-maybe: #1a1200;
  --vote-maybe-text: #ff9900;
  --vote-no: #1a0008;
  --vote-no-text: #ff2255;
  --r: 0px;
  --r-sm: 0px;
  --shadow: 3px 3px 0 #fefe00;
  --topbar-bg: #050505;
  --font: "SF Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
}

/* ---------- 5. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

[data-theme="experimental"] h1,
[data-theme="experimental"] h2,
[data-theme="experimental"] h3 {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.18; letter-spacing: 0; }
h1 { font-size: clamp(1.45rem, 2.2vw, 2rem); font-weight: 800; }
h2 { font-size: 1.08rem; font-weight: 750; }
h3 { font-size: 0.95rem; font-weight: 700; }

p { margin: 0 0 0.6em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--brand-dim);
  outline-offset: 2px;
}

ul { margin: 0 0 0.6em; padding-left: 1.4em; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
}

/* ---------- 6. App shell / sidebar ---------- */
.app-shell {
  min-height: 100vh;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  width: var(--sidebar-width);
  background: var(--topbar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 30px rgba(17, 25, 54, 0.03);
}

.topbar-inner {
  height: 100%;
  padding: 26px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-2);
  margin: 0;
  white-space: nowrap;
}

.topbar-spacer { flex: 1; min-height: 12px; }

.topbar-admin-link {
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: nowrap;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-top: 18px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}

.side-nav a:hover {
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: none;
}

.side-nav a.is-active {
  background: var(--brand-dim);
  color: var(--brand-strong);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--brand);
  font-size: 0.88rem;
  line-height: 1;
}

.sidebar-tools {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- 7. Theme switcher ---------- */
.theme-switcher {
  display: flex;
  gap: 2px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-sm) + 4px);
  padding: 3px;
  flex-shrink: 0;
  justify-content: center;
}

.theme-btn {
  all: unset;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}

.theme-btn:hover { background: var(--border); color: var(--text); }

.theme-btn.is-active {
  background: var(--brand);
  color: #fff;
}

[data-theme="experimental"] .theme-btn.is-active {
  color: #000;
}

/* ---------- 8. Language switcher ---------- */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  width: 100%;
}

.lang-switch label {
  font-size: 0.78rem;
  color: var(--text-2);
  margin: 0;
  font-weight: 400;
  white-space: nowrap;
}

.topbar .lang-switch select {
  width: 100%;
  min-width: 0;
  padding: 4px 7px;
  font-size: 0.82rem;
}

/* ---------- 9. Layout ---------- */
.layout {
  width: min(100%, 1440px);
  margin: 0 auto 24px;
  padding: 28px 32px 0 calc(var(--sidebar-width) + 32px);
}

.app-footer {
  width: min(100%, 1440px);
  margin: 0 auto 40px;
  padding: 0 32px 0 calc(var(--sidebar-width) + 32px);
  color: var(--text-3);
  font-size: 0.78rem;
}

.app-footer a {
  color: var(--text-3);
}

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

/* ---------- 10. Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 22px 26px;
}

.card + .card { margin-top: 18px; }

/* ---------- 11. Notices (flash messages) ---------- */
.notices { margin-bottom: 16px; }

.notice {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.notice:last-child { margin-bottom: 0; }

.notice-success { border-color: var(--ok); background: var(--vote-yes); color: var(--vote-yes-text); }
.notice-warning { border-color: var(--warn); background: var(--vote-maybe); color: var(--vote-maybe-text); }
.notice-error   { border-color: var(--err); background: var(--vote-no); color: var(--vote-no-text); }

/* ---------- 12. Navigation tabs ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-subtle);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tabs a:hover {
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: none;
}

.tabs a.tab-active {
  background: var(--brand-dim);
  color: var(--brand-strong);
  border-color: transparent;
  font-weight: 750;
}

[data-theme="experimental"] .tabs a.tab-active { color: #000; }

/* ---------- 13. Typography helpers ---------- */
.muted { color: var(--text-2); font-size: 0.875rem; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 750;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.badge-success {
  background: var(--vote-yes);
  border-color: rgba(8, 116, 67, 0.18);
  color: var(--vote-yes-text);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 600;
}

/* ---------- 14. Forms ---------- */
input, select, textarea, button { font: inherit; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}

textarea { min-height: 80px; resize: vertical; }

/* Django as_p form rendering */
p > label { margin-bottom: 3px; }
p > input,
p > select,
p > textarea { display: block; }

/* ---------- 15. Buttons ---------- */
button:not(.theme-btn):not(.icon-btn),
.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.4;
  transition: opacity 0.12s;
  text-decoration: none;
  white-space: nowrap;
}
button:not(.theme-btn):not(.icon-btn):hover,
.button-like:hover {
  background: var(--brand-strong);
  text-decoration: none;
}
button:not(.theme-btn):not(.icon-btn):active { opacity: 0.82; }

[data-theme="experimental"] button:not(.theme-btn):not(.icon-btn) { color: #000; }

.btn-ghost {
  background: transparent !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text) !important;
}
.btn-ghost:hover { background: var(--surface-alt) !important; color: var(--text) !important; }

.btn-sm { padding: 4px 10px !important; font-size: 0.82rem !important; }

.btn-danger { background: var(--err) !important; color: #fff !important; }

.copy-feedback.is-copied {
  background: var(--vote-yes) !important;
  border-color: rgba(8, 116, 67, 0.28) !important;
  color: var(--vote-yes-text) !important;
}

.copy-feedback.is-copy-failed {
  background: var(--vote-no) !important;
  border-color: rgba(199, 46, 68, 0.24) !important;
  color: var(--vote-no-text) !important;
}

/* ---------- 16. Layout helpers ---------- */
.row { display: flex; flex-direction: column; gap: 12px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 6px 12px;
  align-items: baseline;
}
.kv dt { color: var(--text-2); font-size: 0.875rem; margin: 0; }
.kv dd { margin: 0; }

/* ---------- 17. Tables (generic) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--surface-alt);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

.sort-link {
  color: inherit;
  text-decoration: none;
}

.sort-link:hover {
  text-decoration: underline;
}

.sort-link.is-active {
  color: var(--text);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
  margin-top: 14px;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.pagination-link:hover {
  text-decoration: none;
  border-color: var(--brand);
}

.pagination-status {
  color: var(--text-2);
  font-size: 0.82rem;
}

/* ---------- 18. Vote matrix ---------- */
.vote-matrix {
  min-width: max-content;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.vote-matrix th,
.vote-matrix td {
  border-right: 1px solid var(--border);
}

.vote-matrix th:last-child,
.vote-matrix td:last-child {
  border-right: none;
}

.vote-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fbfcff;
  box-shadow: inset 0 -1px 0 var(--border);
}

.vote-matrix .participant-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 176px;
  max-width: 220px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}

.vote-matrix thead .participant-col {
  z-index: 4;
  background: #fbfcff;
}

.vote-matrix .participant-name {
  font-weight: 750;
  white-space: nowrap;
  color: var(--text);
}

.vote-matrix th.option-col {
  text-align: center;
  max-width: 118px;
  min-width: 78px;
  line-height: 1.3;
  font-size: 0.74rem;
  vertical-align: bottom;
}

.vote-matrix th.option-col.is-best-option {
  background: var(--result);
  color: var(--result-text);
}

.vote-matrix .option-col-month,
.vote-matrix .option-col-day,
.vote-matrix .option-col-date {
  display: block;
}

.vote-matrix .option-col-month {
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 750;
  margin-bottom: 3px;
}

.vote-matrix .option-col-day {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: none;
}

.vote-matrix .option-col-date {
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-2);
  font-size: 0.72rem;
  margin-top: 2px;
}

.vote-matrix td.vote-cell {
  text-align: center;
  min-width: 78px;
  background: var(--surface);
}

.vote-matrix tfoot td {
  font-weight: 700;
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
  font-size: 0.82rem;
  color: var(--text-2);
  background: var(--surface-alt);
}

.vote-matrix tfoot .vote-cell {
  color: var(--text);
}

.vote-matrix .result-label {
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 800;
}

.vote-matrix .result-cell {
  font-variant-numeric: tabular-nums;
}

.vote-matrix .result-cell.is-best-result {
  background: var(--result);
  color: var(--result-text);
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px rgba(49, 87, 231, 0.2);
}

.vote-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.vote-yes    { background: var(--vote-yes);   color: var(--vote-yes-text); border-color: rgba(8, 116, 67, 0.15); }
.vote-maybe  { background: var(--vote-maybe); color: var(--vote-maybe-text); border-color: rgba(178, 98, 0, 0.18); }
.vote-no     { background: var(--vote-no);    color: var(--vote-no-text); border-color: rgba(199, 46, 68, 0.16); }
.vote-unknown { background: var(--vote-unknown); color: var(--vote-unknown-text); border-color: var(--border); }

/* ---------- 19. Vote pickers (radio pill buttons) ---------- */
.option-vote-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.option-vote-row:last-of-type { border-bottom: none; }

.option-vote-label {
  flex: 1;
  min-width: 160px;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
}

.option-vote-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-2);
  font-weight: 400;
  margin-top: 2px;
}

.vote-picker {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.vote-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  color: var(--text-2);
  transition: border-color 0.1s, background 0.1s, color 0.1s;
  user-select: none;
  white-space: nowrap;
}

.vote-opt input[type="radio"] { display: none; }

.vote-opt:hover {
  border-color: var(--brand);
  color: var(--text);
}

.vote-opt.yes:has(input:checked) {
  background: var(--vote-yes);
  color: var(--vote-yes-text);
  border-color: var(--vote-yes-text);
}
.vote-opt.maybe:has(input:checked) {
  background: var(--vote-maybe);
  color: var(--vote-maybe-text);
  border-color: var(--vote-maybe-text);
}
.vote-opt.no:has(input:checked) {
  background: var(--vote-no);
  color: var(--vote-no-text);
  border-color: var(--vote-no-text);
}
.vote-opt.unknown:has(input:checked) {
  background: var(--vote-unknown);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------- 20. Participant edit (collapsible) ---------- */
.participant-details {
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface);
}
.participant-details:last-child { margin-bottom: 0; }

.participant-details summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
  user-select: none;
  border: none;
}

.participant-details summary::-webkit-details-marker { display: none; }

.participant-details summary::before {
  content: "▶";
  font-size: 0.65rem;
  color: var(--text-2);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.participant-details[open] > summary::before {
  transform: rotate(90deg);
}

.participant-vote-preview {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.participant-vote-preview .vote-pill {
  width: 20px;
  height: 20px;
  font-size: 0.68rem;
  border-radius: 4px;
}

.participant-details .edit-form {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- 21. Comments ---------- */
.comment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-subtle);
}
.comment-card:last-child { margin-bottom: 0; }

/* ---------- 22. Sort links ---------- */
.sort-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.82rem;
  color: var(--text-2);
  margin-bottom: 12px;
}

/* ---------- 23. Poll header ---------- */
.poll-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 10px;
}

.poll-header-meta code {
  max-width: min(100%, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poll-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.poll-hero-main {
  min-width: 0;
}

.poll-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 650;
  margin-bottom: 12px;
}

.breadcrumb a {
  color: var(--text-2);
}

.breadcrumb span:last-child {
  color: var(--text);
}

/* ---------- 24. Icon buttons ---------- */
.icon-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  text-decoration: none;
  flex-shrink: 0;
  box-sizing: border-box;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border); text-decoration: none; }
.icon-btn-danger:hover { color: var(--err); border-color: var(--err); background: var(--vote-no); }
.icon-btn-edit { color: var(--brand); }
.icon-btn-edit:hover { background: var(--brand-dim); border-color: var(--brand); color: var(--brand); }

/* ---------- 25. Option list (configure) ---------- */
#close { height: 0; display: block; }

.opt-list { display: flex; flex-direction: column; margin: 0; }

.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
}
.opt-row:first-child { border-top: 1px solid var(--border); }

.opt-index {
  font-size: 0.75rem;
  color: var(--text-2);
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
}
.opt-label { font-weight: 600; flex: 1; min-width: 0; font-size: 0.9rem; }
.opt-date { font-size: 0.78rem; color: var(--text-2); white-space: nowrap; flex-shrink: 0; }
.opt-actions { display: flex; align-items: center; gap: 1px; flex-shrink: 0; }

.opt-edit {
  display: none;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 0 0 6px;
}
.opt-edit:target { display: block; }

/* ---------- 26. Horizontal form row ---------- */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.form-row > div { flex: 1; min-width: 100px; }
.form-row > div.shrink { flex: 0 0 auto; }
.form-row label { margin-bottom: 3px; }

/* ---------- 27. URL display box ---------- */
.url-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.url-box code {
  flex: 1;
  font-size: 0.88rem;
  word-break: break-all;
  border: none;
  background: none;
  padding: 0;
}

/* ---------- 29. Danger zone ---------- */
.card.danger-zone { border-color: var(--err); }
.danger-zone h2 { color: var(--err); }

/* ---------- 30. History timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 8px 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
  font-size: 0.875rem;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.timeline-action { font-weight: 600; }
.timeline-actor { color: var(--text-2); font-size: 0.82rem; margin-top: 2px; }

/* ---------- 31. Section header with actions ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.section-header h2 { margin: 0; }

/* ---------- 32. Add-option form strip ---------- */
.add-strip {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- 33. Filters bar (history) ---------- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filters-bar > div { flex: 1; min-width: 100px; }
.filters-bar > div.shrink { flex: 0 0 auto; }

/* ---------- 35. Responsive ---------- */
@media (max-width: 1100px) {
  .poll-hero-actions {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .app-shell { padding-top: 64px; }
  .topbar {
    position: fixed;
    right: 0;
    bottom: auto;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(17, 25, 54, 0.06);
  }
  .topbar-inner {
    height: 64px;
    padding: 0 14px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .brand-sub { display: none; }
  .side-nav {
    flex-direction: row;
    width: auto;
    margin-top: 0;
    overflow-x: auto;
    gap: 4px;
  }
  .side-nav a {
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.84rem;
  }
  .nav-icon { display: none; }
  .sidebar-tools {
    width: auto;
    flex-direction: row;
    align-items: center;
    padding-top: 0;
    border-top: none;
    margin-left: auto;
  }
  .theme-switcher { display: none; }
  .layout { width: 100%; padding: 16px 14px 0; margin-top: 0; }
  .app-footer { width: 100%; padding: 0 14px; margin-bottom: 22px; }
  .card { padding: 14px 16px; }
  .grid-2, .kv { grid-template-columns: 1fr; }
  .option-vote-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .vote-picker { flex-wrap: wrap; }
  .topbar-admin-link { display: none; }
  .poll-hero { flex-direction: column; }
  .poll-hero-actions { justify-content: flex-start; width: 100%; }
  .vote-matrix .participant-col { min-width: 132px; max-width: 160px; }
  .vote-matrix th.option-col,
  .vote-matrix td.vote-cell {
    min-width: 66px;
  }
}

@media (max-width: 480px) {
  .lang-switch label { display: none; }
  .topbar .lang-switch { display: none; }
  .tabs a { padding: 4px 10px; font-size: 0.8rem; }
  .brand-logo { height: 26px; }
  .side-nav a span:last-child { display: none; }
  .side-nav a { width: 36px; justify-content: center; }
  .nav-icon { display: inline-flex; }
  .poll-hero-actions > * { flex: 1; }
  .vote-opt { min-width: 64px; }
}

/* ---------- 25. Charset fallback ---------- */
body.charset-fallback {
  --font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  --font-mono: "Courier New", monospace;
}
