:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #e2e8ef;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --yes: #16a34a;
  --maybe: #d97706;
  --no: #dc2626;
  --best: #fff7e6;
  --best-line: #f0b429;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.1rem; }
.site-nav { display: flex; align-items: center; gap: 14px; font-size: .9rem; }
.site-nav a { color: var(--primary); text-decoration: none; }
.inline-logout { display: inline; margin: 0; }
.linklike { border: none; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { color: var(--no); }

/* ---- マイページ ---- */
.mp-list { list-style: none; margin: 8px 0 0; padding: 0; }
.mp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
}
.mp-title { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.02rem; }
.mp-title:hover { color: var(--primary); }
.mp-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.mp-actions { display: flex; gap: 8px; }
.mp-actions .btn { padding: 7px 12px; font-size: .9rem; }
.claim-form { display: inline; margin: 6px 0 0; }

/* ---- 会（名簿） ---- */
.group-pill { background: var(--best); border: 1px solid var(--best-line); color: #5b3d00; border-radius: 10px; padding: 8px 12px; margin: 0; font-size: .92rem; }
.name-select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; background: #fff; }
select { font-family: inherit; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member-row { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 8px 2px; }
.member-row form { margin: 0; }
.form-inline { display: flex; gap: 8px; }
.form-inline input[type=text] { flex: 1; min-width: 0; }

.container { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  padding: 24px 16px 48px;
}
.site-footer a { color: var(--primary); }

/* ---- カード / 共通 ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
h1 { font-size: 1.45rem; margin: 0 0 .4em; }
h2 { font-size: 1.1rem; margin: 0 0 .6em; }
.subtle, .meta { color: var(--muted); font-weight: 400; }
.meta { font-size: .9rem; margin: .2em 0; }
.meta a { color: var(--primary); }
.desc { white-space: pre-line; }
.hint { color: var(--muted); font-size: .85rem; margin: .3em 0; }
.hint.warn { color: var(--no); }
.empty { color: var(--muted); }
.center { text-align: center; }

.hero { margin-bottom: 18px; }
.hero .lead { color: var(--muted); }

/* ---- バッジ / アラート ---- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; }
.badge-closed { background: #fde8e8; color: var(--no); }
.alert { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.alert ul { margin: 0; padding-left: 1.2em; }
.alert-error { background: #fde8e8; color: #991b1b; }
.alert-success { background: #e7f6ec; color: #166534; }

/* ---- フォーム ---- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field-label em { color: var(--no); font-style: normal; font-size: .8rem; margin-left: 4px; }
input[type=text], input[type=datetime-local], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 1rem; font-family: inherit; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
fieldset { border: none; padding: 0; margin: 0 0 16px; }
legend { padding: 0; }

.date-row { display: flex; gap: 8px; margin-bottom: 8px; }
.date-row input { flex: 1; }

/* ---- 候補日 追加UI（カレンダー方式） ---- */
.date-add { display: flex; gap: 8px; align-items: stretch; }
.date-add input[type=date], .date-add input[type=text] { flex: 1; min-width: 0; }
.date-add .btn { white-space: nowrap; }

.cand-list { list-style: none; margin: 12px 0 4px; padding: 0; }
.cand-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px 8px 14px; margin-bottom: 8px; background: #fff;
}
.cand-date { font-weight: 700; min-width: 76px; }
.cand-free { font-weight: 600; }
.cand-time { flex: 1; min-width: 0; padding: 7px 10px !important; font-size: .95rem !important; }
.cand-row .remove { margin-left: auto; flex: none; }
.empty-note { margin: 4px 0 8px; }

.free-add { margin-top: 10px; }
.free-add summary { cursor: pointer; color: var(--primary); font-size: .9rem; }
.free-add .date-add { margin-top: 10px; }

.btn-lg { padding: 13px 22px; font-size: 1.05rem; width: 100%; }

.form-actions { margin-top: 16px; }

/* ---- ○△× 凡例 ---- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.legend > span { white-space: nowrap; }
.legend .mark-yes, .legend .mark-maybe, .legend .mark-no { font-weight: 700; }

/* ---- ○△× ラベル設定（作成/編集フォーム） ---- */
.label-set { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; }
.label-mark { font-weight: 700; font-size: 1.2rem; text-align: center; }
.label-set input { width: 100%; }

/* ---- 候補日 編集行 ---- */
.edit-row { gap: 8px; }
.edit-row input[type=text] { flex: 1; min-width: 0; padding: 8px 10px !important; }
.del-check { white-space: nowrap; color: var(--muted); font-size: .9rem; display: flex; align-items: center; gap: 4px; }

/* ---- ボタン ---- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff;
  color: var(--ink); padding: 10px 18px; border-radius: 8px; font-size: 1rem;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { background: #f0f3f7; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { color: var(--primary); border-color: var(--line); }
.btn-icon {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.btn-icon:hover { background: #fde8e8; color: var(--no); }

/* ---- 集計サマリー ---- */
.summary-head { display: flex; align-items: baseline; justify-content: space-between; }
.respondents { color: var(--muted); font-size: .9rem; }
.summary-list { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.summary-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; background: #fff;
}
.summary-item.is-best { background: var(--best); border-color: var(--best-line); }
.si-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.si-label { font-weight: 600; }
.best-tag {
  background: var(--best-line); color: #5b3d00; font-size: .72rem;
  padding: 1px 8px; border-radius: 999px; margin-left: 6px; font-weight: 700;
}
.si-counts { white-space: nowrap; font-variant-numeric: tabular-nums; }
.si-counts span { margin-left: 10px; font-weight: 600; }
.c-yes { color: var(--yes); }
.c-maybe { color: var(--maybe); }
.c-no { color: var(--no); }
.bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #eef1f5; margin-top: 10px; }
.bar-yes { background: var(--yes); }
.bar-maybe { background: var(--maybe); }
.detail-link { margin: 14px 0 0; }
.detail-link a { color: var(--primary); text-decoration: none; }

.summary:not(.card) { margin-bottom: 18px; }

/* ---- 回答フォーム ---- */
.answer-grid { margin: 8px 0 16px; border-top: 1px solid var(--line); }
.answer-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.ar-label { font-weight: 600; }
.ar-choices { display: flex; gap: 6px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: grid; place-items: center; width: 44px; height: 40px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 1.2rem; color: var(--muted);
  background: #fff;
}
.choice input:checked + span { color: #fff; font-weight: 700; }
.choice-yes  input:checked + span { background: var(--yes);  border-color: var(--yes); }
.choice-maybe input:checked + span { background: var(--maybe); border-color: var(--maybe); }
.choice-no   input:checked + span { background: var(--no);   border-color: var(--no); }

/* ---- 詳細グリッド（横スクロールでレイアウトを崩さない） ---- */
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
.grid { border-collapse: collapse; width: 100%; white-space: nowrap; }
.grid th, .grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: center; font-size: .92rem; }
.grid thead th { background: #f7f9fb; font-weight: 600; position: sticky; top: 0; }
.grid .sticky-col { position: sticky; left: 0; background: #fff; text-align: left; font-weight: 600; box-shadow: 1px 0 0 var(--line); z-index: 1; }
.grid thead .sticky-col { background: #f7f9fb; z-index: 2; }
.grid .name { min-width: 90px; }
.grid .comment { text-align: left; color: var(--muted); white-space: normal; min-width: 140px; }
.grid .mark { font-size: 1.05rem; font-weight: 700; }
.mark-yes { color: var(--yes); }
.mark-maybe { color: var(--maybe); }
.mark-no { color: var(--no); }
.mark-none { color: #c3ccd6; }
.grid tfoot .sum-row td { background: #f7f9fb; font-weight: 700; color: var(--yes); }

/* ---- 共有URL ---- */
.share-row { margin-bottom: 16px; }
.share-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.copybox { display: flex; gap: 8px; }
.copybox input { flex: 1; font-size: .9rem; background: #f7f9fb; }

.admin-actions form { display: inline; }

@media (max-width: 480px) {
  .choice span { width: 38px; height: 38px; }
  .container { padding: 16px 12px 48px; }
}
