/* ひだまり市 選挙シミュレーター ― 部品のスタイル */

/* ---------- 凡例・タグ ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.8125rem; color: var(--ink-2); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.key.line i { height: 3px; width: 16px; border-radius: 2px; }
.t0 { background: var(--s1); } .t1 { background: var(--s2); } .t2 { background: var(--s3); }
.y0 { background: var(--l1); } .y1 { background: var(--l2); } .y2 { background: var(--l3); }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--axis); border-radius: 4px; font-size: 0.6875rem; line-height: 1.5; color: var(--ink-2); white-space: nowrap; }

/* ---------- 当選者の発表 ---------- */
.result-head { display: grid; gap: 8px; }
.winner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; border-radius: 8px; background: var(--win-soft); }
.winner .rose { width: 34px; height: 34px; flex: none; color: var(--win); }
.winner .who { font-family: var(--font-display); font-weight: 900; font-size: 1.35rem; line-height: 1.3; }
.winner .who small { font-family: var(--font-body); font-size: 0.8125rem; font-weight: 700; color: var(--win); display: block; letter-spacing: 0.08em; }
.winner .why { font-size: 0.875rem; color: var(--ink-2); flex: 1 1 14em; min-width: 0; }
.seats { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.seats i { width: 16px; height: 16px; border-radius: 50%; }
.seats-count { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 0.875rem; }
.seats-count b { font-size: 1.15rem; font-family: var(--font-display); }

/* ---------- 順位表（得票の多い順） ---------- */
.rank { position: relative; --rowh: 34px; --cutgap: 22px; }
.rank-row {
  position: absolute; left: 0; right: 0; top: 0; height: var(--rowh);
  display: grid; grid-template-columns: 2ch minmax(6.5em, 9.5em) minmax(0, 1fr) 9.2em 2.2em;
  align-items: center; gap: 8px; font-size: 0.875rem;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s;
}
.rank-no { text-align: right; color: var(--muted); font-size: 0.75rem; }
.rank-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 700; white-space: nowrap; }
.rank-name i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.rank-name span { overflow: hidden; text-overflow: ellipsis; }
.rank-bar { position: relative; height: 16px; }
.rank-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; transition: width 0.25s ease-out, left 0.25s ease-out; }
.rank-val { text-align: right; font-weight: 700; white-space: nowrap; }
.rank-val small { display: inline-block; min-width: 3.6em; margin-left: 4px; font-weight: 400; font-size: 0.6875rem; color: var(--ink-2); }
.rank-badge { justify-self: end; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--win); color: var(--surface); font-size: 0.75rem; font-weight: 700; opacity: 0; transform: scale(0.4); transition: opacity 0.25s, transform 0.25s; }
.rank-row.is-win .rank-badge { opacity: 1; transform: scale(1); }
.rank-row.is-lose { opacity: 0.62; }
.rank-row.is-lose .rank-name { font-weight: 400; }
.cutline { position: absolute; left: 0; right: 0; top: 0; height: var(--cutgap); display: flex; align-items: center; gap: 8px; font-size: 0.6875rem; font-weight: 700; color: var(--win); transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); }
.cutline::before, .cutline::after { content: ""; flex: 1; border-top: 2px dashed var(--win); }
@media (max-width: 560px) {
  .rank { --rowh: 46px; }
  .rank-row { grid-template-columns: 2ch minmax(0, 1fr) auto 2.2em; grid-template-areas: "no name val badge" "no bar bar bar"; gap: 0 8px; align-content: center; }
  .rank-no { grid-area: no; } .rank-name { grid-area: name; } .rank-val { grid-area: val; }
  .rank-badge { grid-area: badge; width: 22px; height: 22px; } .rank-bar { grid-area: bar; height: 8px; }
}

/* ---------- だれが投票に行ったか ---------- */
.layers { display: grid; gap: 10px; }
.layer-row { display: grid; grid-template-columns: 9.6em minmax(0, 1fr) 3.2em; align-items: center; gap: 2px 10px; font-size: 0.875rem; }
.layer-row b { font-weight: 700; }
.layer-bar { height: 16px; background: var(--surface-2); border-radius: 0 4px 4px 0; position: relative; }
.layer-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 0 4px 4px 0; transition: width 0.25s ease-out; }
.layer-val { text-align: right; font-weight: 700; }
.layer-row small { grid-column: 2 / -1; font-size: 0.75rem; color: var(--ink-2); line-height: 1.3; }
.mix { display: flex; gap: 2px; height: 26px; }
.mix span { flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; font-size: 0.75rem; font-weight: 700; transition: flex-grow 0.25s ease-out; }
.mix span:first-child { border-radius: 4px 0 0 4px; } .mix span:last-child { border-radius: 0 4px 4px 0; }
.mix .y0 { color: var(--surface); } .mix .y1 { color: var(--surface); } .mix .y2 { color: var(--ink); }

/* ---------- グラフ（SVG） ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--muted); }
.chart .lbl { fill: var(--ink); font-weight: 700; font-size: 12px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .now { stroke: var(--ink); stroke-width: 1.5; }
.chart .ser { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.c0 { stroke: var(--s1); } .c1 { stroke: var(--s2); } .c2 { stroke: var(--s3); }
.f0 { fill: var(--s1); } .f1 { fill: var(--s2); } .f2 { fill: var(--s3); }
.fy0 { fill: var(--l1); } .fy1 { fill: var(--l2); } .fy2 { fill: var(--l3); }
.chart .cell-off { fill: var(--surface-2); }
.chart .hit { fill: transparent; cursor: ew-resize; }
.tip { position: absolute; z-index: 30; pointer-events: none; min-width: 9em; max-width: 17em; padding: 8px 10px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: 0.75rem; line-height: 1.5; box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.6); }
.tip b { font-size: 0.875rem; }

/* ---------- 表・説明 ---------- */
table.tbl { border-collapse: collapse; width: 100%; font-size: 0.8125rem; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { color: var(--ink-2); font-weight: 700; border-bottom-color: var(--axis); }
.tbl td.on { font-weight: 700; }
.tbl .mark { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--win); color: var(--surface); font-size: 0.6875rem; font-weight: 700; }
.tbl .chg { color: var(--win); font-weight: 700; }
details.more { border-top: 1px solid var(--line); padding-top: 10px; font-size: 0.875rem; }
details.more summary { cursor: pointer; font-weight: 700; }
details.more > div { display: grid; gap: 10px; padding-top: 10px; color: var(--ink-2); }
.story { display: grid; gap: 6px; font-size: 0.9375rem; }
.story b { font-weight: 700; }
.callout { border-left: 4px solid var(--ink); background: var(--surface-2); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 0.875rem; color: var(--ink-2); }
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.person { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: start; font-size: 0.8125rem; color: var(--ink-2); }
.person .no { grid-row: span 2; width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; color: var(--surface); font-weight: 700; font-family: var(--font-display); }
.person b { color: var(--ink); font-size: 0.9375rem; }

/* ---------- 単記移譲式 ---------- */
.last { order: 99; }
.tx { background: var(--axis); }
.v-own { background: var(--s1); } .v-prev { background: var(--s2); } .v-new { background: var(--s3); }
.v-out { background: transparent; border: 2px dashed var(--muted); }
.key i.v-out { box-sizing: border-box; }
.key.line i.v-q { height: 0; border-top: 2px dashed var(--win); border-radius: 0; }
.rank-bar i.seg { box-sizing: border-box; min-width: 0; border-radius: 0; border-right: 2px solid var(--surface); }
.rank-bar i.seg.v-out { border: 2px dashed var(--muted); border-radius: 0 4px 4px 0; }
.rank-bar i.qline { min-width: 0; top: -9px; bottom: -9px; border-left: 2px dashed var(--win); border-radius: 0; transition: none; }
.stv { display: grid; gap: 12px; }
.stv-rank .rank-val small { color: var(--win); font-weight: 700; min-width: 2.4em; }
.stv-rank .rank-row.is-lose .rank-val small { color: var(--ink-2); }
.stv-facts { font-size: 0.875rem; color: var(--ink-2); }
.stv-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stv-pos { font-weight: 700; padding-inline: 4px; }
input[type="text"], input[type="number"] { min-height: 36px; width: 100%; min-width: 0; padding: 4px 10px; border: 1px solid var(--axis); border-radius: 8px; background: var(--surface-2); }
#copies { width: 5.5em; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.ballot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.ballot-btn { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--axis); border-radius: 8px; background: var(--surface); font-weight: 700; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.ballot-btn .ord { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border: 2px solid var(--axis); border-radius: 50%; font-size: 0.9375rem; }
.ballot-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); }
.ballot-btn[aria-pressed="true"] .ord { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.box-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; font-size: 0.875rem; }
.box-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.box-list .prefs { overflow-wrap: anywhere; }
.btn.del { min-height: 28px; padding: 0 10px; font-size: 0.75rem; font-weight: 400; }
.steps3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: s; font-size: 0.875rem; color: var(--ink-2); }
.steps3 li { counter-increment: s; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-content: start; }
.steps3 li::before { content: counter(s); grid-row: span 2; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--surface); font-weight: 700; font-family: var(--font-display); }
.steps3 b { color: var(--ink); font-size: 0.9375rem; }

/* ---------- 複数票・マイナス票 ---------- */
.settings input[type="range"] { flex: 1 1 140px; width: auto; min-width: 0; }
.tbl td small { color: var(--ink-2); font-size: 0.6875rem; }
.tbl td.on, .tbl th.on { background: var(--surface-2); }
.v-minus { background: repeating-linear-gradient(135deg, var(--l1) 0 2px, var(--l2) 2px 6px); }
.rank-bar i.v-minus { box-sizing: border-box; min-width: 0; border-radius: 4px 0 0 4px; border-right: 2px solid var(--surface); }
.rank-bar i.v-net { min-width: 0; top: -5px; bottom: -5px; border-left: 3px solid var(--ink); border-radius: 0; }
.key.line i.v-net { width: 3px; height: 14px; background: var(--ink); border-radius: 0; }
.rank.wide .rank-row { grid-template-columns: 2ch minmax(6.5em, 8.5em) minmax(0, 1fr) 13.5em 2.2em; }
.rank.wide .rank-val small { min-width: 8.2em; text-align: left; }
@media (max-width: 560px) {
  .rank.wide .rank-row { grid-template-columns: 2ch minmax(0, 1fr) auto 2.2em; }
  .rank.wide .rank-val small { min-width: 0; }
}

/* ---------- はじめに（index） ---------- */
.teaser { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.teaser-card { display: grid; gap: 6px; align-content: start; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; min-width: 0; }
.teaser-card .t { font-size: 0.8125rem; font-weight: 700; color: var(--ink-2); }
.teaser-card .t b { font-family: var(--font-display); font-size: 1.6rem; color: var(--ink); line-height: 1; }
.teaser-card .w { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 900; font-size: 1.1rem; line-height: 1.3; }
.teaser-card .w .rose { width: 22px; height: 22px; flex: none; color: var(--win); }
.mini { display: grid; gap: 4px; font-size: 0.75rem; color: var(--ink-2); }
.mini div { display: grid; grid-template-columns: 7.6em minmax(0, 1fr) 3.4em; align-items: center; gap: 6px; }
.mini span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini i { display: block; height: 10px; border-radius: 0 4px 4px 0; }
.mini .num { text-align: right; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.tile { flex: 1 1 300px; min-width: 0; display: grid; gap: 6px; align-content: start; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.tile:hover { border-color: var(--ink); transform: translateY(-2px); }
.tile h3 { font-size: 1.05rem; font-weight: 900; }
.tile p { font-size: 0.875rem; color: var(--ink-2); }
.tile .meta { font-size: 0.75rem; font-weight: 700; color: var(--win); letter-spacing: 0.04em; }
.tile .go { font-size: 0.8125rem; font-weight: 700; }
.plain { display: grid; gap: 8px; font-size: 0.9375rem; color: var(--ink-2); max-width: 46em; }
.plain ul { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; }
@media (max-width: 640px) { .teaser { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 候補者名の設定 ---------- */
details.names { border-top: 0; padding-top: 0; }
.names .name-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.name-item { display: flex; align-items: center; gap: 6px; min-width: 0; }
.name-item i { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- 戻るリンク・運用者表示・コメント送信欄 ---------- */
.backbar { background: var(--ink); color: var(--surface); font-size: 0.8125rem; }
.backbar .wrap { padding-block: 6px; }
.backbar a { color: inherit; font-weight: 700; text-decoration: none; }
.backbar a:hover { text-decoration: underline; }
.site-owner { display: flex; flex-wrap: wrap; gap: 2px 24px; margin-top: 6px; color: var(--ink-2); font-weight: 700; }
.site-owner a { overflow-wrap: anywhere; }
textarea, input[type="password"], input[type="url"], input[type="email"] { font: inherit; color: inherit; min-height: 36px; width: 100%; min-width: 0; padding: 4px 10px; border: 1px solid var(--axis); border-radius: 8px; background: var(--surface-2); }
textarea { padding: 8px 10px; line-height: 1.6; resize: vertical; }
.comment-wrap { padding-bottom: 32px; }
.comment summary { cursor: pointer; font-family: var(--font-display); font-weight: 900; font-size: 1.05rem; }
.comment summary small { display: block; font-family: var(--font-body); font-size: 0.8125rem; font-weight: 400; color: var(--ink-2); }
.comment-form { display: grid; gap: 8px; padding-top: 12px; max-width: 46em; font-size: 0.875rem; }
.comment-form label { font-weight: 700; color: var(--ink-2); }
.comment-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--ink); }
.comment-form .check { font-weight: 400; color: var(--ink); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.comment-msg { font-weight: 700; }
.comment-msg.err { color: var(--win); }

/* ---------- 管理者画面 ---------- */
.admin .narrow { max-width: 28em; }
.form { display: grid; grid-template-columns: minmax(9em, 15em) minmax(0, 1fr); gap: 10px 16px; align-items: center; font-size: 0.9375rem; }
.form > label { font-weight: 700; color: var(--ink-2); font-size: 0.875rem; }
.form > label.check { font-weight: 400; color: var(--ink); font-size: 0.9375rem; }
.form .span { grid-column: 1 / -1; }
.flash { padding: 10px 14px; border: 1px solid var(--axis); border-left: 6px solid var(--ink); border-radius: 8px; background: var(--surface); font-weight: 700; font-size: 0.9375rem; }
.flash.err { border-left-color: var(--win); }
.cm { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.cm.is-done { opacity: 0.6; }
.cm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 0.875rem; color: var(--ink-2); }
.cm-head b { color: var(--ink); }
.cm-body { font-size: 0.9375rem; overflow-wrap: anywhere; }
.cm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; font-size: 0.8125rem; }
.cm-actions form { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .form { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .form > input, .form > label.check { margin-bottom: 10px; }
}
