:root {
  --paper: #f6f3ec;
  --card: #fffdf8;
  --ink: #1d1b18;
  --muted: #6b665e;
  --line: #d9d3c7;
  --accent: #c8402a;
  --accent-soft: #f6e3dd;
  --ok: #2f6b4f;
  --ok-soft: #e1eee6;
  --maybe: #9a6b12;
  --maybe-soft: #f5ecd6;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 80px; }
header.top { border-bottom: 2px solid var(--ink); padding: 12px 0 8px; margin-bottom: 20px; }
header.top h1 { font-size: 20px; margin: 0; letter-spacing: .02em; }
header.top .sub { color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
h2 { font-size: 17px; margin: 28px 0 10px; padding-left: 10px; border-left: 4px solid var(--accent); }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
section.box { background: var(--card); border: 1px solid var(--line); padding: 14px; margin: 10px 0; }
a { color: var(--accent); }

button, .btn { white-space: nowrap;
  font: inherit; font-size: 15px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 4px; min-height: 42px;
}
button.primary { background: var(--ink); color: #fff; }
button.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: none; background: none; color: var(--accent); padding: 4px; min-height: 0; text-decoration: underline; }
button.danger { color: var(--accent); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }

input[type=text], input[type=number], input[type=date], select, textarea {
  font: inherit; font-size: 16px; width: 100%;
  border: 1px solid var(--line); background: #fff; padding: 9px 10px; border-radius: 4px;
}
textarea { min-height: 70px; }
label.field { display: block; font-size: 14px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { margin-top: 4px; color: var(--ink); }

/* 曜日のチェック */
.wd { display: flex; gap: 4px; flex-wrap: wrap; }
.wd label { position: relative; }
.wd input { position: absolute; opacity: 0; }
.wd span { display: inline-block; width: 40px; text-align: center; padding: 6px 0; border: 1px solid var(--line); background: #fff; border-radius: 4px; }
.wd input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.wd input:focus-visible + span { outline: 2px solid var(--accent); }

/* あだ名の一覧 */
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.names button { text-align: left; }

/* 候補日の回答 */
.cand { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cand:last-child { border-bottom: none; }
.cand .date { font-weight: 600; }
.cand .count { grid-column: 1; font-size: 13px; color: var(--muted); }
.cand .hint { font-size: 12px; color: var(--maybe); }
.seg { display: inline-flex; grid-row: span 2; }
.seg button { width: 48px; border-radius: 0; font-size: 18px; padding: 6px 0; border-color: var(--line); margin-left: -1px; }
.seg button:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
.seg button.on[data-v="2"] { background: var(--ok); color: #fff; border-color: var(--ok); }
.seg button.on[data-v="1"] { background: var(--maybe); color: #fff; border-color: var(--maybe); }
.seg button.on[data-v="0"] { background: var(--muted); color: #fff; border-color: var(--muted); }

/* 一覧表 */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table.grid { border-collapse: collapse; font-size: 14px; min-width: 100%; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
table.grid thead th { background: #efeae0; font-weight: 600; }
table.grid td.v2 { background: var(--ok-soft); color: var(--ok); }
table.grid td.v1 { background: var(--maybe-soft); color: var(--maybe); }
table.grid td.v0 { color: var(--muted); }
table.grid td.click { cursor: pointer; }
table.grid tr.sum td { font-weight: 600; background: #efeae0; }

/* 上位3日 */
.rank { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: none; }
.rank .no { font-size: 22px; font-weight: 700; color: var(--accent); text-align: center; }
.rank .d { font-weight: 600; }

/* 確定した日 */
.fixed-date { font-size: 26px; font-weight: 700; letter-spacing: .02em; margin: 4px 0; }
.choice { display: flex; gap: 8px; }
.choice button { flex: 1; }
.choice button.on.yes { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice button.on.no { background: var(--muted); color: #fff; border-color: var(--muted); }
.paid { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); background: #fff; margin-top: 10px; }
.paid input { width: 22px; height: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; }
.tag { font-size: 12px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 2px; }
.tag.open { color: var(--accent); }
.tag.fixed { color: var(--ok); }

details { border-bottom: 1px solid var(--line); padding: 8px 0; }
details summary { cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "＋"; color: var(--muted); }
details[open] summary::after { content: "－"; }

/* 月ごとの棒グラフ */
.bars { display: grid; gap: 4px; font-size: 13px; }
.bars .b { display: grid; grid-template-columns: 64px 1fr 32px; gap: 8px; align-items: center; }
.bars .fill { height: 14px; background: var(--ink); }

.urlbox { display: flex; gap: 6px; }
.urlbox input { font-size: 14px; }
.warn { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 8px 10px; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 4px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--accent); }
footer { margin-top: 40px; color: var(--muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* 支払い先の QR コード */
img.qr { display: block; width: 100%; max-width: 280px; margin: 8px auto; border: 1px solid var(--line); background: #fff; }
.qrbox { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.qrbox img.qr { margin: 0; max-width: 160px; }

/* 候補日のカレンダー */
.cal { user-select: none; }
.cal .nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal .nav strong { font-size: 16px; }
.cal .nav button { min-width: 44px; }
.cal .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .wdh { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal .wdh.sun, .cal .day.sun { color: var(--accent); }
.cal .day { min-height: 44px; padding: 0; border-color: var(--line); background: #fff; font-size: 15px; border-radius: 4px; }
.cal .day.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cal .day:disabled { background: transparent; border-color: transparent; color: var(--line); }
.cal .day.reg:not(.on) { border-color: var(--ink); }

/* 主催者の表のプルダウン */
table.grid select.cell { width: auto; min-width: 56px; padding: 4px 6px; font-size: 16px; background: transparent; border-color: transparent; text-align: center; color: inherit; }
table.grid select.cell:focus { border-color: var(--ink); background: #fff; }
/* まとめて選ぶ */
.bulk { margin: 8px 0 4px; gap: 6px; }
.bulk button { min-height: 36px; padding: 4px 12px; }

/* イベントの操作ボタン */
.evact { margin: -4px 0 8px; gap: 6px; }
.evact button { min-height: 36px; padding: 4px 12px; }

/* メンバー画面：自分の行と出欠の一覧 */
table.grid tr.me td { font-weight: 600; box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
table.grid tr.me td:first-child { box-shadow: inset 2px 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
.att { display: grid; gap: 8px; }
.attrow { border-top: 1px solid var(--line); padding-top: 6px; }
