/* 街あわせ（MACHIAWASE） */

:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --border: #dfe4ea;
  --text: #1f2933;
  --text-muted: #6b7684;
  --primary: #2f7d6e;
  --primary-dark: #26645a;
  --primary-soft: #e6f2ef;
  --accent: #d98324;
  --ok: #2f7d6e;
  --maybe: #b8860b;
  --ng: #9aa4ae;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 41, 51, 0.08);
  --maxw: 900px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

/* ---------- ヘッダー / フッター ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  max-width: var(--maxw);
}

.brand-mark { font-size: 26px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-ja { font-size: 20px; font-weight: 700; letter-spacing: 0.04em; }
.brand-en { font-size: 11px; color: var(--text-muted); letter-spacing: 0.16em; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- カード / 見出し ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card.center { text-align: center; }

h1 { font-size: 24px; margin: 0 0 12px; line-height: 1.4; }
h2 { font-size: 18px; margin: 0 0 14px; }
h2 .count { font-size: 14px; font-weight: 400; color: var(--text-muted); }

.hero { padding: 8px 0 20px; }
.hero h1 { font-size: 27px; }
.lead { color: var(--text-muted); margin: 0 0 4px; }

.hint { font-size: 13px; color: var(--text-muted); margin: 6px 0 0; }
.empty { color: var(--text-muted); background: var(--bg); padding: 14px; border-radius: var(--radius); }
.sep { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- フォーム ---------- */

.field { margin-bottom: 18px; }

label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.required {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* iOS の自動ズームを防ぐため 16px 未満にしない */
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; line-height: 1.6; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 18px;
}

legend { font-weight: 600; font-size: 14px; padding: 0 6px; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 14px;
}
.checkbox input { width: auto; }

.advanced { margin-bottom: 18px; }
.advanced summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  padding: 8px 0;
}
.advanced[open] { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 8px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- ボタン ---------- */

.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  background: none;
}

.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--ng); cursor: not-allowed; }

.btn-secondary { background: var(--primary-soft); color: var(--primary-dark); border-color: #cfe3de; }
.btn-secondary:hover { background: #d9ebe6; }

.btn-ghost { border-color: var(--border); color: var(--text); background: #fff; }
.btn-ghost:hover { background: var(--bg); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1e17; }

.link-sm {
  background: none; border: none; padding: 0;
  color: var(--primary-dark); font-size: 13px;
  text-decoration: underline; cursor: pointer; font-family: inherit;
}
.link-danger { color: var(--danger); }

/* ---------- アラート ---------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-error { background: var(--danger-soft); border-color: #f3c6c2; color: #7d1a15; }
.alert-success { background: var(--primary-soft); border-color: #cfe3de; color: var(--primary-dark); }
.alert-warn { background: #fff6e5; border-color: #f0dcb4; color: #7a5500; }

/* ---------- イベント見出し ---------- */

.event-title { margin-bottom: 6px; word-break: break-word; }
.event-organizer { color: var(--text-muted); font-size: 14px; margin: 0 0 10px; }

.event-memo {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.confirmed-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 16px;
}

.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.badge-confirmed { background: var(--primary); color: #fff; }
.badge-best { background: #fdf0dc; color: #8a5610; border: 1px solid #f0d9b4; }

.share { margin-top: 16px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; font-size: 14px; background: var(--bg); }

.event-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.settings-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---------- 出欠表 ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.answer-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
}

.answer-table th,
.answer-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: center;
  white-space: nowrap;
}

.answer-table thead th {
  background: var(--bg);
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* 候補日程の列は横スクロールしても左端に残す */
.answer-table .col-candidate {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  min-width: 170px;
  max-width: 260px;
  white-space: normal;
  word-break: break-word;
  border-right: 1px solid var(--border);
}
.answer-table thead .col-candidate { z-index: 3; background: var(--bg); }

.col-count { width: 42px; font-variant-numeric: tabular-nums; }
.count-ok { color: var(--ok); font-weight: 700; }
.count-maybe { color: var(--maybe); }
.count-ng { color: var(--ng); }

.col-person { min-width: 74px; max-width: 130px; }
.person-name { display: block; word-break: break-word; white-space: normal; }
.me-tag {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: var(--primary); color: #fff;
  padding: 0 5px; border-radius: 3px; margin-top: 2px;
}

.mark { font-size: 17px; font-weight: 700; }
.mark-ok { color: var(--ok); }
.mark-maybe { color: var(--maybe); }
.mark-ng { color: var(--ng); font-weight: 400; }
.mark-none { color: #c7ced6; }

.answer-table tbody tr.is-best .col-candidate { background: #fffaf1; }
.answer-table tbody tr.is-best td { background: #fffdf8; }
.answer-table tbody tr.is-confirmed .col-candidate { background: var(--primary-soft); }
.answer-table tbody tr.is-confirmed td { background: #f2f9f7; }

.answer-table tfoot th,
.answer-table tfoot td {
  background: var(--bg);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}
.comment-cell { white-space: normal; word-break: break-word; text-align: left; }

/* ---------- 出欠の入力 ---------- */

.answer-inputs { padding-top: 10px; }

.answer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.answer-row:last-of-type { border-bottom: none; }

.answer-label { font-size: 15px; flex: 1 1 160px; word-break: break-word; }

.choices { display: flex; gap: 6px; flex: 0 0 auto; }

/* ラジオ本体は隠し、label をボタンとして見せる */
.choice-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  margin: 0;
  user-select: none;
}

.choice-mark { font-size: 18px; line-height: 1.1; }
.choice-text { font-size: 10px; color: var(--text-muted); }

.choice-input:checked + .choice-ok { background: var(--primary-soft); border-color: var(--ok); color: var(--ok); }
.choice-input:checked + .choice-maybe { background: #fff6e5; border-color: var(--maybe); color: var(--maybe); }
.choice-input:checked + .choice-ng { background: #eef1f4; border-color: #8a949e; color: #5c666f; }
.choice-input:checked + .choice .choice-text { color: inherit; }
.choice-input:focus-visible + .choice { outline: 2px solid var(--primary); outline-offset: 1px; }

.bulk-set, .quick-add {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 14px;
}
.quick-add { margin-top: 10px; }
.quick-add-label { font-size: 13px; color: var(--text-muted); }

.delete-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- コメント ---------- */

.comment-list { list-style: none; margin: 0 0 20px; padding: 0; }

.comment {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.comment:first-child { padding-top: 0; }

.comment-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.comment-name { font-weight: 700; font-size: 14px; }
.comment-time { font-size: 12px; color: var(--text-muted); }
.inline-form { display: inline; margin-left: auto; }
.comment-body { white-space: pre-wrap; word-break: break-word; margin-top: 4px; font-size: 15px; }

.comment-form { border-top: 1px solid var(--border); padding-top: 18px; }

/* ---------- 設定 ---------- */

.candidate-list { list-style: decimal; padding-left: 24px; margin: 0 0 6px; }
.candidate-item { margin-bottom: 8px; }
.danger-zone { border-color: #f3c6c2; }
.danger-zone h2 { color: var(--danger); }

/* ---------- 使い方 ---------- */

.howto { padding: 0 4px; }
.steps { margin: 0; padding-left: 22px; color: var(--text-muted); }
.steps strong { color: var(--text); }

/* ---------- スマホ ---------- */

@media (max-width: 600px) {
  body { font-size: 15px; }
  .container { padding: 14px 12px 40px; }
  .card { padding: 16px 14px; border-radius: 8px; }
  h1 { font-size: 21px; }
  .hero h1 { font-size: 23px; }

  .answer-table .col-candidate { min-width: 130px; max-width: 150px; font-size: 13px; }
  .col-count { width: 34px; }
  .col-person { min-width: 62px; }

  .answer-row { flex-direction: column; align-items: stretch; }
  .choices { justify-content: space-between; }
  .choice { flex: 1; min-width: 0; }

  .btn-lg { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .settings-head { flex-direction: column; }
}

/* ---------- ナビゲーション ---------- */

.site-nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  max-width: 100%;
  overflow-x: auto;
}

.nav-link {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link.is-current { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------- 今日の予定バナー ---------- */

.today-banner { margin-bottom: 18px; }

.today-banner-link {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-soft);
  border: 1px solid #cfe3de;
  border-radius: var(--radius);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--primary-dark);
}
.today-banner-link:hover { background: #d9ebe6; }
.today-banner-icon { font-size: 22px; }
.today-banner-text { flex: 1; display: flex; flex-direction: column; line-height: 1.4; }
.today-banner-sub { font-size: 12px; color: var(--text-muted); }
.today-banner-arrow { font-size: 22px; line-height: 1; }

/* ---------- 日付ピッカー ---------- */

.datepicker {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 12px;
  background: #fff;
}

.dp-head, .cal-month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dp-title { font-weight: 700; font-size: 15px; }

.dp-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}
.dp-nav:hover { background: var(--bg); }

.dp-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.dp-row + .dp-row { margin-top: 3px; }

.dp-wday {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0;
}

.dp-day {
  aspect-ratio: 1 / 1;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
.dp-day:hover { background: #e8edf1; }
.dp-day.is-outside { color: #c2c9d1; background: transparent; }
.dp-day.is-today { border-color: var(--accent); font-weight: 700; }
.dp-day.is-selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}
.dp-day.wd-0 { color: #c0392b; }
.dp-day.wd-6 { color: #2471a3; }
.dp-day.is-selected.wd-0, .dp-day.is-selected.wd-6 { color: #fff; }
.dp-day.is-outside.wd-0, .dp-day.is-outside.wd-6 { color: #d8c0bc; }

.dp-wday.wd-0 { color: #c0392b; }
.dp-wday.wd-6 { color: #2471a3; }

.dp-time {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dp-time-label { margin: 0; font-size: 13px; white-space: nowrap; }
.dp-time input[type="time"] { width: auto; flex: 0 0 auto; }
.dp-time-hint { margin: 0; }
.dp-help { margin-top: 8px; }

/* ---------- 公開設定 ---------- */

.publish-box { background: var(--bg); }
.publish-box .alert { margin: 10px 0 0; }
.pw-required { display: inline; }

.badge-public { background: var(--accent); color: #fff; }
.badge-today { background: var(--primary); color: #fff; }

.public-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.event-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 12px 0 0;
  font-size: 15px;
}
.event-info dt { color: var(--text-muted); font-size: 14px; white-space: nowrap; }
.event-info dd { margin: 0; word-break: break-word; }

.candidate-item { display: flex; align-items: center; gap: 8px; }
.candidate-nodate {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

/* ---------- 公開カレンダー ---------- */

.cal-title { display: flex; flex-direction: column; gap: 2px; }
.cal-sub { font-size: 13px; font-weight: 400; color: var(--text-muted); }

.cal-month { margin: 16px 0; }

.cal-grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.cal-grid th { font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 2px 0; }
.cal-grid th.wd-0 { color: #c0392b; }
.cal-grid th.wd-6 { color: #2471a3; }

.cal-cell { padding: 0; }

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  font-size: 14px;
}
.cal-day:hover { background: #e8edf1; }
.cal-cell.is-outside .cal-day { color: #c2c9d1; background: transparent; }
.cal-cell.is-today .cal-day { border-color: var(--accent); font-weight: 700; }
.cal-cell.is-selected .cal-day {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}
.cal-cell.wd-0 .cal-day { color: #c0392b; }
.cal-cell.wd-6 .cal-day { color: #2471a3; }
.cal-cell.is-selected.wd-0 .cal-day,
.cal-cell.is-selected.wd-6 .cal-day { color: #fff; }

.cal-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.cal-cell.is-selected .cal-dot { background: #fff; color: var(--primary-dark); }

.cal-datenav {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ---------- 予定リスト ---------- */

.day-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.day-subheading {
  font-size: 14px;
  margin: 18px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.day-subheading a { color: var(--text); text-decoration: none; }
.day-subheading a:hover { text-decoration: underline; }

.ev-list { list-style: none; margin: 0; padding: 0; }

.ev {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.ev:last-child { border-bottom: none; }
.ev-list.compact .ev { padding: 10px 0; }

.ev-time {
  flex: 0 0 62px;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.ev-time-range { flex-basis: 96px; font-size: 12px; font-weight: 400; line-height: 1.4; }
.ev-range-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.ev-body { flex: 1; min-width: 0; }
.ev-title { font-size: 16px; margin: 0 0 4px; line-height: 1.4; }
.ev-title a { color: var(--text); text-decoration: none; }
.ev-title a:hover { color: var(--primary-dark); text-decoration: underline; }
.ev-place { margin: 0 0 2px; font-size: 14px; color: var(--text); word-break: break-word; }
.ev-meta { margin: 0 0 2px; font-size: 12px; color: var(--text-muted); }
.ev-memo {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.ev-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ev-adjusting { background: #fffdf8; border-radius: var(--radius); padding-left: 10px; padding-right: 10px; }

@media (max-width: 600px) {
  .site-nav { padding: 0 8px; }
  .nav-link { padding: 10px 12px; }
  .dp-day { min-height: 34px; font-size: 13px; }
  .cal-day { min-height: 40px; font-size: 13px; }
  .cal-grid { border-spacing: 2px; }
  .ev-time { flex-basis: 50px; font-size: 14px; }
  .ev-time-range { flex-basis: 78px; }
  .ev { gap: 10px; }
}
