:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #3b5bdb;
  --accent-soft: #e8ecfd;
  --yes: #16a34a;
  --yes-soft: #e6f6ec;
  --maybe: #d97706;
  --maybe-soft: #fdf1de;
  --no: #dc2626;
  --no-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1d212a;
    --border: #2b303b;
    --text: #e8eaee;
    --muted: #98a1b0;
    --accent: #7c93f5;
    --accent-soft: #232a44;
    --yes: #4ade80;
    --yes-soft: #16281d;
    --maybe: #fbbf24;
    --maybe-soft: #2c2314;
    --no: #f87171;
    --no-soft: #2e1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  background: none;
  border: 0;
  padding: 0;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  cursor: pointer;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 72px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

h3 {
  font-size: 15px;
  margin: 20px 0 8px;
}

.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

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

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 180px;
}

/* ---------- formulare ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

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

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn:hover {
  filter: brightness(1.07);
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn.danger {
  background: transparent;
  color: var(--no);
  border-color: var(--border);
  padding: 6px 10px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 4px 0;
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.actions.end {
  justify-content: flex-end;
}

/* ---------- vyber ze seznamu ---------- */

.choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.12s, transform 0.06s;
}

.choice:hover {
  border-color: var(--accent);
}

.choice:active {
  transform: scale(0.995);
}

.choice strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.choice span {
  color: var(--muted);
  font-size: 13px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

/* ---------- hlasovani ---------- */

.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.vote-row.weekend {
  background: var(--accent-soft);
}

.vote-label {
  min-width: 0;
  font-size: 14px;
}

.vote-label .date-main {
  font-weight: 600;
}

.vote-label .date-dow {
  color: var(--muted);
  font-size: 13px;
  margin-left: 6px;
}

.vote-label a {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.vote-label .tag {
  color: var(--muted);
  font-size: 12px;
}

.opts {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.opt {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 14px;
  line-height: 1;
  min-width: 40px;
}

.opt[aria-pressed="true"][data-v="1"] {
  background: var(--yes-soft);
  border-color: var(--yes);
  color: var(--yes);
  font-weight: 700;
}

.opt[aria-pressed="true"][data-v="0.5"] {
  background: var(--maybe-soft);
  border-color: var(--maybe);
  color: var(--maybe);
  font-weight: 700;
}

.opt[aria-pressed="true"][data-v="0"] {
  background: var(--no-soft);
  border-color: var(--no);
  color: var(--no);
  font-weight: 700;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.bulk {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.progress {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ---------- vysledky ---------- */

.result-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 12px;
  margin-bottom: 8px;
}

.result-item.top {
  border-color: var(--yes);
  background: var(--yes-soft);
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.result-title {
  font-weight: 650;
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}

.score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin: 8px 0 6px;
  display: flex;
}

.bar i {
  display: block;
  height: 100%;
}

.bar .b-yes {
  background: var(--yes);
}

.bar .b-maybe {
  background: var(--maybe);
}

.counts {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.counts .c-yes {
  color: var(--yes);
}

.counts .c-maybe {
  color: var(--maybe);
}

.counts .c-no {
  color: var(--no);
}

details.names {
  margin-top: 6px;
}

details.names summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
}

details.names div {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0 0;
  line-height: 1.6;
}

/* ---------- ostatni ---------- */

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0;
}

.pill {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.error {
  background: var(--no-soft);
  color: var(--no);
  border: 1px solid var(--no);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}

.footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 32px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a:hover {
  color: var(--accent);
}

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

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

@media (max-width: 520px) {
  .vote-row {
    align-items: flex-start;
  }

  .opt {
    padding: 8px 10px;
    min-width: 38px;
  }

  .vote-label a {
    max-width: 150px;
  }
}
