:root {
  color-scheme: light;
  --red: #da1a21;
  --red-dark: #b31219;
  --ink: #172033;
  --muted: #64748b;
  --line: #d7dee8;
  --surface: #fff;
  --background: #f3f5f8;
  font-family: Arial, "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--background); line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(218,26,33,.25); outline-offset: 2px; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-header { position: sticky; z-index: 20; top: 0; border-bottom: 4px solid var(--red); color: #fff; background: var(--ink); }
.header-inner { display: grid; width: min(960px,100%); min-height: 4.75rem; grid-template-columns: 2.75rem minmax(0,1fr) auto; align-items: center; gap: .65rem; margin: 0 auto; padding: max(.65rem,env(safe-area-inset-top)) .8rem .65rem; }
.icon-button { display: grid; width: 2.65rem; height: 2.65rem; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: .45rem; padding: 0; color: #fff; background: transparent; text-decoration: none; }
.icon-button svg { width: 1.2rem; height: 1.2rem; }
.icon-button.dark { border-color: var(--line); color: #475569; background: #f8fafc; }
.header-title { min-width: 0; }
.header-title p { margin: 0 0 .1rem; color: #cbd5e1; font-size: .65rem; font-weight: 700; text-transform: uppercase; }
.header-title h1 { overflow: hidden; margin: 0; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: .4rem; }
.language-control select, .identity-button { min-height: 2.5rem; border: 1px solid #526079; border-radius: .45rem; color: #fff; background: #253149; font-size: .72rem; font-weight: 700; }
.language-control select { padding: .35rem 1.5rem .35rem .45rem; }
.identity-button { max-width: 8rem; overflow: hidden; padding: .35rem .65rem; text-overflow: ellipsis; white-space: nowrap; }
.page-shell { width: min(960px,calc(100% - 1rem)); margin: .85rem auto 2rem; }
.notice, #listPanel, .poll-detail { border: 1px solid var(--line); background: var(--surface); }
.notice { padding: 1rem; }
.notice-error, .form-message { border-color: #fca5a5; color: #991b1b; background: #fef2f2; }
.section-heading { border-bottom: 1px solid var(--line); padding: 1rem; background: #f8fafc; }
.section-heading h2, .list-section h3 { margin: 0; }
.section-heading h2 { font-size: 1.05rem; }
.list-section { padding: 1rem; }
.list-section h3 { margin-bottom: .55rem; color: #475569; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.history-section { border-top: 1px solid var(--line); }
.poll-list { border-top: 1px solid var(--line); }
.poll-row { display: grid; width: 100%; grid-template-columns: 4.75rem minmax(0,1fr) 1rem; align-items: center; gap: .8rem; border: 0; border-bottom: 1px solid var(--line); padding: .7rem 0; color: var(--ink); background: #fff; text-align: left; text-decoration: none; }
.poll-row:hover { background: #f8fafc; }
.poll-row img, .poll-cover-placeholder { width: 4.75rem; height: 3.5rem; object-fit: cover; background: #e2e8f0; }
.poll-cover-placeholder { display: grid; place-items: center; color: #94a3b8; font-size: 1rem; }
.poll-row strong { display: block; overflow: hidden; font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.poll-row small { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; color: var(--muted); font-size: .68rem; }
.poll-row > svg { width: 1rem; }
.empty { margin: .5rem 0 0; padding: 1rem 0; color: var(--muted); font-size: .8rem; }
.back-row { display: inline-flex; align-items: center; gap: .35rem; border: 0; padding: .65rem 0; color: #334155; background: transparent; font-size: .8rem; font-weight: 700; text-decoration: none; }
.back-row svg { width: 1rem; }
.poll-detail { overflow: hidden; }
.cover-image { display: block; width: 100%; max-height: 24rem; object-fit: cover; }
.poll-heading { padding: 1rem; }
.poll-meta { display: flex; align-items: center; justify-content: space-between; gap: .7rem; color: var(--muted); font-size: .7rem; }
.status { display: inline-flex; border-radius: .25rem; padding: .2rem .5rem; color: #334155; background: #e2e8f0; font-weight: 800; }
.status.active { color: #166534; background: #dcfce7; }
.status.scheduled { color: #1e40af; background: #dbeafe; }
.poll-heading h2 { margin: .65rem 0 0; font-size: clamp(1.2rem,4vw,1.65rem); }
.poll-heading p { margin: .55rem 0 0; color: #475569; font-size: .86rem; white-space: pre-line; }
#voteForm { border-top: 1px solid var(--line); padding: 1rem; }
.question-list { border-top: 1px solid var(--line); }
.question { border-bottom: 1px solid var(--line); padding: 1rem 0; }
.question h3 { margin: 0 0 .7rem; font-size: .92rem; }
.required { color: var(--red); }
.reference-image { display: block; max-width: 100%; max-height: 22rem; margin: 0 0 .75rem; border: 1px solid var(--line); object-fit: contain; }
.field { display: block; }
.field > span:first-child { display: block; margin-bottom: .3rem; color: #334155; font-size: .78rem; font-weight: 700; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], select, textarea { width: 100%; min-height: 3rem; border: 1px solid var(--line); border-radius: .4rem; padding: .65rem .7rem; color: var(--ink); background: #fff; }
textarea { min-height: 7rem; resize: vertical; }
.choice-list { display: grid; gap: .45rem; }
.choice-row { display: flex; min-height: 2.9rem; align-items: center; gap: .55rem; border: 1px solid var(--line); padding: .55rem .7rem; font-size: .82rem; }
.choice-row input { width: 1rem; height: 1rem; flex: 0 0 auto; }
.other-row { display: grid; grid-template-columns: 1rem minmax(0,1fr); align-items: center; }
.other-row input[type="text"] { width: 100%; min-height: 2.35rem; grid-column: 1 / -1; }
.other-label { font-weight: 700; }
.counter { margin-top: .25rem; color: var(--muted); font-size: .68rem; text-align: right; }
.question-error { margin: .4rem 0 0; color: #b91c1c; font-size: .72rem; }
.pdpa-box { margin-top: 1rem; border: 1px solid var(--line); padding: .8rem; background: #f8fafc; }
.pdpa-box h3 { margin: 0 0 .3rem; font-size: .8rem; }
.pdpa-box p { margin: 0; color: #475569; font-size: .75rem; }
.consent-row { display: flex; align-items: flex-start; gap: .45rem; margin-top: .6rem; font-size: .78rem; font-weight: 700; }
.consent-row input { width: 1rem; height: 1rem; margin-top: .12rem; }
.primary-button, .secondary-button { width: 100%; min-height: 3rem; border-radius: .4rem; padding: .65rem .8rem; font-weight: 800; }
.primary-button { margin-top: 1rem; border: 1px solid var(--red-dark); color: #fff; background: var(--red); }
.secondary-button { margin-top: .5rem; border: 1px solid var(--line); color: #334155; background: #fff; }
.form-message { margin-top: .8rem; border: 1px solid; padding: .65rem; font-size: .76rem; }
.result-note { display: flex; align-items: center; justify-content: space-between; gap: .6rem; border-top: 1px solid #86efac; border-bottom: 1px solid #86efac; padding: .8rem 1rem; color: #166534; background: #f0fdf4; font-size: .8rem; }
.results-panel { border-top: 1px solid var(--line); }
.results-heading { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1rem; background: #f8fafc; }
.results-heading h3 { margin: 0; font-size: .95rem; }
.result-question { padding: 1rem; border-top: 1px solid var(--line); }
.result-question h4 { margin: 0; font-size: .86rem; }
.result-count { color: var(--muted); font-size: .68rem; }
.result-row { margin-top: .65rem; }
.result-label { display: flex; justify-content: space-between; gap: 1rem; font-size: .76rem; }
.result-bar { height: .45rem; margin-top: .25rem; overflow: hidden; background: #e2e8f0; }
.result-bar span { display: block; height: 100%; background: var(--red); }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); margin-top: .7rem; border: 1px solid var(--line); text-align: center; }
.result-stats div { padding: .55rem; }
.result-stats div + div { border-left: 1px solid var(--line); }
.result-stats small { display: block; color: var(--muted); }
.analysis { border-top: 1px solid var(--line); padding: 1rem; }
.analysis h3 { margin: 0 0 .5rem; font-size: .9rem; }
.analysis p { margin: 0; color: #334155; font-size: .8rem; white-space: pre-line; }
.app-dialog { width: min(28rem,calc(100% - 1rem)); border: 0; border-radius: .5rem; padding: 0; color: var(--ink); background: #fff; }
.app-dialog::backdrop { background: rgba(15,23,42,.72); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: .8rem 1rem; }
.dialog-heading h2 { margin: 0; font-size: 1rem; }
.app-dialog form { padding: .2rem 1rem 1rem; }
.app-dialog .field { margin-top: .8rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 560px) {
  .header-title p { display: none; }
  .header-actions { gap: .25rem; }
  .identity-button { max-width: 5rem; padding-inline: .45rem; }
  .page-shell { width: calc(100% - .7rem); margin-top: .45rem; }
  .poll-row { grid-template-columns: 4rem minmax(0,1fr) 1rem; }
  .poll-row img, .poll-cover-placeholder { width: 4rem; height: 3rem; }
}
