:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #2563eb;
  --brand-soft: #eaf1ff;
  --ok: #0f9d58;
  --warn: #b54708;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .06);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #131c2e;
  --text: #eef2f8;
  --muted: #98a2b3;
  --line: #243049;
  --brand: #7aa2ff;
  --brand-soft: #1b2743;
  --shadow: none;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 12px);
  gap: 3px;
  padding: 7px;
  border-radius: 12px;
  background: var(--brand);
  flex: none;
}

.brand-mark i {
  display: block;
  height: 12px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .92);
  font-style: normal;
  font-size: 0;
}

.brand-mark i:nth-child(2) { height: 12px; opacity: .8; }
.brand-mark i:nth-child(3) { height: 12px; opacity: .65; }
.brand-mark i:nth-child(4) { height: 12px; opacity: .5; }

.brand-text { min-width: 0; }

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: .01em;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer {
  flex: none;
  max-width: 45%;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.gate, .loading { text-align: center; }

.gate-icon { font-size: 28px; line-height: 1; }

.gate h2 { margin: 10px 0 6px; font-size: 17px; }

.gate p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.loading p { margin: 0; font-size: 13.5px; }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.poll-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.4;
  letter-spacing: -.01em;
  word-break: break-word;
}

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

.options { display: grid; gap: 10px; margin: 18px 0 4px; }

.option {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}

.option:hover { border-color: var(--brand); }

.option:active { transform: scale(.995); }

.option:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }

.option[aria-checked="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.option[disabled] { cursor: progress; opacity: .75; }

.option-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--brand);
  opacity: .1;
  transition: width .35s ease;
  pointer-events: none;
}

.option-key {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 15px;
}

.option[aria-checked="true"] .option-key { background: var(--brand); color: #fff; }

.option-body { position: relative; min-width: 0; }

.option-label {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  word-break: break-word;
}

.option-sub {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.option-count {
  position: relative;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.option[aria-checked="true"] .option-count { color: var(--brand); font-weight: 600; }

.poll-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}

.hint { margin: 0; color: var(--muted); font-size: 13px; flex: 1 1 220px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s ease;
}

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

.btn:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

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

.conclusion { border-left: 4px solid var(--brand); }

.conclusion-text {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.65;
  word-break: break-word;
}

.conclusion[data-kind="tie"] { border-left-color: var(--warn); }

.conclusion[data-kind="empty"] { border-left-color: var(--line); }

.conclusion[data-kind="empty"] .conclusion-text { color: var(--muted); }

.compose h2 { margin: 0 0 14px; font-size: 17px; }

.field { display: block; margin-bottom: 12px; }

.field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12.5px; }

.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.field-grid { display: grid; gap: 10px; margin-bottom: 14px; }

.field-grid .field { margin: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; }

.field-grid .field span {
  margin: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 15px;
}

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

.status { min-height: 20px; margin: 4px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

.status[data-tone="error"] { color: #d92d20; }
.status[data-tone="ok"] { color: var(--ok); }

@media (max-width: 480px) {
  .app { padding: 14px 12px 40px; }
  .card { padding: 16px; border-radius: 14px; }
  .poll-head h2 { font-size: 18px; }
  .option { grid-template-columns: 30px minmax(0, 1fr); }
  .option-key { width: 30px; height: 30px; border-radius: 9px; }
  .option-count { grid-column: 2; justify-self: start; margin-top: 4px; }
  .viewer { display: none; }
  .poll-foot { align-items: stretch; }
  .hint { flex-basis: 100%; }
  .btn { width: 100%; }
  .actions .btn { width: 100%; }
}

@media (min-width: 481px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
