/* App shell: sidebar + topbar for signed-in screens, a slim header for public
   ones. body[data-shell] picks the frame; app.js sets it per route. */

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 12px;
  background: var(--ink); color: var(--bg); border-radius: var(--radius); text-decoration: none;
}
.skip-link:focus, .skip-link:hover { top: 12px; color: var(--bg); }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; display: flex; flex-direction: column; }
#view { flex: 1; outline: none; }
body:not([data-shell="app"]) .sidebar,
body:not([data-shell="app"]) .topbar { display: none; }
body:not([data-shell="app"]) .shell { display: block; }

/* --- Sidebar ------------------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; padding: 12px;
  background: var(--surface-alt); border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px;
  font-weight: 600; font-size: 1.07rem; letter-spacing: var(--brand-tracking);
  color: var(--ink); text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand img {
  width: 26px; height: 26px; border-radius: 7px; object-fit: cover;
  box-shadow: 0 0 0 1px var(--border); background: #fff;
}
.acct {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
}
.acct-av {
  width: 28px; height: 28px; border-radius: 6px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 70%, var(--ink)); color: #fff; font-size: 11px; font-weight: 600;
}
.acct-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acct-meta b { font-weight: 500; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-meta span { font-size: 0.86rem; color: var(--ink-muted); }
.acct select {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; margin: 0;
}
.acct:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.acct > svg { color: var(--ink-muted); }

.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 0.86rem; color: var(--ink-muted); padding: 14px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px;
  border-radius: calc(var(--radius) - 2px); color: var(--ink-2); text-decoration: none; font-weight: 450;
}
.nav-item:hover { background: var(--surface-muted); color: var(--ink); }
.nav-item[aria-current="page"] {
  background: var(--surface); color: var(--ink); font-weight: 500;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.nav-item .count { margin-left: auto; font: 0.86rem var(--font-mono); color: var(--ink-muted); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }
.credits {
  display: block; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.credits:hover { border-color: var(--border-strong); color: var(--ink); }
.credits .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.93rem; }
.credits b { font: 500 0.93rem var(--font-mono); }
.credits small { display: block; margin-top: 2px; font-size: 0.82rem; }
.credits.low b { color: var(--warn); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 4px 2px 8px; font-size: 0.93rem; min-width: 0; }
.me > div { min-width: 0; flex: 1; }
.me b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { display: block; color: var(--ink-muted); font-size: 0.86rem; }
.av {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: var(--bg); background: color-mix(in srgb, var(--ink) 72%, var(--bg));
}

/* --- Topbar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 32px; border-bottom: 1px solid var(--border);
  background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(8px);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-muted); font-size: 0.93rem; }
.crumbs a { color: var(--ink-muted); text-decoration: none; white-space: nowrap; }
.crumbs a:hover { color: var(--ink); }
.crumbs b { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .sep { color: var(--border-strong); }
.topbar .new-btn { margin-left: auto; }
.menu-btn { display: none; }

body[data-shell="app"] #view { padding: 32px 32px 72px; max-width: 1240px; width: 100%; }
.page { width: 100%; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--ink-muted); }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Public frame (landing, sign-in) --------------------------------------- */
.public-head {
  display: none; align-items: center; gap: 12px; height: 60px; padding: 0 24px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
body[data-shell="public"] .public-head { display: flex; }
.public-head .brand { padding: 0; }
.public-head nav { margin-left: auto; display: flex; gap: 8px; }
body[data-shell="public"] #view { max-width: 1080px; margin: 0 auto; padding: 40px 24px 72px; }

/* --- Drawer (narrow screens) ------------------------------------------------ */
.scrim { position: fixed; inset: 0; z-index: 39; background: rgba(10, 10, 10, .32); }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: min(288px, 86vw);
    transform: translateX(-100%); visibility: hidden; box-shadow: var(--shadow-lg);
    transition: transform .22s cubic-bezier(.16, 1, .3, 1), visibility 0s .22s;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .22s cubic-bezier(.16, 1, .3, 1); }
  .menu-btn { display: inline-flex; margin-left: -6px; }
  .topbar { padding: 0 16px; }
  body[data-shell="app"] #view { padding: 24px 16px 64px; }
}
@media (max-width: 640px) {
  .topbar .new-btn span { display: none; }
  .topbar .new-btn { width: 36px; padding: 0; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions > * { flex: 1; }
  h1 { font-size: 1.5rem; }
  .public-head { padding: 0 16px; }
  body[data-shell="public"] #view { padding: 28px 16px 56px; }
}
