:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #14181f;
  --muted: #5b6472;
  --line: #d9dde3;
  --accent: #0b6e6e;
  --accent-text: #ffffff;
  --accent-soft: #e0f1f0;
  --danger: #b3261e;
  --warn: #8a5a00;
  --ok: #1d6f42;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --surface: #1a1f26;
    --text: #eef1f5;
    --muted: #a3acb9;
    --line: #2f3742;
    --accent: #4fc3c0;
    --accent-text: #06201f;
    --accent-soft: #173534;
    --danger: #ff8a80;
    --warn: #f2c26b;
    --ok: #7ad3a0;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

button, input, textarea, select { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, .choice:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }

input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
textarea { min-height: 140px; resize: vertical; }

/* ---------- Phone voting page ---------- */

.vote-main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scenario {
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  font-size: 16px;
  white-space: pre-wrap;
}

.question { font-size: 22px; white-space: pre-wrap; }

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

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 14px;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.choice .letter {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 15px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.choice .label { padding-top: 3px; overflow-wrap: anywhere; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.choice[aria-pressed="true"] .letter { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.ratings { display: grid; grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 8px; }
.ratings .choice { justify-content: center; align-items: center; font-size: 20px; font-weight: 650; padding: 10px; }

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

.status { min-height: 24px; font-size: 15px; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.error { color: var(--danger); }

.waiting { text-align: center; padding: 22vh 0 0; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pulse {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.offline {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  text-align: center; font-size: 14px;
  background: var(--text); color: var(--bg);
}

/* ---------- Owner and shared results pages ---------- */

.page { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.login { max-width: 380px; margin: 14vh auto 0; }

.deck-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.deck-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; cursor: pointer;
}
.deck-item:hover { border-color: var(--muted); }
.deck-item .name { font-weight: 650; overflow-wrap: anywhere; }
.deck-item .meta { color: var(--muted); font-size: 14px; }
.deck-item .questions { grid-column: 1 / -1; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.poll { border-top: 1px solid var(--line); padding-top: 16px; }
.poll:first-child { border-top: 0; padding-top: 0; }
.poll h3 { font-size: 18px; white-space: pre-wrap; }
.poll .meta { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }

.bars { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 4px 12px; align-items: center; }
.bar-label { overflow-wrap: anywhere; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; }
.bar-track { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: var(--accent-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--accent); }

.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word { padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 15px; }
.word b { font-weight: 650; margin-left: 4px; }
.responses { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

.flag { padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; border: 1px solid var(--warn); color: var(--warn); font-size: 15px; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 15px; overflow-wrap: anywhere; }
.error-text { color: var(--danger); }
