:root {
  color: #171719;
  background: #f4f5f7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --blue: #0878e6;
  --blue-soft: #eef6ff;
  --green: #16702c;
  --line: #dfe2e7;
  --muted: #6e6e73;
  --card: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f5f7; }
button, input { font: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(8,120,230,.24); outline-offset: 2px; }

.site-header {
  min-height: 104px;
  padding: 20px max(28px, calc((100vw - 1520px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  color: #fff;
  background: #202124;
}
.site-header span { color: #aeb0b5; font-size: 13px; }
.site-header h1 { margin: 4px 0 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.035em; }
.header-rule { display: grid; gap: 5px; text-align: right; }
.header-rule strong { font-size: 14px; }

.app-shell { width: min(1520px, calc(100% - 48px)); margin: 20px auto 0; padding-bottom: 150px; }
.loading-card, .fatal-card { padding: 48px; border: 1px solid var(--line); border-radius: 18px; background: #fff; text-align: center; }
.fatal-card { color: #a2201a; }

.email-gate { width: min(520px, 100%); margin: 64px auto 0; padding: 34px; display: grid; gap: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: 0 18px 50px rgba(0,0,0,.08); }
.email-gate-kicker { color: var(--blue); font-size: 13px; font-weight: 700; }
.email-gate h2 { margin: 0; font-size: 30px; letter-spacing: -.025em; }
.email-gate > p { margin: -5px 0 2px; color: var(--muted); line-height: 1.6; }
.email-gate label { display: grid; gap: 7px; }
.email-gate label span { color: var(--muted); font-size: 12px; }
.email-gate input { min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.email-gate button { min-height: 48px; border: 0; border-radius: 999px; color: #fff; background: var(--blue); font-weight: 700; cursor: pointer; }
.email-gate button:disabled { color: #777; background: #e3e4e6; cursor: wait; }
.email-gate .email-gate-message { margin: -3px 0 0; color: #b4231b; font-size: 13px; }

.voter-identity { min-height: 62px; margin-top: 10px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid #cfe1f5; border-radius: 14px; background: var(--blue-soft); }
.voter-identity div { min-width: 0; display: grid; gap: 3px; }
.voter-identity span { color: var(--muted); font-size: 11px; }
.voter-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voter-identity button { min-height: 38px; padding: 0 16px; border: 1px solid #a9c9ea; border-radius: 999px; color: #075fae; background: #fff; font-weight: 700; cursor: pointer; }
.voter-identity p { margin: 0; color: var(--green); font-weight: 700; }
.voter-identity.is-submitted { border-color: #b7ddc0; background: #f0faf2; }

.vote-notice, .receipt-banner {
  min-height: 58px;
  padding: 13px 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.vote-notice::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: #86868b; }
.vote-notice.is-open::before { background: #2aa048; }
.vote-notice.is-closed::before { background: #c53830; }
.receipt-banner { margin-top: 10px; border-color: #b7ddc0; background: #f0faf2; color: var(--green); }
.receipt-banner small { margin-left: auto; color: var(--muted); }

.track-tabs { margin-top: 12px; display: flex; border-bottom: 1px solid var(--line); }
.track-tabs button { min-width: 210px; padding: 14px 16px; display: grid; gap: 2px; border: 0; border-bottom: 3px solid transparent; background: transparent; text-align: left; cursor: pointer; }
.track-tabs button strong { font-size: 18px; }
.track-tabs button span { color: var(--muted); font-size: 12px; }
.track-tabs button.is-active { color: var(--blue); border-bottom-color: var(--blue); }

.vote-layout { margin-top: 16px; display: grid; grid-template-columns: 242px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.work-nav, .work-card, .prompt-card { border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.work-nav, .prompt-card { position: sticky; top: 16px; }
.work-nav { padding: 15px; }
.work-nav-heading { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.work-nav-heading span { color: var(--muted); font-size: 12px; }
.work-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.work-grid button { min-height: 55px; padding: 5px; display: grid; place-content: center; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.work-grid button span { color: var(--muted); font-size: 10px; }
.work-grid button.is-active { border: 2px solid var(--blue); background: var(--blue-soft); }
.work-grid button.is-selected { border-color: #79bd88; color: var(--green); background: #eff9f1; }

.work-card { padding: 17px; min-width: 0; }
.work-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.work-heading span { color: var(--blue); font-size: 12px; font-weight: 700; }
.work-heading h2 { margin: 3px 0 0; font-size: 25px; }
.select-work { min-height: 42px; padding: 0 18px; border: 0; border-radius: 999px; color: #fff; background: var(--blue); font-weight: 700; cursor: pointer; }
.select-work.is-selected { background: var(--green); }
.select-work:disabled { color: #777; background: #e3e4e6; cursor: not-allowed; }
.read-only-badge { min-height: 38px; padding: 0 16px; display: inline-grid; place-items: center; border-radius: 999px; color: var(--green); background: #e7f5ea; font-weight: 700; }

.media-stage { margin-top: 14px; min-height: 420px; position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 13px; background: #f0f1f3; }
.media-stage:fullscreen { width: 100vw; height: 100vh; margin: 0; border-radius: 0; background: #111; }
.active-media { display: block; max-width: 100%; max-height: 76vh; object-fit: contain; }
video.active-media { width: 100%; background: #000; }
.active-image-button { width: 100%; padding: 0; display: grid; place-items: center; border: 0; background: transparent; cursor: zoom-in; }
.media-stage:fullscreen .active-image-button { height: 100%; cursor: zoom-out; }
.media-stage:fullscreen .active-media { width: 100%; height: 100%; max-height: none; }
.media-count { position: absolute; top: 11px; right: 11px; padding: 5px 10px; border-radius: 99px; background: rgba(20,20,22,.68); color: #fff; font-size: 12px; }
.media-strip { margin-top: 10px; padding: 9px; display: flex; gap: 8px; overflow-x: auto; border-radius: 12px; background: #f1f2f4; }
.media-thumb { width: 82px; height: 66px; flex: 0 0 82px; padding: 4px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 9px; background: #fff; cursor: pointer; }
.media-thumb.is-active { border: 2px solid var(--blue); }
.media-thumb-image { width: 100%; height: 100%; object-fit: contain; }
.video-thumb-icon { font-size: 22px; color: #fff; }
.media-thumb:has(.video-thumb-icon) { color: #fff; background: #17324d; }
.media-thumb small { font-size: 10px; }

.prompt-card { padding: 17px; max-height: calc(100vh - 32px); overflow: auto; }
.prompt-card h2 { margin: 0 0 10px; color: var(--blue); font-size: 16px; }
.prompt-text { white-space: pre-wrap; color: #424245; font-size: 13px; line-height: 1.65; }

.submit-bar { position: fixed; z-index: 10; left: 50%; bottom: 14px; width: min(1180px, calc(100% - 32px)); min-height: 88px; padding: 12px 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; transform: translateX(-50%); border: 1px solid rgba(0,0,0,.12); border-radius: 17px; background: rgba(255,255,255,.95); box-shadow: 0 14px 42px rgba(0,0,0,.16); backdrop-filter: blur(18px); }
.submit-bar.is-readonly { grid-template-columns: 1fr; }
.selection-summary { display: grid; gap: 4px; }
.selection-summary span { color: var(--muted); font-size: 11px; }
.submit-button { min-height: 46px; padding: 0 20px; border: 0; border-radius: 999px; color: #fff; background: var(--blue); font-weight: 700; cursor: pointer; }
.submit-button:disabled { color: #777; background: #e3e4e6; cursor: not-allowed; }
.bar-message { grid-column: 1 / -1; margin: -6px 0 0; color: #b4231b; font-size: 12px; }

@media (max-width: 1100px) {
  .vote-layout { grid-template-columns: 210px minmax(0, 1fr); }
  .prompt-card { grid-column: 2; position: static; max-height: none; }
}
@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-direction: column; gap: 12px; }
  .header-rule { text-align: left; }
  .app-shell { width: calc(100% - 20px); padding-bottom: 245px; }
  .email-gate { margin-top: 24px; padding: 24px 18px; }
  .voter-identity { align-items: stretch; flex-direction: column; }
  .voter-identity button { width: 100%; }
  .track-tabs button { min-width: 0; flex: 1; }
  .vote-layout { grid-template-columns: 1fr; }
  .work-nav, .prompt-card { position: static; grid-column: 1; }
  .work-grid { grid-template-columns: repeat(4, 1fr); }
  .media-stage { min-height: 260px; }
  .submit-bar { bottom: 8px; grid-template-columns: 1fr; gap: 8px; }
  .submit-button { width: 100%; }
}

.admin-body { background: #f4f5f7; }
.admin-header { min-height: 102px; padding: 20px max(32px, calc((100vw - 1460px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: #fff; background: #202124; }
.admin-header span { color: #aeb0b5; font-size: 12px; }
.admin-header h1 { margin: 4px 0 0; font-size: 32px; }
.admin-shell { width: min(1460px, calc(100% - 48px)); margin: 26px auto 64px; }
.admin-summary { display: grid; grid-template-columns: repeat(3, 1fr) 1.2fr; gap: 12px; }
.admin-summary > div { min-height: 105px; padding: 18px; display: grid; align-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.admin-summary span { color: var(--muted); font-size: 12px; }
.admin-summary strong { font-size: 27px; }
.admin-actions { grid-template-columns: 1fr 1fr; align-items: center; gap: 8px !important; }
.admin-actions button, .admin-table-heading button { min-height: 42px; padding: 0 15px; border: 0; border-radius: 999px; color: #fff; background: var(--blue); font-weight: 700; cursor: pointer; }
.admin-actions button.danger { background: #b22922; }
.admin-actions button:disabled { color: #777; background: #e3e4e6; cursor: not-allowed; }
.admin-live { margin: 14px 0 0 auto; width: max-content; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.admin-live span { width: 8px; height: 8px; border-radius: 50%; background: #2aa048; }
.admin-live span.is-stale { background: #d99a16; }
.admin-message { padding: 11px 14px; border-radius: 10px; color: #a2201a; background: #fff0ef; }
.admin-tabs { margin-top: 16px; display: flex; border-bottom: 1px solid var(--line); }
.admin-tabs button { min-width: 190px; padding: 15px; border: 0; border-bottom: 3px solid transparent; background: transparent; font-weight: 700; cursor: pointer; }
.admin-tabs button.is-active { color: var(--blue); border-bottom-color: var(--blue); }
.admin-table-card { margin-top: 15px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.admin-table-heading { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.admin-table-heading h2 { margin: 0; font-size: 21px; }
.admin-table-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.admin-table-scroll { overflow-x: auto; }
.admin-table-card table { width: 100%; border-collapse: collapse; }
.admin-table-card th, .admin-table-card td { padding: 14px 17px; border-bottom: 1px solid #ececef; text-align: left; white-space: nowrap; }
.admin-table-card th { color: var(--muted); background: #fafafa; font-size: 12px; }
.admin-table-card tbody tr:hover { background: #f7fbff; }
.admin-table-card td strong { color: var(--blue); }

@media (max-width: 800px) {
  .admin-header { align-items: flex-start; flex-direction: column; }
  .admin-shell { width: calc(100% - 20px); }
  .admin-summary { grid-template-columns: 1fr 1fr; }
  .admin-actions { grid-column: 1 / -1; }
  .admin-table-heading { align-items: flex-start; flex-direction: column; }
}
