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

/* ---------- 1. Light (default) ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f5f7f6;
  --surface-raised: #ffffff;
  --border: #e1e6e5;
  --border-strong: #bcc8c5;
  --text: #202b29;
  --text-2: #5e6d69;
  --text-3: #657570;
  --brand: #087f72;
  --button-text:#fff;
  --brand-strong: #066457;
  --brand-dim: rgba(8, 127, 114, 0.1);
  --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: #e7f4ef;
  --result-text: #11634e;
  --r: 6px;
  --r-sm: 6px;
  --shadow: none;
  --shadow-subtle: none;
  --topbar-bg: rgba(255, 255, 255, 0.94);

  --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"]) {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-alt: #1c2128;
    --border: #35413e;
    --border-strong: #5a7069;
    --surface-raised: #161b22;
    --brand-strong: #87e8d7;
    --text-3: #a0afa9;
    --vote-unknown: #26312d;
    --vote-unknown-text: #a0afa9;
    --result: #193e32;
    --result-text: #98dfbd;
    --text: #c9d1d9;
    --text-2: #a1ada7;
    --brand: #6dd6c4;
    --button-text:#102b25;
    --brand-dim: rgba(109, 214, 196, 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: none;
    --topbar-bg: rgba(22, 27, 34, 0.92);
  }
}

/* ---------- 3. Explicit dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c2128;
  --border: #35413e;
    --border-strong: #5a7069;
    --surface-raised: #161b22;
    --brand-strong: #87e8d7;
    --text-3: #a0afa9;
    --vote-unknown: #26312d;
    --vote-unknown-text: #a0afa9;
    --result: #193e32;
    --result-text: #98dfbd;
  --text: #c9d1d9;
  --text-2: #a1ada7;
  --brand: #6dd6c4;
    --button-text:#102b25;
  --brand-dim: rgba(109, 214, 196, 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: none;
  --topbar-bg: rgba(22, 27, 34, 0.92);
}

/* ---------- 4. Experimental (Neo-brutalist / Starface-inspired) ---------- */
[data-theme="experimental"] {
  color-scheme: dark;
  --bg: #050505;
  --surface: #0a0a0a;
  --surface-alt: #141414;
  --border: #fefe00;
  --text: #f5f5f5;
  --text-2: #b3b3b3;
  --brand: #fefe00;
  --button-text:#000;
  --brand-strong: #dcdc00;
  --border-strong: #8c8c31;
  --text-3: #b7b7a1;
  --result: #272700;
  --result-text: #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: none;
  --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: 29px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
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: 2px solid var(--brand);
  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;
}

/* Global masthead and centered workspace */
.app-shell { min-height:100vh; display:flex; flex-direction:column; }
.topbar { background:var(--surface); border-bottom:1px solid var(--border); }
.topbar-inner { max-width:1224px; margin:auto; padding:12px 32px; display:flex; align-items:center; gap:28px; flex-wrap:wrap; }
.brand { display:flex; align-items:center; flex-shrink:0; gap:6px; color:var(--text); font-size:23px; font-weight:750; line-height:1; text-decoration:none; }
.brand:hover { text-decoration:none; }
.brand-logo { height:32px; width:32px; display:block; }
.side-nav { display:flex; flex-wrap:wrap; gap:6px; }
.side-nav a { display:flex; align-items:center; min-height:40px; padding:8px 12px; border-radius:var(--r); font-weight:600; font-size:14px; color:var(--text-2); text-decoration:none; }
.side-nav a:hover { background:var(--surface-alt); color:var(--text); }
.side-nav a.is-active { background:var(--brand-dim); color:var(--brand); }
.nav-icon { display:none; }
.topbar-spacer { flex:1; }
.sidebar-tools { display:flex; align-items:center; flex-wrap:wrap; gap:16px; }
.theme-switcher { display:flex; gap:0; }
.theme-btn { appearance:none; border:0; background:transparent; color:var(--text-2); width:40px; height:40px; border-radius:var(--r); cursor:pointer; font-size:16px; }
.theme-btn:hover { background:var(--surface-alt); }
.theme-btn.is-active { background:var(--brand-dim); color:var(--brand); }
.lang-switch { display:flex; align-items:center; gap:8px; }
.lang-switch label { margin:0; }
.topbar .lang-switch select { width:auto; padding:8px; font-size:13px; }
.layout { width:100%; max-width:1224px; margin:0 auto; padding:36px 32px 48px; flex:1; min-width:0; }
.app-footer { width:100%; max-width:1224px; margin:0 auto; padding:20px 32px; border-top:1px solid var(--border); font-size:13px; color:var(--text-2); }
.app-footer a { color:var(--text-2); }
.stack { display:flex; flex-direction:column; gap:16px; }
.card { padding:24px 0; min-width:0; }
.card + .card { border-top:1px solid var(--border); margin-top:8px; }
.layout > .card:first-child { padding-top:0; }
.poll-workspace { display:grid; grid-template-columns:minmax(0, 1fr) 350px; gap:32px; align-items:start; }
.poll-workspace > .card { margin:0; }
.poll-workspace .participation-panel { padding:20px; border:1px solid var(--border); border-radius:var(--r); background:var(--surface-alt); }
.participation-panel .option-vote-row { flex-direction:column; align-items:stretch; gap:6px; padding:8px 0; }
.participation-panel .vote-picker { width:100%; }
.participation-panel .vote-opt { min-width:0; flex:1; padding:8px; }
.participation-panel button[type=submit] { width:100%; }
.poll-heading { margin-bottom:24px; }
.participate-jump { display:none; }
.poll-heading h1 { overflow-wrap:anywhere; }
.create-workspace { max-width:640px; margin:0 auto; }
.create-workspace .row { gap:24px; }
fieldset { border:0; margin:0; padding:0; min-width:0; }
legend { font-size:13px; font-weight:600; margin-bottom:8px; color:var(--text-2); }
.type-choices { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.type-choice { display:flex; align-items:flex-start; gap:10px; padding:16px; border:1px solid var(--border-strong); border-radius:var(--r); margin:0; cursor:pointer; }
.type-choice:has(input:checked) { background:var(--brand-dim); border-color:var(--brand); color:var(--text); }
.type-choice input { margin-top:4px; accent-color:var(--brand); }
.type-choice strong { display:block; margin-bottom:4px; color:var(--text); }
.errorlist { color:var(--err); font-size:13px; padding-left:20px; }
input[aria-invalid=true] { border-color:var(--err); }
.start-surface { max-width:760px; padding:20px 0 36px; }
.start-surface .actions { margin-top:24px; }
.start-guide { display:grid; grid-template-columns:1fr 1fr; gap:32px; margin-top:40px; border-top:1px solid var(--border); padding-top:24px; }
.skip-link { position:absolute; left:16px; top:-100px; z-index:200; padding:10px; background:var(--surface); }
.skip-link:focus { top:8px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ---------- 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); }

/* Poll navigation */
.tabs { display:flex; flex-wrap:wrap; gap:4px 20px; margin-bottom:24px; border-bottom:1px solid var(--border); }
.tabs a { display:inline-flex; align-items:center; min-height:44px; padding:10px 2px; color:var(--text-2); font-size:14px; text-decoration:none; border-bottom:2px solid transparent; margin-bottom:-1px; }
.tabs a:hover { color:var(--text); border-color:var(--border-strong); }
.tabs a.tab-active { color:var(--brand); border-color:var(--brand); font-weight:650; }

/* ---------- 13. Typography helpers ---------- */
pre { max-width:100%; overflow:auto; }
.vote-matrix th.participant-name { text-transform:none; font-size:14px; font-weight:600; }
.vote-matrix .result-label { font-weight:600; text-transform:none; }
.option-vote-row legend { margin-bottom:6px; padding:0; float:left; width:100%; }
.option-vote-row .vote-picker { clear:both; }
.muted { color: var(--text-2); font-size: 0.875rem; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 4px;
  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: var(--button-text);
  min-height:40px; padding:9px 16px;
  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, minmax(0, 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 { position:relative; max-width:100%; 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: var(--r);
  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: var(--surface-alt);
  box-shadow: inset 0 -1px 0 var(--border);
}

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

.vote-matrix thead .participant-col {
  z-index: 4;
  background: var(--surface-alt);
}

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

.vote-matrix th.option-col {
  text-align: center;
  width: 136px;
  max-width: 150px;
  min-width: 136px;
  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(8, 127, 114, 0.2);
}

.vote-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r);
  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: inline; margin-left:6px;
  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 {
  position:relative; min-height:40px; margin:0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  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"] { position:absolute; opacity:0; width:1px; height:1px; }
.vote-opt:has(input:focus-visible) { outline:2px solid var(--brand); outline-offset:3px; }

.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. Editing within the availability matrix ---------- */
.matrix-sort { display:flex; align-items:center; gap:8px; min-width:0; }
.matrix-sort label { margin:0; white-space:nowrap; color:var(--text-2); font-size:13px; }
.matrix-sort select { width:auto; max-width:180px; min-height:36px; padding:6px 28px 6px 10px; }
.matrix-name-display { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.matrix-name-display > span { min-width:0; overflow-wrap:anywhere; }
.matrix-edit-trigger { display:inline-flex; align-items:center; justify-content:center; flex:0 0 32px; width:32px; height:36px; border-radius:4px; color:var(--text-2); font-size:19px; }
.matrix-edit-trigger:hover { color:var(--brand); background:var(--brand-dim); text-decoration:none; }
.matrix-edit-control, .matrix-edit-actions-row { display:none; }
.matrix-participant.is-editing .matrix-edit-control { display:block; }
.matrix-participant.is-editing .matrix-name-display,
.matrix-participant.is-editing .vote-pill { display:none; }
.matrix-participant.is-editing + .matrix-edit-actions-row { display:table-row; }
.matrix-participant.is-editing > th, .matrix-participant.is-editing > td,
.matrix-edit-actions-row > td { background:var(--surface-alt); }
.matrix-participant.is-editing input { min-width:0; width:120px; max-width:100%; padding:8px; }
.matrix-participant.is-editing select { min-width:0; width:108px; max-width:100%; padding:8px 24px 8px 8px; font-size:13px; }
.matrix-edit-actions-row > td { text-align:left; }
.matrix-edit-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; position:sticky; left:12px; width:fit-content; max-width:calc(100vw - 64px); }
.matrix-edit-actions form { margin:0; }
.matrix-delete { color:var(--err); }
.poll-comments { max-width:760px; margin-top:24px; border-top:1px solid var(--border); }

/* ---------- 21. Comments ---------- */
.comment-card {
  overflow-wrap:anywhere;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  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: 40px;
  height: 40px;
  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: var(--r);
  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: var(--r);
  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; }

/* Responsive layout: every preference remains available. */
@media (max-width:960px) {
  .topbar-inner { gap:12px; }
  .topbar-spacer { display:none; }
  .sidebar-tools { margin-left:auto; }
  .poll-workspace { grid-template-columns:minmax(0,1fr) 320px; gap:24px; }
}
@media (max-width:760px) {
  .topbar-inner { padding:12px 20px; gap:8px 14px; }
  .sidebar-tools { width:100%; justify-content:space-between; margin:0; border-top:1px solid var(--border); padding-top:8px; }
  .side-nav { margin-left:auto; }
  .side-nav a { padding:8px; }
  .layout { padding:24px 20px 36px; }
  .app-footer { padding:20px; }
  .poll-workspace { grid-template-columns:minmax(0,1fr); gap:20px; }
  .grid-2,.kv { grid-template-columns:minmax(0,1fr); }
  .poll-hero { gap:12px; }
  .poll-hero-actions { justify-content:flex-start; }
  .vote-matrix .participant-col { width:140px; min-width:140px; max-width:140px; }
  .vote-matrix th.option-col,.vote-matrix td.vote-cell { min-width:70px; }
  .option-vote-row { flex-direction:column; align-items:stretch; gap:8px; }
  .vote-picker { flex-wrap:wrap; }
  .vote-opt { min-width:56px; flex:1; }
  .opt-row { flex-wrap:wrap; }
  .opt-date { white-space:normal; }
  .opt-actions { margin-left:auto; }
  .timeline-item { grid-template-columns:minmax(0,1fr); }
  .tabs { gap:0 20px; flex-wrap:nowrap; overflow-x:auto; margin-bottom:12px; }
  .tabs a { flex:0 0 auto; }
  .poll-heading { margin-bottom:12px; }
  .poll-heading h1 { font-size:28px; }
  .poll-header-meta { margin-top:6px; gap:4px 10px; }
  .poll-workspace > .card:first-child { padding-top:12px; }
  .participate-jump { display:inline-flex; }
  .poll-hero-actions { width:100%; }
  .url-box { flex-wrap:wrap; }
}
@media (max-width:420px) {
  .type-choices,.start-guide { grid-template-columns:minmax(0,1fr); }
  .topbar-inner,.layout,.app-footer { padding-left:16px; padding-right:16px; }
  .brand-logo { height:28px; width:28px; }
  .side-nav a { font-size:13px; }
  .lang-switch label { display:none; }
  .participation-panel { padding:16px; }
}
body.charset-fallback { --font:"Trebuchet MS", "Segoe UI", Arial, sans-serif; --font-mono:"Courier New", monospace; }
