:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dde2e9;
  --text: #1c2330;
  --muted: #667085;
  --accent: #3d6bf2;
  --accent-text: #ffffff;
  --danger: #d14343;
  --success: #2f9e62;
  --thumb-bg: linear-gradient(160deg, #eef2f7, #dfe5ee);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
  --radius: 10px;
  --scene-bg: #e9edf2;
  --grid-major: #9aa4b1;
  --grid-minor: #c8d0da;
  color-scheme: light dark;
}

/* Auto (no data-theme): the Classic palette follows the OS setting. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #12151b;
    --surface: #1a1e26;
    --surface-2: #232833;
    --border: #2d3340;
    --text: #e6e9ef;
    --muted: #8d96a7;
    --accent: #5b82ff;
    --danger: #ef6464;
    --success: #43b97a;
    --thumb-bg: linear-gradient(160deg, #20252f, #181c23);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .25);
    --scene-bg: #1b1f26;
    --grid-major: #55606e;
    --grid-minor: #323943;
  }
}

/* ---------- themes (picked in the top bar, see js/theme.js) ---------- */

:root[data-theme="classic-light"] { color-scheme: light; }

:root[data-theme="classic-dark"] {
  --bg: #12151b;
  --surface: #1a1e26;
  --surface-2: #232833;
  --border: #2d3340;
  --text: #e6e9ef;
  --muted: #8d96a7;
  --accent: #5b82ff;
  --danger: #ef6464;
  --success: #43b97a;
  --thumb-bg: linear-gradient(160deg, #20252f, #181c23);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .25);
  --scene-bg: #1b1f26;
  --grid-major: #55606e;
  --grid-minor: #323943;
  color-scheme: dark;
}

/* Mint */
:root[data-theme="mint"] {
  --bg: #eef7f2;
  --surface: #fbfefc;
  --surface-2: #e2f1e8;
  --border: #cfe3d7;
  --text: #1d2b25;
  --muted: #53665c;
  --accent: #2c7659;
  --accent-text: #ffffff;
  --danger: #b23c3a;
  --success: #2f7543;
  --thumb-bg: linear-gradient(160deg, #e6f3ec, #d4e9dd);
  --shadow: 0 1px 2px rgba(29, 64, 48, .07), 0 2px 8px rgba(29, 64, 48, .07);
  --scene-bg: #e4f0e9;
  --grid-major: #8fb09f;
  --grid-minor: #c2d9cc;
  color-scheme: light;
}

/* Lavender */
:root[data-theme="lavender"] {
  --bg: #f3f1fa;
  --surface: #fdfcff;
  --surface-2: #ebe7f6;
  --border: #dcd6ee;
  --text: #25213a;
  --muted: #5d5876;
  --accent: #6650b4;
  --accent-text: #ffffff;
  --danger: #b03a55;
  --success: #2c7453;
  --thumb-bg: linear-gradient(160deg, #eeeaf8, #dfd8f1);
  --shadow: 0 1px 2px rgba(50, 40, 90, .07), 0 2px 8px rgba(50, 40, 90, .07);
  --scene-bg: #ebe8f5;
  --grid-major: #a39bc3;
  --grid-minor: #d0cae6;
  color-scheme: light;
}

/* Peach */
:root[data-theme="peach"] {
  --bg: #fbf1eb;
  --surface: #fffcfa;
  --surface-2: #f7e6db;
  --border: #ecd6c8;
  --text: #33231b;
  --muted: #6a5447;
  --accent: #a04c2b;
  --accent-text: #ffffff;
  --danger: #b0363a;
  --success: #2f7343;
  --thumb-bg: linear-gradient(160deg, #f9ebe1, #f0dbcc);
  --shadow: 0 1px 2px rgba(90, 50, 30, .07), 0 2px 8px rgba(90, 50, 30, .07);
  --scene-bg: #f6ebe3;
  --grid-major: #c4a592;
  --grid-minor: #e4d0c2;
  color-scheme: light;
}

/* Sky */
:root[data-theme="sky"] {
  --bg: #eef5fb;
  --surface: #fbfdff;
  --surface-2: #e2eef8;
  --border: #cfdfed;
  --text: #1b2733;
  --muted: #526478;
  --accent: #2b67a0;
  --accent-text: #ffffff;
  --danger: #b23c3a;
  --success: #2b7452;
  --thumb-bg: linear-gradient(160deg, #e5f0f9, #d2e3f2);
  --shadow: 0 1px 2px rgba(30, 60, 95, .07), 0 2px 8px rgba(30, 60, 95, .07);
  --scene-bg: #e5eff8;
  --grid-major: #90abc4;
  --grid-minor: #c4d6e8;
  color-scheme: light;
}

/* Dusk: pastel accents on a dark ground */
:root[data-theme="dusk"] {
  --bg: #1b1a24;
  --surface: #23222f;
  --surface-2: #2d2b3b;
  --border: #3b394d;
  --text: #ece9f5;
  --muted: #aaa5be;
  --accent: #aab7f5;
  --accent-text: #1b1a24;
  --danger: #f3a1aa;
  --success: #9fd8b6;
  --thumb-bg: linear-gradient(160deg, #2a2838, #201f2b);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .3);
  --scene-bg: #1f1e29;
  --grid-major: #5e5b75;
  --grid-minor: #35334a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

body.modal-open { overflow: hidden; }
body:not(.can-edit) [data-write] { display: none !important; }

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

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
}
.brand svg { color: var(--accent); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
}
.breadcrumb a { color: var(--muted); text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.breadcrumb a:hover { color: var(--text); background: var(--surface-2); }
.breadcrumb a.current { color: var(--text); font-weight: 600; }
.breadcrumb .sep { color: var(--border); }

.actions { display: flex; align-items: center; gap: 8px; }

#search {
  width: 220px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* ---------- grid ---------- */

main { padding: 20px; max-width: 1600px; width: 100%; min-width: 0; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min, 190px), 100%), 1fr));
  gap: 16px;
}
.grid.folders { margin-bottom: 16px; }
.grid:empty { display: none; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.thumb {
  aspect-ratio: 1;
  width: 100%;
  background: var(--thumb-bg);
  background-size: cover;
  background-position: center;
  position: relative;
}
.thumb.pending::after,
.thumb.failed::after {
  content: attr(data-state);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.thumb.pending::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -34px 0 0 -14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.thumb.failed::before { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted);
  border: 1px solid var(--border);
}

.info { padding: 10px 12px 12px; min-width: 0; }
.info .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info .desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.folder-thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; }
.folder-thumb .folder-icon { margin: 0; transform: scale(1.6); }
.folder-icon {
  flex: none;
  width: 36px;
  height: 28px;
  margin: 0 12px 0 14px;
  border-radius: 4px 6px 6px 6px;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  position: relative;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 16px;
}
.folder-icon::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 0;
  width: 14px;
  height: 6px;
  border-radius: 3px 3px 0 0;
  background: inherit;
}

.card-del {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}
.card:hover .card-del, .card-del:focus-visible { opacity: 1; }
.card-del:hover { color: var(--danger); background: var(--surface-2); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ---------- upload progress / drop ---------- */

.progress {
  position: relative;
  height: 28px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress .bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 35%, transparent); transition: width .15s; }
.progress .label { position: relative; display: block; padding: 4px 12px; font-size: 13px; }

/* Upload button menu: files or a folder. Fixed, so no toolbar clips it. */
.upload-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.upload-menu[hidden] { display: none; }
.upload-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.upload-menu button:hover, .upload-menu button:focus-visible { background: var(--surface-2); outline: none; }
.upload-menu svg { flex: none; color: var(--accent); }

.drop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  pointer-events: none;
}
.drop div {
  padding: 28px 40px;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: var(--surface);
  font-size: 18px;
  font-weight: 600;
}

/* ---------- viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 340px;
  background: var(--bg);
}

.stage { position: relative; min-width: 0; min-height: 0; }
.canvas-host { position: absolute; inset: 0; }
.canvas-host canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.v-status {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: none;
  max-width: 80%;
}
.v-status.show { display: block; }
.v-status.note { top: 16px; transform: translateX(-50%); font-size: 13px; color: var(--muted); }
/* Lychee scenes without their models: Lychee's own preview. */
.v-picture { position: absolute; inset: 56px 16px 72px; width: calc(100% - 32px); height: calc(100% - 128px); object-fit: contain; pointer-events: none; }
.v-status.error { color: var(--danger); }

.toolbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  white-space: nowrap;
}
.tool:hover { background: var(--surface-2); }
.tool:disabled { opacity: .35; cursor: default; background: transparent; }
#v-prev, #v-next { font-size: 20px; line-height: 1; padding: 4px 12px; }
.toggle input { accent-color: var(--accent); margin: 0; }

.close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.close:hover { background: var(--surface-2); }

.panel {
  overflow-y: auto;
  padding: 20px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.panel h2 { margin: 0; font-size: 18px; word-break: break-word; }
.filename { margin: 2px 0 16px; color: var(--muted); font-size: 12px; word-break: break-all; }

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 20px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.meta { display: flex; flex-direction: column; gap: 6px; }
.meta label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.meta input, .meta textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  resize: vertical;
}
.meta input:focus, .meta textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.meta input:disabled, .meta textarea:disabled { opacity: .7; }

.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.saved { color: var(--success); font-size: 13px; }
.panel-actions { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.panel-actions { flex-wrap: wrap; }

/* ---------- library picker ---------- */

.lib-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.lib-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-btn select {
  min-width: 0;
  max-width: 200px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-overflow: ellipsis;
}
.lib-btn select:disabled { cursor: default; opacity: 1; appearance: none; }
.lib-btn select:focus { outline: none; }
.lib-btn:focus-within { border-color: var(--accent); }
.lib-btn svg { flex: none; color: var(--accent); }
.lib-btn:hover { border-color: var(--accent); }
.theme-btn select { max-width: 120px; }
.lang-btn { position: relative; }
.lang-btn .lang-code { font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.lang-btn select { position: absolute; inset: 0; width: 100%; max-width: none; opacity: 0; cursor: pointer; }
html.i18n-wait body { visibility: hidden; }

.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 20, .45);
  overscroll-behavior: contain;
}
/* The dialog is capped to the viewport; only its folder list scrolls, so it
   stays centered however many folders there are. */
.picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(640px, 100%);
  height: min(640px, calc(100vh - 32px));
  height: min(640px, calc(100dvh - 32px));
  padding: 20px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.picker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.picker-head h2 { margin: 0; font-size: 18px; }
.hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.close-sm {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.close-sm:hover { background: var(--surface-2); }

.picker-search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.picker-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.picker-path { display: flex; align-items: center; gap: 10px; min-width: 0; }
.picker-path code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13px;
}
.btn.sm { padding: 5px 10px; font-size: 13px; }

.picker-recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.picker-recent button {
  max-width: 100%;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-recent button:hover { border-color: var(--accent); }

.picker-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.picker-list li button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.picker-list li button:hover, .picker-list li button:focus-visible { background: var(--surface-2); outline: none; }
.picker-list .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list .ppath { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list .count {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.picker-list .ficon { flex: none; width: 18px; height: 14px; border-radius: 2px 3px 3px 3px; background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.picker-list .msg { padding: 16px; color: var(--muted); text-align: center; }

.picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- groups / series ---------- */

.btn.icon { padding: 7px; }

.stack { position: relative; padding: 10px 10px 0; }
.stack::before, .stack::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  height: 8px;
  border-radius: 6px 6px 0 0;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  border: 1px solid var(--border);
  border-bottom: 0;
}
.stack::before { top: 0; left: 26px; right: 26px; opacity: .6; }
.stack::after { top: 4px; }
.stack .thumb { position: relative; z-index: 1; border-radius: 8px; border: 1px solid var(--border); }
.card.group { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.badge.count { z-index: 2; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.info .series { margin-top: 4px; font-size: 11px; color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.group-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.group-title { display: flex; align-items: baseline; gap: 10px; flex: 1; min-width: 0; }
.group-title h2 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack-icon { width: 14px; height: 12px; border-radius: 3px; background: var(--accent); box-shadow: 3px -3px 0 -1px color-mix(in srgb, var(--accent) 45%, transparent); align-self: center; flex: none; }
.group-actions { display: flex; gap: 8px; }

.group-chip {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.group-chip:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.desc-view { margin: 0 0 16px; white-space: pre-wrap; word-break: break-word; }
.meta .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 13px; }
.meta .check input { width: auto; accent-color: var(--accent); }
.meta .hint { margin: 0; }
.empty a { color: var(--accent); }

/* ---------- admin page ---------- */

.admin-title { font-weight: 600; color: var(--muted); }
.admin-page .topbar .actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.admin, #admin-body { max-width: 960px; display: flex; flex-direction: column; gap: 20px; }
#admin-body[hidden] { display: none; }

/* Tabs: a list of sections on the left, the open one on the right. */
main.admin:has(#admin-body:not([hidden])) { max-width: 1200px; }
#admin-body:has(.admin-tabs) { max-width: none; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-tabs { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.admin-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.admin-tab svg { flex: none; opacity: .8; }
.admin-tab:hover { background: var(--bg); color: var(--text); }
.admin-tab[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.admin-tab[aria-selected="true"] svg { opacity: 1; }
.admin-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.admin-panes { min-width: 0; }
.admin-pane { display: flex; flex-direction: column; gap: 20px; animation: pane-in .18s ease-out; }
.admin-pane[hidden] { display: none; }
.pane-head h1 { margin: 2px 0 4px; font-size: 24px; }
.pane-head .hint { margin: 0; }
@keyframes pane-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .admin-pane { animation: none; } }
@media (max-width: 800px) {
  #admin-body:has(.admin-tabs) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .admin-tabs {
    position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px; padding: 8px 16px; border-radius: 0; border-width: 0 0 1px; box-shadow: none;
  }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tab { flex: none; padding: 8px 12px; }
  .pane-head h1 { font-size: 20px; }
}
.panel-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-card.narrow { max-width: 420px; margin: 40px auto; width: 100%; }
.panel-card h2 { margin: 0 0 4px; font-size: 18px; }
.panel-card h3 { margin: 12px 0 0; font-size: 15px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.hint.small { font-size: 12px; margin-top: 10px; }
.err { color: var(--danger); font-size: 13px; }

.form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; align-items: start; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 14px; }
.form label .hint { font-weight: 400; }
.form .gb { color: var(--muted); font-size: 13px; }
.form .limits input[type=number] { width: 110px; }
.form .hint.env { color: var(--accent); }
.form input[type=password], .form input[type=number], .form input[type=text], .form input[type=url], .form input[type=email], .form input[type=time], .form input:not([type]), .form select, .form textarea, .lib-name {
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.form input[type=number] { width: 90px; }
.form input[type=color] { width: 44px; height: 32px; padding: 0 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.form .inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.form fieldset { border: 0; margin: 0; padding: 0; }
.form legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check input { accent-color: var(--accent); }
.narrow-form { max-width: 360px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.row.wrap { flex-wrap: wrap; margin-top: 16px; }

.lib-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lib-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.lib-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 240px; flex-wrap: wrap; }
.lib-name { width: 180px; font-weight: 600; }
.lib-path { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lib-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-empty { padding: 16px; color: var(--muted); text-align: center; border: 1px dashed var(--border); border-radius: 10px; }
.tag { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag.warn { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.stats {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; word-break: break-word; font-variant-numeric: tabular-nums; }
.user-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.user-form input { flex: 1 1 180px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
#user-list { margin-top: 10px; }
.dup-list { display: grid; gap: 10px; }
.dup-group { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px; }
.dup-group h3 { margin: 0 0 6px; font-size: 13px; }
.dup-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dup-group li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dup-group code { flex: 1; min-width: 0; word-break: break-all; font-size: 12px; }
.storage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.storage-row { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px; }
.storage-row .storage-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.storage-row .storage-name { font-weight: 600; }
.storage-row .storage-free { color: var(--muted); font-variant-numeric: tabular-nums; }
.storage-row .storage-free.low { color: var(--danger); font-weight: 600; }
.storage-row .storage-detail { margin-top: 4px; color: var(--muted); font-variant-numeric: tabular-nums; word-break: break-word; }
.storage-bar { height: 6px; margin-top: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.storage-bar > span { display: block; height: 100%; background: var(--accent); }
.storage-bar.low > span { background: var(--danger); }
.failures { margin-bottom: 12px; font-size: 13px; }
.failures summary { cursor: pointer; color: var(--danger); }
.failures ul { margin: 8px 0 0; padding-left: 18px; }
.failures code { font-size: 12px; word-break: break-all; }

.remote-form { margin: 0 0 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.remote-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.remote-form input:not([type=checkbox]), .remote-form select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
.remote-form h3 { margin: 0 0 6px; }
.remote-form.nfs .smb-only { display: none; }
.notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, #e0a200 16%, transparent); font-size: 13px; }
.tag.ok { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.tag.off { background: var(--surface-2); color: var(--muted); }
.remote-err { flex-basis: 100%; font-size: 12px; color: var(--danger); word-break: break-word; }

@media (max-width: 800px) {
  .remote-form .grid2 { grid-template-columns: 1fr; }
  .form.grid2 { grid-template-columns: 1fr; }
  .card-head { flex-direction: column; }
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  max-width: 360px;
  transition: opacity .4s, transform .4s;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- small screens ---------- */

@media (max-width: 800px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .breadcrumb { order: 3; flex-basis: 100%; }
  .actions { margin-left: auto; }
  #search { width: 120px; }
  .brand span { display: none; }
  .lib-btn { max-width: 140px; }
  .theme-btn select { max-width: 72px; }
  .btn span { display: none; }
  main { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min, 150px), calc(50% - 6px)), 1fr)); gap: 12px; }
  .viewer { grid-template-columns: 1fr; grid-template-rows: 58vh 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--border); }
  .toolbar { bottom: 10px; max-width: calc(100% - 20px); overflow-x: auto; }
  .tool { padding: 6px 8px; }
}

/* ---------- layout: sidebar + content ---------- */

.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  align-items: start;
}
body.sidebar-collapsed .layout { grid-template-columns: minmax(0, 1fr); }
body.sidebar-collapsed .sidebar { display: none; }

.sidebar {
  position: sticky;
  top: var(--topbar-h, 57px);
  height: calc(100vh - var(--topbar-h, 57px));
  height: calc(100dvh - var(--topbar-h, 57px));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 12px 24px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar .lib-btn { max-width: none; width: 100%; }
.sidebar .lib-btn select { max-width: none; flex: 1; }
.sidebar-scrim { display: none; }

.side-title {
  margin: 0 0 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list .tree-list { padding-left: 14px; }
.tree-row { display: flex; align-items: center; gap: 2px; border-radius: 6px; }
.tree-row:hover { background: var(--surface-2); }
.tree-row.current { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tree-twist {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tree-twist svg { transition: transform .12s ease; }
[aria-expanded="true"] > .tree-row .tree-twist svg { transform: rotate(90deg); }
.tree-twist.leaf { visibility: hidden; }
.tree-twist:hover { color: var(--text); }
.tree-twist:focus-visible, .tree-link:focus-visible, .series-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tree-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 2px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.tree-row.current .tree-link { font-weight: 600; }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .ficon, .series-link .stack-icon { flex: none; }
.tree .ficon { width: 16px; height: 12px; border-radius: 2px 3px 3px 3px; background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.tree .ficon.root { background: var(--accent); }

.series-list { list-style: none; margin: 0; padding: 0; }
.series-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.series-link:hover { background: var(--surface-2); }
.series-link.current { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
.series-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-link .count {
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

/* ---------- view bar (title, card size, grid/list) ---------- */

.view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.view-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.view-title h1 { margin: 0; font-size: 20px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-title .hint { margin: 0; white-space: nowrap; }
.view-tools { display: flex; align-items: center; gap: 12px; }
.size-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.pick-control { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.pick-control select { max-width: 150px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.pick-control select.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.size-control input { width: 110px; accent-color: var(--accent); }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { color: var(--text); background: var(--surface-2); }
.segmented button[aria-pressed="true"] { color: var(--text); font-weight: 600; background: var(--surface-2); }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- folder tiles ---------- */

.card.folder .card-del {
  top: 8px;
  transform: none;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}
.thumb.picture { background-size: cover; }
.card-pic {
  position: absolute;
  right: 40px;
  top: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}
.card:hover .card-pic, .card-pic:focus-visible { opacity: 1; }
.card-pic:hover { color: var(--accent); background: var(--surface-2); }
.pic-icon {
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Ccircle cx='9' cy='10' r='2'/%3E%3Cpath d='m21 16-5-5-9 9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Ccircle cx='9' cy='10' r='2'/%3E%3Cpath d='m21 16-5-5-9 9'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (hover: none) { .card-pic { opacity: 1; } }

/* ---------- folder picture dialog ---------- */

.picker.fp { height: auto; max-height: min(720px, calc(100dvh - 32px)); }
.fp-now { display: flex; gap: 14px; align-items: center; }
.fp-current {
  flex: none;
  width: 120px;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
}
.fp.previewing .fp-current { width: 176px; outline: 2px solid var(--accent); outline-offset: 2px; }
.fp-current .folder-icon { margin: 0; }
.fp-now-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fp-now-text .row { flex-wrap: wrap; }
.fp-choices { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.fp-choices .side-title { margin: 10px 0 8px; }
.fp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.fp-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
}
.fp-tile span {
  position: absolute;
  inset: auto 0 0;
  padding: 2px 6px;
  overflow: hidden;
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  background: rgba(0, 0, 0, .5);
}
.fp-tile:hover, .fp-tile:focus-visible, .fp-tile.selected { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.fp-current.zoomable { cursor: zoom-in; }
.picker-backdrop.busy .fp, .picker-backdrop.busy .fp-full { opacity: .6; pointer-events: none; }
.fp-full {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: rgb(12, 12, 14);
}
.fp-full-head, .fp-full-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}
.fp-full-name { min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.fp-full-count { flex: 1; font-size: 13px; opacity: .7; white-space: nowrap; }
.fp-full-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .15);
  cursor: pointer;
}
.fp-full-x:hover, .fp-full-x:focus-visible { background: rgba(255, 255, 255, .3); }
.fp-full-stage { position: relative; flex: 1; min-height: 0; display: flex; touch-action: none; }
/* margin: auto centres the picture and still lets it scroll when bigger. */
.fp-full-scroll { flex: 1; min-width: 0; display: flex; overflow: hidden; padding: 12px 16px; }
.fp-full.actual .fp-full-scroll { overflow: auto; cursor: grab; touch-action: pan-x pan-y; }
.fp-full.actual .fp-full-stage { touch-action: auto; }
.fp-full-pic { position: relative; margin: auto; line-height: 0; user-select: none; }
.fp-full-pic img { display: block; max-width: none; pointer-events: none; }
.fp-full-fit {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 16px;
  color: #fff;
  font: inherit;
  font-size: 13px;
  background: transparent;
  cursor: pointer;
}
.fp-full-fit:hover, .fp-full-fit:focus-visible { background: rgba(255, 255, 255, .15); }
.fp-full-shade { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fp-full-shade div { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5); }
.fp-full-crop {
  position: absolute;
  border: 2px solid #fff;
  cursor: move;
  touch-action: none;
}
.fp-h {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
.fp-h::before { content: ""; position: absolute; inset: -12px; } /* a bigger target for fingers */
.fp-h[data-h="nw"] { left: -10px; top: -10px; cursor: nwse-resize; }
.fp-h[data-h="ne"] { right: -10px; top: -10px; cursor: nesw-resize; }
.fp-h[data-h="sw"] { left: -10px; bottom: -10px; cursor: nesw-resize; }
.fp-h[data-h="se"] { right: -10px; bottom: -10px; cursor: nwse-resize; }
.fp-full.locked .fp-full-crop { cursor: default; pointer-events: none; }
/* "Fit whole picture": the 4:3 card as saved, no frame. */
.fp-full.boxed .fp-full-crop, .fp-full.boxed .fp-full-shade,
.fp-full.boxed [data-act="crop-reset"], .fp-full.boxed [data-act="full-fit"] { display: none; }
.fp-full.boxed .fp-full-pic { box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }
.fp-mode { flex-wrap: wrap; gap: 8px; }
.fp-full-foot .fp-mode { margin-top: 0; }
.fp-full.locked .fp-h { display: none; }
.fp-full-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  cursor: pointer;
}
.fp-full-nav.prev { left: 12px; }
.fp-full-nav.next { right: 12px; }
.fp-full-nav:hover:not(:disabled), .fp-full-nav:focus-visible { background: rgba(255, 255, 255, .25); }
.fp-full-nav:disabled { opacity: .3; cursor: default; }
.fp-full-foot { flex-wrap: wrap; }
.fp-full-foot .row { margin-top: 0; }
.fp-full-hint { font-size: 13px; opacity: .8; }
.fp-err:empty { display: none; }

/* ---------- list view ---------- */

.list-view .grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
.list-view .grid.folders { margin-bottom: 6px; }
.list-view .card { flex-direction: row; align-items: center; box-shadow: none; }
.list-view .card:hover { transform: none; }
.list-view .thumb,
.list-view .stack .thumb {
  flex: none;
  width: 52px;
  aspect-ratio: 1;
  margin: 6px;
  border-radius: 6px;
}
.list-view .folder-thumb .folder-icon { transform: none; }
.list-view .stack { padding: 0; }
.list-view .stack::before, .list-view .stack::after { display: none; }
.list-view .thumb.pending::before { width: 16px; height: 16px; margin: -8px 0 0 -8px; }
.list-view .thumb.pending::after, .list-view .thumb.failed::after { content: none; }
.list-view .info { flex: 1; padding: 6px 12px 6px 6px; }
.list-view .info .desc { -webkit-line-clamp: 1; margin-top: 0; }
.list-view .badge { position: static; order: 2; margin-right: 12px; flex: none; }
.list-view .card-del { position: static; transform: none; order: 3; margin-right: 8px; flex: none; }
.list-view .card-pic { position: static; order: 3; margin-right: 4px; flex: none; }

/* ---------- group picker ---------- */

.combo { position: relative; }
.combo-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.combo-btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.combo-btn:focus-visible, .combo-btn[aria-expanded="true"] { outline: 2px solid var(--accent); outline-offset: -1px; }
.combo-btn svg { flex: none; color: var(--muted); }
.combo-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-value.muted { color: var(--muted); }
.combo-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-modal, 0 12px 32px rgba(0, 0, 0, .18));
}
.meta .combo-input {
  padding: 7px 10px;
  border-radius: 6px;
}
.combo-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.combo-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.combo-list li > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-list li:hover { background: var(--surface-2); }
.combo-list li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.combo-list .opt-hint { color: var(--muted); font-size: 12px; }
.combo-list .opt-check { color: var(--accent); font-weight: 700; }
.combo-list .create { color: var(--accent); font-weight: 600; }
.combo-list .sep { padding: 0; margin: 4px 6px; border-top: 1px solid var(--border); cursor: default; }
.combo-list .sep:hover { background: none; }
.combo-list .empty-opt { color: var(--muted); cursor: default; }

/* ---------- covers & pictures ---------- */

.cover-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.cover-opt {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.cover-opt:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.cover-opt.img {
  width: 52px;
  height: 52px;
  padding: 0;
  background-size: cover;
  background-position: center;
}
.cover-opt[aria-checked="true"] { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; font-weight: 600; }
.cover-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.image-strip { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 4px; }
.image-strip button {
  flex: none;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--thumb-bg);
  cursor: zoom-in;
}
.image-strip img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.image-strip button:hover { border-color: var(--accent); }
.image-strip button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: safe center; /* "safe": a zoomed picture larger than the window stays scrollable to its edges */
  padding: 56px 72px;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(10, 14, 20, .88);
}
/* Fitted to the window by default; click a picture that was scaled down to see it at full size and scroll around. */
.lightbox img {
  max-width: calc(100vw - 144px);
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  object-fit: contain;
  border-radius: 8px;
  -webkit-user-drag: none;
  user-select: none;
}
.lightbox.zoomable img { cursor: zoom-in; }
.lightbox.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox .close { position: fixed; left: auto; right: 12px; }
.lb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
.lb-nav:focus-visible, .lightbox .close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lb-caption {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 14px;
  margin: 0;
  text-align: center;
  color: #f2f4f7;
  font-size: 13px;
}

/* ---------- small screens: the sidebar becomes a drawer ---------- */

@media (max-width: 800px) {
  .layout, body.sidebar-collapsed .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar, body.sidebar-collapsed .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 25;
    width: min(300px, 86vw);
    height: auto;
    box-shadow: var(--shadow-modal, 0 20px 60px rgba(0, 0, 0, .3));
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .2s ease, visibility .2s;
  }
  body.sidebar-open .sidebar { transform: none; visibility: visible; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 24; background: var(--backdrop, rgba(10, 14, 20, .45)); }
  .sidebar-scrim[hidden] { display: none; }
  .actions { flex: 1 1 100%; order: 2; min-width: 0; margin-left: 0; }
  #search { flex: 1 1 60px; width: 60px; min-width: 0; }
  .view-bar { margin-bottom: 12px; }
  .view-title h1 { font-size: 18px; }
  .size-control input { width: 80px; }
  .view-tools { flex-wrap: wrap; gap: 8px; }
  .pick-control select { max-width: 120px; }
  .segmented button span { display: none; }
  .lightbox { padding: 56px 12px; }
  .lightbox img { max-width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .tree-twist svg { transition: none; }
}

/* ---------- info panel (README / notes) ---------- */

.layout.with-info { grid-template-columns: 264px minmax(0, 1fr) 340px; }
body.sidebar-collapsed .layout.with-info { grid-template-columns: minmax(0, 1fr) 340px; }

.info-panel {
  position: sticky;
  top: var(--topbar-h, 57px);
  height: calc(100vh - var(--topbar-h, 57px));
  height: calc(100dvh - var(--topbar-h, 57px));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 24px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.info-head { display: flex; align-items: center; gap: 8px; }
.info-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-head select {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}
.info-actions { display: flex; align-items: center; gap: 4px; }
.info-file { margin: -4px 0 0; font-size: 12px; word-break: break-all; }
.info-file:empty { display: none; }

.doc { font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; }
.doc-text { margin: 0; white-space: pre-wrap; font: inherit; }
.doc-md > :first-child { margin-top: 0; }
.doc-md h2, .doc-md h3, .doc-md h4, .doc-md h5, .doc-md h6 { margin: 18px 0 6px; line-height: 1.3; }
.doc-md h2 { font-size: 16px; }
.doc-md h3 { font-size: 15px; }
.doc-md h4, .doc-md h5, .doc-md h6 { font-size: 14px; }
.doc-md p { margin: 0 0 10px; }
.doc-md ul, .doc-md ol { margin: 0 0 10px; padding-left: 20px; }
.doc-md li { margin: 2px 0; }
.doc-md a { color: var(--accent); }
.doc-md code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); font-size: 12.5px; }
.doc-md pre { margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); overflow-x: auto; }
.doc-md pre code { padding: 0; background: none; }
.doc-md blockquote { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.doc-md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

.info-editor { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.info-name-row { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.info-editor input, .info-editor textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.info-editor textarea {
  flex: 1;
  min-height: 280px;
  resize: vertical;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.info-editor input:focus, .info-editor textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.info-editor .row { margin-top: 0; flex-wrap: wrap; }

.btn[aria-pressed="true"] { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }

/* notes of one model, in the viewer panel */
.v-notes { margin: 0 0 16px; display: flex; flex-direction: column; gap: 12px; }
.v-note h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.v-note .doc { max-height: 320px; overflow-y: auto; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }

/* ---------- moving by drag and drop ---------- */

.card[draggable="true"] { cursor: grab; }
.card.drag-source { opacity: .5; }
body.moving .card.folder, body.moving .tree-link, body.moving .breadcrumb a { transition: outline-color .1s; }
.drop-over {
  outline: 2px dashed var(--accent) !important;
  outline-offset: 2px;
  background-color: color-mix(in srgb, var(--accent) 12%, transparent) !important;
}
.tree-link.drop-over, .breadcrumb a.drop-over { outline-offset: -2px; }

@media (max-width: 1100px) {
  .layout.with-info { grid-template-columns: 264px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  body.sidebar-collapsed .layout.with-info { grid-template-columns: minmax(0, 1fr); }
  .layout.with-info .sidebar { grid-row: 1 / span 2; }
  .layout.with-info .info-panel {
    grid-column: -2;
    grid-row: 1;
    position: static;
    height: auto;
    max-height: 45vh;
    border-left: 0;
    border-bottom: 1px solid var(--border);
  }
  .layout.with-info main { grid-column: -2; grid-row: 2; }
}
@media (max-width: 800px) {
  .layout.with-info, body.sidebar-collapsed .layout.with-info { grid-template-columns: minmax(0, 1fr); }
  .layout.with-info .info-panel, .layout.with-info main { grid-column: 1; }
}

/* ---------- orientation (viewer panel, editors) ---------- */

.orient { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.orient h3 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.orient .hint { margin: 0 0 10px; font-size: 12px; }
.orient-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.orient .row { margin-top: 10px; }

/* ---------- daily supporter splash ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 70%, rgba(10, 14, 20, .55));
  backdrop-filter: blur(6px);
  animation: splash-in .25s ease-out;
}
.splash.out { opacity: 0; transition: opacity .25s; }
.splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(460px, 100%);
  margin: auto;
  padding: 28px 24px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-modal, 0 20px 60px rgba(0, 0, 0, .3));
  text-align: center;
  outline: none;
}
.splash-logo {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
}
.splash-logo img { display: block; border-radius: 17px; box-shadow: var(--shadow); }
.splash-card h2 { margin: 4px 0 0; font-size: 22px; }
.splash-card p { margin: 0; line-height: 1.5; }
.splash-points {
  margin: 0;
  padding: 12px 16px;
  list-style: none;
  width: 100%;
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
  font-size: 14px;
}
.splash-points li { position: relative; padding-left: 22px; }
.splash-points li + li { margin-top: 6px; }
.splash-points li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.splash-pay, .splash-coffee { width: 100%; justify-content: center; padding: 11px 16px; font-weight: 600; text-align: center; white-space: normal; text-decoration: none; }
.splash-coffee { gap: 8px; margin-top: -6px; border-color: #ffdd00; background: #ffdd00; color: #111; }
.splash-coffee:hover { background: #ffdd00; filter: brightness(.96); }
.splash-note, .splash-coffee-note { font-size: 12px; }
.splash-card .splash-coffee-note { margin-top: -6px; }
.splash-timer { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; font-size: 12px; color: var(--muted); }
.splash-bar { width: 100%; height: 4px; overflow: hidden; border-radius: 2px; background: var(--surface-2); }
.splash-bar span { display: block; height: 100%; background: var(--accent); transform-origin: left; animation: splash-bar linear forwards; }
@keyframes splash-in { from { opacity: 0; } }
@keyframes splash-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .splash, .splash-bar span { animation: none; } }

/* Supporter reminder in the bottom-right corner (until a license is activated). */
.support-badge {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 35; /* above the viewer, below dialogs and toasts */
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  opacity: .6;
  transition: opacity .2s, color .2s, border-color .2s;
}
.support-badge a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; color: inherit; text-decoration: none; }
.support-badge a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.support-badge .support-coffee { padding-left: 9px; border-left: 1px solid var(--border); border-radius: 0 999px 999px 0; }
.support-badge .support-coffee:hover { color: var(--text); }
.support-donate svg { flex: none; color: #e0245e; }
.support-badge b { color: var(--accent); font-weight: 600; }
.support-badge:hover, .support-badge:focus-within { opacity: 1; color: var(--text); border-color: var(--accent); }
@media (max-width: 700px) {
  .support-badge a { padding: 7px; }
  .support-badge span { display: none; }
}
@media print { .support-badge { display: none; } }

/* ---------- selecting several models ---------- */

.sel-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: 0 1px 4px rgb(0 0 0 / 45%);
  display: none;
  place-items: center;
  pointer-events: none;
  z-index: 3; /* above the picture, the series stack and its count badge */
}
body.selecting .sel-check { display: grid; }
.card.selected .sel-check, .card.partial .sel-check { background: var(--accent); border-color: var(--accent); }
.card.selected .sel-check::after {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -2px;
  border: solid var(--accent-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.card.partial .sel-check::after { content: ""; width: 10px; height: 2px; background: var(--accent-text); }
.card.selected { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -1px; }
body.selecting .card.file { cursor: default; }
body.selecting .card.file:hover { transform: none; }
.list-view .sel-check { position: static; order: -1; margin-left: 10px; flex: none; }
#btn-select[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); color: var(--accent); }

.select-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 8px 10px 8px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .25);
}
.select-bar[hidden] { display: none; }
.sel-count { font-size: 13px; font-weight: 600; margin-right: 6px; white-space: nowrap; }
body.selecting #main { padding-bottom: 90px; }

/* ---------- moving ---------- */

.card-move {
  position: absolute;
  right: 72px;
  top: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}
.card:hover .card-move, .card-move:focus-visible { opacity: 1; }
.card-move:hover { color: var(--accent); background: var(--surface-2); }
@media (hover: none) { .card-move { opacity: 1; } }
.list-view .card-move { position: static; order: 3; margin-right: 4px; flex: none; }
.move-icon {
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Cpath d='M10 13h6m-2-2 2 2-2 2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Cpath d='M10 13h6m-2-2 2 2-2 2'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Other libraries, shown in the sidebar while a card is dragged. */
.move-libs { display: none; margin-top: 14px; }
body.moving .move-libs:not([hidden]) { display: block; }
.lib-drop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lib-drop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.lib-drop.drop-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lib-drop-icon { flex: none; width: 16px; height: 12px; border-radius: 2px; background: var(--accent); }
.move-lib { width: 100%; max-width: none; }
.move-lib select { flex: 1; max-width: none; }
.picker.move-dialog { height: min(560px, calc(100dvh - 32px)); }

/* ---------- admin: trash ---------- */

.trash-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.trash-icon { flex: none; width: 18px; height: 22px; border-radius: 3px; background: color-mix(in srgb, var(--muted) 35%, var(--surface-2)); }
.trash-icon.folder { width: 22px; height: 16px; border-radius: 2px 4px 4px 4px; background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.trash-list { margin-top: 8px; max-height: 420px; overflow-y: auto; }

/* ---------- G-code ---------- */

.tool.layers { cursor: default; }
.tool.layers:hover { background: transparent; }
.tool.layers input { width: 160px; accent-color: var(--accent); }
#v-layers-label { min-width: 92px; font-variant-numeric: tabular-nums; color: var(--muted); }
.gcode-legend { list-style: none; margin: -8px 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.gcode-legend li { display: flex; align-items: center; gap: 6px; }
.gcode-legend .swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid color-mix(in srgb, var(--text) 20%, transparent); }
@media (max-width: 800px) { .tool.layers input { width: 100px; } }
.gcode-view { margin: -8px 0 20px; }
.gcode-view .gcode-legend { margin: 10px 0 6px; }
.gcode-modes { display: flex; flex-wrap: wrap; gap: 8px; }
.gcode-modes .segmented button { padding: 5px 10px; font-size: 12px; }
.gcode-legend label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.gcode-legend input { margin: 0; accent-color: var(--accent); }
.gcode-legend.one-color .swatch { opacity: .35; }

/* ---------- files without a 3D preview (ZBrush) ---------- */

.other-thumb { display: grid; place-items: center; align-content: center; gap: 8px; }
.zbrush-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted) 22%, var(--surface-2));
  color: var(--muted);
  font: 700 30px/1 system-ui, sans-serif;
}
.other-kind { font-size: 12px; color: var(--muted); }
.list-view .other-thumb .zbrush-icon { width: 34px; height: 34px; border-radius: 8px; font-size: 18px; }
.list-view .other-kind { display: none; }
.zbrush-icon.wide { width: auto; min-width: 56px; padding: 0 10px; font-size: 20px; }
.list-view .zbrush-icon.wide { min-width: 34px; padding: 0 4px; font-size: 11px; }
.unpack-btn { position: absolute; right: 8px; bottom: 54px; }
.list-view .unpack-btn { position: static; order: 3; margin-right: 8px; flex: none; }
/* While selecting, the card buttons give way to the tick box. */
body.selecting .card-del, body.selecting .card-pic, body.selecting .card-move, body.selecting .card-ren, body.selecting .unpack-btn { display: none; }
body.selecting .card.folder:hover { transform: none; }

/* ---------- renaming folders ---------- */

.card-ren {
  position: absolute;
  right: 104px;
  top: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}
.card:hover .card-ren, .card-ren:focus-visible { opacity: 1; }
.card-ren:hover { color: var(--accent); background: var(--surface-2); }
@media (hover: none) { .card-ren { opacity: 1; } }
.list-view .card-ren { position: static; order: 3; margin-right: 4px; flex: none; }
.ren-icon {
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- one unzip at a time ---------- */

body.unzipping .unpack-btn { opacity: .45; pointer-events: none; }

/* ---------- sun lamp and thumbnail view ---------- */

.v-light { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.v-tools { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.v-tools h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tool-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tool-buttons .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tool-buttons .shot { display: inline-flex; gap: 4px; align-items: center; }
.tool-buttons select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; }
#t-measure-out { margin: 8px 0 0; font-variant-numeric: tabular-nums; }
#t-measure-out strong { color: var(--text); }
.slicer-open { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; max-width: 100%; min-width: 0; }
.slicer-open select { padding: 6px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; max-width: 120px; }
/* Comparing models: only what applies to both stays in the panel. */
.viewer.comparing :is(#v-prev, #v-next, #t-ar, #t-export, #t-export-tools, #v-zup, #v-gcode, #v-group, #v-images, #v-notes, #v-desc, #v-orient, #meta-form, .panel-actions, #v-facts, #v-filename) { display: none !important; }
.viewer.comparing .toggle:has(#v-zup) { display: none; }
.compare-facts { display: grid; gap: 10px; margin-bottom: 18px; }
.compare-facts .facts { margin: 0; }
.compare-facts h3 { margin: 0 0 4px; font-size: 13px; }
.compare-facts h3 span { color: var(--muted); font-weight: 500; }
/* ---------- accounts, lists and my marks ---------- */
.account-btn span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dialog { width: min(420px, calc(100vw - 32px)); height: auto; gap: 12px; }
.account-dialog .field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.account-dialog .field input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.account-dialog .err { color: var(--danger); font-size: 13px; }
.side-lists { display: grid; gap: 2px; margin: 0 0 12px; }
.list-link { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.list-link:hover { background: var(--surface-2); }
.list-link.current { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
.list-link[hidden], .tag-links[hidden] { display: none; }
.list-icon { width: 18px; text-align: center; color: var(--accent); }
.tag-links { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 10px 0; }
.tag-links a { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 12px; text-decoration: none; }
.tag-links a.current, .tag-links a:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
body.list-mode #folders, body.list-mode #grid, body.list-mode #group-bar, body.list-mode #series-section, body.list-mode #info-panel, body.list-mode .view-tools > :not(.size-control):not(.segmented) { display: none !important; }
body.search-mode #folders, body.search-mode #grid, body.search-mode #group-bar, body.search-mode #info-panel, body.search-mode .view-tools > :not(.size-control):not(.segmented) { display: none !important; }
.search-folder .thumb { display: grid; place-items: center; }
.search-folder .thumb.collage { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; place-items: stretch; gap: 2px; padding: 2px; }
.collage-cell { border-radius: 4px; background: var(--thumb-bg) center / cover no-repeat; min-width: 0; min-height: 0; }
.card .where { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-mark { position: absolute; top: 8px; right: 8px; z-index: 2; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; background: var(--surface); color: #e0a200; font-size: 15px; box-shadow: var(--shadow); }
.v-mine { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.v-mine h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.v-mine .prints-title { margin-top: 6px; }
.fav-btn[aria-pressed="true"] { border-color: #e0a200; color: #b57f00; font-weight: 600; }
.tag-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.tag-chips { display: contents; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); font-size: 12px; }
.tag-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.tag-edit input { flex: 1; min-width: 90px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; outline: none; }
.print-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.print-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.print-list .p-photo { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; cursor: zoom-in; }
.print-list .p-date { font-weight: 600; }
.print-list .p-note { color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.print-list .p-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.print-list .p-empty { display: block; background: none; color: var(--muted); padding: 0; }
.print-add summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.print-form { display: grid; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.print-form label { display: grid; gap: 3px; }
.print-form input:not([type=file]), .print-form textarea { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.bed-tools { display: grid; gap: 8px; margin-top: 10px; }
.bed-tools select { width: 100%; max-width: 100%; }
.bed-tools select, .bed-custom input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.bed-custom { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.bed-custom input { width: 68px; }
.bed-result { margin: 0; font-size: 13px; }
.bed-result.ok { color: var(--success); font-weight: 600; }
.bed-result.bad { color: var(--danger); font-weight: 600; }
.snap-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.snap-row select { flex: 1 1 180px; min-width: 0; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.snap-row .hint { flex-basis: 100%; min-height: 1.2em; }
.section-tools { display: grid; gap: 10px; margin-top: 10px; }
.inline-num { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.inline-num input, .cost-grid input, .cost-grid select { width: 84px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.measure-modes { margin-top: 8px; }
.check-tools { display: grid; gap: 8px; margin-top: 10px; }
.check-tools .check-tools { margin-top: 0; min-width: 0; }
#p-split-seam .row, #p-place-tools .row { flex-wrap: wrap; gap: 8px; margin-top: 0; }
#p-place-angle { width: 5em; }
.v-prepare { margin-top: 16px; }
.p-field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.p-field > span { display: flex; align-items: center; gap: 8px; }
.p-field select, .p-field input[type=range] { width: 100%; max-width: 100%; }
.p-field input[type=range] { flex: 1; min-width: 0; }
.p-field input[type=number] { flex: none; width: 84px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.p-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.p-option {
  display: grid; gap: 2px; padding: 8px 10px; text-align: left;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 12px; cursor: pointer;
}
.p-option strong { font-size: 15px; }
.p-option span { color: var(--muted); }
.p-option:hover { border-color: var(--accent); }
.p-option[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
#p-text-input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.p-edits { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.p-edits[hidden] { display: none; }
.p-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.p-swatch { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 2px solid var(--border); cursor: pointer; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 0 2px #000a; }
.p-swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.p-swatch input { position: absolute; inset: auto 0 0 auto; width: 14px; height: 14px; padding: 0; border: 0; opacity: 0.9; cursor: pointer; }
.check-tools .hint { margin: 0; font-size: 12px; }
.check-result { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.check-result.ok { color: var(--success); }
.check-result.bad strong, .check-result.bad { color: var(--text); }
.thick-legend { display: grid; gap: 2px; }
.thick-bar { display: block; height: 10px; border-radius: 5px; }
.thick-scale { position: relative; height: 15px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.thick-scale span { position: absolute; top: 0; }
.thick-scale span:nth-child(1) { left: 0; }
.thick-scale span:nth-child(2) { left: 12.5%; transform: translateX(-50%); } /* the "thin below" value sits at 1/8 of the bar */
.thick-scale span:nth-child(3) { right: 0; }
.mesh-result { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.mesh-result li.ok strong { color: var(--success); }
.mesh-result li.bad strong { color: var(--danger); }
.mesh-result .swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: baseline; }
.cost-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; }
.cost-grid label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.cost-grid label > span { display: flex; align-items: center; gap: 6px; }
.cost-grid select { width: 100%; }
.cost-facts { margin: 0; }
.spot-label {
  position: absolute; z-index: 2; transform: translate(-50%, -140%); pointer-events: none;
  padding: 2px 7px; border-radius: 999px; background: #e5484d; color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
}
.measure-label {
  position: absolute; z-index: 2; transform: translate(-50%, -130%); pointer-events: none;
  padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-text, #fff);
  font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.v-light h3, .orient .view-title { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.orient .view-title { margin-top: 16px; }
.light-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.light-switch .hint { font-size: 12px; }
.light-tools { display: grid; gap: 10px; margin-top: 10px; }
.light-tools .segmented { flex-wrap: wrap; }
.light-range { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.light-range input { width: 100%; accent-color: var(--accent); }
.orient .row .btn + .btn { margin-left: 6px; }

/* ---------- folder title, tools and progress stay under the top bar ---------- */

.view-head {
  position: sticky;
  top: var(--topbar-h, 57px);
  z-index: 8; /* under the top bar (10), the selection bar and dialogs */
  margin: -20px -20px 16px;
  padding: 16px 20px 12px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.view-head.stuck { border-bottom-color: var(--border); box-shadow: 0 6px 12px -10px rgb(0 0 0 / 35%); }
.view-head .view-bar { margin-bottom: 0; }
.view-head .progress { margin: 12px 0 0; }
/* Short screens (a phone on its side): scroll away to keep room for the models. */
@media (max-height: 560px) { .view-head { position: static; } }

/* ---------- admin: print cost ---------- */
#s-currency { width: 90px; }
.price-table { border-collapse: collapse; font-size: 13px; }
.price-table th { padding: 4px 10px 4px 0; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; }
.price-table td { padding: 3px 10px 3px 0; }
.price-table input { width: 90px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }

/* Share links */
.share-dialog, .import-dialog { width: min(560px, 100%); height: auto; max-height: calc(100dvh - 32px); overflow: auto; }
.share-new { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.share-new label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.share-list li { display: grid; gap: 4px; }
.share-list li.fresh .share-url { border-color: var(--accent); }
.share-list .msg { color: var(--muted); font-size: 13px; }
.share-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.share-url { flex: 1 1 200px; min-width: 0; font: 13px ui-monospace, monospace; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }
.share-bar { padding: 8px 16px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
.stage > .share-bar { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5; width: fit-content; max-width: calc(100% - 24px); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
body.share-mode .layout { grid-template-columns: minmax(0, 1fr); }
body.share-mode .layout.with-info { grid-template-columns: minmax(0, 1fr) 340px; }
.share-gone { font: 16px system-ui, sans-serif; text-align: center; margin-top: 30vh; padding: 0 16px; }
body.share-mode #sidebar, body.share-mode #nav-toggle, body.share-mode #sidebar-scrim, body.share-mode #btn-account, body.share-mode #btn-admin, body.share-mode #lib-wrap { display: none !important; }
body.share-model #search, body.share-model #v-close, body.share-model #v-prev, body.share-model #v-next { display: none !important; }
.share-admin-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.share-admin-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.share-admin-list code { overflow-wrap: anywhere; }
.share-kind { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Compare with… and overlay */
.compare-picker { width: min(560px, 100%); }
.compare-search { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.compare-list { max-height: 55vh; }
.compare-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.compare-item:hover, .compare-item:focus-visible { background: var(--surface-2); }
.compare-thumb { flex: none; width: 48px; height: 48px; border-radius: 6px; background: var(--thumb-bg) center / cover no-repeat; }
.compare-name { display: grid; min-width: 0; }
.compare-name small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-swatch { display: none; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.compare-facts.overlay .compare-swatch { display: inline-block; }
.compare-facts.overlay .compare-side { display: none; }
.compare-facts > .segmented { margin-bottom: 10px; width: fit-content; }

/* Import from a link */
.import-form { display: flex; flex-wrap: wrap; gap: 8px; }
.import-form[hidden] { display: none; }
.import-url { flex: 1 1 220px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.import-status { display: grid; gap: 6px; overflow-wrap: anywhere; }
.import-status p { margin: 0; }
.import-status .ok { color: var(--ok, #2f8a46); }
.import-status .bad { color: var(--danger, #d13a3a); }
.import-status .spinner { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: imp-spin .8s linear infinite; vertical-align: -1px; }
@keyframes imp-spin { to { transform: rotate(360deg); } }
body.share-mode #btn-import { display: none !important; }
.feedback-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Installable app */
.brand-icon { display: block; border-radius: 7px; }
.install-help { height: auto; width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.install-head { display: flex; align-items: center; gap: 12px; }
.install-head img { border-radius: 9px; }
.install-body p, .install-body ol, .install-body ul { margin: 0 0 10px; }
.install-body li { margin: 4px 0; }
.install-body code { overflow-wrap: anywhere; }
body.share-mode #btn-install { display: none !important; }
.icon-choice { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.icon-choice label { display: grid; justify-items: center; gap: 6px; padding: 10px 14px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; }
.icon-choice label:has(input:checked) { border-color: var(--accent); }
.icon-choice img { width: 72px; height: 72px; }
.icon-choice input { margin: 0; }

/* Two-factor sign-in */
.twofa-dialog { height: auto; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.tf-steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.tf-qr { width: 200px; margin: 8px 0 4px; background: #fff; padding: 6px; border-radius: 8px; }
.tf-qr svg { display: block; width: 100%; height: auto; }
.tf-secret { display: inline-block; font-size: 13px; letter-spacing: .05em; overflow-wrap: anywhere; }
.tf-code { width: 9ch; padding: 6px 8px; font: 18px ui-monospace, monospace; letter-spacing: .1em; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.tf-codes { font: 15px ui-monospace, monospace; background: var(--surface-2); padding: 10px 14px; border-radius: 8px; columns: 2; }
.picker-foot [data-actions] { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-2fa { margin-left: 8px; padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); vertical-align: 1px; }
.sso-btn { justify-content: center; text-align: center; text-decoration: none; }
.sso-or { margin: 2px 0 -4px; text-align: center; }
.sso-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 10px 16px; }
.sso-grid label { display: grid; gap: 4px; min-width: 0; font-size: 13px; color: var(--muted); }
.sso-grid label > select, .sso-grid label > input { width: 100%; min-width: 0; }

/* API tokens */
.tokens-dialog { height: auto; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.tok-new { display: flex; flex-wrap: wrap; gap: 8px; }
.tok-new input { flex: 1 1 200px; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.tok-fresh { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.tok-fresh p { flex-basis: 100%; margin: 0; }
.tok-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tok-list li { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }

/* Statistics */
#list-view.stats-view { display: block; }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.st-tile { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.st-label { font-size: 13px; color: var(--muted); }
.st-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.15; }
.st-sub { font-size: 12px; color: var(--muted); }
.st-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.st-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 0; }
.st-card h3 { margin: 0 0 10px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.st-total { font-weight: 400; color: var(--muted); font-size: 12px; }
.st-cols { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; height: 150px; align-items: end; padding-bottom: 18px; position: relative; border-bottom: 1px solid var(--border); }
.st-col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.st-bar { width: 70%; max-width: 22px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; }
.st-col:hover .st-bar, .st-col:focus-visible .st-bar { filter: brightness(1.15); }
.st-x { position: absolute; bottom: -18px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.st-tip { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--surface); font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 2; }
.st-col:hover .st-tip, .st-col:focus-visible .st-tip { opacity: 1; }
.st-col:first-child .st-tip { left: 0; transform: none; }
.st-col:last-child .st-tip { left: auto; right: 0; transform: none; }
.st-hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.st-hbars li { display: grid; grid-template-columns: minmax(60px, 30%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.st-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-track { height: 10px; }
.st-hbar { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.st-num { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-rank { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-size: 13px; }
.st-rank li { padding-left: 2px; }
.st-rank li > a { display: inline-block; max-width: calc(100% - 70px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; color: var(--text); }
.st-rank .st-num { float: right; }
.st-table { margin-top: 10px; font-size: 12px; }
.st-table summary { cursor: pointer; color: var(--muted); }
.st-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.st-table td, .st-table th { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--border); }
body.list-mode:has(#list-view.stats-view:not([hidden])) .view-tools { display: none !important; }
#list-view.stats-view > .hint { margin-top: 12px; }
.notify-channels { display: grid; gap: 8px; margin-top: 12px; }
.notify-channels details, .sso-card { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.notify-channels summary, .sso-card summary { cursor: pointer; }
.notify-channels details[open], .sso-card[open] { display: grid; gap: 8px; padding-bottom: 12px; }
.sso-card { margin: 10px 0; }

/* Bulk edit */
.bulk-dialog { height: auto; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.bulk-field { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; align-items: start; }
.arrange-copies { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.arrange-copies input { width: 70px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.bulk-field > :not(.bulk-label) { grid-column: 2; }
.bulk-label { font-size: 13px; color: var(--muted); padding-top: 7px; }
.bulk-field select, .bulk-field input, .bulk-field textarea { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.bulk-field [hidden] { display: none; }
.license-view { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
@media (max-width: 520px) { .bulk-field { grid-template-columns: 1fr; } .bulk-field > :not(.bulk-label) { grid-column: 1; } }

/* To print */
.list-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; }
.list-badge:empty { display: none; }
.q-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 8px; }
.q-thumb { width: 64px; height: 64px; border-radius: 8px; background: var(--thumb-bg) center / cover no-repeat; }
.q-main { display: grid; gap: 2px; min-width: 0; }
.q-main a { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-note { font-size: 13px; }
.q-edit { display: flex; gap: 6px; align-items: center; }
.q-qty-label { display: flex; align-items: center; gap: 2px; color: var(--muted); }
.q-qty { width: 4.5em; }
.q-mat { width: 10em; }
.q-edit input { padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; }
.q-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) { .q-row { grid-template-columns: 56px minmax(0, 1fr); } .q-edit, .q-actions { grid-column: 1 / -1; } .q-thumb { width: 56px; height: 56px; } }
.can-print { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-right: 6px; }

/* Send to printer */
.printer-list { display: grid; gap: 6px; }
.printer-opt { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.printer-opt:has(input:checked) { border-color: var(--accent); }
.printer-opt.off { opacity: .7; }
.printer-name { font-weight: 600; }
.printer-state { font-size: 12px; color: var(--muted); }
.printer-state.st-idle, .printer-state.st-finished { color: #2f8a46; }
.printer-state.st-printing { color: var(--accent); }
.printer-state.st-error, .printer-state.st-offline { color: var(--danger); }
.printer-err { grid-column: 2 / -1; overflow-wrap: anywhere; }
.printer-form { margin-top: 12px; }
.printer-form [hidden] { display: none; }

/* 3MF plates and filaments */
.slicer-info { display: grid; gap: 8px; margin: -4px 0 14px; }
.slicer-plates { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.slicer-plates select { flex: 1; min-width: 0; }
.slicer-filaments { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; }
.fil { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.fil-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); }

/* Similar models */
.v-similar { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.v-similar h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.similar-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.similar-item { display: grid; gap: 2px; color: var(--text); text-decoration: none; font-size: 12px; min-width: 0; }
.similar-thumb { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border); background: var(--thumb-bg) center / cover no-repeat; }
.similar-item:hover .similar-thumb { border-color: var(--accent); }
.similar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.similar-score { color: var(--muted); font-size: 11px; }
