:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --text: #17171c;
  --text-2: #4a4a55;
  --muted: #84848f;
  --border: #e5e5ea;
  --accent: #5b5bd6;
  --accent-soft: #ededfd;
  --accent-text: #ffffff;
  --danger: #d93a3a;
  --danger-soft: #fdeded;
  --ok: #16915a;
  --ok-soft: #e4f6ec;
  --warn: #b26b00;
  --warn-soft: #fdf2df;
  --like: #e5355f;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, .06);
  --shadow: 0 6px 20px rgba(20, 20, 30, .08);
  --shadow-lg: 0 24px 60px rgba(20, 20, 30, .22);
  --sidebar: 252px;
  --row: 220px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --surface: #17171b;
    --surface-2: #212127;
    --text: #ececf1;
    --text-2: #b5b5c0;
    --muted: #7d7d89;
    --border: #2a2a31;
    --accent: #8d8cf7;
    --accent-soft: #24244a;
    --accent-text: #0e0e11;
    --danger: #f26b6b;
    --danger-soft: #3a1c1e;
    --ok: #4fd08f;
    --ok-soft: #12301f;
    --warn: #e9b456;
    --warn-soft: #33270f;
    --like: #ff5c84;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.hint .i { width: 14px; height: 14px; vertical-align: -2px; }
.center { text-align: center; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.form-error { color: var(--danger); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i.fill { fill: currentColor; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Controls ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, filter .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.soft:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.top-upload { flex-wrap: nowrap; gap: 6px; }
.up-where {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -6px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text-2);
}
.up-where .i { color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn.danger-fill { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 38px; padding: 0; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.sm.icon { width: 32px; padding: 0; }
.btn.sm .i { width: 16px; height: 16px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.link-btn:hover { color: var(--danger); }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input:disabled { opacity: .6; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.w-auto { width: auto !important; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.form { display: grid; gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; min-width: 0; }
legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 10px; }

/* Toggle switch: a styled checkbox */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: var(--border);
  cursor: pointer;
  transition: background .2s;
}
input.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }
input.switch:disabled { opacity: .5; cursor: not-allowed; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  cursor: pointer;
}
.switch-row + .switch-row, .setting-line + .switch-row, .switch-row + .setting-line, .setting-line + .setting-line { border-top: 1px solid var(--border); }
.switch-row strong, .setting-line strong { display: block; font-weight: 500; }
.switch-row small, .setting-line small { display: block; color: var(--muted); font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-2);
}
.badge .i { width: 13px; height: 13px; stroke-width: 2.5; }
.badge.role-admin { background: color-mix(in srgb, #8b5cf6 16%, transparent); color: #8b5cf6; }
.badge.role-member { background: color-mix(in srgb, #3b82f6 16%, transparent); color: #3b82f6; }
.badge.role-viewer { background: color-mix(in srgb, #14b8a6 16%, transparent); color: #0d9488; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--surface-2); color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}
.chip .i { width: 12px; height: 12px; }
.chip.strong { background: var(--accent-soft); color: var(--accent); }
.code {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  padding: 6px 10px;
  border-radius: 8px;
  word-break: break-all;
}

.avatar {
  --size: 34px;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--h) 72% 62%), hsl(calc(var(--h) + 45) 70% 52%));
  color: #fff;
  font-size: calc(var(--size) * .38);
  font-weight: 600;
  letter-spacing: .02em;
}
.avatar.sm { --size: 26px; }
.avatar.lg { --size: 72px; }
.avatar-stack { display: inline-flex; padding-left: 8px; }
.avatar-stack .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }

/* ---- App shell ---- */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}
.logo {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #f97316);
  color: #fff;
  box-shadow: 0 6px 16px rgba(124, 58, 237, .35);
}
.logo .i { width: 20px; height: 20px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-label {
  padding: 18px 12px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.folder-nav a { padding: 7px 12px 7px calc(12px + var(--depth, 0) * 14px); font-size: 13.5px; gap: 10px; }
.folder-nav .i { width: 16px; height: 16px; }
.folder-nav .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.side-hint { padding: 4px 12px; color: var(--muted); font-size: 13px; }
.side-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
}
.me-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.me-link:hover, .me-link.active { background: var(--surface-2); }
.me-link strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-link small { display: block; color: var(--muted); font-size: 12px; }
.me-link > span:last-child { min-width: 0; }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search > .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px !important; border-radius: 12px !important; background: var(--surface) !important; }
.search.sm { max-width: 280px; }
.search.sm input { height: 38px; }
#view { padding: 28px 32px 80px; max-width: 1600px; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.025em; }
.sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.section-title { font-size: 16px; font-weight: 600; margin: 28px 0 14px; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 72px 16px;
  text-align: center;
  color: var(--muted);
}
.empty-state h3 { color: var(--text); font-size: 18px; }
.empty-state .btn { margin-top: 8px; }
.big {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--accent-soft);
  color: var(--accent);
}
.big .i { width: 30px; height: 30px; stroke-width: 1.75; }

/* ---- Grid toolbar: place / type / sort ---- */

.grid-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.hero ~ .grid-tools { margin-top: 20px; }
.tool { position: relative; display: flex; align-items: center; }
.tool > .i { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.tool select {
  width: auto;
  max-width: 260px;
  height: 38px;
  padding: 0 30px 0 34px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.group-title a { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.group-title a:hover { color: var(--accent); }
.group-title a .i { width: 16px; height: 16px; color: var(--accent); }
.section-title .i { width: 17px; height: 17px; vertical-align: -3px; color: var(--accent); }
.section-title .muted { font-weight: 500; font-size: 13px; }
.with-icon { display: flex; align-items: center; gap: 10px; }
.with-icon .i { width: 26px; height: 26px; color: var(--accent); }
.back { display: inline-block; margin-bottom: 10px; color: var(--text-2); font-size: 14px; text-decoration: none; }
.back:hover { color: var(--accent); }

/* ---- Justified photo grid: each tile's width follows its aspect ratio (--r) ---- */

.group { margin-bottom: 8px; }
.group-title { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 12px; font-size: 16px; font-weight: 600; }
.group:first-of-type .group-title { margin-top: 4px; }
.group-title span { color: var(--muted); font-size: 13px; font-weight: 500; }
.jg { display: flex; flex-wrap: wrap; gap: 6px; }
.jg::after { content: ''; flex-grow: 999999; }
.ph {
  position: relative;
  display: block;
  flex-grow: calc(var(--r) * 100);
  width: calc(var(--r) * var(--row));
  max-width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
  cursor: zoom-in;
}
.ph > i { display: block; padding-bottom: calc(100% / var(--r)); }
.ph img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s cubic-bezier(.2, .7, .2, 1), filter .3s;
}
.ph:hover img { transform: scale(1.045); }
.ph:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ph-meta {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 32px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7));
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s;
}
.ph:hover .ph-meta, .ph:focus-visible .ph-meta { opacity: 1; }
.ph-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-stats { display: flex; align-items: center; gap: 4px; flex: none; }
.ph-stats .i { width: 13px; height: 13px; margin-left: 4px; }
.ph-liked { position: absolute; top: 8px; right: 8px; color: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5)); }
.ph-liked .i { width: 18px; height: 18px; color: var(--like); }
.ph-video {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 7px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ph-video .i { width: 11px; height: 11px; stroke-width: 0; }

/* ---- Folder cards ---- */

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px 18px; }
.folder-grid.small { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.fcard { display: block; color: inherit; text-decoration: none; }
.fcover {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}
.fcover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s cubic-bezier(.2, .7, .2, 1); }
.fcard:hover .fcover img { transform: scale(1.05); }
.fcard:hover .fcover { box-shadow: var(--shadow); }
.fempty { height: 100%; display: grid; place-items: center; color: var(--muted); }
.fempty .i { width: 44px; height: 44px; stroke-width: 1.4; }
.finfo { display: grid; gap: 1px; padding: 10px 2px 0; }
.finfo strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finfo span { color: var(--muted); font-size: 13px; }
.badge-float {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}
.badge-float .i { width: 13px; height: 13px; }

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
  padding: 26px 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}
.hero-bg {
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(40px) saturate(1.5);
  opacity: .28;
}
.hero > :not(.hero-bg) { position: relative; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .i { width: 14px; height: 14px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.hero h1 { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.hero h1 .i { width: 26px; height: 26px; color: var(--accent); }
.hero-desc { margin-top: 6px; color: var(--text-2); white-space: pre-wrap; max-width: 70ch; }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 10px; color: var(--muted); font-size: 13px; }

/* ---- Modal, toast ---- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 8, 14, .5);
  backdrop-filter: blur(4px);
  animation: fade .15s ease-out;
}
.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.2);
}
.modal.wide { width: min(720px, 100%); }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-head h2 { font-size: 18px; font-weight: 600; }
.modal-body { display: grid; gap: 16px; padding: 22px; }
.modal-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.confirm-text { color: var(--text-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

#toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 12px;
  background: #1d1d24;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast .i { color: #4fd08f; }
.toast.error .i { color: #ff7a7a; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- Upload ---- */

.drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 30px 16px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { width: 56px; height: 56px; border-radius: 18px; background: var(--surface); margin-bottom: 4px; }
.up-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; max-height: 230px; overflow: auto; }
.up-list:empty { display: none; }
.up-item { position: relative; }
.up-item img, .up-item video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #000; }
.up-badge { position: absolute; left: 6px; bottom: 6px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.up-badge .i { width: 14px; height: 14px; stroke-width: 0; }
.up-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  cursor: pointer;
}
.up-x .i { width: 13px; height: 13px; }
.up-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 600; }
progress {
  flex: 1;
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-2);
}
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; transition: width .2s; }
progress::-moz-progress-bar { background: var(--accent); }
.drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 80;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-overlay div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 18px;
  font-weight: 600;
}
.share-box { display: flex; gap: 8px; }
.up-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat-mini {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}
.stat-mini .i { grid-row: span 2; width: 22px; height: 22px; }
.stat-mini strong { font-size: 20px; line-height: 1.1; }
.stat-mini span { color: var(--muted); font-size: 12px; }
.stat-mini.ok { background: var(--ok-soft); } .stat-mini.ok .i { color: var(--ok); }
.stat-mini.warn { background: var(--warn-soft); } .stat-mini.warn .i { color: var(--warn); }
.stat-mini.danger { background: var(--danger-soft); } .stat-mini.danger .i { color: var(--danger); }
.dup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 300px; overflow-y: auto; }
.dup-list li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; }
.dup-list li:hover { background: var(--surface-2); }
.dup-list li > .i { color: var(--muted); }
.dup-list strong { display: block; font-weight: 500; font-size: 14px; word-break: break-all; }
.dup-list small { display: block; color: var(--muted); font-size: 12px; }

/* ---- Viewer ---- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: #050507;
  animation: fade .2s;
}
.viewer.with-info { grid-template-columns: minmax(0, 1fr) 380px; }
.v-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; }
.v-img { max-width: 100%; max-height: 100vh; object-fit: contain; user-select: none; animation: fade .25s; }
video.v-img { width: 100%; height: 100vh; background: #000; outline: none; }
.v-wait { position: relative; display: grid; place-items: center; max-height: 100vh; }
.v-wait p {
  position: absolute;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  font-size: 14px;
}
.dl-wrap { position: relative; }
.dl-menu {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 5;
  min-width: 250px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: pop .15s ease-out;
}
.dl-head { padding: 8px 12px 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.dl-menu a { display: grid; gap: 1px; padding: 9px 12px; border-radius: 9px; color: var(--text); text-decoration: none; }
.dl-menu a:hover { background: var(--surface-2); }
.dl-menu strong { font-size: 14px; font-weight: 600; }
.dl-menu span { color: var(--muted); font-size: 12px; }
.v-top {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: linear-gradient(rgba(0, 0, 0, .65), transparent);
  color: #fff;
}
.v-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.v-count { color: rgba(255, 255, 255, .6); font-size: 13px; flex: none; margin-left: 4px; }
.v-btn {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.v-btn:hover, .v-btn.on { background: rgba(255, 255, 255, .14); }
.v-btn .i { width: 21px; height: 21px; }
.v-btn.liked { color: var(--like); }
.v-btn.liked .i { fill: currentColor; }
.v-nav {
  position: absolute;
  top: 50%;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background .15s;
}
.v-nav:hover { background: rgba(255, 255, 255, .22); }
.v-nav .i { width: 26px; height: 26px; }
.v-nav.prev { left: 16px; }
.v-nav.next { right: 16px; }
.v-panel { display: none; overflow-y: auto; background: var(--surface); color: var(--text); border-left: 1px solid var(--border); }
.with-info .v-panel { display: block; }
.v-panel-inner { display: grid; gap: 20px; padding: 22px; }
.v-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.v-head h2 { font-size: 20px; font-weight: 700; word-break: break-word; }
.v-desc { margin-top: 8px; color: var(--text-2); white-space: pre-wrap; }
.v-likes { display: flex; align-items: center; gap: 6px; margin: 14px 0; color: var(--text-2); font-size: 13px; }
.v-likes .i { width: 15px; height: 15px; }
.v-likes .i.fill { color: var(--like); }
.v-likes .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); margin: 0 4px; }
.v-details { display: grid; gap: 12px; margin: 0 0 16px; padding: 16px; border-radius: 14px; background: var(--surface-2); }
.v-details div { display: flex; gap: 12px; }
.v-details dt { color: var(--muted); }
.v-details dd { margin: 0; min-width: 0; word-break: break-word; font-size: 14px; }
.v-details small { display: block; color: var(--muted); font-size: 12px; }
.v-details a { color: var(--text); font-weight: 500; }
.v-comments h3 { font-size: 15px; margin-bottom: 12px; }
.v-comments ul { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 14px; }
.v-comments li { display: flex; gap: 10px; }
.v-comments li > div { min-width: 0; }
.c-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.c-head span { color: var(--muted); font-size: 12px; }
.v-comments p { margin-top: 2px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.skeleton {
  height: 22px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
.skeleton.short { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Panels, admin ---- */

.panel { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.panel-head h3 .i { color: var(--accent); }
.panel-body { padding: 18px 20px; }
.stack { display: grid; gap: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; margin-bottom: 18px; }

.tabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 24px;
  padding: 4px;
  border-radius: 13px;
  background: var(--surface-2);
}
.tabs a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a .i { width: 16px; height: 16px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 12px;
  background: color-mix(in srgb, hsl(var(--h) 75% 55%) 15%, transparent);
  color: hsl(var(--h) 65% 52%);
}
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .label small { display: block; font-size: 12px; }
.recent-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.recent-strip button { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; background: var(--surface-2); }
.recent-strip img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.recent-strip button:hover img { transform: scale(1.06); }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.people li { display: flex; align-items: center; gap: 10px; }
.people .hint { margin-left: auto; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.quick-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick-btn .i { color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tr.dim td > * { opacity: .55; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell strong { font-weight: 600; }
.user-cell small { display: block; color: var(--muted); font-size: 13px; }
.folder-cell { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; padding-left: calc(var(--depth, 0) * 18px); }
.folder-cell strong { display: block; font-weight: 600; }
.folder-cell small { display: block; color: var(--muted); font-size: 12px; }
.mini-cover {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.access-cell { display: flex; align-items: center; gap: 10px; }

.role-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.role-card {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 6px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.role-card:hover { border-color: var(--muted); }
.role-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-card:has(input:disabled) { cursor: not-allowed; opacity: .7; }
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.folder-checks {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: opacity .2s;
}
.folder-checks.off { opacity: .45; pointer-events: none; }
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px calc(10px + var(--depth, 0) * 20px);
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
}
.check-row:hover { background: var(--surface-2); }
.check-row .i { width: 16px; height: 16px; color: var(--muted); }
.check-row small { margin-left: auto; color: var(--muted); font-size: 12px; }
.check-row em { display: none; color: var(--accent); font-size: 11px; font-style: normal; font-weight: 600; }
.check-row.inherited em { display: inline; }
.check-row.inherited input { opacity: .6; }
.check-row:has(input:checked) .i { color: var(--accent); }
.access-list { display: grid; gap: 4px; margin: 0 -8px; }
.access-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; cursor: pointer; }
.access-row:hover { background: var(--surface-2); }
.access-row strong { display: block; font-weight: 600; font-size: 14px; }
.access-row small { display: block; color: var(--muted); font-size: 12px; }
.access-row > span.grow { min-width: 0; }

.settings { display: grid; gap: 18px; max-width: 820px; }
.setting-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 12px 0; }
.note { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.save-bar {
  position: sticky;
  bottom: 16px;
  display: flex;
  justify-content: flex-end;
}
.save-bar .btn { box-shadow: var(--shadow-lg); }

.profile-top { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.profile-top h2 { font-size: 22px; }
.profile-top .badge { margin-top: 8px; }
.kv { display: grid; gap: 0; margin: 0; }
.kv div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-weight: 500; }

/* ---- Auth ---- */

.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-art {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 48px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, .18), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(249, 115, 22, .45), transparent 45%),
    linear-gradient(140deg, #312e81, #6d28d9 50%, #c026d3);
  color: #fff;
}
.brand.light { color: #fff; padding: 0; }
.brand.light .logo { background: rgba(255, 255, 255, .18); box-shadow: none; backdrop-filter: blur(6px); }
.art-stack { position: relative; flex: 1; min-height: 280px; }
.art-card {
  position: absolute;
  border: 6px solid rgba(255, 255, 255, .92);
  border-bottom-width: 26px;
  border-radius: 6px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
  animation: float 7s ease-in-out infinite;
}
.art-card.c1 { width: 200px; height: 160px; left: 8%; top: 18%; --rot: -9deg; background: linear-gradient(160deg, #fde68a, #f97316 60%, #7c2d12); }
.art-card.c2 { width: 230px; height: 170px; left: 36%; top: 6%; --rot: 5deg; background: linear-gradient(200deg, #a7f3d0, #0ea5e9 55%, #1e3a8a); animation-delay: -2s; }
.art-card.c3 { width: 170px; height: 200px; left: 58%; top: 40%; --rot: 11deg; background: linear-gradient(180deg, #fbcfe8, #db2777 60%, #4c0519); animation-delay: -4s; }
.art-card.c4 { width: 190px; height: 140px; left: 16%; top: 55%; --rot: 4deg; background: linear-gradient(170deg, #bbf7d0, #22c55e 50%, #14532d); animation-delay: -1s; }
.art-card.c5 { width: 120px; height: 120px; left: 44%; top: 62%; --rot: -6deg; background: linear-gradient(140deg, #e9d5ff, #8b5cf6 60%, #312e81); animation-delay: -3s; }
@keyframes float {
  0%, 100% { transform: rotate(var(--rot)) translateY(0); }
  50% { transform: rotate(var(--rot)) translateY(-12px); }
}
.art-copy h2 { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.art-copy p { margin-top: 12px; max-width: 42ch; color: rgba(255, 255, 255, .8); }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(380px, 100%); display: grid; gap: 16px; }
.auth-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -.025em; }
.auth-head .logo { margin-bottom: 16px; }
.switch-line { text-align: center; color: var(--muted); font-size: 14px; }
.sm-only { display: none; }

/* ---- Small screens ---- */

@media (max-width: 1100px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --row: 140px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, 85vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .25s cubic-bezier(.2, .8, .2, 1), visibility 0s .25s;
  }
  .sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition-delay: 0s; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .45); }
  .scrim.show { display: block; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  #view { padding: 20px 16px 72px; }
  .page-head h1 { font-size: 24px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .hide-sm { display: none; }
  .viewer.with-info { grid-template-columns: minmax(0, 1fr); grid-template-rows: 55vh minmax(0, 1fr); }
  .with-info .v-img { max-height: 55vh; }
  .with-info .v-panel { border-left: 0; border-top: 1px solid var(--border); }
  .v-nav { width: 40px; height: 40px; }
  .v-nav.prev { left: 8px; }
  .v-nav.next { right: 8px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .sm-only { display: grid; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 12px; }
}
@media (max-width: 760px) {
  .row2, .role-pick { grid-template-columns: 1fr; }
  .jg { gap: 4px; }
  .ph { border-radius: 6px; }
  .search.sm { max-width: none; flex-basis: 100%; }
  .tool { flex: 1 1 140px; }
  .tool select { width: 100% !important; max-width: none; }
  .modal-back { align-items: end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  /* Tables become stacked cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .table td:first-child { padding-bottom: 10px; }
  .table td:first-child::before { display: none; }
  .row-actions { justify-content: flex-end !important; padding-top: 10px !important; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 22px; }
  .quick { grid-template-columns: 1fr; }
}

/* ---- QR login labels (Admin → QR labels) ---- */

.qr-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.qr-users { max-height: 260px; overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: 14px; }
.qr-users-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 10px 6px; }
.link-btn.accent { color: var(--accent); font-weight: 600; }
.link-btn.accent:hover { color: var(--accent); text-decoration: underline; }
.qr-preview { padding: 18px; border-radius: 16px; background: var(--surface-2); min-height: 300px; }
.qr-preview-head { display: flex; justify-content: space-between; margin-bottom: 14px; }
.qr-sheet { display: flex; flex-wrap: wrap; gap: 4mm; align-items: flex-start; }

/* Labels are always printed black on white, in real-world sizes */
.qr-label {
  display: flex;
  align-items: center;
  overflow: hidden;
  background: #fff;
  color: #17171c;
  border: 1px dashed #b9b9c3; /* cut line */
  border-radius: 3mm;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.qr-img { flex: none; display: block; image-rendering: pixelated; }
.qr-text { display: flex; flex-direction: column; gap: 1.2mm; min-width: 0; }
.qr-brand { display: flex; align-items: center; gap: 2mm; font-weight: 700; letter-spacing: -.01em; }
.qr-brand .logo { box-shadow: none; border-radius: 1.6mm; }
.qr-name { font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.qr-user, .qr-msg { color: #4a4a55; }
.qr-link { color: #4f46e5; font-weight: 600; word-break: break-all; }

.qr-label.card { width: 85mm; height: 54mm; padding: 4mm; gap: 4mm; }
.qr-label.card .qr-img { width: 40mm; height: 40mm; }
.qr-label.card .qr-brand { font-size: 11pt; }
.qr-label.card .logo { width: 7mm; height: 7mm; }
.qr-label.card .logo .i { width: 4.5mm; height: 4.5mm; }
.qr-label.card .qr-name { font-size: 12pt; }
.qr-label.card .qr-user, .qr-label.card .qr-msg { font-size: 8pt; }
.qr-label.card .qr-link { font-size: 7pt; }

.qr-label.sticker { width: 50mm; height: 30mm; padding: 2.5mm; gap: 2.5mm; }
.qr-label.sticker .qr-img { width: 25mm; height: 25mm; }
.qr-label.sticker .qr-text { gap: .6mm; }
.qr-label.sticker .qr-brand { font-size: 7.5pt; gap: 1.2mm; }
.qr-label.sticker .logo { width: 4.5mm; height: 4.5mm; border-radius: 1mm; }
.qr-label.sticker .logo .i { width: 3mm; height: 3mm; }
.qr-label.sticker .qr-name { font-size: 8.5pt; }
.qr-label.sticker .qr-user, .qr-label.sticker .qr-msg { font-size: 5.5pt; }
.qr-label.sticker .qr-link { font-size: 5pt; }

.qr-label.big { width: 100mm; height: 140mm; padding: 9mm; gap: 6mm; flex-direction: column; justify-content: center; text-align: center; }
.qr-label.big .qr-img { width: 70mm; height: 70mm; }
.qr-label.big .qr-text { align-items: center; gap: 2.5mm; }
.qr-label.big .qr-brand { font-size: 18pt; gap: 3mm; }
.qr-label.big .logo { width: 11mm; height: 11mm; border-radius: 3mm; }
.qr-label.big .logo .i { width: 7mm; height: 7mm; }
.qr-label.big .qr-name { font-size: 20pt; }
.qr-label.big .qr-user, .qr-label.big .qr-msg { font-size: 12pt; }
.qr-label.big .qr-link { font-size: 11pt; }

@media (max-width: 1000px) {
  .qr-layout { grid-template-columns: 1fr; }
}

/* ---- Multi-select ---- */

.ph-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: rgba(0, 0, 0, .25);
  color: transparent;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.ph-check .i { width: 15px; height: 15px; stroke-width: 3; }
.ph:hover .ph-check, .selecting .ph-check { opacity: 1; }
.ph.selected .ph-check { background: var(--accent); border-color: var(--accent); color: #fff; opacity: 1; }
.ph.selected img { transform: scale(.88); border-radius: 8px; }
.ph.selected { background: var(--accent-soft); }
.selecting .ph-video { left: auto; right: 8px; }
.selecting .ph { cursor: pointer; }
.group-select {
  display: none;
  margin-left: auto;
  padding: 2px 10px;
  border: 0;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.selecting .group-select { display: inline-block; }
.selbar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(820px, calc(100% - 24px));
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: pop .2s ease-out;
}
.selbar-count { padding: 0 4px; white-space: nowrap; }
.selecting .tabbar { display: none !important; }
.tool-btn { height: 38px; border-radius: 10px; }

/* ---- Tabs inside a section (Folders | Albums, Places | Map | People) ---- */

.seg-tabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 18px;
  padding: 4px;
  overflow-x: auto;
  border-radius: 13px;
  background: var(--surface-2);
}
.seg-tabs a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.seg-tabs a .i { width: 16px; height: 16px; }
.seg-tabs a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ---- On this day ---- */

.memories { margin-bottom: 8px; }
.memories .section-title { margin-top: 0; }
.mem-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.mem-strip::-webkit-scrollbar { display: none; }
.mem-card {
  position: relative;
  flex: none;
  width: 170px;
  height: 220px;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface-2);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.mem-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.mem-card:hover img { transform: scale(1.06); }
.mem-card span {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  padding: 40px 12px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  color: #fff;
  text-align: left;
}
.mem-card strong { font-size: 16px; }
.mem-card small { font-size: 12px; opacity: .85; }

/* ---- Viewer extras ---- */

.v-caption { display: flex; gap: 8px; margin: 10px 0 6px; color: var(--text-2); font-size: 14px; font-style: italic; }
.v-caption .i { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--accent); }
.v-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.v-tags .chip { text-decoration: none; }
.v-tags .chip:hover { background: var(--accent-soft); color: var(--accent); }
.v-people { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; }
.v-people a { display: grid; justify-items: center; gap: 4px; width: 60px; color: var(--text); font-size: 11px; font-weight: 600; text-align: center; text-decoration: none; }
.v-people img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }
.v-people span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention { padding: 0 3px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mention-box { position: relative; flex: 1; }
.mention-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 5;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.mention-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mention-list button.on, .mention-list button:hover { background: var(--surface-2); }
.mention-list strong { display: block; font-size: 14px; }
.mention-list small { display: block; color: var(--muted); font-size: 12px; }

/* ---- Pick lists (albums), share links ---- */

.pick-list { display: grid; gap: 4px; max-height: 320px; overflow-y: auto; margin: 0 -6px; }
.pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pick-row:hover { background: var(--surface-2); }
.pick-row strong { display: block; font-weight: 600; }
.pick-row small { display: block; color: var(--muted); font-size: 12px; }
.link-list { display: grid; gap: 8px; }
.link-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; }
.link-row.expired { opacity: .55; }
.link-row input { height: 34px; font-size: 13px; }
.link-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.link-ic { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.share-new { margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--border); }
.share-new h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }

/* ---- People ---- */

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 22px 14px; }
.people-grid.small { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); max-height: 60vh; overflow-y: auto; padding: 4px; }
.person {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.person img {
  width: 100%;
  max-width: 130px;
  aspect-ratio: 1;
  margin-bottom: 6px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--border);
  transition: transform .2s, box-shadow .2s;
}
.person:hover img { transform: scale(1.04); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.person strong { font-size: 14px; }
.person span { color: var(--muted); font-size: 12px; }
.person-head { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }
.person-head img { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
.person-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.person-head .actions { margin-top: 10px; }

/* ---- Map ---- */

.map-wrap { position: relative; height: calc(100vh - 200px); min-height: 360px; overflow: hidden; isolation: isolate; z-index: 0; border-radius: 20px; box-shadow: var(--shadow); }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.map-count, .map-empty {
  position: absolute;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
}
.map-count { left: 12px; bottom: 12px; }
.map-count .i { width: 15px; height: 15px; color: var(--accent); }
.map-empty { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.map-pin {
  position: relative;
  width: 46px;
  height: 46px;
  overflow: visible;
  border: 3px solid #fff;
  border-radius: 14px;
  background: #ddd;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}
.map-pin img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; }
.map-pin.cluster { width: 58px; height: 58px; border-radius: 18px; }
.map-pin.cluster img { border-radius: 15px; }
.map-pin b {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 24px;
  padding: 2px 6px;
  border: 2px solid #fff;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

/* ---- Slideshow ---- */

.slideshow { position: fixed; inset: 0; z-index: 120; overflow: hidden; background: #000; animation: fade .3s; }
.ss-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 1.2s ease; }
.ss-img.on { opacity: 1; }
.ss-img.kb { animation: kenburns 9s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.08); } }
.ss-caption {
  position: absolute;
  left: 24px;
  bottom: 84px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
  transition: opacity .4s;
}
.ss-bar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 99px;
  background: rgba(20, 20, 24, .6);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
  transition: opacity .4s;
}
.ss-count { min-width: 64px; color: rgba(255, 255, 255, .75); font-size: 13px; text-align: center; }
.slideshow.idle .ss-bar, .slideshow.idle .ss-caption { opacity: 0; }
.slideshow.idle { cursor: none; }

/* ---- Rotate & crop editor ---- */

.editor { position: fixed; inset: 0; z-index: 130; display: grid; grid-template-rows: auto 1fr auto auto; background: #0b0b0e; color: #fff; animation: fade .2s; }
.ed-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.btn.light { color: #fff; }
.btn.light:hover { background: rgba(255, 255, 255, .1); }
.ed-stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; }
.ed-wrap { position: relative; touch-action: none; }
.ed-wrap canvas { display: block; }
.ed-crop {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .58);
  cursor: move;
  touch-action: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .35) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
  background-position: -1px -1px;
}
.ed-h { position: absolute; width: 26px; height: 26px; border: 4px solid #fff; }
.ed-h.nw { left: -5px; top: -5px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.ed-h.ne { right: -5px; top: -5px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.ed-h.sw { left: -5px; bottom: -5px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.ed-h.se { right: -5px; bottom: -5px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.ed-loading { position: absolute; color: rgba(255, 255, 255, .6); }
.ed-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 12px; }
.ed-tool { display: grid; justify-items: center; gap: 2px; padding: 6px 12px; border: 0; border-radius: 12px; background: none; color: #fff; font: inherit; font-size: 12px; cursor: pointer; }
.ed-tool:hover { background: rgba(255, 255, 255, .1); }
.ed-tool .i { width: 22px; height: 22px; }
.ed-sep { width: 1px; height: 28px; background: rgba(255, 255, 255, .2); }
.ed-chip { padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 99px; background: none; color: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.ed-chip.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.ed-note { margin: 0; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); color: rgba(255, 255, 255, .5); font-size: 12px; text-align: center; }

/* ---- Admin: progress, activity, duplicates ---- */

.progress-row { display: grid; gap: 6px; }
.progress-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.progress-head a { color: var(--text); text-decoration: none; }
.progress-head span { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #a855f7); transition: width .4s; }
.bar.warn span { background: var(--warn); }
.bar.danger span { background: var(--danger); }
.activity { list-style: none; margin: 0; padding: 6px 0; }
.activity li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }
.activity li:last-child { border-bottom: 0; }
.activity li.warn .act-ic { background: var(--warn-soft); color: var(--warn); }
.activity small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.act-ic { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.act-ic .i { width: 16px; height: 16px; }
.dups { display: grid; gap: 14px; margin-top: 12px; }
.dup-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; }
.dup-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; }
.dup-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.dup-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.dup-item strong { display: block; font-size: 13px; }
.dup-item small { display: block; color: var(--muted); font-size: 12px; }
.dup-group .btn { margin-left: auto; }

/* ---- Upload states ---- */

.up-item.done img, .up-item.done video, .up-item.dup img, .up-item.dup video { opacity: .45; }
.up-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ok); }
.up-state.dup { color: var(--warn); }
.up-state .i { width: 30px; height: 30px; stroke-width: 3; }

/* ---- Bottom sheets (phone menus) ---- */

.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(8, 8, 14, .45);
  backdrop-filter: blur(3px);
  animation: fade .2s ease-out;
}
.sheet {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: sheet-up .3s cubic-bezier(.2, .9, .3, 1);
  transition: transform .2s;
}
.sheet-back.closing { opacity: 0; transition: opacity .2s; }
.sheet-back.closing .sheet { transform: translateY(100%) !important; transition: transform .2s ease-in; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-handle { display: block; width: 42px; height: 5px; margin: 0 auto 16px; border-radius: 99px; background: var(--border); }
.sheet-title { margin: 2px 4px 16px; font-size: 19px; font-weight: 700; }
.sheet-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 3px;
  min-height: 156px;
  padding: 18px;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(30, 20, 60, .2);
  transition: transform .15s;
}
.sheet-tile:active { transform: scale(.97); }
.sheet-tile::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}
.sheet-tile.photo { background: linear-gradient(140deg, #6366f1, #8b5cf6 55%, #ec4899); }
.sheet-tile.video { background: linear-gradient(140deg, #0284c7, #0d9488 55%, #22c55e); }
.tile-ic {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, .22);
}
.tile-ic .i { width: 25px; height: 25px; }
.sheet-tile strong { font-size: 19px; font-weight: 700; }
.sheet-tile small { font-size: 12px; opacity: .85; }
.sheet-me {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.sheet-me-text { flex: 1; min-width: 0; }
.sheet-me strong { display: block; font-size: 17px; font-weight: 700; }
.sheet-me small { display: block; color: var(--muted); font-size: 13px; }
.sheet-me > .i { color: var(--muted); }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 2px;
  border-radius: 18px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.sheet-item:active { background: var(--surface-2); }
.sheet-ic {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: color-mix(in srgb, hsl(var(--h) 75% 55%) 16%, transparent);
  color: hsl(var(--h) 65% 50%);
}
.sheet-ic .i { width: 24px; height: 24px; }
.sheet-label { margin: 18px 6px 8px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.sheet-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  margin-top: 18px;
  border: 0;
  border-radius: 18px;
  background: var(--danger-soft);
  color: var(--danger);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Phone layout: bottom tab bar instead of the sidebar ---- */

.tabbar, .m-brand, .m-hero, .m-more { display: none; }

@media (max-width: 760px) {
  :root { --row: 118px; }
  body { -webkit-tap-highlight-color: transparent; }
  .menu-btn, .top-upload { display: none !important; }
  .m-brand { display: inline-flex; flex: none; }
  /* More (profile avatar) next to search */
  .m-more {
    display: grid;
    place-items: center;
    flex: none;
    padding: 2px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--border);
    cursor: pointer;
    transition: box-shadow .2s, transform .15s;
  }
  .m-more .avatar { --size: 36px; font-size: 13px; }
  .m-more:active { transform: scale(.93); }
  .m-more.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
  .m-brand .logo { width: 38px; height: 38px; border-radius: 12px; }
  .topbar { gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  .search input { height: 40px; border-color: transparent; border-radius: 999px !important; background: var(--surface-2) !important; }
  #view { padding: 16px 14px calc(112px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 27px; font-weight: 800; letter-spacing: -.03em; }

  .tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: 66px;
    padding: 0 4px;
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    border-radius: 24px;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: blur(22px) saturate(1.8);
    -webkit-backdrop-filter: blur(22px) saturate(1.8);
    box-shadow: 0 14px 40px rgba(20, 20, 40, .18), 0 2px 6px rgba(20, 20, 40, .06);
  }
  .tabbar a, .tabbar button[data-tab] {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }
  .tabbar .i { width: 22px; height: 22px; transition: transform .2s; }
  .tabbar .active { color: var(--accent); }
  .tabbar .active::before {
    content: '';
    position: absolute;
    top: 7px;
    z-index: -1;
    width: 50px;
    height: 32px;
    border-radius: 12px;
    background: var(--accent-soft);
  }
  .tabbar .active .i { transform: scale(1.06); }
  .tab-fab {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    margin-top: -32px;
    border: 4px solid var(--bg);
    border-radius: 21px;
    background: linear-gradient(135deg, #6366f1, #a855f7 55%, #f97316);
    color: #fff;
    box-shadow: 0 12px 26px rgba(124, 58, 237, .45);
    cursor: pointer;
    transition: transform .15s;
  }
  .tab-fab:active { transform: scale(.92) rotate(90deg); }
  .tab-fab .i { width: 28px; height: 28px; stroke-width: 2.6; }

  .m-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 156px;
    margin: 0 0 18px;
    padding: 20px;
    overflow: hidden;
    border-radius: 26px;
    color: #fff;
    background:
      radial-gradient(circle at 12% 8%, rgba(255, 255, 255, .25), transparent 42%),
      radial-gradient(circle at 92% 95%, rgba(249, 115, 22, .6), transparent 50%),
      linear-gradient(140deg, #4338ca, #7c3aed 55%, #db2777);
    box-shadow: 0 16px 36px rgba(109, 40, 217, .35);
  }
  .m-hero ~ .page-head { display: none; }
  .m-hero-text { position: relative; z-index: 1; min-width: 0; }
  .m-hello { font-size: 14px; opacity: .85; }
  .m-name { display: block; margin: 1px 0 14px; font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
  .m-stats { display: flex; gap: 7px; }
  .m-stats a {
    display: flex;
    flex-direction: column;
    padding: 7px 11px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .17);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 11px;
    text-decoration: none;
  }
  .m-stats b { font-size: 17px; font-weight: 800; line-height: 1.15; }
  .m-hero-stack { position: relative; flex: none; width: 92px; height: 112px; }
  .m-hero-stack img {
    position: absolute;
    top: calc(var(--i) * 9px);
    right: calc(var(--i) * 9px);
    width: 72px;
    height: 92px;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, .95);
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .3);
    transform: rotate(calc((var(--i) - 1) * 9deg));
  }

  .jg { gap: 3px; }
  .ph { border-radius: 5px; }
  .group-title {
    position: sticky;
    top: calc(61px + env(safe-area-inset-top));
    z-index: 5;
    margin: 12px -14px 8px;
    padding: 9px 14px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    font-size: 15px;
  }
  .group:first-of-type .group-title { margin-top: 0; }
  .grid-tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -14px 4px;
    padding: 2px 14px 8px;
    scrollbar-width: none;
  }
  .grid-tools::-webkit-scrollbar { display: none; }
  .tool { flex: none; }
  .tool select { width: auto !important; height: 36px; padding-right: 28px; border-radius: 999px; font-size: 13px; }

  .folder-grid, .folder-grid.small { grid-template-columns: 1fr 1fr; gap: 16px 10px; }
  .fcover { border-radius: 20px; }
  .finfo strong { font-size: 14px; }
  .hero { border-radius: 24px; padding: 18px; }
  .hero h1 { font-size: 22px; }

  .v-top { padding: calc(8px + env(safe-area-inset-top)) 6px 8px; }
  .v-title { font-size: 14px; }
  .v-count, .v-nav { display: none; }
  .with-info .v-panel { position: relative; z-index: 3; margin-top: -20px; border-radius: 22px 22px 0 0; }

  .selbar { bottom: calc(12px + env(safe-area-inset-bottom)); border-radius: 20px; }
  .ph-check { width: 24px; height: 24px; opacity: 0; }
  .selecting .ph-check { opacity: 1; }
  .mem-card { width: 140px; height: 180px; }
  .people-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 18px 10px; }
  .person-head img { width: 84px; height: 84px; }
  .person-head h1 { font-size: 23px; }
  .map-wrap { height: calc(100vh - 230px - env(safe-area-inset-bottom)); border-radius: 18px; }
  .dup-group .btn { margin-left: 0; }
  .seg-tabs { margin-bottom: 14px; }

  /* Login: the art becomes a header with the form sheet over it */
  .auth-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-art { display: flex; min-height: 38vh; padding: calc(24px + env(safe-area-inset-top)) 24px 52px; }
  .art-stack { flex: none; min-height: 300px; margin: 8px 0 4px; zoom: .5; }
  .art-copy h2 { font-size: 24px; }
  .art-copy p { display: none; }
  .auth-panel { position: relative; align-items: start; margin-top: -28px; padding-top: 30px; border-radius: 28px 28px 0 0; background: var(--bg); }
  .sm-only { display: none !important; }
}

@media print {
  @page { margin: 8mm; }
  body.printing-qr { background: #fff; }
  body.printing-qr .sidebar,
  body.printing-qr .scrim,
  body.printing-qr .topbar,
  body.printing-qr .page-head,
  body.printing-qr .tabs,
  body.printing-qr .qr-controls,
  body.printing-qr .qr-preview-head,
  body.printing-qr #toasts,
  body.printing-qr .drop-overlay { display: none !important; }
  body.printing-qr .app,
  body.printing-qr .qr-layout { display: block; }
  body.printing-qr #view,
  body.printing-qr .qr-preview { padding: 0; margin: 0; background: none; min-height: 0; }
  body.printing-qr .qr-sheet { gap: 3mm; }
  body.printing-qr .qr-label { break-inside: avoid; }
}
