/* Navigation follows V4's dense, persistent panel and project-home hierarchy. */
.folder-navigation [role="tree"] { padding-bottom: 12px; }
.folder-navigation + .folder-navigation { margin-top: 8px; }
.folder-navigation [role="treeitem"] { outline: none; }
.folder-tree-row:hover { background: var(--surface); color: var(--ink); }
[aria-current="page"] > .folder-tree-row { background: var(--surface-3); color: var(--ink); }
.folder-navigation [role="treeitem"]:focus-visible > .folder-tree-row { outline: 2px solid var(--info); outline-offset: -2px; }
.folder-tree-row > svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.tree-chevron:hover { background: var(--surface-3); }
.tree-chevron svg { width: 12px; height: 12px; }
[aria-expanded="true"] > .folder-tree-row .tree-chevron svg { transform: rotate(90deg); }
.tree-chevron.is-leaf { visibility: hidden; }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-lock { margin-left: auto; display: flex; }
.tree-lock svg { width: 12px; height: 12px; color: var(--ink-3); }
.tree-note, .tree-retry { margin: 8px 12px; color: var(--ink-3); font-size: 12px; }
.tree-retry { padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.topbar { min-height: 68px; padding: 12px 22px; display: grid; grid-template-columns: minmax(134px, 1fr) minmax(0, 480px) minmax(134px, 1fr); gap: 20px; }
.topbar-left { gap: 12px; justify-content: flex-start; }
.topbar-actions { justify-content: flex-end; margin: 0; }
.workspace-label { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-spotlight { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.search-spotlight .global-search { flex: 1; min-width: 0; width: auto; max-width: none; height: 38px; border: 0; background: transparent; box-shadow: none; }
.search-spotlight:focus-within { border-color: var(--accent-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), 0 12px 36px #0004; }
.search-spotlight.has-search:not(:focus-within) { border-color: var(--line-strong); background: var(--surface); }
.search-location { flex: none; margin-right: 8px; border-left: 1px solid var(--line); }
.search-location select { max-width: 120px; padding: 6px; border: 0; color: var(--ink-2); background: transparent; font-size: 12px; }
.search-spotlight-scrim { position: fixed; z-index: 65; inset: 0; background: color-mix(in srgb, var(--shell) 48%, transparent); animation: fade-in .15s both; }
.search-focused .topbar { z-index: 70; }
.search-focused .topbar-left, .search-focused .topbar-actions { opacity: .45; }
.notifications-panel { inset: 76px auto auto calc(var(--sidebar-width) + 12px); }
.library-screen { position: relative; display: flex; flex-direction: column; min-height: calc(100vh - 68px); border-radius: 8px; padding: 22px 24px 48px; }
.library-screen[hidden] { display: none; }
.library-hero { order: 0; }
.library-toolbar { order: 1; margin-top: 18px; padding: 10px 0; }
.campaign-home { order: 3; }
.library-screen > :not(.library-hero):not(.library-toolbar):not(.campaign-home) { order: 3; }
.library-screen > #activeFilters { order: 2; }
.library-crumbs { display: flex; flex-wrap: wrap; margin-bottom: 10px; gap: 3px; font-size: 12px; }
.library-crumbs [aria-current] { color: var(--ink); }
.library-crumbs button { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-title-row { gap: 10px; }
.library-hero h1 { font-size: 22px; }
.library-hero p { font-size: 12px; }
.category-bar { margin: 4px 0 10px; }
.active-filters { margin: 4px 0 12px; }
.library-screen[data-section="campaigns"] :is(#folderMatches, #statusBar, #driveFolders, #driveFilesHeading, #gridSkeleton, #listHeadings, #assetGrid, #renderProgress, #emptyState, #libraryReadOnly) { display: none !important; }
.library-screen[data-section="campaigns"] .library-toolbar { justify-content: flex-end; }
#campaignGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 20px; }
.campaign-project { display: flex; position: relative; flex-direction: column; padding: 0; text-align: left; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.campaign-project:hover { border-color: var(--line-strong); background: var(--surface-2); }
.campaign-project-cover { width: 100%; aspect-ratio: 16 / 9; position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(125deg, var(--surface-2), var(--shell)); overflow: hidden; color: var(--ink-3); }
.campaign-project-cover > svg { width: 24px; height: 24px; }
.campaign-project-cover > span { font-size: 20px; font-weight: 550; max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campaign-project-cover img { width: 100%; height: 100%; object-fit: cover; }
.campaign-project-info { display: grid; gap: 6px; padding: 14px 36px 15px 14px; min-width: 0; }
.campaign-project-info strong { font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campaign-project-info small { font-size: 12px; color: var(--ink-3); }
.campaign-project-open { position: absolute; right: 12px; bottom: 24px; color: var(--ink-3); }
.campaign-project-open svg { width: 14px; height: 14px; }
#campaignNote { margin: 22px 0 14px; color: var(--ink-3); font-size: 12px; }
#campaignGrid.is-list { display: flex; flex-direction: column; gap: 3px; }
.is-list .campaign-project { flex-direction: row; align-items: center; border-color: transparent; background: transparent; }
.is-list .campaign-project:hover { background: var(--surface); }
.is-list .campaign-project-cover { width: 76px; height: 48px; margin: 8px; border-radius: 4px; flex: none; }
.is-list .campaign-project-cover > span { display: none; }
.is-list .campaign-project-info { flex: 1; }
.is-list .campaign-project-open { position: static; padding: 0 20px; }
.drive-folder { min-height: 62px; border-radius: 6px; }
@media (min-width: 981px) {
  .navigation-hidden .main-content { margin-left: 64px; }
  .navigation-hidden .selection-bar { left: calc(50% + 32px); max-width: calc(100vw - 96px); }
  .navigation-hidden .notifications-panel { left: 76px; }
}
@media (max-width: 980px) {
  .navigation-toggle { display: none; }
  .notifications-panel { left: 14px; right: auto; }
}
@media (max-width: 1280px) { .workspace-label { display: none; } }
@media (max-width: 760px) {
  .navigation-toggle { display: none; }
  .library-screen { padding: 18px 14px 36px; }
  .topbar { display: flex; padding: 8px 12px; gap: 10px; }
  .topbar-left { flex: 1; }
  .search-spotlight { display: none; }
  .mobile-search-open .topbar-left { flex: none; }
  .mobile-search-open .search-spotlight { display: flex; flex: 1; }
  .mobile-search-open .search-location select { max-width: 105px; }
  .search-location { display: none; }
  .mobile-search-open .search-location { display: block; }
  .library-hero { gap: 12px; }
  .library-headline { flex-basis: 100%; }
  .view-actions { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; width: 100%; gap: 6px; }
  .view-actions .filter-button { padding-inline: 9px; }
  .view-actions .sort-control { min-width: 0; width: auto; }
  .view-actions .sort-control select { min-width: 0; width: 100%; text-overflow: ellipsis; }
  #campaignGrid { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
}

/* One view menu owns layout and grid appearance. */
.view-options { display: flex; gap: 6px; }
.view-options button { display: flex; flex: 1; justify-content: center; align-items: center; gap: 6px; min-height: 36px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-2); background: var(--bg); cursor: pointer; font-size: 12px; }
.view-options button.active { color: var(--ink); background: var(--surface-3); border-color: var(--line-strong); }
.view-options svg { width: 15px; height: 15px; }
.grid-appearance { display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.filter-markets { margin: 0 24px 16px; border-top: 1px solid var(--line); }
.filter-markets summary { display: flex; gap: 8px; align-items: center; padding: 12px 0; font-size: var(--text-md); font-weight: 600; cursor: pointer; list-style: none; }
.filter-markets summary::-webkit-details-marker { display: none; }
.filter-markets summary svg { width: 14px; height: 14px; }
.filter-markets[open] summary svg { transform: rotate(90deg); }
.filter-markets .market-preferences { width: auto; padding: 0 0 8px 22px; }
.filter-markets p { color: var(--ink-3); font-size: 12px; line-height: 1.5; }
#filterForm .filter-location-options { padding-inline: 24px; }
.library-heading-actions:has(> [hidden]:only-child) { display: none; }
/* Folder creation shares the primary action, without another header row. */
.library-create-actions { display: flex; gap: 1px; }
.create-options { position: relative; }
.create-options summary { list-style: none; padding-inline: 9px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.create-options summary::-webkit-details-marker { display: none; }
.create-options summary svg { width: 13px; height: 13px; transform: rotate(90deg); }
.library-create-actions:has(.create-options:not([hidden])) > .button { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.create-options .appearance-popover { width: 170px; padding: 6px; }
.create-options .appearance-popover button { justify-content: flex-start; }
@media (max-width: 760px) { .mobile-search-open #libraryCreateActions { display: none; } }
.active-filters:empty { display: none; }
.card-status-menu { position: fixed; inset: auto; margin: 0; width: 240px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; color: var(--ink); }
.card-status-menu button > svg { width: 14px; height: 14px; color: var(--ink-3); }
.card-status-menu button:focus-visible { outline-offset: -2px; background: var(--surface-3); }
@media (prefers-reduced-motion: reduce) { .search-spotlight, .search-spotlight-scrim { transition: none; animation: none; } }

/* ================================ Sidebar ================================
   One spacing system for every row: 34px items, 10px inset, 16px icons,
   10px icon gap, 2px between rows and 20px between sections. */
.sidebar { --nav-inset: 10px; padding: 16px 12px 12px; gap: 0; border-right: 1px solid var(--line); }
.workspace-switcher { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; min-height: 36px; padding: 0 4px 0 6px; margin-bottom: 16px; }
.workspace-switcher .brand-mark { width: 28px; height: 28px; }
.workspace-switcher strong { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.workspace-switcher .stage-badge { margin: 0; }

.sidebar-primary, .tool-nav { display: grid; flex: none; gap: 2px; }
/* The tree's bottom padding and this margin keep a 20px section gap. */
.tool-nav { margin-top: 8px; padding-bottom: 8px; }
.tool-nav[hidden] { display: none; }
.sidebar-navigation { display: flex; flex: 0 1 auto; flex-direction: column; min-height: 0; margin-top: 20px; overflow-y: auto; scrollbar-width: thin; }

.sidebar .browse-value { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 34px; padding: 0 8px 0 var(--nav-inset); border-radius: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.sidebar .browse-value > span { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar .browse-value > span > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .browse-value svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.sidebar .browse-value:hover svg, .sidebar .browse-value.active svg { color: var(--ink); }
.sidebar .browse-value.active { color: var(--ink); background: var(--surface-3); font-weight: 600; }
.sidebar .browse-value:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
/* Counts that ask for action share one pill. */
.sidebar .browse-value > b { min-width: 18px; padding: 1px 6px; border-radius: 999px; color: var(--accent-ink); background: var(--accent); font-size: 10px; font-weight: 700; line-height: 14px; text-align: center; }

.sidebar .browse-title { display: flex; align-items: center; justify-content: space-between; min-height: 28px; padding: 0 4px 0 var(--nav-inset); margin-bottom: 2px; }
.sidebar .browse-title > span { font-size: 11px; letter-spacing: .06em; }
.sidebar .browse-title .icon-button { width: 24px; height: 24px; opacity: 0; transition: opacity .15s, background .15s; }
.sidebar .browse-title .icon-button svg { width: 14px; height: 14px; }
.folder-navigation:is(:hover, :focus-within) .browse-title .icon-button { opacity: 1; }
@media (hover: none) { .sidebar .browse-title .icon-button { opacity: 1; } }

/* Tree chevrons share the nav icon column, so labels line up with the links above. */
.folder-tree-row { display: flex; gap: 6px; align-items: center; min-height: 32px; padding: 0 8px 0 calc(var(--nav-inset) - 2px + var(--depth) * 16px); border-radius: 6px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.tree-chevron { display: grid; place-items: center; width: 20px; height: 24px; flex: none; border-radius: 4px; }

.sidebar-footer { position: relative; flex: none; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.profile-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px 6px 6px; border: 0; border-radius: 6px; color: var(--ink-2); background: transparent; text-align: left; cursor: pointer; }
.profile-row:hover, .profile-row[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }
.profile-row:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.profile-row .avatar { width: 28px; height: 28px; }
.profile-text { display: grid; flex: 1; min-width: 0; }
.profile-text :is(strong, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text strong { color: var(--ink); font-size: 13px; font-weight: 600; }
.profile-text small { color: var(--ink-3); font-size: 11px; }
.profile-more { width: 16px; height: 16px; flex: none; color: var(--ink-3); }

.profile-menu { position: absolute; z-index: 50; left: 0; right: 0; bottom: calc(100% + 6px); display: grid; gap: 2px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.profile-menu[hidden] { display: none; }
.profile-menu hr { height: 1px; margin: 4px 2px; border: 0; background: var(--line); }
.profile-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 0 8px; border: 0; border-radius: 5px; color: var(--ink-2); background: transparent; font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.profile-menu-item:hover, .profile-menu-item:focus-visible { outline: none; color: var(--ink); background: var(--surface-3); }
.profile-menu-item[hidden] { display: none; }
.profile-menu-item svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.profile-menu .app-version { display: block; padding: 6px 8px 2px; color: var(--ink-3); font-size: 10px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.profile-menu .app-version[hidden] { display: none; }

@media (min-width: 981px) {
  .navigation-hidden .sidebar { width: 64px; padding-inline: 10px; }
  .navigation-hidden .workspace-switcher { grid-template-columns: 28px; justify-content: center; padding: 0; }
  .navigation-hidden .sidebar :is(.workspace-switcher > div, .sidebar-navigation, .browse-title, .browse-value > span > span, .profile-text, .profile-more, #sidebarResize) { display: none; }
  .navigation-hidden .tool-nav { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
  .navigation-hidden .sidebar .browse-value { position: relative; justify-content: center; min-height: 40px; padding: 0; }
  .navigation-hidden .sidebar .browse-value svg { width: 18px; height: 18px; }
  .navigation-hidden .sidebar .browse-value > b { position: absolute; top: 3px; right: 3px; min-width: 16px; padding: 0 4px; font-size: 9px; }
  .navigation-hidden .profile-row { justify-content: center; padding: 6px 0; }
  .navigation-hidden .profile-menu { left: 0; right: auto; width: 220px; }
}
@media (max-width: 760px) {
  .folder-tree-row, .sidebar .browse-value { min-height: 40px; }
}
