:root {
  color-scheme: light;
  --page: #f7f7f5;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #74726c;
  --line: #e1e0d9;
  --ring: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --danger: #c23434;
  --track: #ecebe6;
  --ref: #9a9890;
  /* 選択肢の色（固定順。色だけに頼らず、必ず文字のラベルと数値も出す） */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1012;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a998f;
    --line: #2c2c2a;
    --ring: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: #16263b;
    --danger: #e66767;
    --track: #2a2a28;
    --ref: #7a7973;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1012;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a998f;
  --line: #2c2c2a;
  --ring: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --accent-soft: #16263b;
  --danger: #e66767;
  --track: #2a2a28;
  --ref: #7a7973;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.site-header {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: 0.02em; }
.brand-tag { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-header .btn { flex: none; }
.wrap { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; }
.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.lang-select select { min-height: 36px; width: auto; padding: 4px 8px; font-size: 14px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 18px;
  padding: 20px 18px;
  margin-bottom: 14px;
}
.card h1, .card h2 { margin: 0 0 12px; line-height: 1.35; }
.card h2 { font-size: 18px; }
.question { font-size: 22px; font-weight: 800; overflow-wrap: anywhere; }
.desc { margin: -4px 0 10px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ref { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.notice { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.error { color: var(--danger); font-size: 14px; margin: 6px 0 0; }

/* ---------- 回答フォーム ---------- */
.options { display: grid; gap: 10px; margin: 6px 0 18px; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color 0.12s, background 0.12s;
  overflow-wrap: anywhere;
}
.opt:hover { border-color: var(--muted); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .dot {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: grid;
  place-items: center;
}
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt:has(input:checked) .dot { border-color: var(--accent); }
.opt:has(input:checked) .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.attrs { margin: 0 0 16px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.attrs-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.attrs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.attrs-grid label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
select, input[type="text"], input[type="url"], input[type="password"], input[type="number"], input[type="datetime-local"], textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px; /* iPhone で入力時に拡大されないよう 16px 以上 */
}
textarea { resize: vertical; }
.ts { min-height: 65px; margin: 0 0 12px; }
#ts { min-height: 65px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; font-size: 17px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.fine { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- 結果 ---------- */
.status { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.total-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.total { font-size: 28px; font-weight: 800; }
.live { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--s3); }

.seg { display: flex; padding: 3px; border-radius: 999px; background: var(--surface-2); margin: 0 0 16px; }
.seg button {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring); }

.bars { display: grid; gap: 16px; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.bar-label { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.swatch { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.mine { flex: none; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.bar-pct { font-size: 20px; font-weight: 800; white-space: nowrap; }
.bar-pct small { font-size: 12px; font-weight: 600; color: var(--muted); margin-inline-start: 4px; }
.track { height: 12px; border-radius: 4px; background: var(--track); overflow: hidden; }
.fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; min-width: 0; }
.ref-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.ref-row .track { flex: 1; height: 5px; }
.ref-row .fill { background: var(--ref); }
.ref-row span { white-space: nowrap; }
.ref-row .ref-name { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.caveat { margin: 16px 0 0; font-size: 12px; color: var(--muted); }

.section-title { font-size: 16px; font-weight: 800; margin: 30px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.stack-rows { display: grid; gap: 8px; }
.stack-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; font-size: 13px; }
.stack-row .g { color: var(--ink-2); line-height: 1.2; }
.stack-row .g small { display: block; color: var(--muted); font-size: 11px; }
.stackbar { display: flex; gap: 2px; height: 18px; }
.stackbar div { height: 100%; border-radius: 4px; min-width: 2px; }
.stack-row.few { opacity: 0.55; }

.timeline { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-bottom: 1px; border-bottom: 1px solid var(--line); }
.timeline .col { flex: 1; display: flex; flex-direction: column-reverse; gap: 1px; height: 100%; justify-content: flex-start; min-width: 2px; }
.timeline .col div { border-radius: 2px; }
.timeline .col:hover { background: var(--surface-2); }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--page);
  font-size: 12px;
  line-height: 1.5;
  max-width: 240px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

details.table-view { margin-top: 14px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--ink-2); }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
th, td { text-align: end; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: start; }
th { font-weight: 700; color: var(--ink-2); }

.share { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.share .btn { flex: 1; min-width: 0; padding: 10px 14px; white-space: nowrap; }

/* ---------- トップ・管理 ---------- */
.intro p { margin: 0 0 8px; }
.poll-list, .admin-list { list-style: none; padding: 0; margin: 0; }
.poll-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.poll-list li:last-child .poll-link { border-bottom: 0; }
.poll-link-q { font-weight: 700; overflow-wrap: anywhere; }
.poll-link-n { flex: none; color: var(--muted); font-size: 14px; }
form.stack { display: grid; gap: 14px; }
form.stack label { display: grid; gap: 4px; font-size: 14px; font-weight: 700; }
form.stack label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0; }
legend { font-size: 14px; font-weight: 700; padding: 0 4px; }
.req { font-size: 11px; color: var(--danger); margin-inline-start: 6px; }
.opt-edit { display: grid; grid-template-columns: 1fr 84px 36px; gap: 6px; margin-bottom: 8px; }
.opt-edit button { border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; }
.admin-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-list .q { font-weight: 700; overflow-wrap: anywhere; }
.admin-list .meta { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.admin-list .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); margin-inline-start: 6px; }
.badge.open { background: var(--accent-soft); color: var(--accent); }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; }
.prose h2 { margin-top: 22px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 6px; }

@media (max-width: 420px) {
  .question { font-size: 20px; }
}

/* ---------- 追加：通報・作成・管理 ---------- */
.status.warn { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.closes { margin: 14px 0 0; }
.report-row { margin: 18px 0 0; text-align: end; }
.linkish { border: 0; background: none; padding: 4px 0; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; }
.btn.danger { background: var(--danger); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check a { font-weight: 600; }
.dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--ring);
  border-radius: 18px;
  padding: 20px 18px;
  background: var(--surface);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog h2 { margin: 0 0 12px; font-size: 18px; }
.reasons { display: grid; gap: 8px; margin: 0 0 14px; }
.reasons label { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.notice.small { font-size: 13px; }
h3.section-title { font-size: 15px; }
[dir="rtl"] .linkish, [dir="rtl"] .report-row { text-align: start; }
@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
  .brand-tag { max-width: 46vw; }
}
