/* ===================================================================
   ページの骨組み（ヘッダー・タブバー・フッター・本文の幅）。
   PC: 上のヘッダーにメニュー。スマホ（767px 以下）: 上は戻る＋題名、下にタブバー。
   =================================================================== */
.page {
  width: 100%;
  max-width: calc(var(--content-width) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 32px var(--gutter) 64px;
}
.page.narrow { max-width: calc(var(--narrow-width) + var(--gutter) * 2); }
.page.reading { max-width: calc(1120px + var(--gutter) * 2); }

.page-title { font-size: 28px; margin-bottom: 6px; }
.page-lead { color: var(--text-sub); margin-bottom: 24px; }

@media (max-width: 767px) {
  .page { padding: 16px var(--gutter) calc(var(--tabbar-h) + 32px); }
  body.no-tabbar .page { padding-bottom: 32px; }
  .page-title { font-size: 22px; }
  .page-lead { margin-bottom: 16px; }
}

/* ───────── ヘッダー（PC） ───────── */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  box-shadow: var(--shadow-header);
}
.site-header-inner {
  max-width: calc(var(--content-width) + var(--gutter) * 2);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 32px;
}
.site-logo img { height: 40px; width: auto; }
.site-nav { display: flex; align-items: stretch; height: 100%; gap: 4px; }
.nav-group { position: relative; display: flex; }
.nav-button {
  display: flex; align-items: center; gap: 4px;
  padding: 0 14px; height: 100%;
  background: none; border: 0;
  font-weight: 600; color: var(--text);
  box-shadow: inset 0 -3px 0 transparent;
}
.nav-button:hover { color: var(--ink); }
.nav-button[aria-current="true"] { font-weight: 700; color: var(--ink); box-shadow: inset 0 -3px 0 var(--aqua); }
.nav-menu {
  position: absolute; top: calc(100% + 1px); left: 0; min-width: 200px;
  background: var(--surface); box-shadow: var(--shadow-pop); z-index: 50;
  padding: 6px 0;
}
.nav-menu a, .nav-menu button {
  display: block; width: 100%; text-align: left;
  padding: 11px 18px; border: 0; background: none;
  color: var(--text); text-decoration: none; font-size: 14px;
}
.nav-menu a:hover, .nav-menu button:hover { background: var(--bg); color: var(--ink); }
.nav-menu .danger { color: var(--red-text); }
.nav-menu hr { border: 0; border-top: 1px solid var(--line-light); margin: 6px 0; }

.header-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-button {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap);
  border: 0; background: none; color: var(--slate);
}
.icon-button:hover { color: var(--ink); background: var(--bg); }
.notice-badge {
  position: absolute; top: 4px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.user-button {
  display: flex; align-items: center; gap: 10px;
  height: var(--tap); padding: 0 8px; border: 0; background: none;
  font-weight: 600; color: var(--ink);
}
.user-button:hover { background: var(--bg); }
.user-button .warn { color: var(--red-text); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--slate); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex: none;
}
.header-popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 320px; background: var(--surface); box-shadow: var(--shadow-pop); z-index: 50;
}
.header-popover-title {
  padding: 12px 16px; font-weight: 700; color: #fff; background: var(--slate); font-size: 14px;
}
.notice-list { max-height: 360px; overflow-y: auto; }
.notice-item {
  display: block; padding: 12px 16px; border-bottom: 1px solid var(--line-light);
  color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.6;
}
.notice-item:hover { background: var(--bg); }
.notice-item strong { color: var(--ink); }
.notice-empty { padding: 16px; color: var(--text-sub); font-size: 14px; }

/* ───────── ヘッダー（スマホ） ───────── */
.sp-header { display: none; }

@media (max-width: 767px) {
  .site-header-inner { display: none; }
  .sp-header {
    display: grid; grid-template-columns: var(--tap) 1fr auto;
    align-items: center; height: var(--header-h); padding: 0 4px;
  }
  .sp-header-title { text-align: center; line-height: 1.25; min-width: 0; }
  .sp-header-title strong { display: block; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sp-header-title small { display: block; font-size: 11px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sp-header-logo img { height: 30px; margin: 0 auto; }
  .sp-header-actions { display: flex; justify-content: flex-end; min-width: var(--tap); }
  .header-popover { position: fixed; top: var(--header-h); right: 8px; left: 8px; width: auto; }
}

/* ───────── タブバー（スマホ） ───────── */
.tabbar { display: none; }
@media (max-width: 767px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--slate);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: #DCE3EA; text-decoration: none; font-size: 11px; font-weight: 700;
    border-left: 1px solid var(--slate-divider);
  }
  .tabbar a:first-child { border-left: 0; }
  .tabbar a[aria-current="page"] { background: var(--aqua); color: #fff; }
  .tabbar .tab-icon { position: relative; }
  .tabbar .notice-badge { top: -6px; right: -12px; box-shadow: 0 0 0 2px var(--slate); }
  body.no-tabbar .tabbar { display: none; }
}

/* ───────── フッター ───────── */
.site-footer {
  background: var(--slate); color: #DCE3EA;
  font-size: 12.5px; text-align: center; padding: 18px var(--gutter);
}
@media (max-width: 767px) {
  .site-footer { padding-bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); }
  body.no-tabbar .site-footer { padding-bottom: 18px; }
}

/* ───────── 2列のレイアウト ───────── */
.split {
  display: grid; gap: var(--gap); align-items: start;
  grid-template-columns: minmax(0, var(--split-main, 660px)) minmax(0, 1fr);
}
@media (max-width: 1023px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
.stack { display: grid; gap: var(--gap); align-content: start; min-width: 0; }
.stack-sm { display: grid; gap: 12px; align-content: start; min-width: 0; }
