:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1b1b1e;
  --line: #2a2a2f;
  --line-strong: #3a3a40;
  --text: #f2efe8;
  --muted: #9b9ba3;
  --faint: #6b6b73;
  --gold: #c8a45a;
  --gold-strong: #dcbc72;
  --gold-soft: rgba(200, 164, 90, 0.14);
  --silver: #c3c7cf;
  --silver-soft: rgba(195, 199, 207, 0.12);
  --danger: #e0707a;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: dark;
}

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

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: 'M PLUS 1', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.material-symbols-outlined { font-size: 20px; line-height: 1; vertical-align: middle; }

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark, .login-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1.5px solid var(--gold); color: var(--gold);
  font-family: 'Cormorant Garamond', Georgia, serif; font-size: 22px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: 0.08em; font-size: 15px; }
.brand-sub { font-size: 10px; letter-spacing: 0.32em; color: var(--silver); }

.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--bg); background: var(--gold); }

.account { position: relative; flex-shrink: 0; }
.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  border: 1.5px solid var(--silver);
  display: grid; place-items: center; background: var(--surface-2);
  font-weight: 700; color: var(--silver);
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 6px; z-index: 30;
}
.menu-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-name { font-weight: 700; }
.menu-email { font-size: 12px; color: var(--muted); word-break: break-all; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.menu-item:hover { background: var(--surface-2); }

/* ---------- レイアウト ---------- */
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 20px 40px; position: relative; }
.footer { text-align: center; color: var(--faint); font-size: 12px; padding: 20px; letter-spacing: 0.08em; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; color: var(--silver); margin: 28px 0 12px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; font-size: 14px; }

/* ---------- ログイン ---------- */
.login { display: grid; place-items: center; min-height: 70vh; }
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  padding: 44px 28px 36px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
}
.login-mark { width: 56px; height: 56px; font-size: 34px; border-radius: 14px; margin: 0 auto 18px; }
.login-title { margin: 0; font-size: 26px; letter-spacing: 0.2em; font-weight: 700; }
.login-sub { margin: 2px 0 14px; color: var(--silver); letter-spacing: 0.24em; font-size: 13px; }
.login-venues { display: flex; justify-content: center; gap: 8px; margin-bottom: 28px; }
.login-area { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 44px; }
/* ページがダーク指定だと、Google ボタン（ライト）の iframe に白い背景が描かれるため合わせる */
.login-area iframe { color-scheme: light; }
.login-deadline { margin: 22px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.login-deadline b { color: var(--gold); }
.login-msg { margin: 18px 0 0; font-size: 13px; color: var(--danger); line-height: 1.7; }
.login-msg.info { color: var(--muted); }

/* ---------- 共通部品 ---------- */
.venue-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  border: 1px solid;
}
.venue-tag.umeda { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.venue-tag.namba { color: var(--silver); border-color: var(--silver); background: var(--silver-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
  border: 1px solid var(--line-strong); color: var(--text); background: var(--surface-2);
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--silver); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #141007; }
.btn.primary:hover { background: var(--gold-strong); }
.btn.danger { color: var(--danger); border-color: rgba(224, 112, 122, .5); background: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  color: var(--silver); border: 1px solid var(--line);
}
.icon-btn:hover { border-color: var(--silver); color: var(--text); }

/* 2択・多択のセグメントボタン */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line-strong); }
.seg button {
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 72px; justify-content: center;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.on-yes { background: var(--gold); color: #141007; }
.seg button.on-no { background: var(--silver); color: #111214; }
.seg button.on-none { background: var(--line-strong); color: var(--text); }
.seg button.on-umeda { background: var(--gold); color: #141007; }
.seg button.on-namba { background: var(--silver); color: #111214; }
.seg button:disabled { cursor: default; }
.seg.small button { min-width: 0; padding: 5px 10px; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }
.input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line-strong); outline: none;
}
.input:focus { border-color: var(--gold); }
textarea.input { min-height: 80px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 12px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line-strong); color: var(--muted); }
.chip:hover { color: var(--text); border-color: var(--silver); }
.chip.on { color: #141007; background: var(--gold); border-color: var(--gold); font-weight: 700; }

/* ---------- カレンダー ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-title { font-size: 22px; font-weight: 700; letter-spacing: 0.06em; margin-right: auto; }
.cal-title small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.cal {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.cal-dow { padding: 8px 0; text-align: center; font-size: 12px; color: var(--muted); letter-spacing: 0.1em; border-bottom: 1px solid var(--line); }
.cal-dow.sat { color: var(--silver); }
.cal-dow.sun { color: var(--gold); }
.cal-cell {
  position: relative; min-height: 92px; padding: 6px; text-align: left;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
  transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.blank { background: var(--bg); }
.cal-cell.past .cal-num { color: var(--faint); }
.cal-cell.has-events { cursor: pointer; }
.cal-cell.has-events:hover, .cal-cell.selectable:hover { background: var(--surface-2); }
.cal-cell.selectable { cursor: pointer; }
.cal-cell.selected { background: var(--gold-soft); box-shadow: inset 0 0 0 1.5px var(--gold); }
.cal-num { font-size: 13px; font-weight: 500; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-num { background: var(--gold); color: #141007; font-weight: 700; }
.cal-chip {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; border-left: 3px solid;
  white-space: nowrap; overflow: hidden;
}
.cal-chip.umeda { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.cal-chip.namba { border-color: var(--silver); background: var(--silver-soft); color: var(--silver); }
.cal-chip .material-symbols-outlined { font-size: 14px; margin-left: auto; }
.cal-chip .mark-yes { color: var(--gold-strong); font-variation-settings: 'FILL' 1; }
.cal-chip .mark-no { color: var(--muted); }
.cal-chip .chip-label { flex-shrink: 0; }
.cal-chip .chip-time { min-width: 0; overflow: hidden; text-overflow: clip; font-weight: 500; opacity: .85; }
.cal-chip .chip-count { margin-left: auto; padding-left: 2px; flex-shrink: 0; }
/* 見出し書体の数字は旧字体風（10 が IO に見える）なので揃った数字にする */
.ev-date .d, .stat .value, .summary-line b { font-variant-numeric: lining-nums tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend .material-symbols-outlined { font-size: 16px; }

/* ---------- 候補日リスト ---------- */
.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-card {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  transition: box-shadow .3s;
}
.event-card.umeda { border-left-color: var(--gold); }
.event-card.namba { border-left-color: var(--silver); }
.event-card.flash { box-shadow: 0 0 0 2px var(--gold); }
.event-card.clickable { cursor: pointer; }
.event-card.clickable:hover { background: var(--surface-2); }
.ev-date { text-align: center; line-height: 1.1; }
.ev-date .d { font-size: 26px; font-weight: 700; font-family: 'Cormorant Garamond', Georgia, serif; }
.ev-date .w { font-size: 12px; color: var(--muted); }
.ev-date .m { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }
.ev-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ev-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ev-time { font-weight: 700; font-size: 15px; }
.ev-title { font-weight: 500; }
.ev-note { font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.ev-count { font-size: 12px; color: var(--silver); display: inline-flex; align-items: center; gap: 3px; }
.ev-count .material-symbols-outlined { font-size: 16px; }
.ev-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ev-closed { font-size: 11px; color: var(--faint); letter-spacing: 0.06em; }
.status-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; }
.status-badge.yes { color: var(--gold); }
.status-badge.no { color: var(--muted); }
.status-badge.none { color: var(--faint); }

/* ---------- 参加履歴 ---------- */
.stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px; }
.stat { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat .label { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.stat .value { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 40px; font-weight: 600; line-height: 1.1; margin-top: 4px; }
.stat .value small { font-family: 'M PLUS 1', sans-serif; font-size: 13px; color: var(--muted); margin-left: 4px; }
.stat.main { border-color: var(--gold); }
.stat.main .value { color: var(--gold); font-size: 52px; }
.stat.umeda .value { color: var(--gold); }
.stat.namba .value { color: var(--silver); }

/* ---------- 管理 ---------- */
.admin-tabs { margin-bottom: 4px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.panel .hint { font-size: 12px; color: var(--muted); margin: -6px 0 0; }
.selected-dates { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.selected-dates .chip { color: var(--gold); border-color: var(--gold); }
.member-row, .user-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.member-row:last-child, .user-row:last-child { border-bottom: 0; }
.mini-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: grid; place-items: center; background: var(--surface-2); color: var(--silver); font-weight: 700; font-size: 13px;
  border: 1px solid var(--line-strong);
}
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { flex: 1; min-width: 0; }
.who .n { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .e { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-admin { font-size: 10px; letter-spacing: 0.1em; color: var(--gold); border: 1px solid var(--gold); border-radius: 999px; padding: 0 6px; margin-left: 6px; vertical-align: middle; }
.count-pill { font-size: 12px; color: var(--silver); white-space: nowrap; }
.summary-line { display: flex; gap: 12px; font-size: 13px; flex-wrap: wrap; }
.summary-line b { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 18px; }
.summary-line .y b { color: var(--gold); }
.summary-line .n b { color: var(--silver); }
.summary-line .u b { color: var(--faint); }

.ev-deadline { font-size: 12px; color: var(--gold); display: inline-flex; align-items: center; gap: 4px; }
.ev-deadline .material-symbols-outlined { font-size: 15px; }
.ev-title { font-weight: 700; letter-spacing: 0.04em; color: var(--gold); }
.ev-name { font-weight: 700; }
.notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid var(--gold); border-radius: var(--radius); background: var(--gold-soft); font-size: 13px; line-height: 1.7;
}
.notice .material-symbols-outlined { color: var(--gold); margin-top: 1px; }
.notice b { color: var(--gold); }
.hint.warn { color: var(--danger); }
.mail-context { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px dashed var(--gold); font-size: 13px; }
.mail-context .who { color: var(--text); }
.mail-quota { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--silver); }
.mail-quota b { color: var(--gold); font-size: 16px; }
.mail-quota.warn { color: var(--danger); }
.log-kind { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--silver); color: var(--silver); flex-shrink: 0; }
.log-kind.reminder { border-color: var(--gold); color: var(--gold); }
#credit { cursor: default; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.credit-kana { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.credit-story { margin: 0; line-height: 2; color: var(--text); }
.credit-story b { color: var(--gold); }

/* ---------- モーダル ---------- */
.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border-radius: 18px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
}
.modal::backdrop { background: rgba(0, 0, 0, .7); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- トースト・ローディング ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100;
  padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--text); color: var(--bg); width: max-content; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- スマートフォン ---------- */
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .brand-text { display: none; }
  .tabs { margin: 0; flex: 1; justify-content: center; }
  .tab { padding: 8px 10px; }
  .tab span:last-child { display: none; }
  .tab.active span:last-child { display: inline; }
  main { padding: 16px 16px 32px; }
  .cal-cell { min-height: 64px; padding: 4px 3px; gap: 3px; }
  .cal-num { width: 22px; height: 22px; font-size: 12px; }
  .cal-chip { padding: 1px 3px; font-size: 10px; border-left-width: 2px; }
  .cal-chip .chip-time { display: none; }
  .event-card { grid-template-columns: 48px 1fr; gap: 10px; padding: 12px; }
  .ev-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { padding: 14px; }
  .stat .value { font-size: 32px; }
  .stat.main { grid-column: 1 / -1; }
  .admin-grid { grid-template-columns: 1fr; }
}
