/* 東根中央RC 会員アプリ — スマホ前提。CSP のためインライン style は使わない */

:root {
  --blue: #17458f;          /* ロータリーブルー */
  --blue-strong: #0f3270;
  --gold: #f7a81b;          /* ロータリーゴールド */
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #16181d;
  --text-2: #5b6270;
  --line: #e1e5ec;
  --ok: #18794e;  --ok-bg: #e6f4ec;
  --ng: #b42318;  --ng-bg: #fdecea;
  --wait: #8a5a00; --wait-bg: #fff4d6;
  --focus: #3b82f6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue); text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 上部バー ---------- */

.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: env(safe-area-inset-top, 0px) 8px 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar h1 { font-size: 1.15rem; font-weight: 700; flex: 1; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--blue); }
.appbar .back:active { background: var(--surface-2); }
.appbar .back svg { width: 26px; height: 26px; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); }
body.no-tabs main { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- 下部タブバー ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2); font-size: .72rem; font-weight: 600;
}
.tabbar svg { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--blue); }

/* ---------- 共通部品 ---------- */

.section-title { font-size: .85rem; font-weight: 700; color: var(--text-2); margin: 28px 4px 8px; letter-spacing: .02em; }
.section-title:first-child { margin-top: 4px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.card > :first-child { margin-top: 0; }
.card > :last-child, .card > .field:last-of-type { margin-bottom: 0; }
.card p { margin: 0 0 10px; }
/* ホーム画面から開いているときは「ホーム画面に追加」の案内を出さない */
@media (display-mode: standalone) { .install-hint { display: none; } }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; width: 100%;
  font: inherit; font-weight: 700; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--blue); color: #fff;
}
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--ng-bg); color: var(--ng); }
.btn svg { width: 22px; height: 22px; }

.link-btn { background: none; border: 0; font: inherit; color: var(--blue); padding: 12px 0; cursor: pointer; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.ng { background: var(--ng-bg); color: var(--ng); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.toast { background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 16px; margin-bottom: 12px; font-weight: 600; }
.toast.error { background: var(--ng); color: #fff; }

.empty { text-align: center; color: var(--text-2); padding: 40px 16px; }

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

.field { margin-bottom: 18px; }
.field > label, .field-label { display: block; font-size: .9rem; font-weight: 700; margin-bottom: 6px; }
.field small, .help { display: block; color: var(--text-2); font-size: .82rem; margin-top: 6px; line-height: 1.5; }
.field small ul, .help ul { margin: 4px 0 0; padding-left: 1.2em; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], textarea, select {
  width: 100%; min-height: 52px; padding: 12px 14px;
  font: inherit; font-size: 17px; /* 16px 未満だと iOS が拡大する */
  color: var(--text); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  appearance: none;
}
input:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent); }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--ng); font-size: .88rem; font-weight: 600; }
.form-errors { background: var(--ng-bg); color: var(--ng); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-weight: 600; }
.form-errors .errorlist { margin: 0; }

/* 2択の大きなボタン（出席・欠席） */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border: 0; padding: 0; margin: 0 0 16px; }
.segmented label {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 84px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 800; font-size: 1.1rem; cursor: pointer;
}
.segmented label svg { width: 28px; height: 28px; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.segmented label:has(input[value=attend]:checked) { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.segmented label:has(input[value=absent]:checked) { border-color: var(--ng); background: var(--ng-bg); color: var(--ng); }

/* スイッチ（お弁当・バス） */
.switch-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 16px; background: var(--surface); cursor: pointer;
}
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-row .label { flex: 1; font-weight: 700; }
.switch-row .label small { display: block; font-weight: 400; color: var(--text-2); font-size: .82rem; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-row .track { position: relative; width: 52px; height: 32px; border-radius: 999px; background: var(--line); transition: background .15s; flex: none; }
.switch-row .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch-row input:checked + .track { background: var(--ok); }
.switch-row input:checked + .track::after { transform: translateX(20px); }
.switch-row input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-group { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; }

/* 欠席を選んだらお弁当・バスを隠す（JS 不要） */
.answer-form:has(input[value=absent]:checked) .attend-only { display: none; }

/* 画面下に固定する保存ボタン */
.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); z-index: 5;
  padding-top: 8px; margin-top: 8px;
}
body.no-tabs .sticky-actions { bottom: calc(var(--safe-b) + 8px); }
.sticky-actions .btn { box-shadow: 0 6px 20px color-mix(in srgb, var(--blue) 35%, transparent); }

/* ---------- 例会一覧 ---------- */

.meeting-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.meeting-card { display: flex; gap: 14px; align-items: stretch; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; color: var(--text); }
.meeting-card:active { transform: scale(.99); }
.datebox { flex: none; width: 60px; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 0; }
.datebox .m { font-size: .75rem; font-weight: 700; color: var(--text-2); }
.datebox .d { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.datebox .w { font-size: .75rem; font-weight: 700; color: var(--text-2); }
.meeting-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.meeting-card .title { font-weight: 800; font-size: 1.05rem; }
.meeting-card .meta { color: var(--text-2); font-size: .88rem; display: flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting-card .meta svg { width: 16px; height: 16px; flex: none; }
.meeting-card .chips { margin-top: 4px; }
.meeting-card.todo { box-shadow: inset 4px 0 0 var(--gold), var(--shadow); }

/* ---------- 例会詳細 ---------- */

.hero { background: linear-gradient(135deg, #17458f, #0f3270); color: #fff; border-radius: var(--radius); padding: 18px; }
.hero .date { font-size: .95rem; opacity: .9; font-weight: 600; }
.hero h2 { font-size: 1.4rem; margin: 4px 0 12px; }
.hero dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .95rem; }
.hero dt { opacity: .8; display: flex; align-items: center; }
.hero dt svg { width: 18px; height: 18px; }
.hero dd { margin: 0; overflow-wrap: anywhere; }
.hero .deadline { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.25); font-size: .9rem; display: flex; justify-content: space-between; gap: 8px; }
.notice { background: var(--wait-bg); color: var(--wait); border-radius: 12px; padding: 12px 14px; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 8px; text-align: center; }
.stat .n { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat .l { font-size: .75rem; white-space: nowrap; color: var(--text-2); font-weight: 700; }
.stat.ok .n { color: var(--ok); } .stat.ng .n { color: var(--ng); } .stat.wait .n { color: var(--wait); }

details.people { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 10px; overflow: hidden; }
details.people summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 16px; font-weight: 700; cursor: pointer; }
details.people summary::-webkit-details-marker { display: none; }
details.people summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2); transform: rotate(45deg); transition: transform .15s; margin-right: 4px; }
details.people[open] summary::after { transform: rotate(-135deg); }
details.people ul { list-style: none; margin: 0; padding: 0 16px 8px; }
details.people li { padding: 10px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
details.people li .c { color: var(--text-2); font-size: .88rem; text-align: right; }

/* ---------- 名簿 ---------- */

.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-2); pointer-events: none; }
.search input { padding-left: 44px; border-radius: 999px; background: var(--surface); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 68px; color: var(--text); }
.list a:active { background: var(--surface-2); }
.list .main { flex: 1; min-width: 0; }
.list .name { display: block; font-weight: 700; }
.list .sub { display: block; color: var(--text-2); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .chevron { width: 20px; height: 20px; color: var(--text-2); flex: none; }

.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; background: color-mix(in srgb, var(--blue) 14%, var(--surface)); color: var(--blue); }
.avatar.lg { width: 84px; height: 84px; font-size: 2rem; margin: 0 auto 12px; }

.profile-head { text-align: center; padding: 8px 0 4px; }
.profile-head h2 { font-size: 1.4rem; }
.profile-head .kana { color: var(--text-2); font-size: .9rem; }
.profile-head .chips { justify-content: center; margin-top: 10px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 8px; }
.action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 72px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-size: .8rem; font-weight: 700; color: var(--blue); }
.action svg { width: 26px; height: 26px; }
.action[aria-disabled="true"] { color: var(--text-2); opacity: .45; pointer-events: none; }

.info { margin: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px; }
.info div { padding: 12px 0; }
.info div + div { border-top: 1px solid var(--line); }
.info dt { font-size: .8rem; color: var(--text-2); font-weight: 700; }
.info dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* ---------- マイページ ---------- */

.menu { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 16px; font: inherit; font-weight: 600; color: var(--text); background: none; border: 0; text-align: left; cursor: pointer; }
.menu svg { width: 22px; height: 22px; color: var(--text-2); }
.menu .danger { color: var(--ng); }
.menu .danger svg { color: var(--ng); }

.role-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.role-row input[type=text] { flex: 1; }
.role-row .del { display: flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--ng); white-space: nowrap; min-height: 44px; }
.role-row .del input { width: 20px; height: 20px; }

/* ---------- ログイン系 ---------- */

.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: 24px 20px calc(24px + var(--safe-b)); }
.brand { text-align: center; margin-bottom: 28px; }
.brand .mark { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px; background: var(--blue); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 8px 24px color-mix(in srgb, var(--blue) 35%, transparent); }
.brand .mark b { font-size: 1.5rem; line-height: 1; letter-spacing: .02em; }
.brand .mark i { font-style: normal; font-size: .62rem; color: var(--gold); font-weight: 800; letter-spacing: .1em; margin-bottom: 2px; }
.brand h1 { font-size: 1.35rem; }
.brand p { margin: 4px 0 0; color: var(--text-2); font-size: .9rem; }
.auth .card { padding: 20px; }
.auth .below { text-align: center; margin-top: 16px; }
.auth .lead { color: var(--text-2); margin: 0 0 16px; font-size: .95rem; }
