:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #211b31;
  background: #f7f6fa;
  font-synthesis: none;
  --ink: #211b31;
  --muted: #665f76;
  --line: #e8e4ee;
  --surface: #fff;
  --soft: #f7f5fb;
  --violet: #6240b7;
  --violet-dark: #4e2e9f;
  --violet-tint: #efe9fa;
  --green: #1d654e;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; font-size: 14px; line-height: 1.55; }
input, textarea, button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--violet-dark); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }
p, h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(20px, 3vw, 26px); line-height: 1.3; overflow-wrap: anywhere; }
h2 { font-size: 15px; line-height: 1.4; }
small { color: var(--muted); font-size: 12px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(960px, 100% - 40px); margin: auto; min-height: 60px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: flex; width: 30px; height: 30px; align-items: flex-end; justify-content: center; gap: 2.5px; padding-bottom: 7px; border-radius: 9px; background: var(--violet); }
.brand-mark i { width: 3.5px; height: 7px; border-radius: 1px; background: #fff; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; }
.profile { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.workspace { width: min(960px, 100% - 40px); margin: 34px auto 56px; }
.page-heading { display: grid; gap: 9px; margin-bottom: 22px; }
.context { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.context-dot { width: 7px; height: 7px; flex: 0 0 auto; background: #8661cc; border-radius: 50%; }
.layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(255px, 1fr); align-items: start; gap: 16px; }
.stack { display: grid; gap: 16px; min-width: 0; }
.panel { min-width: 0; padding: 21px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.panel.empty { max-width: 540px; margin: 48px auto; display: grid; gap: 14px; padding: 26px; }
.empty h1 { font-size: 23px; }
.empty p { color: var(--muted); }
.empty .button { justify-self: start; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.section-heading small { font-variant-numeric: tabular-nums; }

.field { display: grid; gap: 7px; min-width: 0; padding: 0; margin: 0; border: 0; }
.field > span, .field legend { font-weight: 650; }
.field > span small { margin-left: 4px; font-weight: 400; }
.field legend { margin-bottom: 7px; padding: 0; }
input[type="text"], input[type="search"], input[type="datetime-local"], textarea, select {
  width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fcfbfe;
}
input[type="datetime-local"] { min-height: 42px; }
input::placeholder, textarea::placeholder { color: #746c83; }
textarea { resize: vertical; }
.settings { position: sticky; top: 16px; }
.switcher { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.switcher label { position: relative; text-align: center; cursor: pointer; }
.switcher label span { display: block; border-radius: 6px; padding: 6px; color: var(--muted); }
.switcher input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; cursor: pointer; }
.switcher input:checked + span { background: var(--surface); color: var(--violet-dark); font-weight: 700; box-shadow: 0 1px 3px #30234c19; }
.switcher input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 1px; }
.mention-setting { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-block: 1px solid var(--line); }
.mention-setting small { display: block; margin-top: 3px; }
.mention-setting input { flex: 0 0 auto; appearance: none; width: 34px; height: 20px; margin: 0; padding: 2px; border: 1px solid #8e859e; border-radius: 20px; background: #e7e3ed; cursor: pointer; }
.mention-setting input::before { display: block; width: 14px; height: 14px; border-radius: 50%; background: white; content: ""; box-shadow: 0 1px 2px #211b3152; }
.mention-setting input:checked { background: var(--violet); border-color: var(--violet); }
.mention-setting input:checked::before { transform: translateX(14px); }
.mention-setting input:disabled { opacity: .45; cursor: default; }
.fine-print { color: var(--muted); font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; gap: 5px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; line-height: 1.35; text-decoration: none; }
.button.primary { background: var(--violet); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--violet-dark); }
.button.outline { background: var(--surface); border-color: var(--line); color: var(--violet-dark); }
.button.outline:hover:not(:disabled) { background: var(--violet-tint); border-color: #dcccfa; }
.button-link, .upload-button { padding: 3px 0; border: 0; background: transparent; color: var(--violet-dark); font-weight: 650; cursor: pointer; }
.button-link:hover, .upload-button:hover { text-decoration: underline; }
.notice { padding: 8px 10px; border-radius: 8px; font-size: 13px; background: #edf7f2; color: #1c624e; overflow-wrap: anywhere; }
.notice.error, .image-error { color: #a12648; }
.notice.error { background: #fdf0f3; }
.image-error { font-size: 12px; }

.image-picker { display: grid; gap: 8px; }
.cover-picker { padding: 10px 12px; border: 1px dashed #cfc2e5; border-radius: 9px; background: #fbf8ff; }
.upload-preview { display: block; max-width: 100%; max-height: 140px; object-fit: contain; border-radius: 8px; }
.image-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.image-actions:focus-within .upload-button:has(+ input:focus-visible) { outline: 2px solid var(--violet); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.choice-list, .tally-list, .roster-list { list-style: none; display: grid; gap: 8px; padding: 0; margin: 0; }
.choice-editor { padding: 9px; border: 1px solid var(--line); border-radius: 10px; }
.choice-line { display: flex; gap: 9px; align-items: flex-start; }
.choice-fields { display: grid; gap: 6px; flex: 1; min-width: 0; }
.choice-fields textarea { min-height: 56px; font-size: 13px; }
.choice-number { display: grid; flex: 0 0 24px; height: 24px; place-content: center; border-radius: 6px; background: var(--violet-tint); color: var(--violet-dark); font-weight: 700; font-size: 12px; }
.delete-option { width: 27px; height: 32px; flex: 0 0 auto; color: var(--muted); font-size: 22px; line-height: 1; }
.option-picker { display: grid; gap: 7px; margin: 5px 0 0 33px; font-size: 12px; }
.attachment-previews { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.attachment-preview { position: relative; display: flex; align-items: center; gap: 4px; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.attachment-preview img { display: block; width: 46px; height: 42px; object-fit: cover; border-radius: 5px; }
.video-filename { padding-left: 6px; min-width: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.button.remove-attachment { min-height: 22px; min-width: 22px; border-radius: 5px; padding: 0; color: var(--ink); background: var(--surface); }
.attachment-preview img + button { position: absolute; top: 0; right: 0; }
.add-button { justify-self: start; }

.poll-page {
  background: #f5f7fa;
  color: #182337;
  --ink: #182337;
  --muted: #526178;
  --line: #dde4ee;
  --soft: #eef2f8;
  --violet: #3559c7;
  --violet-dark: #2745a4;
  --violet-tint: #eaf0ff;
}

.poll-page .topbar-inner { min-height: 43px; }
.poll-page .brand { gap: 7px; font-size: 13px; }
.poll-page .brand-mark { width: 23px; height: 23px; padding-bottom: 5px; border-radius: 6px; }
.poll-page .brand-mark i { width: 2.5px; height: 5px; }
.poll-page .brand-mark i:nth-child(2) { height: 12px; }
.poll-page .brand-mark i:nth-child(3) { height: 8px; }
.poll-page .profile { font-size: 12px; }
.poll-page .workspace { margin-block: 17px 28px; }
.poll-page h1 { font-size: clamp(18px, 2.4vw, 22px); }
.poll-page h2 { font-size: 14px; }
.poll-page .panel { padding: 14px; border-radius: 10px; }
.poll-page .button { min-height: 31px; padding: 5px 10px; border-radius: 6px; font-size: 12px; }

.vote-heading { gap: 6px; margin-bottom: 13px; }
.vote-title { display: flex; align-items: baseline; gap: 8px; }
.vote-title .badge { flex: 0 0 auto; }
.vote-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 12px; color: var(--muted); font-size: 12px; }
.badge { width: fit-content; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 650; background: #e7f4eb; color: var(--green); }
.badge.closed, .badge.pending { background: var(--soft); color: var(--muted); }
.vote-overview { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding-top: 4px; }
.description { flex: 1 1 210px; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.poll-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.poll-page .cover-preview { width: 80px; height: 54px; padding: 0; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }

.poll-navigation { display: flex; gap: 14px; border-bottom: 1px solid var(--line); margin-bottom: 11px; }
.poll-page .poll-tab { min-height: 34px; border-width: 0 0 2px; border-radius: 0; padding-inline: 2px; background: transparent; color: var(--muted); font-size: 13px; }
.poll-tab[aria-pressed="true"] { color: var(--violet-dark); border-color: var(--violet); }
.comparison-form { display: grid; gap: 9px; }
.comparison-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pair-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.pair-selector .field { gap: 4px; }
.pair-selector span { color: var(--muted); font-size: 12px; }
.pair-selector select { padding: 5px 7px; background: var(--surface); font-size: 13px; }
.comparison-grid { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; padding: 0; margin: 0; }
.comparison-card { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.comparison-card:has(.comparison-choice input:checked) { border-color: var(--violet); box-shadow: inset 0 0 0 1px var(--violet); }
.comparison-choice { min-height: 42px; padding: 9px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; cursor: pointer; }
.comparison-title { font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.comparison-choice input { flex: 0 0 auto; accent-color: var(--violet); width: 15px; height: 15px; margin: 2px 0 0; }
.comparison-choice:has(input:disabled) { cursor: default; }
.option-details { margin: 0 10px 9px; border-block-start: 1px solid var(--line); padding-top: 6px; font-size: 12px; color: var(--muted); }
.option-details summary { width: fit-content; padding: 3px 4px; cursor: pointer; }
.option-details .option-text { margin: 5px 4px 2px; color: var(--ink); font-size: 13px; }
.option-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.gallery { display: grid; gap: 5px; margin: 0 9px 9px; }
.gallery-stage { position: relative; aspect-ratio: 8 / 5; min-height: 72px; border-radius: 7px; overflow: hidden; background: var(--soft); }
.gallery-stage > .button, .gallery-video { display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; }
.gallery-video { background: #182032; object-fit: contain; }
.gallery-image-button .poll-image { position: absolute; inset: 0; }
.gallery-stage > .gallery-image-button:focus-visible { outline-offset: -3px; }
.zoom-label { position: absolute; right: 5px; bottom: 5px; padding: 2px 5px; border-radius: 4px; background: #142135d9; color: #fff; font-size: 11px; font-weight: 500; }
.gallery-navigation { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.poll-page .gallery-selector { min-height: 27px; min-width: 27px; padding: 3px 5px; border-color: var(--line); color: var(--muted); background: var(--surface); }
.gallery-selector[aria-pressed="true"] { color: var(--violet-dark); border-color: #9eb4f2; background: var(--violet-tint); }

.poll-page:has(.photo-viewer[open]) { overflow: hidden; }
.photo-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0 0 max(12px, env(safe-area-inset-bottom));
  border: 0;
  background: #111317;
  color: #eceef2;
  color-scheme: dark;
  overflow: hidden;
}
.photo-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.photo-viewer::backdrop { background: #111317; }
.photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: max(6px, env(safe-area-inset-top)) clamp(12px, 2.6vw, 28px) 6px;
}
.photo-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.photo-title:focus { outline: 0; }
.photo-stage {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin-inline: clamp(8px, 2vw, 24px);
  overflow: hidden;
}
.photo-stage .poll-image { min-width: 0; min-height: 0; }
.photo-status { color: #b4bac4; font-size: 13px; }
.photo-navigation {
  display: flex;
  justify-self: center;
  align-items: center;
  gap: 3px;
  margin-top: 10px;
  padding: 2px;
  border: 1px solid #ffffff16;
  border-radius: 24px;
  background: #1b1e24;
}
.photo-position { min-width: 44px; text-align: center; color: #c5cad3; font-size: 12px; font-variant-numeric: tabular-nums; }
.photo-control {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #eceef2;
}
.photo-control:hover:not([aria-disabled="true"]) { background: #ffffff16; }
.photo-control:focus-visible { outline: 2px solid #c5d6ff; outline-offset: -2px; }
.photo-control[aria-disabled="true"] { cursor: default; opacity: .33; }
.photo-control::before, .photo-close::after { grid-area: 1 / 1; display: block; content: ""; }
.photo-close { background: #ffffff0c; }
.photo-close::before, .photo-close::after { width: 15px; height: 1.5px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
.photo-close::after { transform: rotate(-45deg); }
.photo-previous::before, .photo-next::before { width: 8px; height: 8px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; }
.photo-previous::before { transform: translateX(1px) rotate(135deg); }
.photo-next::before { transform: translateX(-1px) rotate(-45deg); }

.ballot-actions { position: sticky; z-index: 1; bottom: 0; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 -3px 14px #17253c0c; }
.vote-feedback { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.vote-feedback.error { color: #a12648; }
.poll-results { display: grid; gap: 10px; }
.tally { display: grid; gap: 10px; }
.tally-list { gap: 8px; }
.tally-row { display: grid; gap: 4px; }
.tally-label { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-size: 13px; overflow-wrap: anywhere; }
.tally-label span:last-child { flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 5px; border: 0; appearance: none; overflow: hidden; border-radius: 5px; background: var(--violet-tint); }
progress::-webkit-progress-bar { background: var(--violet-tint); }
progress::-webkit-progress-value { background: #5577dc; border-radius: 5px; }
progress::-moz-progress-bar { background: #5577dc; border-radius: 5px; }
.roster { gap: 10px; }
.roster-search { display: flex; gap: 8px; }
.roster-search input, .roster-search select { padding: 5px 7px; background: var(--surface); font-size: 13px; }
.roster-search select { width: auto; flex: 0 0 auto; }
.roster-list { gap: 0; }
.roster-list li { display: grid; grid-template-columns: minmax(112px, 1fr) minmax(0, 2fr) auto; align-items: baseline; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; font-size: 13px; }
.roster-list li:first-child { border-top: 0; }
.roster-list p > small { display: block; }
.member-choices p + p { margin-top: 4px; }
.member-choices small { display: block; }

@media (max-width: 700px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .settings { position: static; }
}

@media (max-width: 540px) {
  .photo-control { width: 44px; height: 44px; }
  .comparison-grid:not(.is-pair) { grid-template-columns: minmax(0, 1fr); }
  .comparison-grid.is-pair { gap: 6px; }
  .is-pair .comparison-choice { padding-inline: 7px; }
  .is-pair .comparison-title { font-size: 13px; }
  .is-pair .gallery, .is-pair .option-details { margin-inline: 5px; }
}

@media (max-width: 460px) {
  .workspace, .topbar-inner { width: calc(100% - 26px); }
  .workspace { margin-top: 20px; }
  .topbar-inner { min-height: 52px; }
  .page-heading { margin-bottom: 15px; }
  .panel { padding: 15px; border-radius: 12px; }
  .roster-list li { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; }
  .roster-list .member-choices { grid-row: 2; grid-column: 1 / -1; }
  .roster-list .badge { grid-column: 2; }
}
