/* ==========================================================================
   Layout — top bar, sidebar, workspace, footer
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 16px; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; color: var(--text-3); }

.topbar-actions { margin-left: auto; display: flex; gap: 6px; }

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-2);
  overflow: hidden;
}
.sidebar-head {
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 0;
}
.sidebar-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--border);
}
.sidebar-tabs [role="tab"] {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: -1px;
}
.sidebar-tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.sidebar-tabs .count:not(:empty) {
  font-size: 11px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-2);
}
.tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Workspace */
.workspace {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 40px) 40px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}
.results { display: flex; flex-direction: column; gap: var(--gap); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 20px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-3);
}
.footer span:first-child { color: var(--text-2); font-weight: 500; }

.only-mobile { display: none !important; }
.scrim { display: none; }

@media (max-width: 900px) {
  :root { --sidebar-w: 320px; }
  .only-mobile { display: flex !important; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    width: min(var(--sidebar-w), 88vw);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .25s var(--ease);
    box-shadow: 0 0 40px rgba(0, 0, 0, .4);
  }
  body.sidebar-open .sidebar { transform: none; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  body.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  body.sidebar-open { overflow: hidden; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; }
  .brand-text small { display: none; }
  .workspace { padding: 16px 16px 32px; }
  .footer { flex-direction: column; }
}
