/* Portal clickable prototype
   IBM Plex Sans UI, IBM Plex Mono data, Lucide icons, light "clean SaaS" theme.
   --accent is the single whitelabel hook. */

:root {
  --accent: #2d6be0;
  --accent-soft: #eaf1fd;
  --accent-text: #1d4ea8;

  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f3f3f1;
  --surface-3: #ebebe8;

  --text: #1a1a18;
  --text-2: #6c6c68;
  --text-3: #9c9c97;

  --border: rgba(0, 0, 0, 0.09);
  --border-2: rgba(0, 0, 0, 0.16);

  --radius: 4px;
  --radius-lg: 6px;

  --sidebar-w: 272px;
  --collection-hero-h: 285px;
  --font: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --heading: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[data-lucide] { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }

button { font-family: inherit; cursor: pointer; }

img { display: block; }

.hidden { display: none !important; }

h1, h2, h3, h4,
.brand-name,
.login-title,
.context-title,
.collection-hero-copy h1,
.markdown-card-title,
.landing-hero-copy h1,
.landing-head h1,
.collection-overlay .cm-name,
.empty h3,
.lb-panel .p-name,
.settings-head h2,
.settings-section-heading h3,
.setting-info .si-title,
.builder-title,
.builder-section-head h3,
.boot-error h2,
.admin-info-head h2,
.release-entry h3,
.release-entry h4 {
  font-family: var(--heading);
  letter-spacing: 0;
}

.nav-cat-count,
.suggest-item .count,
.context-count,
.pill,
.chip,
.card-details,
.badge-type,
.tray-count,
.landing-cat-count,
.folder-row .fr-count,
.lb-counter,
.lb-panel .p-date,
.meta-row,
.panel-label,
.tag-cloud .pill,
.builder-match,
.builder-count,
.filetype-ext,
.settings-status,
.logo-size-val,
.release-entry-head,
.release-version,
.release-date,
.version-note {
  font-family: var(--mono);
}

.media-loader {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--surface-2);
  z-index: 0;
}
.media-loader::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,0.62), transparent),
    var(--surface-2);
  transform: translateX(-100%);
  animation: media-shimmer 1.1s ease-in-out infinite;
}
.media-loader.loaded::before,
.media-loader.load-error::before {
  opacity: 0;
  animation: none;
}
.media-loader img,
.media-loader video {
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity .18s ease;
}
.media-loader img.is-loaded,
.media-loader video.is-loaded {
  opacity: 1;
}
.media-loader img.is-error,
.media-loader video.is-error {
  opacity: 0;
}
@keyframes media-shimmer {
  to { transform: translateX(100%); }
}

/* ---------- App shell ---------- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.app.sidebar-collapsed .sidebar,
.app.sidebar-collapsed .sidebar-resizer { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: 176px;
  max-width: 380px;
  flex-shrink: 0;
  border-right: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-resizer {
  position: relative;
  z-index: 30;
  flex: 0 0 9px;
  margin-left: -4px;
  margin-right: -5px;
  cursor: col-resize;
  touch-action: none;
}
.sidebar-resizer::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 4px;
  width: 0.5px;
  background: var(--border);
  transition: background .12s ease, width .12s ease, transform .12s ease;
}
.sidebar-resizer:hover::before,
.app.sidebar-resizing .sidebar-resizer::before {
  width: 2px;
  background: var(--accent);
  transform: translateX(-0.75px);
}
.app.sidebar-resizing,
.app.sidebar-resizing * {
  cursor: col-resize !important;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  margin-bottom: 14px;
  cursor: pointer;
  min-width: 0;
}
.brand-mark {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.brand-mark [data-lucide] { width: 15px; height: 15px; color: var(--bg); }
.brand-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
}

/* Top-level section headings (Collections / Folders): darker + heavier than the
   nested category labels, with a leading icon, to read as one level up. */
.nav-group-label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 0 0 7px 6px;
}
.nav-group-ico { width: 14px; height: 14px; color: var(--text-2); flex-shrink: 0; }
.nav-group-chevron { width: 13px; height: 13px; color: var(--text-3); margin-left: auto; flex-shrink: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}
.nav-item [data-lucide] { width: 16px; height: 16px; flex-shrink: 0; }
.nav-text,
.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item.active [data-lucide] { color: var(--accent-text); }

.sidebar-foot {
  position: sticky;
  bottom: -16px;
  z-index: 20;
  margin-top: auto;
  padding: 20px 8px 18px;
  border-top: 1px solid var(--border-2);
  background: var(--surface);
}
.sidebar-foot::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -26px;
  height: 26px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(250,250,250,0), var(--surface));
}

.nav-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-right: 4px;
}
.nav-group-toggle {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px 7px 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav-group-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Folders mirrors the spacing above the collections section for an even rhythm. */
.nav-section-folders { margin-top: 22px; }
.nav-group-toggle:hover .nav-group-chevron { color: var(--text-2); }
.group-add {
  width: 22px; height: 22px; border-radius: var(--radius);
  border: none; background: transparent; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.group-add [data-lucide] { width: 15px; height: 15px; }
.group-add:hover { background: var(--surface-2); color: var(--text); }
.nav-section-collections { margin-top: 22px; }
/* Collections heading with create actions that fade in on hover (New collection /
   New category). Reserved layout (pointer-events toggle) so the row never shifts. */
.nav-collections-head { margin-bottom: 7px; }
.nav-collections-head .nav-group-label { margin: 0 0 0 8px; }
/* The categories list sits inset under the Collections heading for hierarchy. */
#navCollections { padding-left: 16px; }
/* Folder rows are inset further so they line up with the individual collections
   nested inside categories above (16px category inset + 10px nested-item inset). */
.nav-folders-list { padding-left: 26px; }
.nav-group-actions {
  display: flex; align-items: center; gap: 2px;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.nav-collections-head:hover .nav-group-actions,
.nav-collections-head:focus-within .nav-group-actions { opacity: 1; pointer-events: auto; }

/* ---------- Sidebar categories ---------- */
.nav-category { margin-top: 16px; }
.nav-cat-head {
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px 5px; border-radius: var(--radius);
  user-select: none;
}
.nav-cat-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 500; color: var(--text-3);
}
.nav-cat-count { font-size: 11.5px; color: var(--text-3); flex-shrink: 0; }
.nav-cat-del {
  width: 18px; height: 18px; margin: -3px -2px 0 0; padding: 0;
  border: none; background: transparent; color: var(--text-3);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.nav-cat-del [data-lucide] { width: 13px; height: 13px; }
.nav-cat-head:hover .nav-cat-del { opacity: 1; pointer-events: auto; }
.nav-cat-del:hover { background: var(--surface-3); color: var(--text); }
/* Nested collections sit slightly inset from their category heading. */
.nav-cat-items { display: flex; flex-direction: column; gap: 1px; min-height: 4px; padding-left: 10px; }
.nav-cat-rename {
  flex: 1; min-width: 0; border: 0.5px solid var(--accent); border-radius: 4px;
  background: var(--bg); color: var(--text); font-family: inherit;
  font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 500; padding: 1px 5px; outline: none;
}
.nav-collection.dragging, .nav-category.dragging { opacity: 0.45; }
.nav-collection[draggable="true"], .nav-cat-head[draggable="true"] { cursor: grab; }

/* muted settings entry, sits in the foot where read-only used to be */
.nav-item-muted { color: var(--text-3); }
.nav-item-muted [data-lucide] { width: 15px; height: 15px; color: var(--text-3); }

/* collection rows carry a hover edit pencil. It stays in the layout (reserved
   slot) and only fades in, so the row never changes height/width on hover. */
.nav-collection .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-edit {
  width: 18px; height: 18px; margin: -2px 0; padding: 0;
  border: none; background: transparent; color: var(--text-3);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.nav-edit [data-lucide] { width: 14px; height: 14px; }
.nav-collection:hover .nav-edit { opacity: 1; pointer-events: auto; }
.nav-edit:hover { background: var(--surface-3); color: var(--text); }

.edit-collection-btn { height: 30px; font-size: 12.5px; }
.edit-collection-btn [data-lucide] { width: 15px; height: 15px; }
.context-tags:empty + .edit-collection-btn { margin-left: auto; }

/* ---------- Main ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 0.5px solid var(--border);
}

.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar-sync { flex-shrink: 0; }
.topbar-sync.syncing { color: var(--accent-text); cursor: default; }
.topbar-sync.syncing [data-lucide] { animation: topbar-spin 0.8s linear infinite; }
@keyframes topbar-spin { to { transform: rotate(360deg); } }

.search {
  flex: 1;
  position: relative;
  min-width: 0;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-3);
}
.search-field [data-lucide] { width: 16px; height: 16px; }
.search-field input {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.search-field input::placeholder { color: var(--text-3); }
.search.focused .search-field { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search.focused .search-field [data-lucide] { color: var(--accent); }

.suggest {
  position: absolute;
  top: 40px; left: 0; right: 0;
  background: var(--bg);
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  z-index: 30;
}
.suggest-label {
  font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); margin: 6px 8px 4px;
}
.suggest-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius);
  font-size: 13px; cursor: pointer;
}
.suggest-item [data-lucide] { width: 15px; height: 15px; color: var(--text-3); }
.suggest-item:hover { background: var(--surface-2); }
.suggest-item .count { margin-left: auto; font-size: 11px; color: var(--text-3); }
.suggest-item b { font-weight: 500; }

.segmented {
  display: flex;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  overflow: hidden;
  height: 34px;
  flex-shrink: 0;
}
.segmented button {
  width: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: none; color: var(--text-3);
}
.segmented button + button { border-left: 0.5px solid var(--border-2); }
.segmented button.active { background: var(--surface-2); color: var(--text); }

/* ---------- Context bar ---------- */
.context-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px 6px;
}
.context-title { font-size: 16px; font-weight: 500; }
.context-count { font-size: 12px; color: var(--text-3); letter-spacing: 0.01em; }
.context-tags { margin-left: auto; display: flex; gap: 6px; }
.collection-context { padding-top: 10px; }

.gallery-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.pill {
  font-size: 11.5px; padding: 3px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2);
}

/* ---------- Collection hero ---------- */
.collection-hero {
  position: relative;
  min-height: var(--collection-hero-h);
  margin: 14px 18px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
}
.collection-hero.no-cover {
  background:
    linear-gradient(135deg, rgba(45,107,224,0.26), rgba(26,26,24,0.08)),
    var(--surface-2);
}
.collection-hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.70), rgba(0,0,0,0.18) 52%, rgba(0,0,0,0.02));
}
.collection-hero-copy {
  position: absolute;
  left: 22px; right: 22px; bottom: 19px;
  color: #fff;
  max-width: 640px;
}
.collection-hero-kicker {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: rgba(255,255,255,0.82);
  margin-bottom: 7px;
}
.collection-hero-kicker [data-lucide] { width: 14px; height: 14px; color: rgba(255,255,255,0.82); }
.collection-hero h1 {
  font-size: 28px; line-height: 1.1; font-weight: 550;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.collection-hero p {
  max-width: 560px;
  margin-top: 7px;
  font-size: 13px;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.all-tags-head {
  margin: 14px 18px 0;
  padding: 16px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  display: grid;
  gap: 14px;
}
.all-tags-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.all-tags-copy h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: 0;
}
.all-tags-copy p {
  margin: 0;
  color: var(--text-3);
  font-size: 13px;
  text-align: right;
}
.main-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.main-tag {
  min-height: 32px;
  max-width: 100%;
  padding: 6px 9px 6px 11px;
  border: 0.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.main-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main-tag b {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}
.main-tag:hover {
  border-color: var(--border-2);
  color: var(--text);
  background: var(--surface-2);
}
.main-tag.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.main-tag.active b {
  background: rgba(255,255,255,0.72);
  color: var(--accent-text);
}
.all-tags-empty {
  color: var(--text-3);
  font-size: 13px;
}

.chip {
  font-size: 11.5px; padding: 3px 6px 3px 9px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-text);
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
}
.chip [data-lucide] { width: 13px; height: 13px; }

/* ---------- Grid ---------- */
.grid-scroll { flex: 0 0 auto; overflow: visible; padding: 14px 18px 28px; }

.asset-grid { display: grid; gap: 10px; }
.asset-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.asset-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.asset-grid.card-layout { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }

.asset-grid.masonry {
  display: grid;
  grid-template-columns: repeat(var(--masonry-columns, 3), minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}
.masonry-column {
  display: grid;
  gap: 10px;
  align-content: start;
}
.asset-grid.masonry .card {
  width: 100%;
  margin-bottom: 0;
}

.card {
  position: relative;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}
.card:hover { border-color: var(--border-2); }
.card.selected { border-color: var(--accent); }
.gallery-scroll.picker-mode .card { cursor: cell; }
.gallery-scroll.picker-mode .card.selected {
  border-color: var(--accent);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.14);
}

.card .thumb { width: 100%; display: block; background: var(--surface-2); }
.asset-grid:not(.masonry) .card .thumb { aspect-ratio: 4 / 3; object-fit: cover; }
.card-media { position: relative; }
.asset-grid.masonry .card-media { aspect-ratio: var(--masonry-aspect, 4 / 3); }
.asset-grid.masonry .card .thumb,
.asset-grid.masonry .card .filetype,
.asset-grid.masonry .card .markdown-card-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-view {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.card-view .card-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  padding: 18px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, rgba(0,0,0,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0,0,0,0.025) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.025) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.025) 75%),
    var(--surface-2);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.asset-grid.card-layout .card .thumb {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  aspect-ratio: auto;
  background: transparent;
}
.card-view .filetype {
  width: auto;
  aspect-ratio: auto;
  background: transparent;
}
.markdown-asset .card-media,
.card-view.markdown-asset .card-preview {
  background: #f4f1ea;
}
.card-view.markdown-asset .card-preview {
  padding: 14px;
}
.markdown-card-preview {
  width: 100%;
  height: 100%;
  min-height: 150px;
  padding: 16px;
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.68)),
    #f8f5ee;
  color: var(--text);
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
}
.card:not(.card-view) .markdown-card-preview { aspect-ratio: 4 / 3; }
.markdown-card-top {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--text-3); text-transform: uppercase;
}
.markdown-card-top [data-lucide] { width: 15px; height: 15px; color: var(--text-3); }
.markdown-card-title {
  margin-top: auto;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.markdown-card-excerpt {
  margin-top: 9px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badge-markdown { background: rgba(255,255,255,0.92); color: var(--text); }
.card-info {
  padding: 9px 10px 10px;
  border-top: 0.5px solid var(--border);
  display: grid;
  gap: 4px;
  min-height: 54px;
}
.card-name {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-details {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-3);
}
.card-details span + span::before {
  content: "·";
  margin-right: 6px;
  color: var(--text-3);
}

.card .filetype {
  width: 100%; aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.card .filetype [data-lucide] { width: 26px; height: 26px; }

.card .overlay {
  position: absolute; inset: 0;
  z-index: 4;
  background: linear-gradient(to bottom, rgba(0,0,0,0.30), rgba(0,0,0,0) 36%, rgba(0,0,0,0) 58%, rgba(0,0,0,0.58));
  opacity: 0;
  transition: opacity .12s ease;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 8px;
}
.card:hover .overlay, .card.selected .overlay { opacity: 1; }
.gallery-scroll.picker-mode .card .overlay {
  opacity: 1;
  background: linear-gradient(to bottom, rgba(0,0,0,0.24), rgba(0,0,0,0) 46%, rgba(0,0,0,0) 68%, rgba(0,0,0,0.42));
}
.gallery-scroll.picker-mode .overlay-actions { display: none; }
.gallery-scroll.picker-mode .checkbox {
  width: 26px;
  height: 26px;
  border-width: 1.5px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.16);
}

.overlay-top { display: flex; align-items: flex-start; justify-content: space-between; }
.overlay-actions { display: flex; gap: 6px; }
.mini-btn {
  width: 24px; height: 24px; border-radius: var(--radius);
  background: var(--bg); border: none; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.mini-btn [data-lucide] { width: 14px; height: 14px; }

.checkbox {
  width: 20px; height: 20px; border-radius: var(--radius);
  background: rgba(255,255,255,0.9); border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.card.selected .checkbox { background: var(--accent); border-color: var(--accent); color: #fff; }
.card.selected .checkbox [data-lucide] { width: 13px; height: 13px; }
.gallery-scroll.picker-mode .card.selected .checkbox [data-lucide] { width: 16px; height: 16px; }

.overlay-name {
  font-size: 11px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-view .overlay {
  background: linear-gradient(to bottom, rgba(0,0,0,0.30), rgba(0,0,0,0) 42%);
}
.card-view .overlay-name { display: none; }
.badge-type {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 9.5px; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 3px;
  display: flex; align-items: center; gap: 4px;
  opacity: 1; transition: opacity .12s;
  z-index: 2;
}
.badge-type [data-lucide] { width: 11px; height: 11px; color: #fff; }
.card:hover .badge-type { opacity: 0; }
.card .duration {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.65); color: #fff;
  font-size: 10px; padding: 2px 5px; border-radius: 3px;
  font-family: var(--mono);
}

/* ---------- Selection tray ---------- */
.tray {
  position: absolute;
  left: 50%; bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  width: min(620px, calc(100% - 48px));
  min-height: 52px;
  padding: 10px 12px 10px 18px;
  box-shadow: 0 16px 44px rgba(0,0,0,0.32);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 40;
}
.tray.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.tray.picker-mode {
  background: #151514;
  border: 1px solid rgba(255,255,255,0.12);
}
.tray-count {
  flex: 1;
  min-width: 140px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.tray-count b { font-size: 18px; font-weight: 650; }
.tray-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}
.tray .tray-clear {
  background: transparent; border: none; color: rgba(255,255,255,0.6);
  font-size: 12px; display: flex; align-items: center; gap: 5px;
  min-height: 34px;
  padding: 0 6px;
}
.tray .tray-clear [data-lucide] { width: 13px; height: 13px; }
.tray .tray-dl,
.tray .tray-share {
  background: var(--bg); color: var(--text); border: none;
  border-radius: var(--radius); font-size: 13px; font-weight: 500;
  min-height: 38px;
  padding: 0 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
}
.tray .tray-share {
  background: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.82);
}
.tray .tray-dl [data-lucide],
.tray .tray-share [data-lucide] { width: 15px; height: 15px; }
.tray .tray-dl.is-busy [data-lucide] { animation: topbar-spin 0.8s linear infinite; }
.tray .tray-dl:disabled,
.tray .tray-share:disabled {
  cursor: default;
  opacity: 0.62;
}

.toolbar-pick.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.toolbar-pick.active:hover {
  background: var(--text);
  color: var(--bg);
}

/* ---------- Empty state ---------- */
.empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 24px; gap: 6px;
}
.empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); margin-bottom: 12px;
}
.empty-icon [data-lucide] { width: 26px; height: 26px; }
.empty h3 { font-size: 15px; font-weight: 500; }
.empty p { font-size: 13px; color: var(--text-3); max-width: 300px; }
.empty .btn { margin-top: 14px; }

/* ---------- Buttons ---------- */
.btn {
  height: 34px; padding: 0 14px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius);
  background: var(--bg); color: var(--text-2); font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn [data-lucide] { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500;
}
.btn-primary:hover { background: var(--accent-text); color: #fff; }
.btn-dark { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 500; }

/* ---------- Collections landing ---------- */
.landing { flex: 1; overflow-y: auto; padding: 26px 30px 40px; }
.landing-hero {
  position: relative;
  min-height: var(--collection-hero-h);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--surface-2);
  margin-bottom: 24px;
}
.landing-hero.no-cover {
  background:
    linear-gradient(135deg, rgba(45,107,224,0.18), rgba(26,26,24,0.08)),
    var(--surface-2);
}
/* Crossfading background layers for the cycling home header. */
.landing-hero-bg {
  position: absolute; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.1s ease;
}
.landing-hero-bg.is-shown { opacity: 1; z-index: 1; }
.landing-hero-shade {
  position: absolute;
  inset: 0; z-index: 2;
  background: linear-gradient(to top, rgba(0,0,0,0.62), rgba(0,0,0,0.10) 62%, rgba(0,0,0,0.02));
}
.landing-hero-copy {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 20px;
  z-index: 3;
  color: #fff;
  max-width: 660px;
}
.landing-hero-copy h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 550;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.landing-hero-copy p {
  font-size: 13px;
  color: rgba(255,255,255,0.88);
  margin-top: 7px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.landing-head { margin-bottom: 22px; }
.landing-head h1 { font-size: 22px; font-weight: 500; }
.landing-head p { font-size: 14px; color: var(--text-2); margin-top: 3px; }
.landing-section-label {
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); margin: 26px 0 12px;
}
.collection-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.landing-category { margin-top: 30px; }
.landing-category + .landing-category { margin-top: 26px; }
/* Category headings read as proper display headings, not eyebrow labels. */
.landing-cat-head {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 15px; cursor: pointer; user-select: none;
  font-size: 21px; font-weight: 600; letter-spacing: -0.015em;
  color: var(--text);
}
.landing-cat-head [data-lucide] { width: 19px; height: 19px; color: var(--text-3); }
.landing-cat-head:hover [data-lucide] { color: var(--text-2); }
.landing-cat-count { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--text-3); }
.landing-category.collapsed .landing-cat-head { margin-bottom: 0; }
.collection-card {
  border: 0.5px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; cursor: pointer; background: var(--bg);
}
.collection-card:hover { border-color: var(--border-2); }
.collection-cover {
  position: relative;
  display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr;
  gap: 1.5px; aspect-ratio: 4 / 3; background: var(--surface-2);
}
.collection-cover .media-loader { min-height: 0; }
.collection-cover .media-loader:first-child { grid-row: 1 / 3; }
.collection-cover img { width: 100%; height: 100%; object-fit: cover; }

/* Collections with no preview, plus card-view collections, fall back to a
   solid dark grey tile with no image treatment. */
.collection-card.no-preview .collection-cover { background: #383735; }
.collection-card.no-preview .collection-overlay { background: none; }

.collection-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.64) 0%, rgba(0,0,0,0.14) 44%, rgba(0,0,0,0) 72%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 14px 16px;
}
.collection-overlay .cm-name {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: #fff;
  display: flex; align-items: center; gap: 8px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.collection-overlay .cm-name [data-lucide] { width: 18px; height: 18px; color: #fff; }
.collection-overlay .cm-sub { font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 3px; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.folder-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border: 0.5px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px; cursor: pointer; background: var(--bg);
}
.folder-row:hover { border-color: var(--border-2); background: var(--surface); }
.folder-row [data-lucide] { width: 17px; height: 17px; color: var(--text-2); }
.folder-row .fr-name { font-size: 13px; font-weight: 500; }
.folder-row .fr-count { margin-left: auto; font-size: 12px; color: var(--text-3); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: #141414;
  display: flex; flex-direction: column;
}
.lb-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 0.5px solid rgba(255,255,255,0.1);
  color: #fff;
  min-width: 0;
}
.lb-crumb {
  min-width: 0;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.lb-crumb [data-lucide] { width: 14px; height: 14px; color: rgba(255,255,255,0.3); }
.lb-crumb .now {
  min-width: 0;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-counter { margin-left: auto; font-size: 12px; color: rgba(255,255,255,0.45); font-family: var(--mono); }
.lb-close {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: 0.5px solid rgba(255,255,255,0.18); border-radius: var(--radius);
  background: transparent; color: #fff;
}
.lb-close [data-lucide] { color: #fff; }

.lb-body { flex: 1; display: flex; min-width: 0; min-height: 0; }
.lb-stage {
  flex: 1; min-width: 0; position: relative;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  container-type: size; /* expose stage size as cqw/cqh for fitting the media box */
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.1); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
}
.lb-nav:hover { background: rgba(255,255,255,0.18); }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.lb-nav [data-lucide] { width: 20px; height: 20px; color: #fff; }

/* Plain media (single full image / video) fills the stage and scales up to fit. */
.lb-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lb-media img, .lb-media video { width: 100%; height: 100%; object-fit: contain; border-radius: var(--radius); }

/* Progressive lightbox: the box is sized to the fitted image via its known
   dimensions (--w / --h), so the blurred proxy and the full image share one
   rectangle. The blur is then clipped at the image edge by overflow:hidden
   instead of spilling into the surrounding letterbox area. */
.lb-progressive {
  position: relative;
  aspect-ratio: var(--w) / var(--h);
  width: min(100cqw, calc(100cqh * var(--w) / var(--h)));
  max-width: 100%; max-height: 100%;
  overflow: hidden; border-radius: var(--radius);
}
.lb-progressive .lb-thumb,
.lb-progressive .lb-full {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 0;
}
.lb-progressive .lb-thumb {
  object-fit: cover; /* fill the box so the blur has no transparent edge */
  filter: blur(16px); transform: scale(1.06);
  transition: opacity 0.35s ease;
}
.lb-progressive .lb-full {
  object-fit: contain; /* exact fit (box matches image aspect); never distorts */
  opacity: 0; transition: opacity 0.35s ease;
}
.lb-progressive .lb-full.is-loaded { opacity: 1; }
/* Once the full image has faded in, drop the blurred proxy entirely. */
.lb-progressive:has(.lb-full.is-loaded) .lb-thumb { opacity: 0; }

.lb-video {
  width: 100%; max-width: 880px; aspect-ratio: 16/9; background: #000;
  border-radius: var(--radius); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.lb-video img { width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.lb-video .play {
  position: absolute; width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255,255,255,0.92); display: flex; align-items: center; justify-content: center;
}
.lb-video .play [data-lucide] { width: 26px; height: 26px; color: #111; }
.lb-video .vbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}
.lb-video .vbar [data-lucide] { width: 18px; height: 18px; color: #fff; }
.lb-video .vtrack { flex: 1; height: 3px; background: rgba(255,255,255,0.3); border-radius: 2px; position: relative; }
.lb-video .vtrack::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 32%; background: #fff; border-radius: 2px; }
.lb-video .vtime { font-size: 11px; font-family: var(--mono); }

.lb-pdf {
  width: 100%; max-width: 620px; height: 76vh; background: #fff;
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.lb-pdf .pdf-page {
  flex: 1; margin: 16px; border: 0.5px solid var(--border);
  display: flex; flex-direction: column; gap: 10px; padding: 30px;
}
.lb-pdf .pdf-line { height: 9px; background: var(--surface-3); border-radius: 2px; }
.lb-pdf .pdf-line.short { width: 55%; }
.lb-pdf .pdf-block { flex: 1; background: var(--surface-2); border-radius: 3px; margin-top: 8px; }
.lb-pdf .pdf-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 9px; border-top: 0.5px solid var(--border); color: var(--text-2); font-size: 12px;
}
.lb-pdf .pdf-bar [data-lucide] { width: 15px; height: 15px; }

.lb-panel {
  width: clamp(360px, 32vw, 500px);
  flex: 0 0 clamp(360px, 32vw, 500px);
  background: var(--bg);
  padding: 18px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto;
}
.lb-panel .p-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
}
.lb-panel .p-date { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.dl-split { position: relative; display: flex; gap: 0; }
.dl-split .btn-primary { flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.dl-split .btn-primary span,
.dl-split .btn-primary {
  white-space: nowrap;
}
.dl-split .dl-more {
  width: 34px; height: 34px; border: 0.5px solid var(--accent); border-left-color: rgba(255,255,255,0.25);
  background: var(--accent); color: #fff; border-radius: 0 var(--radius) var(--radius) 0;
  display: flex; align-items: center; justify-content: center;
}
.download-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  min-width: 174px;
  padding: 5px;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 12px 30px rgba(0,0,0,0.16);
}
.download-menu button {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: none;
  border-radius: calc(var(--radius) - 1px);
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  text-align: left;
}
.download-menu button:hover { background: var(--surface-2); color: var(--text); }
.download-menu [data-lucide] { width: 14px; height: 14px; color: currentColor; }
.meta-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 7px 0; border-bottom: 0.5px solid var(--border); font-size: 11.5px;
}
.meta-row .k {
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.045em;
  white-space: nowrap;
}
.meta-row .v {
  min-width: 0;
  color: var(--text-2);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-row .v a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}
.meta-lines {
  display: grid;
  gap: 3px;
}
.meta-lines span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-label {
  font-size: 10.5px; letter-spacing: 0.055em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 8px;
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-cloud .pill { cursor: pointer; }
.tag-cloud .pill:hover { background: var(--accent-soft); color: var(--accent-text); }
.coll-link {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent-text);
  cursor: pointer;
}
.coll-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coll-link [data-lucide] { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; z-index: 200;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 340px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-mark {
  width: 48px; height: 48px; border-radius: 8px; background: var(--text); color: var(--bg);
  display: flex; align-items: center; justify-content: center; margin-bottom: 20px;
}
.login-mark [data-lucide] { width: 26px; height: 26px; color: var(--bg); }
.login-title { font-size: 18px; font-weight: 500; }
.login-sub { font-size: 12px; color: var(--text-3); margin: 4px 0 40px; }
.login-box {
  width: 100%; background: var(--bg); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px;
}
.login-box label { font-size: 12px; color: var(--text-2); text-align: left; display: block; margin-bottom: 6px; }
.login-input {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius);
}
.login-input [data-lucide] { width: 16px; height: 16px; color: var(--text-3); }
.login-input input {
  border: none; outline: none; background: transparent; font-family: inherit;
  font-size: 14px; width: 100%; color: var(--text);
}
.login-foot { font-size: 11px; color: var(--text-3); margin-top: 22px; display: flex; align-items: center; gap: 6px; }
.login-foot [data-lucide] { width: 14px; height: 14px; }
.login-powered { font-size: 11px; color: var(--text-3); margin-top: 30px; }
.login-powered b { color: var(--text-2); font-weight: 500; }

/* ---------- Settings ---------- */
.settings-wrap { flex: 1; overflow-y: auto; padding: 26px 30px 50px; }
.settings-card {
  max-width: 580px; background: var(--bg);
  border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.settings-head { padding: 16px 22px; border-bottom: 0.5px solid var(--border); }
.settings-head h2 { font-size: 16px; font-weight: 500; }
.settings-head p { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.settings-body { padding: 22px; display: flex; flex-direction: column; gap: 0; }
.settings-section-heading {
  padding: 0 0 12px;
  border-bottom: 0.5px solid var(--border);
}
.settings-section-heading-spaced { padding-top: 24px; }
.settings-section-heading h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
}
.settings-section-heading p {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
}
.setting-row { display: flex; gap: 16px; align-items: center; padding: 18px 0; border-bottom: 0.5px solid var(--border); }
.setting-row-stack { align-items: stretch; flex-direction: column; gap: 12px; }
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; }
.setting-info .si-title { font-size: 13px; font-weight: 500; }
.setting-info .si-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.field-input {
  height: 36px; min-width: 180px; display: flex; align-items: center; padding: 0 12px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius); font-size: 13px;
}
.swatches { display: flex; gap: 8px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; }
.swatch.active { outline: 2px solid var(--text); outline-offset: 2px; }
.logo-prev { width: 44px; height: 44px; border-radius: 6px; background: var(--text); color: var(--bg); display: flex; align-items: center; justify-content: center; }
.logo-prev [data-lucide] { width: 22px; height: 22px; color: var(--bg); }
.toggle { width: 38px; height: 22px; border-radius: 20px; background: var(--border-2); position: relative; cursor: pointer; }
.toggle .knob { width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; transition: left .12s; }
.toggle.on { background: var(--accent); }
.toggle.on .knob { left: 18px; }
.settings-foot { padding: 14px 22px; border-top: 0.5px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.theme-seg { display: flex; border: 0.5px solid var(--border-2); border-radius: var(--radius); overflow: hidden; }
.theme-seg button { padding: 6px 14px; font-size: 12px; background: var(--bg); border: none; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.theme-seg button + button { border-left: 0.5px solid var(--border-2); }
.theme-seg button.active { background: var(--surface-2); color: var(--text); }
.theme-seg button [data-lucide] { width: 14px; height: 14px; }

/* ---------- Smart-folder builder (left drawer) ---------- */
.builder { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.builder.show { pointer-events: auto; }
.builder-scrim {
  position: absolute; inset: 0; z-index: 0; background: rgba(0,0,0,0.28);
  opacity: 0; transition: opacity .18s ease;
}
.builder.show .builder-scrim { opacity: 1; }
.builder-panel {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 1;
  width: 440px; max-width: 94vw;
  background: var(--surface); border-right: 0.5px solid var(--border);
  box-shadow: 8px 0 32px rgba(0,0,0,0.16);
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .2s ease;
}
.builder.show .builder-panel { transform: translateX(0); }

.builder-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 22px 18px; border-bottom: 0.5px solid var(--border);
  background: var(--bg);
}
.builder-kicker {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 5px;
}
.builder-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.builder-title [data-lucide] { width: 18px; height: 18px; color: var(--accent); }
.builder-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.builder-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.builder-section {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 16px;
}
.builder-section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 0.5px solid var(--border);
}
.builder-section-head h3 {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--text);
}
.builder-section-head span {
  font-size: 11.5px; color: var(--text-3); text-align: right;
}
.builder-section-head b { font-weight: 600; color: var(--text); }
.builder-label { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); display: block; margin: 14px 0 7px; }
.builder-section .builder-label:first-of-type { margin-top: 0; }
.builder-name {
  width: 100%; height: 38px; padding: 0 12px; font-family: inherit; font-size: 14px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius); background: var(--bg); color: var(--text);
  outline: none; margin-bottom: 0;
}
.builder-name:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.name-row { display: flex; gap: 8px; align-items: center; }
.name-row .builder-name { flex: 1; margin-bottom: 0; }
.icon-current {
  width: 38px; height: 38px; flex-shrink: 0;
  border: 0.5px solid var(--border-2); border-radius: var(--radius);
  background: var(--bg); color: var(--text); display: flex; align-items: center; justify-content: center;
}
.icon-current [data-lucide] { width: 18px; height: 18px; color: var(--accent); }
.icon-current:hover { background: var(--surface-2); }

.icon-picker {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  margin: 10px 0 2px; padding: 8px;
  border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.icon-choice {
  aspect-ratio: 1; border: 0.5px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.icon-choice [data-lucide] { width: 17px; height: 17px; }
.icon-choice:hover { background: var(--surface-2); color: var(--text); }
.icon-choice.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

.builder-description {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  padding: 9px 10px;
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.builder-description:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.builder-category {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.builder-category:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.builder-view-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  margin-bottom: 0;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface);
}
.builder-view-toggle button {
  height: 32px;
  border: none;
  border-radius: calc(var(--radius) - 1px);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.builder-view-toggle button [data-lucide] { width: 14px; height: 14px; }
.builder-view-toggle button:hover { background: var(--surface-2); color: var(--text); }
.builder-view-toggle button.active { background: var(--bg); color: var(--accent-text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.builder-match {
  font-size: 12px; color: var(--text-2);
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 0 0 12px;
  padding: 10px 11px;
  border-radius: var(--radius);
  background: var(--surface);
}
.builder-match select {
  height: 28px; padding: 0 8px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 12.5px;
}

.rule-list { display: flex; flex-direction: column; gap: 10px; }
.rule-row {
  display: grid; grid-template-columns: 1.05fr 0.9fr 1.15fr auto; gap: 8px; align-items: center;
  padding: 8px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.rule-row select, .rule-row input {
  height: 34px; padding: 0 9px; font-family: inherit; font-size: 12.5px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius);
  background: var(--bg); color: var(--text); outline: none; min-width: 0; width: 100%;
}
.rule-row select:focus, .rule-row input:focus { border-color: var(--accent); }
.rule-del {
  width: 26px; height: 26px; border: none; background: transparent; color: var(--text-3);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
}
.rule-del [data-lucide] { width: 15px; height: 15px; }
.rule-del:hover { background: var(--surface-2); color: var(--color-text-danger, var(--text)); }

.add-rule { margin-top: 12px; height: 34px; font-size: 12.5px; width: 100%; justify-content: center; }
.add-rule [data-lucide] { width: 14px; height: 14px; }

.builder-cover-label { margin-top: 16px; }
.cover-picker {
  max-height: 176px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.settings-cover-picker {
  max-height: 260px;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}
.cover-choice {
  min-width: 0;
  min-height: 68px;
  border: 0.5px solid transparent;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.cover-choice img {
  width: 100%;
  height: 52px;
  object-fit: cover;
  background: var(--surface-2);
}
.cover-choice span {
  min-width: 0;
  padding: 4px 5px;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cover-choice:hover { border-color: var(--border-2); color: var(--text); }
.cover-choice.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); color: var(--accent-text); }
.cover-auto {
  grid-column: span 2;
  justify-content: center;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 8px;
}
.cover-auto [data-lucide] { width: 18px; height: 18px; color: var(--accent); }
.cover-auto span { padding: 0; white-space: normal; }
.cover-empty {
  grid-column: 1 / -1;
  padding: 14px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.builder-foot {
  border-top: 0.5px solid var(--border); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; background: var(--bg);
}
.builder-foot-left { display: flex; align-items: center; gap: 10px; }
.builder-count { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.builder-count [data-lucide] { width: 15px; height: 15px; color: var(--text-3); }
.builder-count b { font-weight: 500; color: var(--text); }
.builder-actions { display: flex; align-items: center; gap: 8px; }
.builder-del {
  width: 30px; height: 30px; border: 0.5px solid var(--border-2); background: var(--bg);
  border-radius: var(--radius); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.builder-del [data-lucide] { width: 15px; height: 15px; }
.builder-del:hover { background: var(--color-background-danger, #fce8e8); border-color: var(--color-border-danger, #e0a0a0); color: var(--color-text-danger, #b42318); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* Boot error (library failed to load) */
.boot-error {
  max-width: 460px; margin: 80px auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-2);
}
.boot-error [data-lucide] { width: 34px; height: 34px; color: var(--color-text-warning, #b4690e); }
.boot-error h2 { margin: 4px 0 0; color: var(--text); }
.boot-error p { margin: 0; font-size: 14px; }
.boot-error .boot-hint { color: var(--text-3); font-size: 13px; }
.boot-error code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ---- File-type cards & previews (txt / svg / video / pdf) ---- */
.card .filetype {
  flex-direction: column; gap: 8px; background: var(--surface-2);
}
.filetype-ext {
  font-size: 10px; font-family: var(--mono); letter-spacing: 0.04em;
  color: var(--text-2); text-transform: uppercase;
}
.play-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.play-badge [data-lucide] { width: 20px; height: 20px; margin-left: 2px; }
.card:hover .play-badge { background: rgba(0,0,0,0.65); }

.lb-videofile { max-width: 100%; max-height: 76vh; border-radius: var(--radius); background: #000; }

.lb-file {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 48px 32px; text-align: center; color: var(--text-2);
}
.lb-file > [data-lucide] { width: 56px; height: 56px; color: var(--text-3); }
.lb-file-name { font-size: 15px; color: var(--text); font-weight: 500; max-width: 360px; word-break: break-word; }
.lb-file-sub { font-size: 13px; color: var(--text-3); }
.lb-file .btn-primary { margin-top: 6px; }

.lb-markdown {
  width: min(840px, calc(100vw - 120px));
  max-height: calc(100vh - 154px);
  overflow: auto;
  padding: 46px 56px 54px;
  border: 0.5px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  background: #fbfaf7;
  color: #24231f;
  box-shadow: 0 18px 50px rgba(0,0,0,0.26);
}
.lb-markdown h1,
.lb-markdown h2,
.lb-markdown h3,
.lb-markdown h4 {
  margin: 1.2em 0 0.45em;
  line-height: 1.08;
  letter-spacing: 0;
  color: #1f1e1b;
}
.lb-markdown h1:first-child,
.lb-markdown h2:first-child,
.lb-markdown h3:first-child { margin-top: 0; }
.lb-markdown h1 { font-size: 34px; font-weight: 700; }
.lb-markdown h2 { font-size: 24px; font-weight: 650; }
.lb-markdown h3 { font-size: 18px; font-weight: 650; }
.lb-markdown p,
.lb-markdown li {
  font-size: 16px;
  line-height: 1.62;
}
.lb-markdown p { margin: 0 0 1em; }
.lb-markdown ul,
.lb-markdown ol { padding-left: 1.35em; margin: 0 0 1.1em; }
.lb-markdown blockquote {
  margin: 1.25em 0;
  padding: 0.1em 0 0.1em 1em;
  border-left: 3px solid var(--border-2);
  color: var(--text-2);
}
.lb-markdown a { color: var(--accent-text); }
.lb-markdown code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: #ece8df;
  border-radius: 4px;
  padding: 0.1em 0.32em;
}
.lb-markdown pre {
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius);
  background: #1f1e1b;
  color: #f8f5ee;
}
.lb-markdown pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}
.lb-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: 14px;
}
.lb-markdown th,
.lb-markdown td {
  border-bottom: 0.5px solid #ddd8ce;
  padding: 8px 10px;
  text-align: left;
}
.markdown-loading {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.markdown-loading [data-lucide] { width: 36px; height: 36px; color: var(--text-3); }

/* SVGs often have no intrinsic size and dark ink — give them a definite box + light backing */
.card .thumb.is-svg { object-fit: contain; background: #fff; padding: 12%; }
.asset-grid.masonry .card .thumb.is-svg { aspect-ratio: 4 / 3; }
.lb-media img.is-svg {
  width: min(100%, 780px); height: auto; max-height: 70vh;
  background: #fff; padding: 28px; border-radius: var(--radius);
}

/* ---- Settings page (functional) & branding ---- */
.settings-input {
  height: 34px; min-width: 220px; padding: 0 12px;
  border: 0.5px solid var(--border-2); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 13px;
}
.settings-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.settings-status { font-size: 12.5px; color: var(--text-3); margin-right: auto; }

.brand-mark-img { background: transparent; overflow: hidden; }
.brand-mark-img img { width: 100%; height: 100%; object-fit: contain; }
.login-mark-img { background: transparent; overflow: hidden; }
.login-mark-img img { width: 100%; height: 100%; object-fit: contain; }
.logo-prev {
  width: 40px; height: 40px; border-radius: var(--radius);
  border: 0.5px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-3); overflow: hidden;
}
.logo-prev-img { background: #fff; }
.logo-prev-img img { width: 100%; height: 100%; object-fit: contain; }

.login-error {
  font-size: 12.5px; color: var(--color-text-danger, #b42318);
  background: var(--color-background-danger, #fdeceb); border-radius: var(--radius);
  padding: 7px 10px;
}
.kiosk-note { cursor: default; }
.kiosk-note:hover { background: transparent; color: var(--text-3); }

/* Logo size control in settings */
.logo-size-control { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.logo-size-control input[type="range"] { flex: 1; accent-color: var(--accent); }
.logo-size-val { font-size: 12.5px; color: var(--text-2); font-family: var(--mono); min-width: 40px; text-align: right; }
.config-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.danger-zone-heading h3 { color: var(--color-text-danger, #b42318); }
.danger-zone-row {
  border-color: var(--color-border-danger, #e0a0a0);
  background: var(--color-background-danger, #fdeceb);
}
.danger-btn {
  border-color: var(--color-border-danger, #e0a0a0);
  color: var(--color-text-danger, #b42318);
}
.danger-btn:hover {
  background: #fff5f4;
  color: var(--color-text-danger, #b42318);
}
.sync-token-settings { gap: 14px; }
.sync-token-card,
.sync-token-empty,
.sync-token-reveal {
  width: 100%;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}
.sync-token-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.sync-token-meta { min-width: 0; display: grid; gap: 4px; }
.sync-token-meta strong { font-size: 13px; font-weight: 600; }
.sync-token-meta span,
.sync-token-empty,
.sync-token-reveal p {
  color: var(--text-3);
  font-size: 12px;
}
.sync-token-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sync-token-reveal {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--accent-soft);
  display: grid;
  gap: 10px;
}
.sync-token-reveal strong { font-size: 13px; }
.sync-token-reveal p { margin: 3px 0 0; color: var(--accent-text); }
.sync-token-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.sync-token-field {
  font-family: var(--mono);
  font-size: 12px;
}
.sync-token-create { align-self: flex-start; }

/* ---------- Admin docs / changelog modal ---------- */
.admin-info-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.admin-info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 20, 0.46);
}
.admin-info-dialog {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius-lg);
  background: var(--bg);
  box-shadow: 0 22px 70px rgba(0,0,0,0.24);
}
.admin-info-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px 15px;
  border-bottom: 0.5px solid var(--border);
}
.admin-info-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}
.admin-info-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.admin-info-close {
  flex-shrink: 0;
  color: var(--text-2);
  border-color: var(--border-2);
}
.admin-info-close [data-lucide] { color: currentColor; }
.admin-info-body {
  overflow: auto;
  padding: 20px;
}
.admin-info-copy,
.release-entry {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.admin-info-intro,
.release-entry > p {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}
.admin-info-copy section,
.release-entry section {
  padding-top: 2px;
}
.admin-info-copy h3,
.release-entry h3,
.release-entry h4 {
  margin: 0 0 7px;
  color: var(--text);
}
.admin-info-copy h3 { font-size: 16px; }
.release-entry h3 { font-size: 20px; }
.release-entry h4 { font-size: 14px; }
.admin-info-copy p,
.release-entry li {
  margin: 0 0 7px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}
.release-entry ul {
  margin: 0;
  padding-left: 18px;
}
.release-entry-head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 12px;
}
.release-version {
  color: var(--accent-text);
  font-family: var(--mono);
  font-weight: 600;
}
.version-note {
  font-family: var(--mono);
  font-size: 12.5px;
}
.admin-info-state {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-3);
}
.admin-info-state [data-lucide] {
  width: 28px;
  height: 28px;
}

/* ---------- Toasts ---------- */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  max-width: min(360px, calc(100vw - 36px));
  padding: 10px 13px;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius-lg);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 16px 42px rgba(0,0,0,0.22);
  font-size: 13px;
  line-height: 1.35;
}
