/* Base layer: page skeleton, navigation, focus. Everything reads from design-tokens.
   Loaded AFTER app.css so the alias map below wins over app.css's legacy :root values. */

/* Legacy aliases — app.css still speaks the old variable names.
   This must come after app.css, otherwise app.css's own :root resets these. */
:root {
  --canvas: var(--wb-canvas);
  --surface: var(--wb-surface);
  --ink: var(--wb-ink);
  --muted: var(--wb-muted);
  --line: var(--wb-line);
  --purple: var(--wb-accent);
  --purple-dark: var(--wb-accent-strong);
  --lavender: var(--wb-accent-soft);
  --shadow: var(--wb-module-shadow);
  --radius: var(--wb-module-radius);
  --blue: var(--wb-info);
  --blue-bg: var(--wb-info-soft);
  --green: var(--wb-success);
}

body {
  background: var(--wb-canvas);
  color: var(--wb-ink);
  font-family: var(--wb-font-family);
}

/* --- App skeleton --- */
.sidebar {
  background: var(--wb-sidebar-bg);
  border-right-color: var(--wb-line-soft);
}

.topbar {
  background: var(--wb-topbar-bg);
  border-bottom-color: var(--wb-line-soft);
}

.main-content {
  max-width: 1500px;
}

/* --- Navigation --- */
.nav-item {
  border-radius: var(--wb-radius-sm);
  color: var(--wb-ink-strong);
  transition: background var(--wb-motion-fast) ease, color var(--wb-motion-fast) ease;
}

.nav-item:hover {
  background: var(--wb-hover-bg);
  color: var(--wb-accent-strong);
}

.nav-item.active {
  background: var(--wb-nav-active-bg);
  color: var(--wb-accent-strong);
  box-shadow: inset 3px 0 0 var(--wb-accent);
}

/* --- Search --- */
.search-wrap {
  background: var(--wb-input-bg);
  border: 1px solid transparent;
}

.search-wrap:focus-within {
  border-color: var(--wb-line-hover);
  background: var(--wb-surface);
}

/* --- Mobile --- */
.mobile-nav {
  background: var(--wb-topbar-bg);
  border-top-color: var(--wb-line-soft);
}

.mobile-nav-item.active {
  color: var(--wb-accent-strong);
}

/* --- Auth screen --- */
.auth-screen {
  background:
    radial-gradient(ellipse at 12% 10%, #faf3e9 0%, transparent 38%),
    radial-gradient(ellipse at 90% 90%, #e1f2eb 0%, transparent 34%),
    var(--wb-canvas);
}

/* --- Focus: one ring for every interactive element --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--wb-focus-ring);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .main-content {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-item {
    transition: none;
  }
}
/* --- Short viewports ---------------------------------------------------
   The rail is 100vh with a fixed vertical stack; below ~780px the last item
   (网盘管理) was clipped instead of scrolling. Compact the stack, and keep the
   nav list itself scrollable so any height degrades gracefully. */
.side-nav {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

@media (max-height: 780px) {
  .sidebar { padding-top: 16px; padding-bottom: 12px; }
  .brand-row { height: 46px; margin-bottom: 14px; }
  .nav-item { height: 40px; }
  .side-nav { gap: 3px; }
  .nav-section-label { padding: 12px 12px 4px; }
  .nav-divider { margin: 10px 10px 7px; }
}

@media (max-height: 660px) {
  .nav-item { height: 36px; font-size: 13px; }
  .side-nav { gap: 2px; }
  .sidebar-bottom { padding-top: 6px; }
}

/* --- Brand wordmark (backon) --- */
.brand-logo {
  display: inline-flex;
  align-items: center;
  color: var(--wb-ink-strong);
  flex: 0 0 auto;
}
.brand-logo svg {
  height: 32px;
  width: 152px;
  display: block;
}
.brand-logo-sm svg {
  height: 22px;
  width: 104px;
}
.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.auth-app-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: block;
  flex: 0 0 auto;
  box-shadow: 0 8px 22px rgb(31 26 20 / 12%);
}
.brand-logo-auth {
  margin-bottom: 0;
}
.brand-logo-auth svg {
  height: 30px;
  width: 142px;
}
@media (max-width: 640px) {
  .brand-logo svg { height: 26px; width: 124px; }
  .mobile-brand .brand-logo { max-width: 100%; }
}
