.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}
.scrim.show { display: block; }

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 18px 0 12px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 18px 18px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: #2a3324; color: #c5d4b4;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  letter-spacing: -0.04em; overflow: hidden; flex-shrink: 0;
}
.brand-mark img { width: 34px; height: 34px; object-fit: cover; }
.brand strong { display: block; font-size: 13px; letter-spacing: -0.02em; color: var(--sidebar-text); }
.brand span { display: block; font-size: 11px; color: var(--sidebar-muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; flex: 1; padding: 0 10px; }
.nav-label {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 16px 10px 6px;
}
.nav-label:first-child { padding-top: 0; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 12px;
  border-radius: 8px;
  color: var(--sidebar-muted);
  font-weight: 550; font-size: 13.5px;
  width: 100%; min-height: 38px;
  border-left: 0;
  position: relative;
}
.nav a svg { opacity: .55; flex-shrink: 0; }
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav a:hover svg { opacity: .9; }
.nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
}
.nav a.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px; width: 3px;
  background: #9caf88;
  border-radius: 0 2px 2px 0;
}
.nav a.active svg { opacity: 1; color: #c5d4b4; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 12px 4px;
  padding: 12px 10px 4px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: #2a3324; display: grid; place-items: center;
  font-size: 11px; color: #c5d4b4; font-weight: 700; flex-shrink: 0;
}
.sidebar-user strong { display: block; font-size: 13px; color: var(--sidebar-text); }
.sidebar-user small { color: var(--sidebar-muted); display: block; font-size: 11px; margin-top: 1px; }

.main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
}

.topbar {
  min-height: var(--header);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 28px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-subtle);
  background: var(--topbar);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-title { min-width: 160px; }
.top-title strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.top-title span { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

.search-wrap { flex: 1; max-width: none; position: relative; }
.search-wrap input {
  padding-left: 40px;
  background: var(--surface);
  border-color: var(--border);
  height: 42px;
}
.search-wrap .ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px; display: none; z-index: 30; max-height: 360px; overflow: auto;
}
.search-results.open { display: block; }
.search-results .group { font-size: 11px; color: var(--faint); padding: 8px 8px 4px; text-transform: uppercase; letter-spacing: .06em; }
.search-results a {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 10px 8px; border-radius: 8px; font-size: 13px; min-height: 44px;
}
.search-results a:hover { background: var(--surface-2); }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border-subtle); position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}

.content {
  padding: 22px 32px 48px;
  flex: 1;
  width: 100%;
  max-width: none;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.04em; }
.page-head p { color: var(--muted); margin-top: 6px; font-size: 13.5px; max-width: 640px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.menu-toggle, .bottom-nav { display: none; }
.theme-fab {
  position: fixed; top: 16px; right: 16px; z-index: 25;
}

.page-error, .page-loading { padding: 48px 16px; }

@media (max-width: 1100px) {
  .shell { display: block; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50;
    transform: translateX(-105%); transition: transform .2s ease; height: 100%;
    padding-top: max(18px, env(safe-area-inset-top));
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .main { height: auto; min-height: 100vh; overflow: visible; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .content { padding: 18px 16px calc(var(--bottom) + 28px); }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--bottombar); border-top: 1px solid var(--border);
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 11px; color: var(--muted); padding: 8px 0; border-radius: 12px; font-weight: 650;
    min-height: 52px; justify-content: center;
  }
  .bottom-nav a.active { color: var(--accent); background: var(--accent-dim); }
  .icon-btn { width: 44px; height: 44px; }
}

@media (max-width: 700px) {
  .top-title { display: none; }
  .topbar { gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .content { padding: 14px 12px calc(var(--bottom) + 24px); }
  .page-head { margin-bottom: 10px; }
  .page-head h1 { font-size: 20px; }
  .page-head p { display: none; }
  .head-actions { width: auto; }
  .head-actions .btn { flex: 0 1 auto; min-height: 40px; }
  .bottom-nav a { font-size: 10px; min-height: 56px; }
}

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; padding: 0 12px; }
  .chip { min-height: 40px; padding: 8px 14px; }
  .nav a { min-height: 44px; }
  .m-actions .btn { min-height: 36px; }
}
