:root {
  --bg-1: #0f766e;
  --bg-2: #1d4ed8;
  --card: #ffffff;
  --ink: #101828;
  --ink-soft: #667085;
  --border: #e4e7ec;
  --accent: #0f766e;
  --accent-2: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --radius: 16px;
  --shadow: 0 20px 50px -24px rgba(16, 24, 40, 0.35);
}

* { box-sizing: border-box; }

/* Several classes below set their own `display` (flex/inline-flex) at the
   same specificity as the browser's default `[hidden]{display:none}` rule,
   which — being author CSS vs. UA CSS — would otherwise win and leave a
   "hidden" element visible. Force hidden to always mean hidden. */
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 8%, #14b8a6 0%, transparent 45%),
              radial-gradient(circle at 88% 92%, #3b82f6 0%, transparent 45%),
              linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand .dot {
  width: 14px; height: 14px; border-radius: 5px;
  background: linear-gradient(135deg, #5eead4, #60a5fa);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.nav-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  transition: background 0.15s, border-color 0.15s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.6); }

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 8px clamp(16px, 4vw, 48px) 64px;
}

.wrap { width: 100%; max-width: 880px; }
.wrap-wide { max-width: 1160px; }

/* When a poll page is iframed by /demo (?embed=1) — see vote.js — the site's
   own chrome and this poll's own share box would be redundant/confusing
   nested inside another page. */
body.embedded header.topbar,
body.embedded footer,
body.embedded #toggleShareBtn,
body.embedded #shareBox { display: none; }
body.embedded main { padding-top: 20px; }

.hero { text-align: center; color: #fff; margin: 12px auto 30px; max-width: 640px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 10px; letter-spacing: -0.02em; }
.hero p { margin: 0; opacity: 0.9; font-size: 1.02rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 32px);
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Poll type tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  flex: 1;
  min-width: 140px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tab:hover { border-color: var(--accent); }
.tab.active { border-color: var(--accent); color: var(--accent); background: #f0fdfa; }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.88rem; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.hint { color: var(--ink-soft); font-size: 0.82rem; margin-top: 5px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 70px; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.checkbox-row:last-child { border-bottom: none; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.checkbox-row .ctext { flex: 1; }
.checkbox-row .ctext strong { display: block; font-size: 0.92rem; }
.checkbox-row .ctext span { color: var(--ink-soft); font-size: 0.82rem; }

.radio-group { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.radio-group input[type="radio"] { accent-color: var(--accent); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .two-col { grid-template-columns: 1fr; } }

/* Option rows (create form) */
.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.option-row .option-index {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #f0fdfa;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.option-row .option-index:active { cursor: grabbing; }
.option-row input[type="text"] { flex: 1; min-width: 90px; }
/* The generic `input[type="file"] { width: 100% }` rule (below) fights the
   caption text input for space in this flex row — without this override the
   file input claims the whole row and squeezes the caption down to an
   empty-looking sliver. Let it size to its own content instead. */
.option-row input[type="file"] { width: auto; flex: 0 1 auto; min-width: 0; }
.option-row .thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  border: 1.5px solid var(--border); flex-shrink: 0; background: #f6f7f9;
}
.option-row .remove-btn {
  background: none; border: none; color: var(--ink-soft); cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 4px 8px; flex-shrink: 0;
}
.option-row .remove-btn:hover { color: var(--danger); }
.option-row .remove-btn:disabled { color: #d0d5dd; cursor: not-allowed; }
.option-row .remove-btn:disabled:hover { color: #d0d5dd; }
.option-row .add-picture-btn { flex-shrink: 0; white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  transition: transform 0.1s, opacity 0.15s;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary { background: #eef2f6; color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-ghost { background: none; color: var(--accent); padding: 8px 10px; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* Messages */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-success { background: #f0fdf4; color: var(--success); }
.alert-info { background: #f0fdfa; color: var(--accent); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-open { background: #f0fdf4; color: var(--success); }
.badge-closed { background: #f1f5f9; color: var(--ink-soft); }

/* Vote options */
.vote-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.vote-option:hover { border-color: var(--accent); }
.vote-option.checked { border-color: var(--accent); background: #f0fdfa; }
.vote-option input { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.vote-option img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.vote-option .label { flex: 1; font-weight: 600; }
.vote-option .sublabel { color: var(--ink-soft); font-size: 0.82rem; font-weight: 400; }

/* Results */
.result-row { margin-bottom: 14px; }
.result-row .rlabel {
  display: flex; justify-content: space-between; gap: 10px;
  font-weight: 600; margin-bottom: 6px; font-size: 0.92rem;
}
.result-row .rlabel .count { color: var(--ink-soft); font-weight: 500; }
.result-bar-track { background: #f1f5f9; border-radius: 999px; height: 12px; overflow: hidden; display: flex; }
.result-bar-fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); height: 100%; transition: width 0.4s ease; }
.result-bar-fill-maybe { background: #f59e0b; height: 100%; transition: width 0.4s ease; }
.result-row .breakdown { color: var(--ink-soft); font-size: 0.78rem; margin-top: 3px; }

/* Toggle switches */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .ttext strong { display: block; font-size: 0.92rem; }
.toggle-row .ttext span { color: var(--ink-soft); font-size: 0.82rem; }
.toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0; background: #d0d5dd; border-radius: 999px; cursor: pointer; transition: background 0.15s;
}
.toggle .slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(18px); }
.toggle input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Calendar */
.cal-wrap { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-header .cal-title { font-weight: 700; }
.cal-nav-btn {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  font-size: 1.1rem; padding: 4px 10px; border-radius: 8px;
}
.cal-nav-btn:hover { color: var(--accent); background: #f0fdfa; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 0.68rem; color: var(--ink-soft); font-weight: 700; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 0.85rem; cursor: pointer; color: var(--ink);
}
.cal-day:hover { background: #f0fdfa; }
.cal-day.outside { color: #cbd5e1; cursor: default; }
.cal-day.outside:hover { background: none; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.selected { background: var(--accent); color: #fff; font-weight: 700; }
.cal-day.range-mid { background: #ccfbf1; color: var(--ink); border-radius: 6px; }
.cal-day.pending { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; color: var(--accent); }

/* Meeting date cards */
.date-card { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.date-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; font-size: 0.92rem; }
.date-card-header button { background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 1.15rem; line-height: 1; }
.date-card-header button:hover { color: var(--danger); }
.time-range-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.time-range-row input[type="time"] { flex: 1; }
.time-range-row .remove-range { background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 1rem; flex-shrink: 0; }
.time-range-row .remove-range:hover { color: var(--danger); }
.no-dates-hint { color: var(--ink-soft); font-size: 0.88rem; text-align: center; padding: 30px 10px; }

/* Tri-state (Yes / If need be / No) voting control */
.tri-toggle { display: flex; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--border); flex-shrink: 0; }
.tri-toggle button {
  padding: 7px 10px; border: none; background: #fff; font-size: 0.76rem; font-weight: 700;
  cursor: pointer; color: var(--ink-soft); white-space: nowrap;
}
.tri-toggle button + button { border-left: 1.5px solid var(--border); }
.tri-toggle button.active-yes { background: #f0fdf4; color: var(--success); }
.tri-toggle button.active-maybe { background: var(--warn-bg); color: var(--warn); }
.tri-toggle button.active-no { background: #f1f5f9; color: var(--ink); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.share-box {
  display: flex; gap: 8px; align-items: center;
  background: #f8fafc; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.share-box input { border: none; background: none; flex: 1; padding: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }

.center { text-align: center; }
.stack-gap > * + * { margin-top: 14px; }

footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.8rem;
  padding: 0 20px 26px;
}

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite; display: inline-block;
}

/* Collapsible section (e.g. the Privacy card) */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.collapsible-chevron {
  color: var(--ink-soft);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.collapsible-header[aria-expanded="true"] .collapsible-chevron { transform: rotate(180deg); }
.collapsible-body { margin-top: 16px; }

/* Drag-to-reorder (shared by manage-page option lists and ranking votes) */
.drag-handle {
  cursor: grab;
  touch-action: none;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  flex-shrink: 0;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
[data-drag-item].dragging {
  box-shadow: var(--shadow);
  opacity: 0.95;
  background: #fff;
}
.drag-placeholder {
  border: 2px dashed var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  background: #f8fafc;
}

/* Ranking rows (voting UI + manage results) */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  background: #fff;
}
.rank-row .rank-badge {
  width: 26px; height: 26px; border-radius: 50%;
  background: #f0fdfa; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.rank-row .label { flex: 1; font-weight: 600; }
.rank-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.rank-not-important .rank-badge { background: #f1f5f9; color: var(--ink-soft); }
.rank-not-important { opacity: 0.75; }
.rank-bucket-title {
  color: var(--ink-soft); font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; margin: 18px 0 8px;
}

/* Rating rows (1-10 slider, red-to-green) */
.rating-row {
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
  background: #fff;
}
.rating-row img {
  width: 100%; max-height: 160px; object-fit: cover;
  border-radius: 8px; margin-bottom: 10px; display: block;
}
.rating-row .label { font-weight: 600; margin-bottom: 10px; }
.rating-row .rating-value {
  text-align: center; font-size: 1.4rem; font-weight: 800; margin-bottom: 6px;
}
.rating-track { position: relative; padding: 6px 0; }
.rating-slider {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, #dc2626, #f59e0b, #16a34a);
  outline: none;
  cursor: pointer;
  touch-action: none;
}
.rating-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.rating-slider::-webkit-slider-thumb:active { cursor: grabbing; }
.rating-slider::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.rating-slider::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dc2626, #f59e0b, #16a34a);
}
.rating-scale-ends {
  display: flex; justify-content: space-between;
  color: var(--ink-soft); font-size: 0.75rem; margin-top: 4px;
}
