/* ─── Reset / base ─── */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;

  /* Palette */
  --bg:           #f4f1ec;
  --paper:        #ffffff;
  --sidebar-bg:   #ffffff;
  --topbar-bg:    #ffffff;
  --ink:          #1c1917;
  --muted:        rgba(28, 25, 23, 0.55);
  --border:       rgba(28, 25, 23, 0.10);
  --border-mid:   rgba(28, 25, 23, 0.18);
  --accent:       #6b2d3c;
  --accent-soft:  rgba(107, 45, 60, 0.08);
  --accent-mid:   rgba(107, 45, 60, 0.18);
  --ok:           #1e5c36;
  --ok-bg:        #e8f4ed;
  --danger:       #9b1c1c;
  --danger-bg:    #fef2f2;
  --warn:         #92400e;
  --warn-bg:      #fffbeb;
  --info-bg:      #eff6ff;
  --info:         #1d4ed8;

  /* Geometry */
  --sidebar-w:    260px;
  --topbar-h:     56px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:    0 20px 60px rgba(84,35,49,.12);

  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 0 18px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--ink);
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn-ghost:hover { background: rgba(28,25,23,.05); border-color: rgba(28,25,23,.3); }
.btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(155,28,28,.25);
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 0 14px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { min-height: 32px !important; padding: 0 12px !important; font-size: 0.8125rem !important; border-radius: var(--radius-xs) !important; }
.btn-icon { min-width: 38px; padding: 0 !important; }
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon.is-spinning svg { animation: spin .7s linear infinite; }
.full-width { width: 100%; }

.btn-link {
  text-decoration: none !important;
}

/* ─── Inputs ─── */
.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink);
}

.field-hint {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.field-label input,
.field-label select,
.field-label textarea {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--paper);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  font-size: 0.875rem;
}

.field-label textarea {
  padding: 8px 12px;
  resize: vertical;
  min-height: 80px;
}

.field-label input:focus,
.field-label select:focus,
.field-label textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group legend {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 0 4px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
  font-size: 0.875rem;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: unset;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── Login screen ─── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  width: min(380px, 100%);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 32px;
}

.login-logo {
  font-size: 2.2rem;
  text-align: center;
  margin-bottom: 10px;
  display: block;
}

.login-title {
  font-size: 1.4rem;
  font-family: Georgia, serif;
  font-weight: 600;
  text-align: center;
  margin: 0 0 24px;
}

.login-card .field-label { margin-bottom: 14px; }

.error-msg {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-top: 8px;
}

/* ─── Shell layout ─── */
.admin-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo { font-size: 1.3rem; line-height: 1; }

.sidebar-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: Georgia, serif;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
  padding: 0;
}
.sidebar-close svg { width: 16px; height: 16px; }
.sidebar-close:hover { background: var(--bg); color: var(--ink); }

/* Sidebar nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px 4px;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}

.nav-item:hover { background: var(--bg); color: var(--ink); }

.nav-item.is-on {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke-width: 2;
}

/* Album list section */
.sidebar-albums {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sidebar-albums-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 6px;
  flex-shrink: 0;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.sidebar-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.sidebar-add-btn svg { width: 14px; height: 14px; }
.sidebar-add-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-mid); }

.album-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.album-list li { list-style: none; }

.album-list-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: background .12s;
}

.album-list-btn:hover { background: var(--bg); }
.album-list-btn.is-on { background: var(--accent-soft); }
.album-list-btn.is-on .album-item-name { color: var(--accent); }

.album-item-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.album-item-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

/* ─── Main area ─── */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top bar */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
  padding: 0;
  margin-left: -4px;
}
.hamburger svg { width: 20px; height: 20px; }
.hamburger:hover { background: var(--bg); }

.topbar-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: Georgia, serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Quota */
.quota-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.quota-text { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.quota-bar {
  width: 100px;
  height: 4px;
  border-radius: 99px;
  background: rgba(28,25,23,.10);
  overflow: hidden;
}
.quota-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .4s ease;
}

/* Watch badge */
.watch-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px 4px 8px;
}
.watch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}
.watch-dot.is-active { background: #22c55e; }
.watch-dot.is-warn   { background: #f59e0b; }
.watch-dot.is-dead   { background: #ef4444; }

/* ─── Main content ─── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left));
  background: var(--bg);
}

/* ─── Content pane ─── */
.content-pane { }

.pane-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.pane-header-left { min-width: 0; }
.pane-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.pane-title {
  font-size: 1.3rem;
  font-family: Georgia, serif;
  font-weight: 600;
  margin-bottom: 3px;
}

.pane-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ─── Settings sections ─── */
.settings-section {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
}

.settings-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 14px;
}

.settings-section-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 14px;
  margin-top: -8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}

.settings-grid:last-child { margin-bottom: 0; }

.settings-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.short-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 12px;
}

.short-link-url {
  font-size: 0.9rem;
  word-break: break-all;
}

.short-link-status {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.short-link-status[data-state="on"] {
  color: #1f6b3a;
  border-color: rgba(31, 107, 58, 0.35);
  background: rgba(31, 107, 58, 0.08);
}

.short-link-actions {
  margin-top: 0;
}

.short-link-qr {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.short-link-qr-desc {
  margin-top: 0;
}

.short-link-qr-preview {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}

#shortLinkQrCanvas {
  width: min(280px, 100%);
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Checkerboard so transparent export is obvious in the admin preview */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e8e4de 25%, transparent 25%),
    linear-gradient(-45deg, #e8e4de 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e4de 75%),
    linear-gradient(-45deg, transparent 75%, #e8e4de 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

@media (max-width: 700px) {
  .settings-grid, .settings-grid-3 { grid-template-columns: 1fr; }
}

/* Form actions */
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-actions-tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* ─── Tabs ─── */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .15s;
  margin-bottom: -1px;
}

.tab-btn.is-on { color: var(--ink); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.is-on) { color: var(--ink); }

.tab-pane { display: none; }
.tab-pane.is-on { display: block; }

/* ─── Watch info banner ─── */
.watch-info {
  background: var(--warn-bg);
  border: 1px solid rgba(146,64,14,.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--warn);
  margin-top: 12px;
}

/* ─── QR panel ─── */
.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.qr-url { font-size: 0.8rem; color: var(--muted); }

#qrCanvas {
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 200px;
  height: 200px;
}

/* ─── Media toolbar ─── */
.media-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.media-toolbar-left, .media-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Media grid ─── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.media-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  transition: box-shadow .15s;
}

.media-card:hover { box-shadow: var(--shadow-md); }

.media-card.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.media-card img, .media-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  border: 2px solid rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.media-card.is-selected .card-check {
  background: var(--accent);
  border-color: var(--accent);
}

.media-card.is-selected .card-check::after {
  content: "✓";
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
}

.card-meta {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 20px 8px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #fff;
  font-size: .72rem;
  line-height: 1.3;
  opacity: 0;
  transition: opacity .15s;
}
.media-card:hover .card-meta { opacity: 1; }

.card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.card-btn {
  min-height: unset;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  border: 0;
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .8rem;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.media-card:hover .card-btn { opacity: 1; }
.card-btn:hover { background: rgba(255,255,255,.35); }
.card-btn.is-delete { background: rgba(200,30,30,.6); }

.card-type-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: .65rem;
  padding: 2px 5px;
  border-radius: 5px;
  font-weight: 500;
  pointer-events: none;
}

/* ─── Chart ─── */
.chart-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.stats-chart { width: 100%; height: auto; display: block; }

/* ─── Danger zone ─── */
.danger-zone {
  background: var(--danger-bg);
  border: 1px solid rgba(155,28,28,.2);
  border-radius: var(--radius);
  padding: 20px;
}

.danger-zone-title { color: var(--danger); margin-bottom: 6px; }

.danger-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }

.danger-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ─── Empty states ─── */
.empty-msg {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
  font-size: 0.875rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  text-align: center;
  padding: 40px 24px;
}

.empty-state-icon { font-size: 3rem; margin-bottom: 14px; }

.empty-state-text {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── Users pane ─── */
.users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.user-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.user-role-badge.is-admin {
  background: var(--accent-soft);
  color: var(--accent);
}

.user-role-badge.is-viewer {
  background: #eff6ff;
  color: #1d4ed8;
}

.user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Fullscreen viewer ─── */
.admin-viewer {
  margin: auto;
  max-width: 90vw;
  max-height: 90vh;
  border: 0;
  border-radius: 18px;
  background: #1a1a1a;
  color: #fff;
  padding: 0;
  box-shadow: 0 25px 80px rgba(0,0,0,.6);
}

.admin-viewer::backdrop {
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.viewer-meta { font-size: 0.8rem; color: rgba(255,255,255,.7); }

.viewer-close {
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  min-height: auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  opacity: .8;
  padding: 0;
}
.viewer-close svg { width: 18px; height: 18px; }
.viewer-close:hover { opacity: 1; background: rgba(255,255,255,.1); }

.viewer-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 50vw;
  min-height: 40vh;
  max-height: calc(90vh - 60px);
  position: relative;
}

.viewer-stage img, .viewer-stage video {
  max-width: 90vw;
  max-height: calc(90vh - 70px);
  object-fit: contain;
  display: block;
}

.viewer-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in .2s ease;
  font-size: 0.875rem;
  line-height: 1.4;
}

.toast.is-success { border-left: 3px solid var(--ok); }
.toast.is-error   { border-left: 3px solid var(--danger); }
.toast.is-warn    { border-left: 3px solid #f59e0b; }
.toast.is-info    { border-left: 3px solid #3b82f6; }

.toast-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.4; }
.toast-msg  { flex: 1; }

.toast-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  min-height: auto;
  line-height: 1;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--ink); }

.toast.is-leaving { animation: toast-out .18s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.97); height: 0; padding: 0; margin: 0; overflow: hidden; } }

/* ─── Misc ─── */
.text-muted { color: var(--muted); }
.text-sm    { font-size: 0.8rem; }
.msg.is-error { color: var(--danger); font-size: 0.8125rem; margin-top: 8px; }
.msg.is-ok    { color: var(--ok);     font-size: 0.8125rem; margin-top: 8px; }

/* ─── Mobile ─── */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-close { display: flex; }

  .sidebar-overlay { display: block; }
  .sidebar-overlay.is-visible { opacity: 1; pointer-events: auto; }

  .hamburger { display: flex; }

  .admin-main { width: 100%; }

  .topbar-title { font-size: 0.875rem; }

  .quota-wrap { display: none; }

  .main-content { padding: 16px 16px 32px; }

  .form-actions-tools { margin-left: 0; }
}

@media (max-width: 500px) {
  .pane-header { flex-direction: column; }
  .pane-header-right { width: 100%; }
}
