/* ponpon — 白地にくすみピンクを少しだけ。 */

/* ---------- tokens ---------- */

:root {
  color-scheme: light dark;
  /* 面と文字 */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f3f3f4;
  --ink: #2b2b2f;
  --ink-2: #5d5d64;
  --ink-3: #8b8b92;
  --line: #e7e7ea;
  --line-2: #d4d4d9;
  --line-3: #a9a9b0;
  /* アクセント（くすみピンク）。面を広く塗らない */
  --accent: #c97b8e;          /* 線・フォーカス・選択中タブの下線 */
  --accent-strong: #a85a6e;   /* 主要ボタンの地（白文字で 4.5:1 以上） */
  --accent-hover: #964c60;
  --accent-ink: #ffffff;      /* accent-strong の上の文字 */
  --accent-text: #9f5367;     /* リンク・強調文字 */
  --accent-weak: #f8ecef;     /* 選択中セグメントなど、ごく小さい面 */
  --danger: #b3261e;
  --danger-ink: #ffffff;
  /* ○△×（ピンクと混同しない色） */
  --ok: #2f7466;
  --ok-bg: #cfe6df;
  --maybe: #85621a;
  --maybe-bg: #f2e3b8;
  --ng: #8b8b92;
  --off: #ececee;             /* 範囲外のマス */
  --sun: #b4483c;
  --sat: #3d63a0;
  /* 集計の濃淡（○=1, △=0.5） */
  --heat-1: #e6f1ed;
  --heat-2: #c7e1d8;
  --heat-3: #98c8b8;
  --heat-4: #5ea590;
  --heat-5: #2f7a66;
  --heat-ink-strong: #ffffff;
  --backdrop: rgb(30 30 34 / 0.45);

  /* 余白・角丸・フォント */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --radius-sm: 4px;
  --radius: 6px;
  --font: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --fs-sm: 0.8125rem;
  --fs: 0.9375rem;
  --fs-lg: 1.125rem;
  --tap: 44px;
  --ctl-h: 40px;

  --bar-h: 56px; /* 入力画面の塗りツールバーの高さ（JS が更新） */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181a;
    --surface: #202023;
    --surface-2: #29292d;
    --ink: #e9e9ec;
    --ink-2: #b4b4bb;
    --ink-3: #85858d;
    --line: #313135;
    --line-2: #424248;
    --line-3: #63636b;
    --accent: #d38fa0;
    --accent-strong: #d895a6;
    --accent-hover: #e3a9b8;
    --accent-ink: #18181a;
    --accent-text: #e2a3b3;
    --accent-weak: #3a2a2f;
    --danger: #f08a80;
    --danger-ink: #18181a;
    --ok: #8fd2bf;
    --ok-bg: #24493f;
    --maybe: #e9cd7f;
    --maybe-bg: #4f421c;
    --ng: #85858d;
    --off: #2a2a2e;
    --sun: #f0968a;
    --sat: #96b5ea;
    --heat-1: #22302b;
    --heat-2: #284a3f;
    --heat-3: #326856;
    --heat-4: #4b9580;
    --heat-5: #7cc6ae;
    --heat-ink-strong: #10201b;
    --backdrop: rgb(0 0 0 / 0.6);
  }
}

@media (pointer: coarse) {
  :root { --ctl-h: 44px; }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-bottom: var(--sp-6); }
h1, h2, h3, p, dl, dd, ol, ul, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
a { color: var(--accent-text); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 700; }
.num, input, select, table { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute; left: 8px; top: -48px;
  background: var(--ink); color: var(--bg);
  padding: 6px 12px; z-index: 100; border-radius: var(--radius-sm);
}
.skip:focus { top: 8px; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 var(--sp-4); }
.wrap-wide { max-width: 1120px; }
.stack > * + * { margin-top: var(--sp-4); }

/* ---------- header / footer ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.hdr-bar { display: flex; align-items: center; min-height: 44px; }
.logo {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1;
  padding: var(--sp-2) 0;
}
/* イベント名と、そのイベントに対する操作（URLをコピー・主催者設定）を同じ行に。狭いと下に折り返す */
.hdr-event { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); padding-bottom: var(--sp-3); }
.hdr-title {
  flex: 1 1 14rem;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.hdr-title:empty { display: none; }
.hdr-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.site-footer { color: var(--ink-3); font-size: var(--fs-sm); padding: var(--sp-4) 0 var(--sp-5); }

/* ---------- headings / blocks ---------- */

.page-title { font-size: 1.25rem; line-height: 1.4; margin: var(--sp-5) 0 var(--sp-3); }
.sec-title { font-size: 1rem; font-weight: 700; margin: var(--sp-5) 0 var(--sp-2); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-2); }
.sec-head .sec-title { margin: 0; }
.loading { padding: var(--sp-6) 0; color: var(--ink-3); }
.notfound { padding: var(--sp-5) 0; }
.notfound p { margin-top: var(--sp-3); }

.box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.notice {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

/* ---------- forms ---------- */

.form > * + * { margin-top: var(--sp-4); }
.field { min-width: 0; }
.field > label, .field > .label, .field > legend { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--sp-1); padding: 0; }
.field-row { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.opt { font-weight: 400; color: var(--ink-3); margin-left: 0.4em; }
.field-hint { color: var(--ink-3); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.field-error, .form-error { color: var(--danger); font-size: var(--fs-sm); font-weight: 600; }
.field-error:empty, .form-error:empty { display: none; }
.field-error { margin-top: var(--sp-1); }

.input {
  display: block;
  width: 100%;
  min-height: var(--ctl-h);
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* iOS の自動ズームを防ぐ */
  line-height: 1.4;
}
.input:hover { border-color: var(--line-3); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled { background: var(--surface-2); color: var(--ink-3); }
textarea.input { resize: vertical; min-height: 4.5rem; }
select.input { width: auto; min-width: 6.5rem; padding-right: 2rem; }
.input-inline { display: inline-block; width: auto; }

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-strong); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: var(--ctl-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); background: transparent; }
.btn-danger:hover { border-color: var(--danger); background: transparent; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn-outline { background: var(--surface); border-color: var(--accent); color: var(--accent-text); }
.btn-outline:hover { background: var(--accent-weak); border-color: var(--accent); }
.btn-muted { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.btn-muted:hover { background: var(--surface-2); border-color: var(--line-3); color: var(--ink); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-lg { min-height: 48px; padding: 0 var(--sp-5); }
.btn-block { display: flex; width: 100%; }
@media (pointer: coarse) { .btn-sm { min-height: var(--tap); } }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

/* ---------- tabs（表示切り替え。多いときは横スクロール） ---------- */

.tabs {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs);
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; }

/* ---------- segmented control（ラジオ） ---------- */

.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg label > span {
  display: flex; align-items: center; gap: 0.35rem;
  min-height: var(--ctl-h);
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2);
  border-left: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
}
.seg label:first-of-type > span { border-left: 0; }
.seg input:hover + span { color: var(--ink); background: var(--surface-2); }
.seg input:checked + span { background: var(--accent-weak); color: var(--accent-text); box-shadow: inset 0 -2px 0 var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.seg input:disabled + span { opacity: 0.5; }

/* ---------- badges / symbols / chips ---------- */

.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.25em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  vertical-align: 0.1em;
  margin-left: 0.3em;
  white-space: nowrap;
}
.badge-req { border-color: var(--accent); color: var(--accent-text); }

.sym { display: inline-block; min-width: 1.1em; text-align: center; font-weight: 700; }
.sym-2 { color: var(--ok); }
.sym-1 { color: var(--maybe); }
.sym-0 { color: var(--ng); }
/* 参加可・未定・不可（文字で出すとき） */
.lbl { font-weight: 600; white-space: nowrap; }
.lbl-2 { color: var(--ok); }
.lbl-1 { color: var(--maybe); }
.lbl-0 { color: var(--ink-2); }
.counts { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.25em; font-size: var(--fs-sm); }
.counts .num { font-weight: 700; }
.counts-sep { color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center;
  min-height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-sm);
}
button.chip { cursor: pointer; }
@media (pointer: coarse) { button.chip { min-height: var(--tap); } }

/* ---------- dialog ---------- */

.dlg {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: var(--sp-5);
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.14);
}
.dlg::backdrop { background: var(--backdrop); }
.dlg-form > * + * { margin-top: var(--sp-3); }
.dlg-title { font-size: 1.05rem; overflow-wrap: anywhere; }
.dlg-body { color: var(--ink-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.dlg-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }

/* ---------- toast ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: opacity 0.2s;
}
.toast-error { background: var(--danger); color: var(--danger-ink); }
.toast.is-leaving { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- 時間の表（入力グリッド・集計表の共通。行 = 日付、列 = 時刻） ---------- */

.grid-host { margin-top: var(--sp-2); }
.tgrid-scroll {
  --col-w: 32px;
  --row-h: 36px;
  --date-w: 76px;
  position: relative;
  overflow: auto;
  max-width: 100%;
  width: max-content;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.tgrid {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12px;
  line-height: 1;
}
/* 罫線は inset の box-shadow で引く（sticky 見出しでも崩れない）。--bl: 左, --bt: 上 */
.tgrid th, .tgrid td {
  padding: 0;
  font-weight: 400;
  --bl: var(--line);
  --bt: var(--line);
  box-shadow: inset 1px 0 0 var(--bl), inset 0 1px 0 var(--bt);
}
.tgrid td, .tgrid th.tg-col { width: var(--col-w); min-width: var(--col-w); max-width: var(--col-w); }
.tgrid td { height: var(--row-h); text-align: center; vertical-align: middle; }
.tgrid td.is-hr { --bl: var(--line-2); }
.tgrid td.is-off { background: var(--off); }
/* 時刻見出し（上に sticky）。1 時間ごとのラベルは右隣の列にはみ出してよいので前面に */
.tgrid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 28px;
  background: var(--surface-2);
  color: var(--ink-2);
  text-align: left;
  vertical-align: middle;
  padding-left: 3px;
  box-shadow: inset 1px 0 0 var(--bl), inset 0 -1px 0 var(--line-2);
}
.tgrid thead th.is-hr { z-index: 4; --bl: var(--line-3); }
.tg-h { position: relative; font-size: 11.5px; font-weight: 700; color: var(--ink); white-space: nowrap; pointer-events: none; }
/* 日付列（左に sticky） */
.tgrid .tg-side {
  position: sticky;
  left: 0;
  z-index: 2;
  width: var(--date-w);
  min-width: var(--date-w);
  max-width: var(--date-w);
  padding: 0 var(--sp-2);
  background: var(--surface-2);
  color: var(--ink-2);
  text-align: left;
  white-space: nowrap;
  box-shadow: inset -1px 0 0 var(--line-2), inset 0 1px 0 var(--bt);
}
.tgrid thead th.tg-corner { left: 0; z-index: 6; box-shadow: inset -1px 0 0 var(--line-2), inset 0 -1px 0 var(--line-2); }
.tg-md { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.tg-dow { font-size: 11px; margin-left: 3px; }
.tg-md.is-sun, .tg-dow.is-sun { color: var(--sun); }
.tg-md.is-sat, .tg-dow.is-sat { color: var(--sat); }
.tgrid-box {
  position: absolute;
  left: 0; top: 0;
  z-index: 1;
  width: var(--bw, 0);
  height: var(--bh, 0);
  transform: translate(var(--bx, 0), var(--by, 0));
  pointer-events: none;
}
/* ○△× のマス（記号 + 色） */
.tgrid td[data-v="2"] { background: var(--ok-bg); color: var(--ok); }
.tgrid td[data-v="1"] { background: var(--maybe-bg); color: var(--maybe); }
.tgrid td[data-v="0"] { color: var(--ng); }
.tgrid td:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* 凡例（記号と呼び名の対応） */
.rv-legend { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--ink-2); display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg-sw {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lg-sw-2 { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.lg-sw-1 { background: var(--maybe-bg); color: var(--maybe); border-color: transparent; }
.lg-sw-0 { background: var(--surface); color: var(--ng); }
.lg-sw-heat { background: var(--heat-4); color: var(--heat-ink-strong); border-color: transparent; }

/* ===================================================================
   以下はページ固有（event / input）。index / admin 固有は editor.css
   =================================================================== */

/* ---------- event（集計） ---------- */

.ev-app { display: flex; flex-direction: column; }
.ev-app > * + * { margin-top: var(--sp-3); }
.ev-app > :first-child { margin-top: var(--sp-4); }
.ev-meta { color: var(--ink-2); font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); }
.ev-desc { color: var(--ink-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.ev-top { margin-top: var(--sp-4); }
.final {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-3);
}
.final-label { font-size: var(--fs-sm); font-weight: 700; color: var(--accent-text); }
.final-when { font-size: var(--fs-lg); font-weight: 700; }

/* 「予定を入力する」: 候補の上に全幅。スマホでは画面下に固定 */
.cta .btn { min-height: 52px; font-size: 1.0625rem; }
@media (max-width: 640px) {
  .ev-app.has-cta { --cta-h: 69px; }
  .cta {
    order: 99;
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-left: calc(-1 * var(--sp-4));
    margin-right: calc(-1 * var(--sp-4));
    padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--line);
  }
  .ev-app.has-cta .rv-detail { bottom: calc(var(--cta-h) + env(safe-area-inset-bottom)); }
  /* スクロールで要素を見せるとき、下の固定ボタンの裏に入れない */
  html:has(.ev-app.has-cta:not([hidden])) { scroll-padding-bottom: calc(69px + 8px + env(safe-area-inset-bottom)); }
}

/* 開催候補（上位 3 件） */
.sg-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sg { display: flex; align-items: center; }
.sg + .sg { border-top: 1px solid var(--line); }
.sg-fin { margin-right: var(--sp-2); }
.sg-btn {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3);
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sg-btn:hover { background: var(--surface-2); }
.sg-btn:focus-visible { outline-offset: -2px; }
.sg-rank { font-weight: 700; color: var(--ink-3); min-width: 1.2em; }
.sg-when { font-weight: 700; flex: 1 1 auto; }
.sg-time { margin-left: 0.4em; }
.sg.is-picked .sg-btn { box-shadow: inset 3px 0 0 var(--accent); }
.sg-empty { padding: var(--sp-3); color: var(--ink-3); font-size: var(--fs-sm); }

/* 表示切り替え + 集計表 */
.rv-tabs { margin-top: var(--sp-5); }
.rv-person { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); }
.rv-comment { flex: 1 1 16rem; color: var(--ink-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.rv-comment:empty { display: none; }

.grid-sum { --col-w: 28px; max-height: max(360px, 75dvh); }
.grid-sum th, .grid-sum td { cursor: default; }
.grid-sum td { font-size: 11px; color: var(--ink-2); }
.grid-sum td[data-h="1"] { background: var(--heat-1); }
.grid-sum td[data-h="2"] { background: var(--heat-2); }
.grid-sum td[data-h="3"] { background: var(--heat-3); color: var(--ink); }
.grid-sum td[data-h="4"] { background: var(--heat-4); color: var(--heat-ink-strong); }
.grid-sum td[data-h="5"] { background: var(--heat-5); color: var(--heat-ink-strong); }
.grid-sum td.is-full { font-weight: 800; }
.grid-sum td[data-v] { font-weight: 700; }
.grid-sum td.is-inspect { box-shadow: inset 0 0 0 2px var(--ink); }
.grid-sum .tgrid-box { border: 2px solid var(--accent-strong); border-radius: 2px; }
.grid-sum.slot-15 td { font-size: 10px; }
@media (hover: hover) { .grid-sum.is-heat td:not(.is-off):hover { box-shadow: inset 0 0 0 2px var(--ink-3); } }
/* 全員: 日付の集計行 + その日の参加者の行 */
.grid-sum.is-all { --date-w: 112px; }
.grid-sum.is-all tr.is-date > * { --bt: var(--line-3); }
.grid-sum.is-all tr.is-member > td { height: 30px; }
.grid-sum.is-all tr.is-member > .tg-side { background: var(--surface); padding: 0; }
.tg-name {
  display: flex; align-items: center; gap: 2px;
  width: 100%; height: 30px;
  padding: 0 var(--sp-2) 0 var(--sp-4);
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.tg-name:hover { color: var(--accent-text); text-decoration: underline; }
.tg-name:focus-visible { outline-offset: -2px; }
.tg-name-t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tg-name .badge { margin-left: 2px; padding: 0.15em 0.25em; }

/* マスの内訳。画面下に貼り付いて常に見える */
.rv-detail {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + env(safe-area-inset-bottom));
  max-height: 42vh;
  overflow: auto;
  font-size: var(--fs-sm);
}
.rd-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.rd-when { font-weight: 700; }
.rd-groups { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--sp-3); margin-top: var(--sp-1); }
.rd-groups dt { white-space: nowrap; }
.rd-groups dt .num { display: inline-block; min-width: 1.4em; color: var(--ink-2); }
.rd-groups dd { overflow-wrap: anywhere; }

/* ---------- input（予定入力） ---------- */

.in-name { margin-top: var(--sp-4); }
.in-name .input { max-width: 22rem; }
.in-auth { margin-top: var(--sp-4); }
.in-auth-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-start; }
.in-auth-row .input { flex: 1 1 12rem; max-width: 18rem; }

.paint-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding: var(--sp-2) 0;
  background: var(--bg);
}
.paint-bar .push { margin-left: auto; }
.sw { font-weight: 700; }
.sw-2 { color: var(--ok); }
.sw-1 { color: var(--maybe); }
.sw-0 { color: var(--ng); }
.touch-only { display: none !important; }
@media (any-pointer: coarse) { .touch-only { display: inline-flex !important; } }

.grid-input { --row-h: 40px; max-height: max(300px, calc(100dvh - var(--bar-h) - 24px)); }
@media (pointer: coarse) { .grid-input { --row-h: 44px; } }
.grid-input td { cursor: cell; }
.grid-input th.tg-col, .grid-input .tg-row { cursor: pointer; }
.grid-input td[data-v="2"]::after, .grid-input td[data-v="1"]::after { font-size: 13px; font-weight: 700; }
.grid-input td[data-v="2"]::after { content: "○"; }
.grid-input td[data-v="1"]::after { content: "△"; }
.grid-input td.is-off { cursor: not-allowed; }
.grid-input .tgrid-box { outline: 2px dashed var(--ink-2); outline-offset: -1px; }
.grid-input.mode-paint, .grid-input.mode-paint * { touch-action: none; }
.grid-input.mode-scroll, .grid-input.mode-scroll * { touch-action: manipulation; }
@media (hover: hover) {
  .grid-input:not(.is-disabled) td:not(.is-off):hover { box-shadow: inset 0 0 0 2px var(--ink-3); }
  .grid-input:not(.is-disabled) th.tg-col:hover,
  .grid-input:not(.is-disabled) .tg-row:hover { background: var(--accent-weak); }
}
.grid-input.is-disabled td, .grid-input.is-disabled th { cursor: default; }
.grid-input.is-disabled .tgrid { opacity: 0.6; }

.in-bottom { margin-top: var(--sp-5); }
.in-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); }

/* ---------- small screens ---------- */

@media (max-width: 480px) {
  .hdr-title { font-size: 1.125rem; }
  .seg label > span { padding: 0 var(--sp-2); }
  .tgrid-scroll { --date-w: 64px; }
  .grid-sum.is-all { --date-w: 96px; }
  .in-actions .btn-primary { flex: 1 1 100%; }
}
