:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe3ee;
  --paper: #ffffff;
  --canvas: #f3f6fa;
  --yes: #087c68;
  --yes-soft: #e3f5f0;
  --no: #c33a4a;
  --no-soft: #fdecef;
  --blank: #52606f;
  --blank-soft: #edf1f5;
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(38, 102, 170, .08), transparent 34rem),
    var(--canvas);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .04em; }
.brand-button { border: 0; background: transparent; color: inherit; padding: 0; }
.brand-logo { display: block; width: 34px; height: 52px; object-fit: contain; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: .875rem; padding: 10px; }
.text-button:hover { color: var(--ink); }

.workspace { padding: clamp(44px, 8vw, 92px) 0 72px; }
.compact-intro { margin-bottom: 24px; }
.intro { max-width: 650px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 10px; color: #2e6ca8; font-size: .75rem; font-weight: 900; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.18; letter-spacing: -.045em; }
.intro > p:last-child, .result-heading p, .handoff > p { color: var(--muted); font-size: 1rem; line-height: 1.8; }

.setup-card, .summary-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .07);
}
.setup-card { display: grid; grid-template-columns: 1fr 250px; gap: 28px; padding: clamp(24px, 5vw, 42px); }
.setup-card.single-column { grid-template-columns: 1fr; }
.full-field { grid-column: 1 / -1; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 20px; align-items: stretch; }
.create-panel { display: flex; flex-direction: column; justify-content: center; padding: 34px; border-radius: 18px; background: #e7eef6; }
.create-panel h2, .roster-card h2, .admin-actions h2 { margin: 0 0 10px; font-size: 1.3rem; }
.create-panel p, .admin-actions p { color: var(--muted); line-height: 1.7; }
.create-panel .secondary-button { margin-top: 12px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.login-only { max-width: 420px; margin: 0 auto; }
.login-panel { min-height: 210px; text-align: center; }
.organizer-key-button { display: block; margin-top: 8px; }
.narrow-card { max-width: 620px; }
.field { display: flex; flex-direction: column; gap: 10px; font-weight: 800; }
.field textarea, .field input {
  width: 100%;
  border: 1px solid #b8c4d2;
  border-radius: 10px;
  background: #fbfdff;
  color: var(--ink);
  outline: none;
}
.field input { min-height: 50px; padding: 0 14px; text-transform: uppercase; letter-spacing: .08em; }
.field textarea { min-height: 128px; padding: 16px; resize: vertical; line-height: 1.65; }
.field textarea:focus, .field input:focus { border-color: #2e6ca8; box-shadow: 0 0 0 3px rgba(46, 108, 168, .13); }
.field small { align-self: flex-end; color: var(--muted); font-weight: 500; }
.check-field { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.check-field input { width: 18px; height: 18px; }
.number-control { display: grid; grid-template-columns: 46px 1fr 46px auto; align-items: center; gap: 8px; }
.number-control button { height: 48px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 1.35rem; }
.number-control input { height: 48px; text-align: center; font-size: 1.2rem; font-weight: 800; }
.number-control span { color: var(--muted); }
.primary-button, .secondary-button { min-height: 52px; border-radius: 11px; padding: 0 24px; font-weight: 800; }
.primary-button { grid-column: 1 / -1; border: 0; background: var(--ink); color: white; }
.primary-button:hover { background: #263447; }
.secondary-button { border: 1px solid #9eabba; background: white; color: var(--ink); }

.vote-heading, .result-heading { display: flex; justify-content: space-between; gap: 32px; align-items: flex-end; }
.vote-heading h1 { max-width: 760px; font-size: clamp(1.8rem, 4vw, 3rem); }
.progress-copy { white-space: nowrap; color: var(--muted); }
.progress-copy strong { color: var(--ink); font-size: 2.3rem; }
.progress-track { height: 4px; margin: 30px 0 40px; overflow: hidden; border-radius: 4px; background: #dce3ea; }
.progress-track div { height: 100%; width: 0; background: #2e6ca8; transition: width .25s ease; }
.ballot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 0; padding: 0; border: 0; }
.choice { min-height: 220px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; border: 1px solid var(--line); border-radius: 16px; padding: 24px; background: white; text-align: left; transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease; }
.choice:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(15, 23, 42, .09); }
.choice-yes:hover { border-color: var(--yes); }
.choice-no:hover { border-color: var(--no); }
.choice-blank:hover { border-color: var(--blank); }
.choice-symbol { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; font-size: 1.75rem; font-weight: 900; }
.choice-yes .choice-symbol { background: var(--yes-soft); color: var(--yes); }
.choice-no .choice-symbol { background: var(--no-soft); color: var(--no); }
.choice-blank .choice-symbol { background: var(--blank-soft); color: var(--blank); }
.choice strong { display: block; font-size: 1.7rem; margin-bottom: 5px; }
.choice small { color: var(--muted); font-size: .875rem; }
.choice:disabled { opacity: .55; cursor: wait; transform: none; }
.privacy-note { margin-top: 22px; color: var(--muted); font-size: .875rem; }
.privacy-note span { color: #2e6ca8; font-size: .6rem; margin-right: 7px; }

.handoff { min-height: calc(100vh - 76px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-top: 0; }
.handoff-icon { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 24px; border-radius: 50%; background: var(--yes-soft); color: var(--yes); font-size: 2rem; font-weight: 900; }
.handoff .primary-button { margin-top: 18px; min-width: 230px; }

.complete-badge { border-radius: 999px; background: var(--yes-soft); color: var(--yes); padding: 9px 14px; font-size: .875rem; font-weight: 800; white-space: nowrap; }
.voter-chip { display: inline-block; margin: 0 0 16px; padding: 7px 11px; border-radius: 999px; background: #e7eef6; color: #315a82; font-size: .875rem; font-weight: 800; }
.code-banner { display: flex; align-items: center; gap: 18px; margin: 30px 0 18px; padding: 22px 26px; border-radius: 16px; background: var(--ink); color: white; }
.code-banner span { color: #b9c6d6; }
.code-banner strong { margin-right: auto; font-size: clamp(1.8rem, 5vw, 2.7rem); letter-spacing: .18em; }
.copy-button { border: 1px solid #b8c4d2; border-radius: 8px; background: white; color: var(--ink); padding: 8px 12px; font-size: .8rem; font-weight: 800; }
.credential-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: white; }
.credential-table { width: 100%; border-collapse: collapse; }
.credential-table th, .credential-table td { padding: 15px 18px; border-bottom: 1px solid var(--line); text-align: left; }
.credential-table th { color: var(--muted); font-size: .8rem; }
.credential-table tr:last-child td { border: 0; }
.credential-table code { font-size: 1rem; font-weight: 800; letter-spacing: .08em; }
.credential-table .invite-url { display: block; max-width: 440px; overflow: hidden; color: var(--muted); font-family: ui-monospace, monospace; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.credential-table .row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.invite-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 12px; }
.invite-actions .secondary-button { min-height: 42px; }
.admin-secret { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding: 18px 22px; border: 1px dashed #9ba9b8; border-radius: 14px; }
.admin-secret span { display: block; color: var(--muted); font-size: .78rem; }
.admin-secret strong { display: block; margin-top: 5px; font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.warning-note { color: #8a4b16; font-size: .875rem; }
.wide-button { width: 100%; margin-top: 10px; }
.compact-button { grid-column: auto; min-height: 44px; }
.poll-list { display: grid; gap: 12px; margin-top: 28px; }
.poll-list-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); text-align: left; }
.poll-list-item:hover { border-color: #7f91a5; box-shadow: 0 8px 24px rgba(15, 23, 42, .06); }
.poll-list-item strong { display: block; font-size: 1rem; }
.poll-list-item small { display: block; margin-top: 7px; color: var(--muted); }
.poll-count { white-space: nowrap; font-weight: 800; color: #315a82; }
.empty-note { margin-top: 28px; padding: 30px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 36px 0 22px; }
.result-card { min-height: 188px; padding: 24px; border-radius: 16px; background: white; border-top: 5px solid; }
.result-card.yes { border-color: var(--yes); }
.result-card.no { border-color: var(--no); }
.result-card.blank { border-color: var(--blank); }
.result-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 800; }
.result-value { display: flex; align-items: baseline; gap: 8px; margin-top: 28px; }
.result-value strong { font-size: 3rem; letter-spacing: -.05em; }
.result-value span { color: var(--muted); }
.result-bar { height: 7px; margin-top: 18px; border-radius: 5px; background: #edf1f5; overflow: hidden; }
.result-bar div { height: 100%; }
.yes .result-bar div { background: var(--yes); }
.no .result-bar div { background: var(--no); }
.blank .result-bar div { background: var(--blank); }
.summary-card { margin-bottom: 22px; padding: 8px 24px; }
.summary-row { display: flex; justify-content: space-between; padding: 17px 0; border-bottom: 1px solid var(--line); }
.summary-row:last-child { border: 0; }
.summary-row span { color: var(--muted); }
.summary-row.outcome strong { color: #2e6ca8; }
.progress-summary { margin: 32px 0 24px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.progress-summary strong { font-size: 2rem; }
.progress-summary span { color: var(--muted); }
.progress-summary .progress-track { margin: 18px 0 0; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 20px; }
.roster-card, .admin-actions { padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.roster-card ul { margin: 18px 0 0; padding: 0; list-style: none; }
.roster-card li { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.roster-card li:last-child { border: 0; }
.roster-card li span small { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.roster-card strong { font-size: .8rem; }
.roster-card .voted { color: var(--yes); }
.roster-card .waiting { color: var(--muted); }
.admin-actions { align-self: start; display: grid; gap: 12px; }
.danger-button { min-height: 50px; border: 0; border-radius: 11px; background: #b92f41; color: white; font-weight: 800; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px); padding: 12px 18px; border-radius: 10px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .shell { width: min(100% - 24px, 1080px); }
  .topbar { min-height: 64px; }
  .setup-card { grid-template-columns: 1fr; }
  .two-column, .admin-grid { grid-template-columns: 1fr; }
  .ballot, .result-grid { grid-template-columns: 1fr; }
  .choice { min-height: 116px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 20px; }
  .vote-heading, .result-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .progress-copy strong { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
