/* Sidebar-first layout — loaded after styles.css */

:root {
  --sidebar-w: 264px;
  --feed-gap: clamp(12px, 1.5vw, 24px);
}

body {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
}

/* ---------- Compact left rail ---------- */

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  width: var(--sidebar-w);
  padding: 26px 19px 18px;
  display: flex;
  flex-direction: column;
  gap: 17px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--line-strong);
}

.sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-brand {
  font-size: 31px;
}

.sidebar-subtitle {
  max-width: 190px;
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--ink-soft);
}

.sidebar-subtitle em {
  color: var(--accent);
}

.sidebar-counts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  margin-top: 2px;
  font-size: 8.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sidebar-counts strong {
  color: var(--ink-soft);
  font-weight: 500;
}

.sidebar-count-divider {
  opacity: 0.55;
}

.sidebar-close {
  display: none;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
}

.sidebar-close .icon {
  width: 13px;
  height: 13px;
}

.sidebar-search {
  flex: none;
  width: 100%;
  max-width: none;
  height: 38px;
  padding: 0 10px;
  gap: 9px;
  background: color-mix(in srgb, var(--bg-elev) 38%, transparent);
}

.sidebar-search input {
  font-size: 11.5px;
}

.sidebar-search .icon {
  width: 14px;
  height: 14px;
}

.sidebar-search .search-kbd {
  width: 18px;
  height: 18px;
  font-size: 9px;
}

.sidebar-results {
  margin: 0;
  font-size: 8.5px;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sidebar-active {
  justify-content: flex-start;
  gap: 5px;
  margin-top: -4px;
}

.sidebar-active:empty {
  display: none;
}

.sidebar .active-filter {
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 9px;
  gap: 4px;
}

.sidebar .active-filter .icon {
  width: 8px;
  height: 8px;
}

.sidebar-section {
  margin: 0;
}

.sidebar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 7px;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.category-list {
  display: flex;
  flex-direction: column;
  margin: 0 -7px;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 4.5px 7px;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  text-align: left;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--ink-soft);
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.category-row:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--bg-elev) 48%, transparent);
}

.category-row.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--bg-elev) 62%, transparent);
}

.category-count {
  flex: none;
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.category-row.is-active .category-count {
  color: var(--accent);
}

.sidebar-details summary {
  list-style: none;
  cursor: pointer;
  margin-bottom: 0;
}

.sidebar-details summary::-webkit-details-marker {
  display: none;
}

.sidebar-details summary .icon {
  width: 11px;
  height: 11px;
  transition: transform 0.2s ease;
}

.sidebar-details[open] summary {
  margin-bottom: 8px;
}

.sidebar-details[open] summary .icon {
  transform: rotate(180deg);
}

.sidebar .tag-cloud {
  max-height: 152px;
  gap: 4px;
  padding-right: 3px;
}

.sidebar .tag-cloud .filter-chip {
  height: 23px;
  padding: 0 7px;
  font-size: 9px;
  gap: 4px;
}

.sidebar .tag-cloud .chip-count {
  font-size: 8px;
}

.sidebar-segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
}

.sidebar-segmented button {
  height: 28px;
  padding: 0 4px;
  font-size: 9px;
  letter-spacing: 0.02em;
}

.sidebar-sort {
  width: 100%;
  height: 33px;
  margin-top: 8px;
}

.sidebar-sort select {
  width: 100%;
  padding: 0 30px 0 10px;
  font-size: 10px;
}

.sidebar-sort .icon {
  right: 10px;
  width: 12px;
  height: 12px;
}

.sidebar-switch {
  margin-top: 10px;
  padding-top: 0;
  font-size: 10.5px;
}

.sidebar-filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
}

.sidebar .clear-btn {
  font-size: 8.5px;
}

.filter-done {
  display: none;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: auto;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sidebar-foot button,
.sidebar-foot a {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-faint);
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  transition: color 0.2s ease;
}

.sidebar-foot button:hover,
.sidebar-foot a:hover {
  color: var(--accent);
}

.sidebar-foot .theme-toggle {
  width: 28px;
  height: 28px;
  margin-left: auto;
}

.sidebar-foot .theme-toggle .icon {
  width: 13px;
  height: 13px;
}

/* ---------- Masonry feed ---------- */

.feed {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  padding: 26px clamp(16px, 2vw, 32px) 70px;
}

.feed .masonry {
  gap: var(--feed-gap);
}

.feed .masonry-col {
  gap: var(--feed-gap);
}

.feed .empty-state {
  margin-top: 8vh;
  border-top: 0;
}

.feed .load-more-wrap {
  padding-top: 36px;
}

.feed .end-note {
  margin-top: 34px;
}

/* ---------- Mobile bar + drawer ---------- */

.mobile-bar {
  display: none;
}

@media (max-width: 900px) {
  body.is-drawer-open {
    overflow: hidden;
  }

  .mobile-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 54;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
  }

  .mobile-brand {
    font-size: 27px;
  }

  .mobile-bar-actions {
    display: flex;
    align-items: center;
    gap: 7px;
  }

  .mobile-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: none;
    color: var(--ink-soft);
    transition: border-color 0.2s ease, color 0.2s ease;
  }

  .mobile-icon-btn:hover,
  .mobile-icon-btn.has-filters {
    border-color: var(--accent);
    color: var(--accent);
  }

  .mobile-icon-btn .icon {
    width: 15px;
    height: 15px;
  }

  .mobile-icon-btn .filter-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 15px;
    height: 15px;
    font-size: 8px;
  }

  .sidebar {
    width: min(88vw, 340px);
    padding: 19px 18px 18px;
    transform: translateX(-101%);
    transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow);
    border-right: 1px solid var(--line);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: grid;
  }

  .sidebar-brand {
    font-size: 29px;
  }

  .sidebar-subtitle {
    font-size: 15px;
  }

  .sidebar .search-kbd {
    display: none;
  }

  .sidebar-filter-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .sidebar .clear-btn {
    text-align: left;
  }

  .filter-done {
    display: block;
    width: 100%;
  }

  .feed {
    margin-left: 0;
    padding: 74px 14px 54px;
  }

  .filter-backdrop {
    z-index: 55;
  }

  .filter-backdrop.is-visible {
    pointer-events: auto;
  }
}

@media (min-width: 901px) {
  .filter-backdrop {
    display: none !important;
  }

  .sidebar {
    transform: none !important;
  }
}

@media (max-width: 420px) {
  .feed {
    padding-left: 11px;
    padding-right: 11px;
  }

  .sidebar {
    width: min(92vw, 340px);
  }
}

/* ---------- Logo mark ---------- */

.brand {
  align-items: center;
  gap: 0;
}

.brand-icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: block;
  border-radius: 6px;
  margin-right: 7px;
}

.sidebar-brand .brand-icon {
  width: 23px;
  height: 23px;
}

.mobile-brand .brand-icon {
  width: 22px;
  height: 22px;
}

.sidebar-sort-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
  margin-top: 8px;
}

.sidebar-sort-row .sidebar-sort {
  flex: 1;
  width: auto;
  margin-top: 0;
}

.shuffle-btn {
  width: 36px;
  height: 33px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.shuffle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.shuffle-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.shuffle-btn .icon {
  width: 14px;
  height: 14px;
}

.sidebar-note {
  margin: 6px 0 0;
  font-size: 8px;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
}
