.sidebar {
  width: min(var(--sidebar-width), 85vw);
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 160;
}

/* ── Logo ─────────────────────────────────────────────── */
.sidebar__logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  display: block;
}

.sidebar__logo:hover { text-decoration: none; }

.sidebar__logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar__logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.sidebar__logo-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}

/* ── Nav ──────────────────────────────────────────────── */
.sidebar__nav {
  padding: 10px 0 16px;
  flex: 1;
}

.sidebar__section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 8px 18px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-item:hover {
  background: var(--border-light);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-item__num {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 18px;
}

.nav-item.active .nav-item__num { color: var(--accent); opacity: 0.7; }

.nav-item__title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item__badge {
  font-size: 0.65rem;
  background: var(--border-light);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.nav-item.active .nav-item__badge {
  background: var(--accent-bg);
  color: var(--accent);
}

.nav-item__badge--progress {
  background: var(--accent-bg);
  color: var(--accent);
}

.nav-item__badge--done {
  background: var(--easy-bg);
  color: var(--success);
  font-weight: 600;
}

/* ── Footer ───────────────────────────────────────────── */
.sidebar__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Theme toggle ─────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-border);
}

.theme-toggle--mobile {
  margin-left: auto;
  display: none;
}

@media (max-width: 900px) {
  .theme-toggle--mobile { display: block; }
}

/* ── Mobile header ────────────────────────────────────── */
.mobile-header {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
}

.mobile-header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}

/* ── Overlay ──────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 150;
}

.sidebar-overlay.active { display: block; }

/* ── Desktop: show sidebar permanently ────────────────── */
@media (min-width: 901px) {
  .mobile-header { display: none; }

  .sidebar {
    transform: translateX(0);
    transition: none;
  }
}

/* ── Mobile/Tablet ────────────────────────────────────── */
.sidebar.open { transform: translateX(0); }

/* ── Auth widget ──────────────────────────────────────── */
.auth-widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-widget__name {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-widget__logout {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.auth-widget__logout:hover { color: var(--error); border-color: var(--error); }

.auth-widget__login {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-widget__login:hover { text-decoration: underline; }

.auth-widget--guest {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.auth-widget__hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}
