:root {
  color-scheme: dark;
  --bg: #0f1012;
  --bg-raised: #17181b;
  --bg-sunken: #0b0c0d;
  --line: #26282c;
  --line-strong: #34373c;
  --text: #ecebe8;
  --text-dim: #a3a29e;
  --text-faint: #6f6e6a;
  --accent: #e8a33d;
  --accent-ink: #1a1306;
  --accent-soft: rgba(232, 163, 61, 0.14);
  --fave: #ef6f6c;
  --danger: #d9534f;
  --ok: #4fae74;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --cell: 200px;
  --sidebar: 260px;
  --topbar: 64px;
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f6f5f2;
    --bg-raised: #ffffff;
    --bg-sunken: #ecebe6;
    --line: #e2e0da;
    --line-strong: #cfccc4;
    --text: #1b1b1a;
    --text-dim: #5d5c58;
    --text-faint: #8f8d87;
    --accent: #b8741a;
    --accent-ink: #ffffff;
    --accent-soft: rgba(184, 116, 26, 0.12);
    --fave: #d1423f;
    --danger: #c43c38;
    --ok: #2f8a55;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-sunken); padding: 1px 5px; border-radius: 4px; }
a { color: var(--accent); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.brand-mark { width: 44px; height: 44px; display: block; }
.brand-mark.small { width: 30px; height: 30px; flex: none; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--bg-raised); cursor: pointer; font-weight: 550;
}
.btn:hover { border-color: var(--text-faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-raised); border-color: var(--line); color: var(--text); }
.btn.ghost.on { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); }
.danger-text, .btn.ghost.danger-text { color: var(--danger); }
.btn svg { width: 16px; height: 16px; }
.muted { color: var(--text-dim); }
.small { font-size: 12.5px; }
.admin-only { display: none !important; }
body.is-admin .admin-only:not([hidden]) { display: revert !important; }
body.is-admin .btn.admin-only:not([hidden]) { display: inline-flex !important; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text-dim);
}
.icon-btn:hover { background: var(--bg-raised); border-color: var(--line); color: var(--text); }
.icon-btn.flipped svg { transform: scaleY(-1); }

/* ---------- Landing ---------- */
.landing { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.landing-card { width: min(560px, 100%); text-align: center; }
.landing-card .brand-mark { margin: 0 auto 18px; }
.landing h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.lede { color: var(--text-dim); margin: 0 0 26px; }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 16px; padding: 34px 20px; background: var(--bg-raised);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.drop-sub { color: var(--text-dim); margin: 0 0 20px; }
.drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.progress { margin-top: 22px; text-align: left; }
.progress-label { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.progress-bar { height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.progress-bar.indeterminate #progress-fill { width: 35%; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .progress-bar.indeterminate #progress-fill { animation: none; width: 100%; opacity: .5; } }
.error { color: var(--fave); margin-top: 16px; }
.login {
  display: grid; gap: 14px; text-align: left; background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; width: min(380px, 100%); margin: 0 auto;
}
.login label, .stack label, .up-shared label, .user-form label { display: grid; gap: 5px; font-size: 13px; color: var(--text-dim); font-weight: 550; }
input:not([type=checkbox]):not([type=range]):not([type=file]), textarea, .modal select {
  height: 38px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg);
  color: var(--text); font-size: 14px; font-weight: 400; min-width: 0; width: 100%;
}
textarea { height: auto; padding: 8px 11px; resize: vertical; line-height: 1.4; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.login .btn { justify-content: center; height: 40px; margin-top: 4px; }
.login .error { margin: 0; }
.notice { color: var(--ok); margin: 10px 0 0; word-break: break-word; }

/* ---------- App layout ---------- */
.app {
  display: grid; height: 100%;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: var(--topbar) 1fr;
  grid-template-areas: "top top" "side main";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--bg); z-index: 3;
}
.who { display: flex; align-items: center; gap: 10px; min-width: calc(var(--sidebar) - 32px); flex: none; }
.who-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-stats { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.search {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 38px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 9px; color: var(--text-faint);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; }
.controls { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.account-area { display: flex; align-items: center; gap: 8px; flex: none; }
.menu-wrap { position: relative; }
.account-btn {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-raised); max-width: 180px;
}
.account-btn:hover { border-color: var(--line-strong); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
}
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 550; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 10; padding: 6px;
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow);
}
.menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.menu-head span { color: var(--text-faint); font-size: 12px; }
.menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 6px; }
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.select { display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 12.5px; }
.select select {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-raised);
  color: var(--text); font-size: 14px;
}
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--bg-raised); padding: 0 12px; height: 34px; color: var(--text-dim); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#zoom { width: 90px; accent-color: var(--accent); }

.sidebar {
  grid-area: side; overflow-y: auto; padding: 14px 10px 30px; border-right: 1px solid var(--line);
  background: var(--bg);
}
.sidebar h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint);
  margin: 22px 8px 8px; font-weight: 650;
}
.nav-item {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
  border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; text-align: left; color: var(--text-dim);
}
.nav-item:hover { background: var(--bg-raised); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item .count { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-faint); }
.nav-item.on .count { color: inherit; }
.nav-item.all { font-weight: 600; color: var(--text); }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.year-row { display: grid; grid-template-columns: 1fr; }
.year-btn { display: grid; grid-template-columns: 42px 1fr 40px; align-items: center; gap: 8px; }
.year-btn .bar { height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.year-btn .bar i { display: block; height: 100%; background: var(--text-faint); border-radius: 3px; }
.year-btn.on .bar i, .year-btn:hover .bar i { background: var(--accent); }
.year-btn .count { text-align: right; }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 4px 8px 8px 58px; }
.month {
  border: 0; background: var(--bg-raised); border-radius: 4px; font-size: 10.5px; padding: 3px 0; color: var(--text-dim);
  position: relative;
}
.month:disabled { opacity: .3; cursor: default; }
.month.on { background: var(--accent); color: var(--accent-ink); }
.month:not(:disabled):hover { outline: 1px solid var(--accent); }

.album-btn { gap: 10px; }
.album-btn .cover { width: 28px; height: 28px; border-radius: 5px; background: var(--bg-sunken) center/cover; flex: none; }
.album-btn .label { flex: 1; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 6px; }
.tag {
  border: 1px solid var(--line); background: var(--bg-raised); border-radius: 999px; padding: 2px 9px;
  font-size: 12px; color: var(--text-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag:hover { border-color: var(--accent); color: var(--text); }
.tag.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.warnings { margin: 24px 8px 0; color: var(--text-faint); font-size: 12px; }
.warnings summary { cursor: pointer; }

.main { grid-area: main; overflow-y: auto; padding: 0 20px 40px; position: relative; }
.resultbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; min-height: 50px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 0; font-size: 12.5px; font-weight: 550;
}
.chip svg { width: 14px; height: 14px; }
.result-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.result-count { color: var(--text-faint); font-size: 12.5px; white-space: nowrap; padding-left: 4px; }
.selbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sel-count { font-weight: 600; margin-right: 4px; font-variant-numeric: tabular-nums; }

.section-head {
  grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; margin: 18px 0 2px;
  font-size: 16px; font-weight: 650; letter-spacing: -0.01em;
}
.section-head:first-child { margin-top: 4px; }
.section-head span { color: var(--text-faint); font-size: 12.5px; font-weight: 500; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr)); gap: 10px; }
.card {
  display: block; padding: 0; border: 0; background: none; text-align: left; border-radius: var(--radius);
  content-visibility: auto; contain-intrinsic-size: auto var(--cell) auto calc(var(--cell) + 46px);
}
.thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--bg-raised);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s, transform .3s; }
.thumb img.loaded { opacity: 1; }
.card:hover .thumb img { transform: scale(1.03); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.thumb .badge {
  position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  background: rgba(0, 0, 0, .62); color: #fff; backdrop-filter: blur(4px);
}
.thumb .badge svg { width: 12px; height: 12px; }
.thumb .badge.rank { left: auto; right: 8px; background: var(--accent); color: var(--accent-ink); }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; pointer-events: none; }
.thumb .play svg { width: 42px; height: 42px; fill: rgba(0,0,0,.5); stroke-width: 1.4; }
.thumb .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-faint); font-size: 12px; }
.meta { padding: 7px 2px 0; min-width: 0; }
.meta .title { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .sub { display: flex; gap: 10px; white-space: nowrap; overflow: hidden; color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.meta .sub .fv { color: var(--fave); }
.meta .sub span { display: inline-flex; align-items: center; gap: 3px; }
.meta .sub svg { width: 12px; height: 12px; }
.thumb .check {
  position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 50%; display: none;
  place-items: center; background: rgba(0, 0, 0, .45); border: 2px solid rgba(255, 255, 255, .85); color: transparent;
}
.thumb .check svg { width: 16px; height: 16px; stroke-width: 2.6; }
.grid.selecting .thumb .check { display: grid; }
.grid.selecting .card:hover .thumb img { transform: none; }
.card.selected .thumb { outline: 3px solid var(--accent); outline-offset: -3px; }
.card.selected .thumb img { opacity: .78; }
.card.selected .thumb .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sentinel { height: 1px; }
.empty { padding: 80px 0; text-align: center; color: var(--text-faint); }

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #070708; color: #ecebe8; display: none; grid-template-columns: 1fr 360px;
}
.lightbox[open] { display: grid; }
.lightbox.no-info { grid-template-columns: 1fr 0; }
.lightbox.no-info .lb-info { display: none; }
.lightbox::backdrop { background: #000; }
.lb-stage { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.lb-media { width: 100%; height: 100%; display: grid; place-items: center; padding: 56px 64px 24px; }
.lb-media img, .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.lb-media .loading { color: #777; }
.lb-top { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
.lb-top .icon-btn { color: #bbb; }
.lb-top .icon-btn:hover { background: rgba(255,255,255,.08); border-color: transparent; color: #fff; }
.lb-pos { color: #888; font-size: 12.5px; font-variant-numeric: tabular-nums; padding-left: 6px; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; z-index: 1;
  background: transparent; color: #aaa; border-radius: 10px;
}
.lb-nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.lb-nav svg { width: 28px; height: 28px; }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-info { overflow-y: auto; padding: 22px 22px 40px; background: #121214; border-left: 1px solid #222; font-size: 13.5px; }
.lb-info h3 { font-size: 19px; margin: 0 0 6px; line-height: 1.3; letter-spacing: -0.01em; word-wrap: break-word; }
.lb-info .desc { color: #c9c8c4; white-space: pre-line; word-wrap: break-word; margin: 0 0 16px; }
.lb-info h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #777; margin: 22px 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stat { background: #1b1b1e; border-radius: 8px; padding: 10px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat small { color: #888; }
.stat.fave b { color: #ef6f6c; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 5px 10px; margin: 0; }
.kv dt { color: #888; }
.kv dd { margin: 0; word-break: break-word; }
.lb-info .tags { padding: 0; }
.lb-info .tag { background: #1b1b1e; border-color: #2a2a2e; color: #c9c8c4; }
.comment { padding: 10px 0; border-top: 1px solid #222; }
.comment .who { width: auto; display: block; color: #888; font-size: 12px; margin-bottom: 3px; }
.comment .body { white-space: pre-line; word-wrap: break-word; color: #d6d5d1; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.lb-actions .btn { background: #1b1b1e; border-color: #2e2e33; color: #ecebe8; text-decoration: none; font-size: 13px; padding: 7px 12px; }

/* ---------- Modals ---------- */
.modal {
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow);
}
.modal.wide { width: min(760px, calc(100vw - 32px)); }
.modal[open] { display: flex; flex-direction: column; }
.modal > form { display: flex; flex-direction: column; min-height: 0; }
.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; }
.modal h2 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.modal h3 { font-size: 13px; margin: 0 0 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.modal-body { padding: 16px 20px; overflow-y: auto; min-height: 0; }
.modal-body.stack, .stack { display: grid; gap: 12px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.modal-foot .muted { margin-right: auto; font-size: 12.5px; }
.check-row:not([hidden]) { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; font-weight: 500 !important; }
.check-row input { width: 16px; height: 16px; accent-color: var(--danger); }

.up-drop { padding: 22px 16px; text-align: center; }
.up-drop.compact { padding: 12px 16px; display: flex; align-items: center; gap: 12px; text-align: left; }
.up-drop.compact .drop-title { font-size: 14px; margin: 0; }
.up-drop.compact .drop-sub { display: none; }
.up-drop.compact .btn { margin-left: auto; }
.up-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.up-item {
  display: grid; grid-template-columns: 88px 1fr auto; gap: 12px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
.up-thumb {
  width: 88px; height: 88px; border-radius: 8px; overflow: hidden; background: var(--bg-sunken);
  display: grid; place-items: center; color: var(--text-faint); font-size: 11px; font-weight: 700;
}
.up-thumb img, .up-thumb video { width: 100%; height: 100%; object-fit: cover; }
.up-fields { display: grid; gap: 6px; min-width: 0; }
.up-meta { display: flex; gap: 10px; justify-content: space-between; font-size: 12px; color: var(--text-faint); min-width: 0; }
.up-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { white-space: nowrap; font-variant-numeric: tabular-nums; }
.up-bar { height: 3px; border-radius: 2px; background: var(--bg-sunken); overflow: hidden; visibility: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up-item[data-state=uploading] .up-bar { visibility: visible; }
.up-item[data-state=done] { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.up-item[data-state=done] .up-status { color: var(--ok); font-weight: 600; }
.up-item[data-state=error] { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.up-item[data-state=error] .up-status { color: var(--danger); white-space: normal; text-align: right; }
.up-remove { align-self: start; }
.up-shared { display: grid; grid-template-columns: 1fr 220px; gap: 12px; margin-top: 14px; }

table.users { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.users th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 650; padding: 0 8px 6px; }
.users td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.users td select { height: 32px; width: auto; }
.row-actions { text-align: right; white-space: nowrap; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user-form { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.user-form .row { display: grid; grid-template-columns: 1fr 1fr 130px auto; gap: 10px; align-items: end; }
.user-form .row .btn { height: 38px; }
.user-form p { margin-top: 10px !important; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  font-weight: 550; font-size: 13.5px;
}
.toast.error { background: var(--danger); color: #fff; }

.lb-actions .btn.danger-text { color: #ef7b77; }

/* ---------- Narrow screens ---------- */
.only-narrow { display: none; }
@media (max-width: 900px) {
  :root { --topbar: auto; }
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; grid-template-rows: auto 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .only-narrow { display: inline-grid; }
  .who { width: auto; flex: 1; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .controls { order: 4; flex-basis: 100%; margin: 0; flex-wrap: wrap; }
  #zoom, .search kbd { display: none; }
  .who { min-width: 0; }
  .meta .sub { gap: 8px; }
  .meta .sub .vw { display: none; }
  .sidebar {
    position: fixed; z-index: 5; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .main { padding: 0 16px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--cell), 140px), 1fr)); gap: 8px; }
  .lightbox, .lightbox.no-info { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .lb-info { max-height: 45vh; border-left: 0; border-top: 1px solid #222; }
  .lb-media { padding: 52px 8px 8px; }
  .lb-nav { width: 40px; }
  .account-area { margin-left: auto; }
  .account-name, #upload-btn .label { display: none; }
  .account-btn { padding: 0 4px; }
  .resultbar { flex-wrap: wrap; padding: 6px 0; }
  .up-shared { grid-template-columns: 1fr; }
  .up-item { grid-template-columns: 64px 1fr auto; }
  .up-thumb { width: 64px; height: 64px; }
  .user-form .row { grid-template-columns: 1fr 1fr; }
  .users th:nth-child(3), .users td:nth-child(3) { display: none; }
  .row-actions { white-space: normal; }
}
