/* レイアウト: 上部の細いトップバー＋左サイドメニュー（幅 ≥ 960px は常時表示、未満はドロワー） */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  padding: 4px 16px;
  min-height: 52px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.02em;
  color: var(--text); text-decoration: none; min-height: 44px;
}
.brand small { font-weight: 500; font-size: 0.8rem; color: var(--text-muted); }
.brand__mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px;
  background: var(--accent); color: var(--accent-on); font-size: 0.8rem; font-weight: 800;
}
.user-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.user-box__name { display: flex; flex-direction: column; line-height: 1.3; font-size: 0.85rem; text-align: right; }
.user-box__name strong { font-size: 0.9rem; }
.btn.nav-toggle { display: none; }

/* ── シェル ─────────────────────────── */
.app-shell { flex: 1 0 auto; display: grid; grid-template-columns: 256px minmax(0, 1fr); align-items: start; }
.app-shell[data-auth="false"] { grid-template-columns: minmax(0, 1fr); }
.app-body { min-width: 0; min-height: calc(100vh - 53px); display: flex; flex-direction: column; }
.app-body main { flex: 1 0 auto; width: 100%; max-width: 1240px; margin: 0 auto; padding: 20px 16px 40px; }
@media (min-width: 1100px) { .app-body main { padding: 28px 28px 56px; } }
.app-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 0.82rem; }
.app-footer p { margin: 0; padding: 12px 16px; }

/* ── サイドバー ─────────────────────────── */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  padding: 12px 10px 24px;
}
.sidebar[hidden] { display: none !important; }
.sidebar__head { display: none; align-items: center; justify-content: space-between; margin: 0 4px 8px; }
.sidebar__title { font-weight: 700; color: var(--text-muted); font-size: 0.85rem; }
.drawer-overlay { display: none; }

.site-nav { display: flex; flex-direction: column; gap: 10px; }
.nav-group__toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 36px; padding: 4px 8px; background: transparent; border: 0; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 800; font-size: 0.78rem; letter-spacing: 0.06em; text-align: left; cursor: pointer;
}
.nav-group__toggle:hover { background: var(--surface-2); color: var(--text); }
.nav-group__toggle::before { content: '▸'; display: inline-block; width: 1em; transition: transform 0.15s; }
.nav-group__toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.nav-group__list { list-style: none; margin: 2px 0 0; padding: 0; }
.nav-group__list[hidden] { display: none; }
.nav-group__list a, .nav-group__note {
  display: flex; align-items: center; min-height: 40px; padding: 4px 10px 4px 22px;
  border-radius: var(--radius-sm); border-left: 3px solid transparent;
  color: var(--text); text-decoration: none; font-size: 0.92rem; line-height: 1.35;
}
.nav-group__note { color: var(--text-muted); font-size: 0.82rem; }
.nav-group__list a:hover { background: var(--surface-2); }
.nav-group__list a[aria-current="page"] {
  background: var(--accent-soft); border-left-color: var(--accent); font-weight: 700;
}

/* ── ドロワー（幅 < 960px） ─────────────────────────── */
@media (max-width: 959px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .btn.nav-toggle { display: inline-flex; }
  .user-box { order: 3; flex-basis: 100%; margin-left: 0; justify-content: space-between; flex-wrap: nowrap; gap: 8px; padding-bottom: 6px; }
  .user-box__name { min-width: 0; text-align: left; }
  .user-box .badge, .user-box .btn { flex: none; }
  .sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: 100%;
    transform: translateX(-102%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
  }
  .sidebar[data-open="true"] { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .sidebar__head { display: flex; }
  .drawer-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 20, 0.55); }
  .drawer-overlay[data-open="true"] { display: block; }
  body.drawer-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar[data-open="true"] { transition: none; }
}
@media (forced-colors: active) {
  .nav-group__list a[aria-current="page"] { outline: 2px solid Highlight; }
}
