/* ==========================================================================
   Print Vault — Liquid Glass design system
   Palette and material rules come from docs/DESIGN.md; this file is the
   single stylesheet for the whole web UI (no build step, no CSS imports).
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Palette */
  --canvas: #12141a;
  --accent: #19c2b2;
  --accent-deep: #0e7f76;
  --selection: #8b87d6;
  --warning: #ffb340;
  --error: #ff5a5f;
  --success: #30d158;
  --text: #ebebf5;
  --text-secondary: rgba(235, 235, 245, 0.7);
  --text-tertiary: rgba(235, 235, 245, 0.4);
  --hairline: rgba(255, 255, 255, 0.13);
  --glass-bg: rgba(30, 32, 40, 0.55);
  --glass-grey: rgba(154, 160, 184, 0.14);
  --smoke: rgba(20, 20, 24, 0.46);
  --bar-blue: #0a84ff;
  --bar-red: #ff453a;

  /* Motion — springs only */
  --spring: 320ms cubic-bezier(.2, .9, .25, 1.15);

  /* Shape & material */
  --radius-card: 20px;
  --radius-panel: 26px;
  --radius-pill: 999px;
  --shadow-glass: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.42);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--canvas);
  /* Ambient colour so the glass has something rich to refract. */
  background-image: radial-gradient(
      1100px 740px at 8% -14%,
      rgba(25, 194, 178, 0.18),
      rgba(25, 194, 178, 0) 62%
    ),
    radial-gradient(
      980px 700px at 102% 2%,
      rgba(139, 135, 214, 0.16),
      rgba(139, 135, 214, 0) 60%
    ),
    radial-gradient(
      900px 640px at 46% 118%,
      rgba(10, 132, 255, 0.12),
      rgba(10, 132, 255, 0) 68%
    );
  background-repeat: no-repeat;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid rgba(25, 194, 178, 0.8);
  outline-offset: 2px;
}

::selection {
  background: rgba(25, 194, 178, 0.35);
  color: var(--text);
}

/* Thin, unobtrusive scrollbars that still read on glass. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------------------------------------------------------- Material */

.glass-panel,
.glass-pill,
.glass-button {
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  background: var(--glass-bg);
  border: 1px solid var(--hairline);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.42);
}

.glass-panel {
  border-radius: var(--radius-panel);
}

.glass-pill {
  border-radius: var(--radius-pill);
}

.glass-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease,
    transform var(--spring), box-shadow var(--spring);
}

.glass-button:hover {
  background: rgba(154, 160, 184, 0.24);
}

.glass-button:active {
  transform: scale(0.97);
}

.glass-button:disabled {
  cursor: default;
  opacity: 0.5;
}

/* Icons from js/icons.js */
.pv-icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.18em;
  pointer-events: none;
}

/* ------------------------------------------------------------------ Login */

.login-screen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(400px, 100%);
  padding: 32px 30px 28px;
  border-radius: var(--radius-panel);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  background: var(--glass-bg);
  border: 1px solid var(--hairline);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.42);
  animation: pv-bud-in var(--spring) both;
}

.login-logo {
  display: grid;
  place-items: center;
  align-self: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  color: var(--accent);
  font-size: 30px;
  background: radial-gradient(
      120% 120% at 28% 18%,
      rgba(25, 194, 178, 0.32),
      rgba(30, 32, 40, 0.4) 68%
    ),
    var(--glass-grey);
  border: 1px solid rgba(25, 194, 178, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 30px rgba(25, 194, 178, 0.18);
}

.login-title {
  font-size: 24px;
  font-weight: 640;
  letter-spacing: -0.02em;
  text-align: center;
}

.login-sub {
  margin-top: -8px;
  font-size: 13.5px;
  text-align: center;
  color: var(--text-secondary);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group > label {
  padding-left: 2px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
}

.glass-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  background: var(--glass-grey);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  appearance: none;
  transition: border-color 180ms ease, box-shadow 180ms ease,
    background-color 180ms ease;
}

.glass-input::placeholder {
  color: var(--text-tertiary);
}

.glass-input:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.glass-input:focus {
  border-color: rgba(25, 194, 178, 0.7);
  background: rgba(154, 160, 184, 0.18);
  box-shadow: 0 0 0 3px rgba(25, 194, 178, 0.16);
}

textarea.glass-input {
  min-height: 86px;
  resize: vertical;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(25, 194, 178, 0.55);
  background: linear-gradient(180deg, #21d3c1, var(--accent-deep));
  color: #052421;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: 0.005em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 10px 26px rgba(25, 194, 178, 0.24);
  transition: transform var(--spring), filter 180ms ease,
    box-shadow var(--spring);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  cursor: default;
  filter: none;
  opacity: 0.55;
}

.login-error {
  min-height: 1.2em;
  margin: -4px 0 0;
  font-size: 12.5px;
  text-align: center;
  color: var(--error);
}

/* ---------------------------------------------------------- Library shell */

.library-shell {
  position: relative;
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex: 0 0 272px;
  flex-direction: column;
  width: 272px;
  margin: 14px 0 14px 14px;
  border-radius: var(--radius-panel);
  overflow: hidden;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  background: var(--glass-bg);
  border: 1px solid var(--hairline);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.42);
}

.sidebar-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-header .pv-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.sidebar-section {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 8px 10px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease,
    border-color var(--spring), transform var(--spring);
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.sidebar-item.is-active {
  background: rgba(25, 194, 178, 0.16);
  border-color: rgba(25, 194, 178, 0.3);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-item .pv-icon {
  color: var(--text-tertiary);
}

.sidebar-item.is-active .pv-icon {
  color: var(--accent);
}

/* Folder tree rows */
.folder-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 30px;
  padding: 4px 6px 4px calc(4px + var(--depth, 0) * 14px);
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease,
    border-color var(--spring), box-shadow var(--spring);
}

.folder-row:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.folder-row.is-active {
  background: rgba(139, 135, 214, 0.16);
  border-color: rgba(139, 135, 214, 0.32);
  color: var(--text);
}

.folder-row.is-drop-target {
  background: rgba(25, 194, 178, 0.2);
  border-color: rgba(25, 194, 178, 0.6);
  box-shadow: inset 0 0 0 1px rgba(25, 194, 178, 0.35),
    0 0 18px rgba(25, 194, 178, 0.22);
  color: var(--text);
}

.folder-expand-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  transition: transform var(--spring), color 160ms ease,
    background-color 160ms ease;
}

.folder-expand-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.folder-expand-btn .pv-icon {
  width: 12px;
  height: 12px;
}

.folder-expand-btn.is-open {
  transform: rotate(90deg);
}

.folder-row > .pv-icon {
  color: var(--text-tertiary);
}

.folder-row.is-active > .pv-icon,
.folder-row:hover > .pv-icon {
  color: var(--accent);
}

.folder-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  flex: none;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.folder-menu-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-tertiary);
  opacity: 0;
  cursor: pointer;
  transition: opacity 160ms ease, background-color 160ms ease,
    color 160ms ease;
}

.folder-menu-btn:hover,
.folder-menu-btn:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.folder-row:hover .folder-menu-btn,
.folder-row.is-active .folder-menu-btn,
.folder-menu-btn:focus-visible {
  opacity: 1;
}

.new-folder-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: calc(100% - 16px);
  min-height: 34px;
  margin: 4px 8px 8px;
  padding: 0 10px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease,
    background-color 160ms ease;
}

.new-folder-btn:hover {
  border-color: rgba(25, 194, 178, 0.5);
  background: rgba(25, 194, 178, 0.1);
  color: var(--text);
}

/* Tag filter list */
.tag-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease,
    border-color var(--spring);
}

.tag-filter-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.tag-filter-item.is-active {
  background: rgba(25, 194, 178, 0.16);
  border-color: rgba(25, 194, 178, 0.3);
  color: var(--text);
}

.tag-filter-item .pv-icon {
  color: var(--text-tertiary);
}

.tag-count {
  flex: none;
  margin-left: auto;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  border: 0;
  padding: 0;
  background: rgba(10, 11, 14, 0.52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.sidebar-backdrop.is-visible,
.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ------------------------------------------------------- Library main area */

.library-main {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Floating chrome — the grid scrolls underneath, never a solid bar. */
.top-chrome {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 0;
  pointer-events: none;
}

.top-chrome > * {
  pointer-events: auto;
  min-width: 0;
}

.top-left {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.top-center {
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
  margin-inline: auto;
  min-width: 0;
}

.top-right {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.sidebar-toggle-btn {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--glass-grey);
  color: var(--text-secondary);
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  transition: color 160ms ease, background-color 160ms ease,
    transform var(--spring);
}

.sidebar-toggle-btn:hover {
  color: var(--text);
  background: rgba(154, 160, 184, 0.24);
}

.sidebar-toggle-btn:active {
  transform: scale(0.95);
}

.view-title {
  min-width: 0;
  padding: 0 4px;
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

.view-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  width: clamp(140px, 16vw, 230px);
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--glass-grey);
  color: var(--text-tertiary);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  transition: border-color 160ms ease, background-color 160ms ease,
    box-shadow 160ms ease;
}

.search-wrap:focus-within {
  border-color: rgba(25, 194, 178, 0.6);
  background: rgba(30, 32, 40, 0.72);
  box-shadow: 0 0 0 3px rgba(25, 194, 178, 0.14);
}

.search-wrap .pv-icon {
  width: 15px;
  height: 15px;
  flex: none;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.sort-select,
.ext-select {
  width: 112px;
  height: 36px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background-color: var(--glass-grey);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23EBEBF5' stroke-opacity='.55' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  transition: border-color 160ms ease, color 160ms ease,
    background-color 160ms ease;
}

.sort-select:hover,
.ext-select:hover {
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text);
}

.sort-select option,
.ext-select option {
  background: #1b1e26;
  color: var(--text);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(25, 194, 178, 0.45);
  border-radius: var(--radius-pill);
  background: rgba(25, 194, 178, 0.18);
  color: #c8fbf5;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: background-color 160ms ease, border-color 160ms ease,
    transform var(--spring);
}

.upload-btn:hover {
  background: rgba(25, 194, 178, 0.28);
  border-color: rgba(25, 194, 178, 0.7);
}

.upload-btn:active {
  transform: scale(0.97);
}

.logout-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--glass-grey);
  color: var(--text-secondary);
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  transition: color 160ms ease, background-color 160ms ease,
    transform var(--spring);
}

.logout-btn:hover {
  color: var(--text);
  background: rgba(154, 160, 184, 0.24);
}

.logout-btn:active {
  transform: scale(0.95);
}

/* --------------------------------------------------------- Storage pill */

.storage-pill-wrap {
  position: relative;
  display: flex;
  justify-content: center;
}

.storage-pill {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 190px;
  padding: 8px 16px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  text-align: center;
  cursor: default;
  transition: border-color 160ms ease, transform var(--spring);
}

.storage-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.storage-pill-text {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.storage-pill-text strong {
  font-weight: 700;
  color: var(--text);
}

.storage-bar-track {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--bar-blue);
  transition: width var(--spring), background-color var(--spring);
}

.storage-bar-fill.is-critical {
  background: var(--bar-red);
}

.storage-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 224px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: rgba(26, 28, 36, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 44px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  translate: -50% 4px;
  pointer-events: none;
  transition: opacity 180ms ease, translate var(--spring), visibility 0s linear 180ms;
}

.storage-pill-wrap:hover .storage-popover,
.storage-pill-wrap:focus-within .storage-popover,
.storage-pill-wrap.is-open .storage-popover {
  opacity: 1;
  visibility: visible;
  translate: -50% 0;
  pointer-events: auto;
  transition-delay: 0s;
}

.storage-popover .pv-icon {
  color: var(--text-tertiary);
}

/* ------------------------------------------------------- Grid & content */

.library-scroll {
  flex: 1 1 auto;
  min-height: 0;
  /* Top padding clears the floating chrome, which overlays the scrolling grid. */
  padding: 108px 22px 128px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.trash-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 179, 64, 0.3);
  border-radius: 16px;
  background: rgba(255, 179, 64, 0.12);
  color: var(--text);
  font-size: 12.5px;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.trash-banner .pv-icon {
  flex: none;
  color: var(--warning);
}

.trash-banner button {
  margin-left: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46vh;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.empty-state .pv-icon {
  width: 46px;
  height: 46px;
  color: var(--text-tertiary);
}

.empty-state strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  align-items: start;
  gap: 16px;
}

.model-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: rgba(30, 32, 40, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 32px rgba(0, 0, 0, 0.36);
  overflow: hidden;
  transition: box-shadow var(--spring), border-color var(--spring),
    background-color var(--spring);
}

.model-card:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(34, 37, 47, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.46);
}

.model-card.is-selected {
  border-color: var(--selection);
  box-shadow: inset 0 0 0 1px var(--selection),
    0 0 26px rgba(139, 135, 214, 0.35), 0 16px 40px rgba(0, 0, 0, 0.42);
}

.model-card.is-dragging {
  opacity: 0.55;
  transform: scale(0.97);
}

.model-thumb-tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  background: radial-gradient(
      120% 120% at 28% 16%,
      rgba(25, 194, 178, 0.18),
      rgba(30, 32, 40, 0) 62%
    ),
    radial-gradient(
      100% 100% at 80% 88%,
      rgba(139, 135, 214, 0.16),
      rgba(30, 32, 40, 0) 60%
    ),
    rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.model-thumb-img {
  width: 100%;
  height: 100%;
  padding: 14px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.model-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  font-size: 42px;
}

.model-open-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
  cursor: zoom-in;
}

.model-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
}

.model-name {
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.model-size {
  font-variant-numeric: tabular-nums;
}

.model-ext-badge {
  padding: 1px 6px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--glass-grey);
  color: var(--text-secondary);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.tag-chip {
  max-width: 100%;
  padding: 1px 7px;
  border: 1px solid rgba(25, 194, 178, 0.24);
  border-radius: var(--radius-pill);
  background: rgba(25, 194, 178, 0.13);
  color: #8fe8df;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-sentinel {
  grid-column: 1 / -1;
  width: 100%;
  height: 1px;
}

/* ----------------------------------------------------------- Selection bar */

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 8px 10px 8px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: rgba(30, 32, 40, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  opacity: 0;
  pointer-events: none;
  translate: -50% 18px;
  transition: opacity var(--spring), translate var(--spring);
}

.selection-bar.is-visible {
  opacity: 1;
  pointer-events: auto;
  translate: -50% 0;
}

.selection-count {
  flex: none;
  margin-right: 2px;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sel-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--glass-grey);
  color: var(--text);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease,
    transform var(--spring);
}

.sel-btn:hover {
  background: rgba(154, 160, 184, 0.26);
  border-color: rgba(255, 255, 255, 0.22);
}

.sel-btn:active {
  transform: scale(0.96);
}

.sel-btn.is-danger {
  border-color: rgba(255, 90, 95, 0.38);
  background: rgba(255, 90, 95, 0.14);
  color: #ffb9bb;
}

/* ------------------------------------------------------------- Detail sheet */

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--smoke);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: pv-fade-in 220ms ease both;
}

.detail-sheet {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 71;
  display: flex;
  flex-direction: column;
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--hairline);
  border-radius: var(--radius-panel);
  background: rgba(26, 28, 36, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 70px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  overflow: hidden;
  animation: pv-sheet-in var(--spring) both;
}

.detail-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.detail-header h2,
.detail-header h3 {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-viewer-wrap {
  position: relative;
  flex: none;
  height: clamp(220px, 34vh, 320px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: radial-gradient(
      100% 100% at 50% 20%,
      rgba(25, 194, 178, 0.09),
      rgba(30, 32, 40, 0) 70%
    ),
    rgba(12, 13, 18, 0.55);
  overflow: hidden;
}

.detail-viewer-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.detail-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 14px 16px 20px;
  overflow-y: auto;
}

.detail-name-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--glass-grey);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.detail-name-input:focus {
  border-color: rgba(25, 194, 178, 0.65);
  box-shadow: 0 0 0 3px rgba(25, 194, 178, 0.14);
}

.detail-tags-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.detail-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 4px 2px 8px;
  border: 1px solid rgba(25, 194, 178, 0.26);
  border-radius: var(--radius-pill);
  background: rgba(25, 194, 178, 0.14);
  color: #8fe8df;
  font-size: 11px;
  white-space: nowrap;
}

.detail-tag-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 10px;
  cursor: pointer;
  opacity: 0.7;
}

.detail-tag-chip button:hover {
  background: rgba(255, 255, 255, 0.14);
  opacity: 1;
}

.detail-tag-input {
  flex: 1 1 120px;
  min-width: 100px;
  height: 26px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

.detail-tag-input::placeholder {
  color: var(--text-tertiary);
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: -6px;
}

.tag-suggestions button {
  padding: 2px 9px;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease,
    background-color 160ms ease;
}

.tag-suggestions button:hover {
  border-color: rgba(25, 194, 178, 0.5);
  background: rgba(25, 194, 178, 0.1);
  color: var(--text);
}

.detail-notes-input {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--glass-grey);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.detail-notes-input:focus {
  border-color: rgba(25, 194, 178, 0.65);
  box-shadow: 0 0 0 3px rgba(25, 194, 178, 0.14);
}

.detail-source-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--glass-grey);
  color: var(--text-secondary);
  font-size: 12px;
}

.detail-source-card a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  overflow-wrap: anywhere;
  color: var(--accent);
}

.detail-source-card .pv-icon {
  width: 13px;
  height: 13px;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 0;
  font-size: 12px;
}

.detail-meta-grid dt {
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.detail-meta-grid dd {
  margin: 0;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.detail-actions .sel-btn,
.detail-actions .glass-button {
  height: 34px;
}

/* -------------------------------------------------- Drop overlay & uploads */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(18, 20, 26, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drop-overlay::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 2px dashed rgba(25, 194, 178, 0.55);
  border-radius: var(--radius-panel);
  background: rgba(25, 194, 178, 0.06);
  box-shadow: inset 0 0 70px rgba(25, 194, 178, 0.1);
}

.drop-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.drop-overlay > * {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text);
}

.drop-overlay .pv-icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
}

.drop-overlay strong {
  font-size: 18px;
  font-weight: 640;
}

.drop-overlay span {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.upload-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 36px));
  max-height: 46vh;
  border: 1px solid var(--hairline);
  border-radius: 22px;
  background: rgba(26, 28, 36, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 20px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  translate: 0 16px;
  transition: opacity 180ms ease, translate var(--spring);
}

.upload-panel.is-visible {
  opacity: 1;
  pointer-events: auto;
  translate: 0 0;
}

.upload-panel-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12.5px;
  font-weight: 600;
}

.upload-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px 12px 14px;
  overflow-y: auto;
}

.upload-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
}

.upload-item > .name,
.upload-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.upload-item-progress-track {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.upload-item-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 200ms ease, background-color 200ms ease;
}

.upload-item-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.upload-item-status .pv-icon {
  width: 12px;
  height: 12px;
}

.badge-duplicate,
.badge-error,
.badge-skipped,
.badge-done {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: var(--radius-pill);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-duplicate {
  border-color: rgba(255, 179, 64, 0.36);
  background: rgba(255, 179, 64, 0.12);
  color: var(--warning);
}

.badge-error {
  border-color: rgba(255, 90, 95, 0.36);
  background: rgba(255, 90, 95, 0.12);
  color: var(--error);
}

.badge-skipped {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
}

.badge-done {
  border-color: rgba(48, 209, 88, 0.34);
  background: rgba(48, 209, 88, 0.12);
  color: var(--success);
}

/* ------------------------------------------- Context menus, dialogs, organize */

.context-menu {
  position: fixed;
  z-index: 95;
  min-width: 192px;
  max-width: 260px;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: rgba(30, 32, 40, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 44px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  animation: pv-pop-in 180ms ease both;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.context-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.context-menu-item .pv-icon {
  color: var(--text-tertiary);
}

.context-menu-item.is-danger {
  color: var(--error);
}

.context-menu-item.is-danger:hover {
  background: rgba(255, 90, 95, 0.14);
}

.context-menu-item.is-danger .pv-icon {
  color: var(--error);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--smoke);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: pv-fade-in 200ms ease both;
}

.dialog-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(430px, 100%);
  max-height: min(84vh, 720px);
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: 24px;
  background: rgba(26, 28, 36, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 70px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  overflow: hidden;
  animation: pv-pop-in var(--spring) both;
}

.dialog-card h2,
.dialog-card h3 {
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.dialog-card p {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.dialog-card .glass-input {
  font-size: 14px;
}

.folder-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  overflow-y: auto;
}

.folder-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease,
    border-color 140ms ease;
}

.folder-picker-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.folder-picker-item.is-selected {
  border-color: rgba(25, 194, 178, 0.4);
  background: rgba(25, 194, 178, 0.14);
  color: var(--text);
}

.folder-picker-item .pv-icon {
  color: var(--text-tertiary);
}

/* AI organize preview */
.organize-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 98;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(780px, calc(100vw - 32px));
  max-height: min(84vh, 800px);
  padding: 18px 18px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-panel);
  background: rgba(26, 28, 36, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  overflow: hidden;
  translate: -50% -50%;
  animation: pv-bud-in var(--spring) both;
}

.organize-hint-row {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.organize-hint-row .glass-input {
  flex: 1 1 auto;
  min-height: 38px;
  font-size: 13px;
}

.organize-hint-row .primary-btn {
  flex: none;
  min-height: 38px;
  padding: 0 16px;
  font-size: 13px;
}

.organize-spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pv-spin 850ms linear infinite;
}

.organize-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  align-items: start;
  gap: 10px;
  min-height: 0;
  padding: 2px;
  overflow-y: auto;
}

.organize-category-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: var(--glass-grey);
  transition: border-color 160ms ease, background-color 160ms ease,
    box-shadow 160ms ease;
}

.organize-category-card.is-drop-target {
  border-color: rgba(25, 194, 178, 0.6);
  background: rgba(25, 194, 178, 0.14);
  box-shadow: inset 0 0 0 1px rgba(25, 194, 178, 0.35),
    0 0 20px rgba(25, 194, 178, 0.2);
}

.organize-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.organize-cat-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
}

input.organize-cat-name:focus {
  border-color: rgba(25, 194, 178, 0.5);
  background: rgba(255, 255, 255, 0.06);
}

.organize-cat-badge {
  flex: none;
  padding: 1px 7px;
  border: 1px solid rgba(25, 194, 178, 0.24);
  border-radius: var(--radius-pill);
  background: rgba(25, 194, 178, 0.15);
  color: #8fe8df;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.organize-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 168px;
  min-height: 24px;
  overflow-y: auto;
}

.organize-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 2px 4px 2px 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 10.5px;
  white-space: nowrap;
}

.organize-chip > span,
.organize-chip-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.organize-chip-move {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 9px;
  cursor: grab;
  transition: background-color 140ms ease, color 140ms ease;
}

.organize-chip-move:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.organize-uncategorized {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--hairline);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.organize-uncategorized > .sidebar-section-title {
  padding: 0;
}

/* ----------------------------------------------------------------- Toasts */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 78px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  translate: -50% 0;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: rgba(30, 32, 40, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 40px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: auto;
  animation: pv-toast-in var(--spring) both;
}

.toast .pv-icon {
  flex: none;
  color: var(--accent);
}

.toast.is-error .pv-icon {
  color: var(--error);
}

.toast.is-success .pv-icon {
  color: var(--success);
}

/* -------------------------------------------------------------- Animations */

@keyframes pv-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pv-bud-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pv-pop-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pv-sheet-in {
  from {
    opacity: 0;
    transform: translateX(28px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes pv-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pv-spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------------------------------------- Responsive */

@media (max-width: 1180px) {
  .search-wrap {
    width: clamp(150px, 18vw, 240px);
  }

  .view-title {
    font-size: 15px;
  }

  /* The chrome may wrap to two rows here; keep the first card and trash banner clear of it. */
  .library-scroll {
    padding-top: 132px;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: min(304px, 86vw);
    margin: 0;
    border-radius: 0 24px 24px 0;
    transform: translateX(-105%);
    transition: transform var(--spring);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 24px 70px rgba(0, 0, 0, 0.6);
  }

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

  .sidebar-backdrop {
    display: block;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
  }

  .top-chrome {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 0;
  }

  .top-left {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Promote the action cluster's children to rows of the chrome: upload and
     sign-out ride with the title, the search + filters take their own row and
     the storage pill keeps its own centred row. Nothing can overlap. */
  .top-right {
    display: contents;
  }

  .top-right > * {
    order: 2;
  }

  .top-center {
    order: 3;
    flex: 1 1 100%;
    justify-content: center;
  }

  .search-wrap {
    order: 4;
    flex: 1 1 96px;
    width: auto;
  }

  .sort-select {
    order: 5;
  }

  .ext-select {
    order: 6;
  }

  .sort-select,
  .ext-select {
    width: 100px;
  }

  .library-scroll {
    padding: 172px 14px 148px;
  }

  .model-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
  }

  .detail-sheet {
    top: 8px;
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    border-radius: 22px;
  }

  .organize-modal {
    width: calc(100vw - 20px);
    max-height: 88vh;
    padding: 14px 14px 12px;
  }

  .organize-categories {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .upload-panel {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-height: 42vh;
  }

  .selection-bar {
    bottom: 16px;
    padding: 7px 8px 7px 14px;
  }

  .toast-stack {
    bottom: 72px;
  }
}

@media (max-width: 520px) {
  .logout-btn {
    display: none;
  }

  .upload-btn {
    padding: 0 11px;
  }

  .view-actions {
    gap: 4px;
  }

  .detail-meta-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------------ Reduce motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }

  /* The organize spinner is the only essential animation. */
  .organize-spinner {
    animation: pv-spin 1.6s linear infinite !important;
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}
