:root {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #222;
  background: #faf9f6;
  --accent: #8e293c;
  --line: #e5e1db;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #000; }
h1, h2, p { margin: 0; }
h1 { margin-bottom: 25px; font-size: 30px; line-height: 1.4; letter-spacing: -.8px; font-weight: 700; word-break: keep-all; }
h2 { margin-bottom: 4px; font-size: 16px; font-weight: 600; }

.topbar, main { width: calc(100% - 40px); margin-left: auto; margin-right: auto; }
.topbar { max-width: 880px; padding: 22px 0 0; border-bottom: 1px solid #d6d1ca; }
.site-name, .site-name:hover { display: block; margin-bottom: 10px; padding: 9px 21px; border-radius: 6px; background: #444; color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; }
.topbar nav { display: flex; gap: 4px; margin-bottom: -1px; font-size: 14px; white-space: nowrap; }
.topbar nav a { padding: 8px 20px; border: 1px solid #d6d1ca; border-radius: 6px 6px 0 0; background: #efebe4; color: #5f5952; font-weight: 500; text-decoration: none; }
.topbar nav a:hover { background: #e6e1d8; color: #222; }
.topbar nav [aria-current="page"], .topbar nav [aria-current="page"]:hover { border-top: 2px solid var(--accent); border-bottom-color: #faf9f6; background: #faf9f6; color: var(--accent); font-weight: 650; }
.form-layout { max-width: 540px; margin-top: 34px; margin-bottom: 60px; }
body[data-page="form"] .topbar, body[data-page="home"] .topbar { max-width: 540px; }
.status-layout { max-width: 880px; margin-top: 34px; margin-bottom: 60px; }
body[data-page="admin"] .topbar, body[data-page="admin"] .status-layout { max-width: 1160px; }

button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { padding: 6px 15px; border: 1px solid #d6d1ca; border-radius: 5px; background: #fff; white-space: nowrap; }
button:hover { background: #f0ede7; }
#submit-button { min-width: 160px; padding: 10px 24px; border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
#submit-button:hover { background: #762132; }
button:disabled { opacity: .6; cursor: wait; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:not([type="radio"]):not([type="checkbox"]), select, textarea { min-height: 38px; padding: 8px 11px; border: 1px solid #d6d1ca; border-radius: 5px; background: white; max-width: 100%; }
input:not([type="radio"]):not([type="checkbox"]), textarea { display: block; width: 100%; }
input[type="radio"] { accent-color: #444; margin: 0; width: 15px; height: 15px; }
textarea { resize: vertical; }
.field { min-width: 0; padding: 0; border: 0; margin: 0 0 23px; }
.field > label, legend { display: block; margin-bottom: 9px; padding: 0; font-size: 13px; font-weight: 650; }
.field .hint { font-weight: 400; }
.kind-options { display: flex; gap: 22px; margin-bottom: 10px; }
.kind-options label, .choices label { display: flex; align-items: center; gap: 7px; cursor: pointer; min-height: 30px; }
[data-status="yes"] { --status-color: #24683c; --status-bg: #edf6ef; --member-color: #222; }
[data-status="maybe"] { --status-color: #245ba7; --status-mark: #24683c; --status-bg: #edf4ff; --member-color: #444; }
[data-status="unlikely"] { --status-color: #805b00; --status-mark: #e3b719; --status-bg: #fff2b8; --status-selected-bg: #f5d454; --status-selected-text: #4d3900; --member-color: #888; }
[data-status="no"] { --status-color: #606060; --status-mark: #ccc; --status-bg: #eee; --member-color: #ccc; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices [data-status="yes"] { --status-color: #b33333; --status-bg: #fff0f0; }
.choices label { min-height: 40px; padding: 8px 12px; border: 1px solid var(--status-color); border-radius: 5px; color: var(--status-color); background: var(--status-bg); font-size: 14px; }
.choices input { flex-shrink: 0; accent-color: var(--status-color); }
.choices label:hover { outline: 1px solid var(--status-color); }
.choices label:has(input:checked) { background: var(--status-selected-bg, var(--status-color)); color: var(--status-selected-text, #fff); font-weight: 600; }
.choices label:has(input:checked) input { accent-color: #fff; }
.choices label:has(input:focus-visible) { outline: 2px solid #222; outline-offset: 3px; }
#cohort-value { min-width: 180px; }
#conversion { margin-top: 5px; }
.hint, .privacy-note { color: #666; font-size: 12px; line-height: 1.7; }
.privacy-note { margin-bottom: 17px; }
.error { margin: 12px 0; color: #a02020; font-size: 14px; }
.success > p { margin-top: 8px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-top: 22px; }

.stats { display: grid; grid-template-columns: 1.2fr repeat(4, 1fr); gap: 12px; padding: 18px 20px; margin-bottom: 30px; background: #f0ede7; border-top: 2px solid var(--accent); font-variant-numeric: tabular-nums; }
.stats p { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.stat-label { font-size: 12px; color: #77716a; }
.stats strong { font-size: 25px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; }
.stats .total strong { color: var(--accent); }
.stat-unit { margin-left: 4px; font-size: 11px; color: #908981; }
.stats [data-status] .stat-label::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 5px; background: var(--status-mark, var(--status-color)); vertical-align: middle; }
.stats [data-status="yes"] .stat-label::before { display: none; }
.section-top { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin: 0; }
.toolbar select, .toolbar button { font-size: 13px; min-height: 35px; }
.group-columns, .cohort-row { display: grid; grid-template-columns: 48px minmax(0, .8fr) minmax(0, 1.2fr); column-gap: 12px; }
.group-columns { padding: 9px 10px; background: #f0ede7; font-size: 11px; font-weight: 500; color: #7c756d; word-break: keep-all; }
.cohort-row { align-items: stretch; border-bottom: 1px solid #ece8e2; padding: 4px 10px; }
.cohort-row:nth-child(even) { background: #f5f3ee; }
.cohort-row:hover { background: #f0ede7; }
.cohort-title strong { display: block; font-size: 12px; font-weight: 550; color: #837b72; font-variant-numeric: tabular-nums; }
.cohort-title { white-space: nowrap; padding-top: 3px; }
.members { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 4px 16px; min-width: 0; min-height: 28px; }
.member { min-width: 0; max-width: 100%; }
.member-head { display: flex; align-items: center; gap: 1px; min-width: 0; min-height: 28px; }
.member-name { position: relative; padding-left: 12px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; color: var(--member-color); }
.member-name::before { content: ""; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--status-mark, var(--status-color)); }
.member-name[data-status="yes"] { padding-left: 0; }
.member-name[data-status="yes"]::before, .stats [data-status="yes"]::before { display: none; }
.message-button { flex-shrink: 0; padding: 0; min-width: 0; min-height: 28px; border: 0; background: transparent; font-size: 16px; line-height: 1; }
.message-button:hover, .message-button[aria-expanded="true"] { background: #eee; }
.message-popover { position: fixed; inset: auto; margin: 0; width: 300px; max-width: calc(100vw - 24px); max-height: min(300px, calc(100dvh - 24px)); overflow: auto; padding: 12px 14px; border: 1px solid #ddd6cc; border-radius: 6px; background: #fff; color: #222; box-shadow: 0 3px 12px #0002; font-size: 13px; }
.message-popover strong { font-size: 13px; overflow-wrap: anywhere; }
.message-popover p { margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { font-size: 14px; padding: 22px 0; border-top: 1px solid #ddd; color: #666; }
.updated { padding: 9px 10px 0; font-size: 11px; color: #9a9288; }
.history { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 14px; color: #77716a; }
.history summary { cursor: pointer; font-size: 14px; }
#history-count { margin-left: 5px; color: #666; font-size: 12px; }
.history > .hint { margin: 10px 0; }
.history-entry { padding: 8px 0; border-bottom: 1px solid #eee; }
.history-entry .member-head { flex-wrap: wrap; }
.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; }
[hidden] { display: none !important; }

.poll-notice { margin: -12px 0 24px; font-size: 12px; color: #77716a; overflow-wrap: anywhere; }
.poll-description { margin: -8px 0 26px; font-size: 14px; overflow-wrap: anywhere; }
.poll-description:empty { display: none; }
.poll-description > * { margin: 0; }
.poll-description > * + * { margin-top: 9px; }
.poll-description h2 { font-size: 17px; }
.poll-description h3 { font-size: 15px; font-weight: 600; }
.poll-description h4 { font-size: 14px; font-weight: 600; }
.poll-description ul, .poll-description ol { padding-left: 20px; }
.poll-description blockquote { padding-left: 12px; border-left: 3px solid var(--line); color: #666; }
.poll-description hr { border: 0; border-top: 1px solid var(--line); }
.response-fields { min-width: 0; padding: 0; margin: 0; border: 0; }
.response-fields:disabled { opacity: .55; }
.response-fields:disabled input, .response-fields:disabled select, .response-fields:disabled button, .response-fields:disabled label { cursor: not-allowed; }
.accent-button { padding: 8px 18px; border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.accent-button:hover { background: #762132; }
.login-form { max-width: 380px; margin-top: 24px; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 22px 0 28px; }
#logout { margin-left: auto; }
.poll-editor { padding: 22px; border: 1px solid var(--line); background: #f5f3ee; margin-bottom: 28px; }
.poll-editor h2 { margin-bottom: 20px; }
.date-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.date-fields input { width: 100%; min-width: 0; }
.date-help { margin-top: -12px; margin-bottom: 18px; }
.enabled-option { display: flex; align-items: center; gap: 7px; font-size: 14px; margin-bottom: 5px; }
input[type="checkbox"] { width: 16px; min-height: 16px; accent-color: var(--accent); }
.poll-item { display: grid; grid-template-columns: minmax(0, 1fr) 74px 232px 250px 164px; align-items: center; column-gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); }
.poll-title { margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poll-state { justify-self: start; font-size: 11px; padding: 2px 7px; background: #e8e4de; color: #666; border-radius: 3px; white-space: nowrap; }
.poll-state[data-state="open"] { background: #e8f2e9; color: #24683c; }
.poll-state[data-state="scheduled"] { background: #e9eff9; color: #245ba7; }
.poll-period { font-size: 12px; color: #666; white-space: nowrap; font-variant-numeric: tabular-nums; }
.poll-url { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.poll-links { display: flex; justify-content: flex-end; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.poll-links button { font-size: 12px; padding: 3px 9px; }
.copy-buffer { position: fixed; left: -10000px; }
#admin-notice:not(:empty) { margin-bottom: 12px; }

@media (max-width: 1040px) {
  .poll-item { grid-template-columns: minmax(0, 1fr) 74px 232px 164px; row-gap: 2px; }
  .poll-url { grid-row: 2; grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .poll-item { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .poll-period, .poll-url, .poll-links { grid-column: 1 / -1; grid-row: auto; }
  .poll-links { justify-content: flex-start; }
}

@media (max-width: 600px) {
  .date-fields { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .poll-editor { padding: 16px; }
  .topbar, main { width: calc(100% - 32px); }
  .topbar { padding-top: 18px; }
  .site-name, .site-name:hover { padding: 8px 17px; font-size: 13px; }
  .topbar nav a { padding: 7px 16px; }
  .form-layout, .status-layout { margin-top: 26px; }
  h1 { font-size: 24px; margin-bottom: 22px; letter-spacing: -.6px; }
  input:not([type="radio"]):not([type="checkbox"]), select, textarea { font-size: 16px; }
  .group-columns, .cohort-row { grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr); column-gap: 8px; }
  .members { gap: 4px 12px; }
  .stats { grid-template-columns: 1.15fr repeat(4, 1fr); gap: 5px; padding: 14px 10px; margin-bottom: 24px; }
  .stats strong { font-size: 21px; }
  .stat-label { font-size: 10px; }
  .stat-unit { font-size: 9px; margin-left: 2px; }
  .stats [data-status] .stat-label::before { width: 4px; height: 4px; margin-right: 3px; }
  .section-top { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  .toolbar select, .toolbar button { min-height: 32px; font-size: 12px; }
  .group-columns, .cohort-row { padding-left: 6px; padding-right: 6px; }
}
