/* Shared Vault page canvas and the grouped sidebar's light/dark surfaces. */
:root {
  --vault-canvas:var(--sorty-neutral-canvas); --sp-bg:var(--vault-canvas);
  --pill-track:#2b2b2b; --pill-fill:#2d2d2d; --pill-edge:#424242;
  --vault-collection-elevation:drop-shadow(0 16px 28px #0009) drop-shadow(0 4px 8px #0006);
  --vault-collection-edge:#ffffff24;
}
html { background:var(--vault-canvas); }
:is(#vault-sidebar-shell,#library-rail,#rail-brand-panel,#vault-account-menu) {
  --sidebar-canvas:var(--vault-canvas);
  --sidebar-surface:#1c1c1e;
  --sidebar-hover:var(--sorty-neutral-highlight);
  --sidebar-text:#fff;
  --sidebar-muted:#a1a1a6;
  --sidebar-separator:#38383a;
  --sidebar-control-surface:#1c1c1e;
  --sidebar-control-shadow:0 1px 4px #0003;
  --sidebar-account-inset:#2c2c2e;
  --sp-panel:var(--sidebar-surface);
  --sp-raised:var(--sidebar-hover);
  --sp-text:var(--sidebar-text);
  --sp-muted:var(--sidebar-muted);
  --sp-border:var(--sidebar-separator);
}
@media(prefers-color-scheme:light) {
  :root {
    --pill-track:#f2f2f7; --pill-fill:#fff; --pill-edge:#d8d8dc;
    --vault-collection-elevation:drop-shadow(0 16px 28px #00000024) drop-shadow(0 4px 8px #00000014);
    --vault-collection-edge:#00000014;
  }
  :is(#vault-sidebar-shell,#library-rail,#rail-brand-panel,#vault-account-menu) {
    --sidebar-surface:#fff;
    --sidebar-text:#1c1c1e;
    --sidebar-muted:#68686e;
    --sidebar-separator:#e5e5ea;
    --sidebar-control-surface:#fff;
    --sidebar-control-shadow:0 1px 4px #00000012;
    --sidebar-account-inset:#f2f2f7;
  }
}
body.has-library-sidebar #vault-sidebar-shell {
  position:fixed; top:18px; bottom:18px; left:var(--library-gutter); width:var(--library-width);
  display:flex; flex-direction:column; gap:12px; padding:0; box-sizing:border-box;
  border-radius:0; background:transparent; color:var(--sidebar-text); z-index:40;
  font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",sans-serif;
}
body.has-library-sidebar:not(.sidebar-collapsed) #library-brand-header {
  position:static; width:100%; height:64px; flex:0 0 64px; padding:12px;
  border:0; border-radius:16px; background:var(--sidebar-surface); box-shadow:none; color:var(--sidebar-text);
}
body.has-library-sidebar:not(.sidebar-collapsed) #library-sidebar {
  position:static; flex:1; width:100%; height:auto; min-height:0; padding:0; border:0;
  background:transparent; border-radius:0; box-shadow:none; overflow:hidden;
}
#library-sidebar > .library-panel-scroll {
  display:flex; flex-direction:column; width:100%; margin:0; padding:0; min-height:0;
  overflow:auto; scrollbar-gutter:auto; scrollbar-width:thin;
}
#library-sidebar nav { display:flex; flex-direction:column; gap:12px; flex:0 0 auto; min-height:0; }
#library-sidebar [data-library-view=watchlist] {
  display:flex; align-items:center; gap:9px; min-height:40px; flex:0 0 40px; padding:6px 10px;
  border:0; border-radius:14px; background:var(--sidebar-surface); color:var(--sidebar-text);
  font-family:inherit; font-size:13px; font-weight:500;
}
#library-sidebar [data-library-view=watchlist]:hover { background:var(--sidebar-hover); }
#library-sidebar [data-library-view=watchlist][aria-current=page] { background:var(--sidebar-surface); color:var(--sidebar-text); font-weight:650; }
.sidebar-watchlist-symbol { display:grid; place-items:center; width:26px; height:26px; border-radius:7px; background:linear-gradient(#a67bff,#8054e8); color:#fff; }
.sidebar-watchlist-symbol svg { width:18px; height:18px; }
.sidebar-row-chevron { margin-left:auto; color:var(--sidebar-muted); font-size:20px; font-weight:400; }
#library-sidebar .sidebar-collection { display:flex; flex-direction:column; flex:0 0 auto; min-height:0; gap:5px; --sidebar-project-row-height:38px; }
#library-sidebar .sidebar-collection h2 { margin:0 8px; color:var(--sidebar-text); font-size:12px; font-weight:500; line-height:18px; letter-spacing:0; text-transform:none; }
.sidebar-collection-panel { flex:0 0 auto; min-height:0; overflow:auto; border-radius:16px; background:var(--sidebar-surface); padding:0; }
#sidebar-ideas-panel { display:flex; flex-direction:column; }
#sidebar-projects { flex:0 0 auto; min-height:calc(5 * var(--sidebar-project-row-height)); }
#sidebar-production-panel { height:calc(6 * var(--sidebar-project-row-height)); }
#library-sidebar .sidebar-project { position:relative; display:flex; align-items:center; gap:4px; box-sizing:border-box; height:var(--sidebar-project-row-height,38px); padding:8px; }
#library-sidebar .sidebar-project + .sidebar-project::before { content:""; position:absolute; top:0; left:37px; right:8px; height:1px; background:var(--sidebar-separator); }
#library-sidebar .sidebar-project-box { display:flex; align-items:center; flex:1; min-width:0; gap:2px; padding:0; border:0; border-radius:0; background:transparent; }
#library-sidebar .sidebar-project-box .sidebar-project-trigger { flex:1; min-width:0; width:auto; height:24px; padding:0; border:0; border-radius:0; background:transparent; color:var(--sidebar-text); font-family:inherit; font-size:12px; font-weight:500; gap:7px; }
#library-sidebar .sidebar-project-trigger[aria-current=page] { font-weight:700; }
#library-sidebar .sidebar-project-trigger .sidebar-project-folder-icon {
  display:grid; place-items:center; flex:0 0 22px; width:22px; height:22px;
  min-width:22px; min-height:22px; box-sizing:border-box; overflow:hidden;
  border-radius:6px; background:linear-gradient(#51adff,#007aff); color:#fff;
}
#library-sidebar .sidebar-project-folder-icon svg {
  display:block; flex:none; width:14px; height:14px; padding:0; color:inherit;
}
#library-sidebar .sidebar-project-trigger .sidebar-project-name {
  flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#library-sidebar .sidebar-project:is(:hover,:has(.sidebar-project-trigger[aria-current=page])) { background:var(--sidebar-hover); }
#library-sidebar .sidebar-project:is(:hover,:has(.sidebar-project-trigger[aria-current=page]))::before,
#library-sidebar .sidebar-project:is(:hover,:has(.sidebar-project-trigger[aria-current=page])) + .sidebar-project::before { background:transparent; }
/* Reserve identical control geometry in every row so hover and selection
   only change the surfaces, without shifting the icon centers. */
#library-sidebar .sidebar-project-platforms {
  --icon-size:22px; --icon-gap:2px; --platform-index:0;
  position:relative; display:flex; align-items:center; flex:none; gap:var(--icon-gap); padding:4px 6px;
  border-radius:999px; background:transparent;
}
#library-sidebar .sidebar-project-platforms:has(>button:nth-child(2)[aria-pressed=true]) { --platform-index:1; }
#library-sidebar .sidebar-project-platforms:has(>button:nth-child(3)[aria-pressed=true]) { --platform-index:2; }
#library-sidebar .sidebar-project-platforms:has(>[aria-pressed=true])::before {
  content:""; position:absolute; pointer-events:none; left:6px; top:4px;
  width:var(--icon-size); height:var(--icon-size); border-radius:50%;
  background:color-mix(in srgb,var(--sidebar-surface) 80%,var(--sidebar-text));
  transform:translateX(calc((var(--icon-size) + var(--icon-gap)) * var(--platform-index)));
}
@media(prefers-reduced-motion:no-preference) {
  #library-sidebar .sidebar-project-platforms::before { transition:transform 220ms cubic-bezier(.22,1,.36,1); }
}
#library-sidebar .sidebar-project-platform {
  position:relative; display:grid; place-items:center; flex:0 0 var(--icon-size); width:var(--icon-size); height:var(--icon-size);
  padding:3px; border:0; border-radius:50%; background:transparent; color:var(--sidebar-muted);
}
#library-sidebar .sidebar-project-platform svg { display:block; width:13px; height:13px; }
/* An even viewport avoids the Instagram glyph's half-pixel raster offset. */
#library-sidebar .sidebar-project-platform[data-project-platform=IG] svg { width:14px; height:14px; }
#library-sidebar .sidebar-project-platform:is(:hover,:focus-visible,[aria-pressed=true]) {
  background:transparent; color:var(--sidebar-text); border:0;
}
#library-sidebar .sidebar-project-platform:focus-visible:not([aria-pressed=true]) { background:var(--sidebar-hover); }
#library-sidebar .sidebar-project-settings {
  display:grid; place-items:center; position:static; flex:0 0 30px; width:30px; height:30px;
  padding:7px; border:0; border-radius:50%; background:transparent; color:var(--sidebar-muted);
}
#library-sidebar .sidebar-project:is(:hover,:focus-within,:has(.sidebar-project-trigger[aria-current=page])) :is(.sidebar-project-platforms,.sidebar-project-settings) {
  background:var(--sidebar-control-surface); box-shadow:var(--sidebar-control-shadow);
}
#library-sidebar .sidebar-project-settings:is(:hover,:focus-visible) {
  background:color-mix(in srgb,var(--sidebar-surface) 80%,var(--sidebar-hover)); color:var(--sidebar-text);
}
#library-sidebar .sidebar-project-arrow { display:none; }
#library-sidebar .sidebar-project-footer { display:flex; align-items:center; flex:0 0 38px; min-height:38px; margin-top:auto; border-radius:0 0 16px 16px; }
#library-sidebar #sidebar-new-project { flex:0 1 auto; min-width:0; width:auto; height:28px; min-height:28px; margin-left:4px; padding:5px 8px; border:0; border-radius:999px; color:var(--sidebar-text); background:transparent; font-family:inherit; font-size:11px; line-height:18px; }
#library-sidebar #sidebar-new-project:hover { background:var(--sidebar-hover); }
#library-sidebar #sidebar-new-project { display:inline-flex; align-items:center; gap:6px; }
#library-sidebar #sidebar-new-project > svg { display:block; flex:none; width:15px; height:15px; }
#library-sidebar .sidebar-project-footer > [hidden] { display:none !important; }
#library-sidebar .sidebar-project-footer.is-adding { display:block; flex:0 0 auto; min-height:38px; padding:3px 8px; box-sizing:border-box; }
#library-sidebar .sidebar-inline-create { display:grid; grid-template-columns:18px minmax(0,1fr) 24px 24px; align-items:center; gap:6px; width:100%; min-width:0; margin:0; }
#library-sidebar .sidebar-inline-folder { display:grid; place-items:center; color:var(--sidebar-muted); }
#library-sidebar .sidebar-inline-folder svg { width:18px; height:18px; }
#library-sidebar .sidebar-inline-create input {
  width:100%; min-width:0; height:32px; padding:6px 8px; border:1px solid var(--sidebar-separator); border-radius:8px;
  background:var(--sidebar-hover); color:var(--sidebar-text); caret-color:var(--sidebar-text); font-family:inherit; font-size:12px; font-weight:400; line-height:18px;
}
#library-sidebar .sidebar-inline-create input::placeholder { color:var(--sidebar-muted); }
#library-sidebar .sidebar-inline-create input:focus { border-color:var(--sidebar-muted); outline:none; box-shadow:none; }
#library-sidebar .sidebar-inline-create input[aria-invalid=true] { border-color:var(--sorty-button-danger); }
#library-sidebar .sidebar-inline-create button {
  display:grid; place-items:center; width:24px; height:24px; min-height:24px; padding:5px; border:0; border-radius:50%;
  background:var(--sidebar-hover); color:var(--sidebar-text);
}
#library-sidebar .sidebar-inline-create button[type=submit] { background:var(--sidebar-text); color:var(--sidebar-surface); }
#library-sidebar .sidebar-inline-create button svg { width:14px; height:14px; }
#library-sidebar .sidebar-inline-create button:disabled { opacity:.35; cursor:not-allowed; }
#library-sidebar .sidebar-inline-create button:focus-visible { outline:2px solid var(--sidebar-muted); outline-offset:2px; }
#library-sidebar .sidebar-inline-create [role=alert] { grid-column:2 / -1; margin:0; color:var(--sorty-button-danger); font-size:11px; line-height:16px; overflow-wrap:anywhere; }
#sidebar-project-pagination { display:flex; align-items:center; flex:0 0 auto; margin-left:auto; }
#library-sidebar .sidebar-project-pager { height:28px; padding:0 6px 0 0; gap:4px; font-size:10px; }
#library-sidebar .sidebar-project-pager button { display:grid; place-items:center; width:24px; height:24px; padding:4px; border:0; border-radius:50%; background:transparent; color:var(--sidebar-text); }
#library-sidebar .sidebar-project-pager button svg { display:block; width:14px; height:14px; }
#library-sidebar .sidebar-project-pager button:hover:not(:disabled) { background:var(--sidebar-hover); }
#library-sidebar .sidebar-project-pager button:disabled { opacity:.35; cursor:default; background:transparent; }
#library-sidebar .sidebar-project-pager > span { min-width:30px; text-align:center; font-variant-numeric:tabular-nums; }
#library-sidebar .sidebar-project-menu { border-color:var(--sidebar-separator); background:var(--sidebar-surface); color:var(--sidebar-text); }
#library-sidebar .sidebar-project-menu button:hover { color:var(--sidebar-text); background:var(--sidebar-hover); }
#library-sidebar .sidebar-visually-hidden { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
body.has-library-sidebar:not(.sidebar-collapsed) #vault-sidebar-footer {
  position:static; display:grid; grid-template-columns:50px minmax(0,1fr); align-items:center; gap:7px;
  width:100%; height:72px; flex:0 0 72px; padding:11px 16px 11px 18px; border:0; border-radius:22px;
  background:var(--sidebar-surface); color:var(--sidebar-text); box-shadow:none;
}
#vault-sidebar-footer #vault-account-menu-button { display:none; }
#vault-sidebar-footer .sidebar-account-avatar {
  display:grid; place-items:center; width:50px; height:50px; border-radius:50%;
  background:var(--sidebar-account-inset); color:var(--sidebar-muted); text-decoration:none;
}
#vault-sidebar-footer .sidebar-account-avatar:has(> #sidebar-account-photo[hidden])::before {
  content:""; width:100%; height:100%; border-radius:inherit;
  background:url('/assets/default-instagram-profile.jpeg') center / cover no-repeat;
}
#vault-sidebar-footer #sidebar-account-photo { display:block; width:100%; height:100%; border-radius:inherit; object-fit:cover; }
#vault-sidebar-footer #sidebar-account-photo[hidden] { display:none; }
#vault-sidebar-footer .sidebar-account-content { display:grid; grid-template-columns:minmax(0,1fr) 22px; align-items:center; gap:2px 6px; min-width:0; }
#vault-sidebar-footer #sidebar-account-name { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--sidebar-text); text-decoration:none; font-size:10px; font-weight:600; line-height:12px; }
#vault-sidebar-footer #sidebar-account-plan { grid-column:2; grid-row:1; justify-self:center; padding:1px 4px; border-radius:999px; background:var(--sidebar-account-inset); color:var(--sidebar-text); font-size:7px; line-height:10px; }
#vault-sidebar-footer .sidebar-account-actions { grid-column:1 / -1; display:flex; align-items:center; gap:3px; }
#vault-sidebar-footer .sidebar-account-actions > :is(a,button) {
  display:grid; place-items:center; flex:0 0 22px; width:22px; height:22px; min-height:22px;
  margin:0; padding:5px; border:0; border-radius:7px; background:var(--sidebar-account-inset);
  color:var(--sidebar-text); text-decoration:none; cursor:pointer; box-sizing:border-box;
}
#vault-sidebar-footer .sidebar-account-actions > [hidden],#vault-sidebar-footer > [hidden] { display:none !important; }
#vault-sidebar-footer .sidebar-account-actions #sidebar-collapse { flex:0 0 22px; width:22px; height:22px; padding:5px; margin-left:auto; }
#vault-sidebar-footer .sidebar-account-actions svg { display:block; flex:none; width:12px; height:12px; }
#vault-sidebar-footer :is(a,button):focus-visible { outline:2px solid var(--sidebar-muted); outline-offset:2px; }
#vault-sidebar-footer #sidebar-account-name:hover { text-decoration:underline; text-underline-offset:2px; }
#vault-sidebar-footer #sidebar-account-sign-out:hover { background:color-mix(in srgb,var(--sidebar-surface) 88%,var(--sorty-button-danger)); color:var(--sorty-button-danger); }
body.has-library-sidebar:not(.sidebar-collapsed) #library-rail { display:none; }
/* Tool and account panels share the dropdown elevation without changing layout. */
#vault-account-menu {
  --sidebar-surface:var(--vault-popover-surface);
  --sidebar-hover:var(--vault-popover-hover);
  --sorty-button-secondary:var(--vault-popover-hover);
}
#vault-account-menu #vault-connection-status { margin:4px 8px 10px; font-size:11px; }
#vault-account-menu {
  width:min(var(--library-expanded-width,295px),calc(100vw - 24px)); box-sizing:border-box; padding:10px;
  border:0; border-radius:14px; background:var(--sidebar-surface); color:var(--sidebar-text);
  box-shadow:var(--vault-popover-shadow); animation:vault-menu-appear 120ms ease-out;
}
#vault-account-menu p { margin:4px 10px 8px; padding-bottom:12px; border-color:var(--sidebar-separator); color:var(--sidebar-muted); }
#vault-account-menu :is(a,button) { border-radius:8px; }
#vault-account-menu :is(a,button):is(:hover,:focus-visible) { background:var(--sidebar-hover); }
#vault-account-menu :is(a,button):focus-visible { outline:2px solid var(--sidebar-muted); outline-offset:-2px; }
#vault-sidebar-shell button:focus-visible, #library-rail button:focus-visible { outline:2px solid var(--sidebar-muted); outline-offset:-2px; }
body.sidebar-collapsed #vault-sidebar-shell { display:contents; }
/* Each collapsed collection opens as its own surface, without a menu shell. */
body.sidebar-collapsed #library-sidebar {
  width:min(var(--library-expanded-width),calc(100vw - 24px)); height:auto; min-height:0; max-height:calc(100dvh - 24px);
  padding:0; background:transparent; border:0; border-radius:16px; box-shadow:none;
}
body.sidebar-collapsed #library-sidebar > .library-panel-scroll { overflow:auto; padding:0; }
body.sidebar-collapsed #library-sidebar :is(h2,[data-library-view],#sidebar-location) { display:none; }
body.sidebar-collapsed #library-sidebar:not([data-collection=production]) .sidebar-collection:has(#sidebar-production-panel),
body.sidebar-collapsed #library-sidebar[data-collection=production] .sidebar-collection:has(#sidebar-ideas-panel) { display:none; }
body.sidebar-collapsed #library-sidebar .sidebar-collection-panel { flex:none; }
/* The wrapper follows the card's alpha, so its shadow stays visible beyond
   the scrolling surface without adding another background or outer padding. */
body.sidebar-collapsed #library-sidebar[popover] {
  opacity:0; pointer-events:none; filter:var(--vault-collection-elevation); animation:none;
}
body.sidebar-collapsed #vault-account-menu[popover] { opacity:0; pointer-events:none; animation:none; }
body.sidebar-collapsed #library-sidebar[popover][data-collection],
body.sidebar-collapsed #vault-account-menu[popover] {
  transition:opacity 180ms ease,display 180ms allow-discrete,overlay 180ms allow-discrete;
}
body.sidebar-collapsed #library-sidebar[popover]:popover-open,
body.sidebar-collapsed #vault-account-menu[popover]:popover-open { opacity:1; pointer-events:auto; }
body.sidebar-collapsed #library-sidebar[popover] .sidebar-collection-panel { box-shadow:inset 0 0 0 1px var(--vault-collection-edge); }
/* Keep the native popover in the top layer until its exit fade is finished. */
@starting-style {
  body.sidebar-collapsed #library-sidebar[popover]:popover-open,
  body.sidebar-collapsed #vault-account-menu[popover]:popover-open { opacity:0; }
}
@media(prefers-reduced-motion:reduce) {
  body.sidebar-collapsed #library-sidebar[popover][data-collection],
  body.sidebar-collapsed #vault-account-menu[popover] { transition:none; }
}
body.sidebar-collapsed #library-rail { overflow-y:auto; scrollbar-width:none; }
body.sidebar-collapsed #library-rail > button { flex:0 0 44px; }
body.sidebar-collapsed #library-rail > button[aria-current=page] { background:var(--sidebar-hover); color:var(--sidebar-text); }
/* Short and zoomed windows still fit all five navigation/account controls. */
@media(max-height:380px) {
  body.sidebar-collapsed { --collapsed-rail-button-size:clamp(28px,calc((100dvh - 92px) / 5),44px); }
  body.sidebar-collapsed #library-brand-header { top:10px; height:44px; }
  body.sidebar-collapsed #library-rail { top:64px; bottom:12px; gap:4px; }
  body.sidebar-collapsed #library-rail > button { width:var(--collapsed-rail-button-size); height:var(--collapsed-rail-button-size); flex-basis:var(--collapsed-rail-button-size); padding:0; }
}
body.sidebar-collapsed #library-brand-header { color:var(--sidebar-text); }
#library-rail button { border:0; background:var(--sidebar-surface); color:var(--sidebar-text); }
#library-rail button:is(:hover,[aria-expanded=true]) { background:var(--sidebar-hover); color:var(--sidebar-text); }
@media(prefers-reduced-motion:reduce) { #vault-account-menu { animation:none; } }

/* Folder actions use the same neutral surfaces as the grouped sidebar. */
:is(.vault-project-dialog,.project-create-popout) {
  --sp-panel:#1c1c1e; --sp-raised:#2c2c2e; --sp-text:#f5f5f7;
  --sp-muted:#a1a1a6; --sp-border:#38383a;
  --sorty-field-bg:var(--sp-raised); --sorty-field-text:var(--sp-text);
  --sorty-field-muted:var(--sp-muted); --sorty-field-border:var(--sp-border);
  --sorty-field-accent:var(--sp-muted); --sorty-field-ring:#ffffff14;
  border:0; background:var(--sp-panel); color:var(--sp-text);
  box-shadow:var(--vault-popover-shadow);
}
.vault-project-dialog :focus-visible { outline-color:var(--sp-muted); }
.vault-project-dialog .vault-dialog-error { color:var(--sorty-button-danger); }
@media(prefers-color-scheme:light) {
  :is(.vault-project-dialog,.project-create-popout) {
    --sp-panel:#fff; --sp-raised:#f2f2f7; --sp-text:#1c1c1e;
    --sp-muted:#68686e; --sp-border:#d1d1d6; --sorty-field-ring:#0000000a;
  }
}
