/* App shell: sidebar (desktop), top bar + bottom tab bar + navigation sheet (below 1024px). */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.content { min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: calc(var(--content-max) + 80px); margin: 0 auto; padding: 44px 40px 96px; flex: 1; }
#banner:empty { display: none; }
#banner { width: 100%; max-width: calc(var(--content-max) + 80px); margin: 0 auto; padding: 20px 40px 0; }
#banner .callout { margin: 0; }

/* ---------- sidebar */
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 6px; padding: 20px 14px 16px; background: var(--surface); border-right: 1px solid var(--line); scrollbar-width: thin; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: inherit; text-decoration: none; }
.brand-mark { position: relative; display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-weight: 700; font-size: 0.95rem; letter-spacing: -0.04em; box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.12); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 0.98rem; font-weight: 650; letter-spacing: -0.015em; }
.brand-text small { color: var(--ink-3); font-size: 0.74rem; }

.nav-group { margin: 0 0 10px; }
.nav-group-label { display: block; padding: 10px 12px 6px; font-size: 0.68rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.nav-group-label a { color: inherit; text-decoration: none; }
.nav-group-label a:hover { color: var(--ink); }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-list a { position: relative; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 6px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; transition: background-color var(--t-fast), color var(--t-fast); }
.nav-list a:hover { background: var(--surface-sunken); color: var(--ink); }
.nav-list a[aria-current="page"] { background: var(--surface-sunken); color: var(--ink); }
.nav-list a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav-icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; color: var(--ink-3); transition: color var(--t-fast), background-color var(--t-fast); }
.nav-icon .icon { width: 18px; height: 18px; }
.nav-list a:hover .nav-icon, .nav-list a[aria-current="page"] .nav-icon { color: var(--lc, var(--ink)); }
.nav-text { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.nav-de { font-size: 0.92rem; font-weight: 560; }
.nav-en { font-size: 0.72rem; color: var(--ink-3); }
.nav-count:not(:empty) { font-family: var(--mono); font-size: 0.72rem; font-weight: 600; min-width: 22px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.sidebar-foot .nav-list a { padding-left: 2px; }
@media (min-width: 1024px) and (max-height: 900px) {
  .sidebar { padding-top: 14px; gap: 2px; }
  .brand { padding-bottom: 10px; }
  .nav-group { margin-bottom: 4px; }
  .nav-group-label { padding: 6px 12px 3px; }
  .nav-list a { min-height: 34px; padding: 3px 10px; }
  .nav-en { display: none; }
  .sidebar-foot { padding-top: 10px; gap: 8px; }
}
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 10px; }
.theme-switch button { display: grid; place-items: center; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-3); cursor: pointer; transition: background-color var(--t-fast), color var(--t-fast); }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.theme-switch .icon { width: 16px; height: 16px; }
.privacy-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--ink-3); font-size: 0.74rem; line-height: 1.45; }
.privacy-note .icon { width: 14px; height: 14px; margin-top: 2px; }

/* ---------- top bar + tab bar (hidden on desktop) */
.topbar, .tabbar, .scrim { display: none; }

@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  main { padding: 24px 20px calc(var(--tabbar-h) + 48px + env(safe-area-inset-bottom)); }
  #banner { padding: 16px 20px 0; }

  .topbar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 12px; height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 16px;
    background: color-mix(in srgb, var(--canvas) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: 0.82rem; border-radius: 9px; }
  .topbar-title { flex: 1; min-width: 0; font-weight: 600; font-size: 0.98rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; border: 0; background: none; font: inherit; font-size: 0.68rem; font-weight: 560; color: var(--ink-3); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar .tab-icon { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; transition: background-color var(--t-mid) var(--ease-out), color var(--t-fast); }
  .tabbar .icon { width: 21px; height: 21px; }
  .tabbar [aria-current="page"] { color: var(--ink); }
  .tabbar [aria-current="page"] .tab-icon { background: var(--accent); color: var(--accent-ink); }
  .tabbar a:active .tab-icon, .tabbar button:active .tab-icon { transform: scale(0.94); }
  .tabbar .nav-count:not(:empty) { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; font-size: 0.66rem; box-shadow: 0 0 0 2px var(--surface); }

  /* the sidebar becomes a navigation sheet */
  .sidebar { position: fixed; z-index: 90; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); height: auto; padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line); box-shadow: var(--shadow-3); transform: translateX(-104%); transition: transform var(--t-slow) var(--ease-out); visibility: hidden; }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 80; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--t-mid) var(--ease-out); }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .nav-list a[aria-current="page"]::before { left: -14px; }
}
@media (max-width: 767px) {
  main { padding-left: 16px; padding-right: 16px; padding-top: 20px; }
  #banner { padding-left: 16px; padding-right: 16px; }
}
