/* Shared styling. Every colour is a variable in this block, so retheming the
   whole app to your brand palette means editing these ten lines. */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --ink: #14161f;
  --muted: #5f6577;
  --line: #e2e5ef;
  --brand: #3b46d8;
  --brand-dark: #2a33ad;
  --brand-wash: #eceefc;
  --accent: #d6453f;
  --ok: #16794f;
  --warn: #9a6608;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 31, .06), 0 8px 24px rgba(20, 22, 31, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }

a { color: var(--brand); }

/* ---------------------------------------------------------------- controls */

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 20px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background .12s ease, transform .06s ease, opacity .12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: 44px; /* comfortable phone target */
}
button:hover, .btn:hover { background: var(--brand-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, .btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); }
button.subtle { background: var(--surface-2); color: var(--ink); }
button.subtle:hover { background: var(--line); }
button.danger { background: transparent; color: var(--accent); border-color: #f0cfce; }
button.danger:hover { background: #fdf1f0; }
button.small { padding: 6px 13px; min-height: 34px; font-size: 13px; }
button.icon { padding: 6px 10px; min-height: 32px; min-width: 32px; }

input[type=text], input[type=number], textarea, select {
  font: inherit;
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.hidden { display: none !important; }

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.pill.ok { background: #e6f4ec; color: var(--ok); }
.pill.warn { background: #fdf3e0; color: var(--warn); }
.pill.brand { background: var(--brand-wash); color: var(--brand-dark); }

.code {
  font-variant-numeric: tabular-nums;
  letter-spacing: .16em;
  font-weight: 700;
}

/* ------------------------------------------------------------ live status */

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3c8d6; flex: none; }
.dot.live { background: #21a366; box-shadow: 0 0 0 3px rgba(33, 163, 102, .18); }
.dot.down { background: var(--accent); }

/* ------------------------------------------------------------------ toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 120%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  max-width: calc(100vw - 32px);
  text-align: center;
}
#toast.show { transform: translate(-50%, 0); }
#toast.bad { background: var(--accent); }

/* -------------------------------------------------------- question cards */

.qlist { display: grid; gap: 10px; }

.qcard {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.qcard.answered { opacity: .62; }
.qcard .qtext { font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.qcard .qmeta { margin-top: 7px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.vote {
  flex: none;
  min-width: 56px;
  min-height: 56px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1.5px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px;
  font-size: 15px;
  line-height: 1.1;
}
.vote:hover { background: var(--line); }
.vote.on { background: var(--brand-wash); border-color: var(--brand); color: var(--brand-dark); }
.vote .arrow { font-size: 13px; }
.vote .n { font-weight: 700; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- results */

.bars { display: grid; gap: 12px; }
.bar-row .bar-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-weight: 600; }
.bar-track { height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .45s cubic-bezier(.2,.8,.2,1); }

.cloud { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: baseline; justify-content: center; }
.cloud span { font-weight: 650; line-height: 1.15; transition: font-size .3s ease; }

.empty { color: var(--muted); text-align: center; padding: 36px 12px; }

/* --------------------------------------------------------------- choices */

.choices { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 17px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  min-height: 54px;
}
.choice:hover { background: var(--surface-2); }
.choice.on { border-color: var(--brand); background: var(--brand-wash); color: var(--brand-dark); }
.choice .tick {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
}
.choice.on .tick { border-color: var(--brand); background: var(--brand); color: #fff; }

/* ------------------------------------------------------------------- misc */

.qr { background: #fff; border-radius: 10px; padding: 6px; line-height: 0; }
.qr svg { display: block; width: 100%; height: auto; }

.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 999px; }
.tabs button {
  flex: 1; background: transparent; color: var(--muted); min-height: 38px; padding: 8px 14px; font-size: 14px;
}
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tabs button:hover { background: rgba(255, 255, 255, .6); }
.tabs button.on:hover { background: var(--surface); }
