:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --bg-soft: #11151c;
  --panel: #171c24;
  --panel-raised: #1d2430;
  --panel-hover: #232c39;
  --line: #303948;
  --line-soft: #252d39;
  --text: #eef2f8;
  --muted: #9da9ba;
  --accent: #5b8fff;
  --accent-strong: #76a2ff;
  --danger: #e3616d;
  --danger-soft: #2b1a20;
  --good: #5fcf96;
  --warning: #ffc978;
  --shadow-sm: 0 8px 24px rgba(0,0,0,.18);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.42);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --vb-visual-bottom-offset: 0px;
  --vb-visual-top-offset: 0px;
  --vb-visual-left-offset: 0px;
  --vb-visual-width: 100vw;
  --vb-visual-height: 100dvh;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(91,143,255,.10), transparent 34rem),
    linear-gradient(180deg, #0d1015 0%, var(--bg) 42%, #0b0e13 100%);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, .file-button, input, select, textarea { transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease; }
button, .file-button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: #fff;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset;
}
button:hover, .file-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
button:active, .file-button:active { transform: translateY(0); }
button.secondary, .file-button.secondary { background: var(--panel-raised); border-color: var(--line); color: var(--text); }
button.secondary:hover, .file-button.secondary:hover { background: var(--panel-hover); border-color: #445066; }
button.danger { background: linear-gradient(180deg, #ee727e, var(--danger)); }
button:focus-visible, .file-button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .brand-home:focus-visible {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(91,143,255,.22);
}
button:disabled, input:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #0d1117;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset;
}
input:hover, select:hover, textarea:hover { border-color: #414c5e; }
input:focus, select:focus, textarea:focus { background: #10151c; }
textarea { resize: vertical; min-height: 108px; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 550; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.015em; }
p { margin-top: .55em; margin-bottom: .8em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.crypto-progress {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #30415b;
  border-radius: var(--radius-sm);
  background: #111925;
  color: #cbd8ec;
}
.crypto-progress::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid #52647e;
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: vault-spin .85s linear infinite;
}
@keyframes vault-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .crypto-progress::before { animation: none; } }

/* Application shell. The optional storage footer is viewport-fixed in 0.2.7. */
#appView { min-height: 100dvh; display: flex; flex-direction: column; }
#appView.footer-visible main { padding-bottom: calc(58px + env(safe-area-inset-bottom) + var(--vb-visual-bottom-offset)); }

.brand { font-size: 28px; font-weight: 820; letter-spacing: -.65px; }
.brand.small { font-size: 20px; white-space: nowrap; }
.brand-lockup { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.brand-home {
  color: var(--text);
  text-decoration: none;
  border-radius: 9px;
  padding: 5px 6px;
  margin: -5px -6px;
}
.brand-home:hover { color: #fff; background: rgba(255,255,255,.045); }
.brand-home span { overflow: hidden; text-overflow: ellipsis; }
.brand-icon { width: 38px; height: 38px; object-fit: contain; border-radius: 9px; flex: 0 0 auto; }
.brand-icon.small { width: 28px; height: 28px; border-radius: 7px; }
.admin-mode {
  margin-right: auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(23,28,36,.9);
  font-size: 12px;
  font-weight: 650;
}

.center-card {
  width: min(420px, calc(100% - 32px));
  margin: 12vh auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(29,36,48,.96), rgba(23,28,36,.96));
  box-shadow: var(--shadow-lg);
}
.center-card .brand { margin-bottom: 3px; }
.stack { display: grid; gap: 13px; }
.link-button { background: transparent; color: var(--accent-strong); padding-left: 0; margin-top: 12px; box-shadow: none; }
.link-button:hover { background: transparent; transform: none; text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(48,57,72,.88);
  background: rgba(12,15,20,.88);
  backdrop-filter: blur(18px) saturate(135%);
  box-shadow: 0 5px 18px rgba(0,0,0,.14);
}
.search-wrap {
  position: relative;
  flex: 1 1 520px;
  max-width: 760px;
  margin-right: auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}
.search {
  width: 100%;
  max-width: none;
  border-radius: 10px;
  background: rgba(13,17,23,.94);
}
.search::placeholder { color: #738096; }
.search-button { min-width: 78px; }
.search-suggestions {
  grid-column: 1 / -1;
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(340px, 48vh);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(18,23,31,.985);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}
.search-suggestion {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}
.search-suggestion:hover, .search-suggestion:focus-visible { background: var(--panel-hover); transform: none; }
.search-suggestion .suggestion-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-suggestion .suggestion-meta { color: var(--muted); font-size: 11px; font-weight: 600; }
.top-actions { display: flex; gap: 8px; }
.top-actions button { white-space: nowrap; }

main { flex: 1 0 auto; width: 100%; padding: 18px; }
.notice {
  max-width: 900px;
  margin: 28px auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  box-shadow: var(--shadow-sm);
}
.notice h2 { margin-top: 0; }
.row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.file-button input { display: none; }

.gallery-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin: 0 0 10px;
}
.search-status, .live-status {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(23,28,36,.92);
  font-size: 12px;
  box-shadow: 0 5px 18px rgba(0,0,0,.10);
}
.search-status { color: var(--muted); }
.live-status { gap: 7px; color: var(--good); }
.live-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(95,207,150,.11); }
.gallery { columns: 220px; column-gap: 14px; }
.tile {
  break-inside: avoid;
  margin: 0 0 14px;
  border: 1px solid var(--line-soft);
  background: var(--panel);
  border-radius: 11px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(0,0,0,.12);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tile:hover { transform: translateY(-2px); border-color: #44516a; box-shadow: 0 12px 30px rgba(0,0,0,.24); }
.tile img { display: block; width: 100%; min-height: 90px; object-fit: cover; background: #080b0f; }
.tile-info { padding: 8px 10px; color: var(--muted); font-size: 12px; border-top: 1px solid rgba(48,57,72,.55); }
.gallery-footer { display: flex; justify-content: center; padding: 22px 18px; }
.status-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--vb-visual-bottom-offset);
  z-index: 40;
  min-height: 34px;
  padding: 8px 16px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(9,12,16,.94);
  backdrop-filter: blur(14px) saturate(125%);
  color: var(--muted);
  text-align: right;
  font-size: 12px;
}

/* Dialogs */
dialog {
  border: 1px solid #374154;
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  padding: 0;
  max-height: 92vh;
  max-width: 95vw;
  box-shadow: var(--shadow-lg);
  overflow: auto;
}
dialog::backdrop { background: rgba(2,4,8,.76); backdrop-filter: blur(4px); }
.dialog-card { width: min(520px, 90vw); padding: 22px; display: grid; gap: 15px; }
.dialog-card.wide { width: min(900px, 92vw); }
.dialog-card.extra-wide { width: min(1180px, 94vw); }
.dialog-card > h2:first-child, .dialog-row h2 { margin-top: 0; }
.dialog-actions, .dialog-row { display: flex; gap: 9px; justify-content: space-between; align-items: center; }
.dialog-sticky-header {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: -22px -22px 0;
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(23,28,36,.97);
  backdrop-filter: blur(14px) saturate(125%);
}
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px; align-items: end; }
.form-end { align-self: end; }
.table-wrap { overflow: auto; max-height: 48vh; margin-top: 12px; border: 1px solid var(--line-soft); border-radius: 10px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { border-bottom: 1px solid var(--line-soft); padding: 10px 11px; text-align: left; vertical-align: top; }
th { color: var(--muted); background: #12171e; font-weight: 700; position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.018); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { padding: 6px 9px; font-size: 12px; }
.image-dialog { position: relative; width: 96vw; height: 94vh; overflow: hidden; }
.image-layout { display: grid; grid-template-columns: 310px 1fr; height: 94vh; }
.tag-sidebar { overflow: auto; padding: 17px; border-right: 1px solid var(--line); background: #141922; }
.dialog-floating-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 25;
  box-shadow: 0 8px 28px rgba(0,0,0,.44);
}
.image-info-header { padding-right: 88px; }
.image-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.tag-section h4 { margin: 15px 0 6px; text-transform: capitalize; color: var(--muted); }
.tag {
  display: block;
  width: 100%;
  margin: 2px 0;
  padding: 5px 8px;
  border: 0;
  color: #c2d4ff;
  background: transparent;
  text-align: left;
  font-weight: 550;
  box-shadow: none;
}
.tag:hover { background: rgba(91,143,255,.09); transform: none; }
.image-stage { display: flex; align-items: center; justify-content: center; overflow: auto; background: #05070a; }
.image-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.metadata { margin-top: 16px; color: var(--muted); word-break: break-word; }

/* Archive jobs and account recovery */
.job-list { margin-top: 14px; }
.job-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 12px; }
.job-card {
  min-width: 0;
  display: grid;
  gap: 11px;
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: linear-gradient(180deg, #171d26, #131820);
  box-shadow: 0 7px 22px rgba(0,0,0,.14);
}
.job-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.job-url { margin-top: 3px; max-width: 50ch; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.state-pill {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #10151c;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.state-running, .state-queued { color: #bcd0ff; border-color: #405d9c; background: #141f36; }
.state-idle { color: var(--good); border-color: #32664c; background: #11261c; }
.state-stopped, .state-disabled { color: #c2c8d2; border-color: #48505c; background: #181b20; }
.state-error { color: #ffadb4; border-color: #793b43; background: var(--danger-soft); }
.job-tags { display: grid; grid-template-columns: 70px minmax(0,1fr); gap: 7px 9px; align-items: start; color: var(--muted); font-size: 12px; }
.job-tags > .job-tags { grid-column: 1 / -1; }
.job-tags code { color: #dce6fa; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; white-space: normal; }
.job-meta { color: var(--muted); font-size: 12px; }
.job-run-progress { display: grid; gap: 6px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: #10151c; }
.job-run-progress-text { color: #dbe6fa; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.job-run-progress-bar { width: 100%; height: 8px; accent-color: #6f9cff; }
.job-error { padding: 9px 10px; border: 1px solid #71343c; border-radius: 8px; background: var(--danger-soft); color: #ffbdc3; font-size: 12px; overflow-wrap: anywhere; }
.job-actions { padding-top: 2px; }
.job-policy-note {
  margin: 2px 0 13px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #111720;
  color: var(--muted);
  font-size: 12px;
}
.job-schedule-fields { display: grid; gap: 9px; }
.job-schedule-control { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) auto; align-items: end; gap: 9px; }
.job-schedule-control .toggle { align-self: center; }
@media (max-width: 650px) { .job-schedule-control { grid-template-columns: 1fr; } }

.job-limit-control {
  display: grid;
  grid-template-columns: minmax(0,1fr) 92px auto;
  gap: 8px;
  align-items: end;
  padding-top: 3px;
}
.job-limit-control label { font-size: 12px; }
.job-limit-control input { min-width: 0; }
.form-hint { align-self: end; padding-bottom: 9px; font-size: 12px; }
.compact-note { margin: -5px 0 2px; font-size: 12px; line-height: 1.4; }
.empty-state { padding: 22px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); text-align: center; }
.account-section { min-width: 0; }
.account-dialog-card { width: min(760px, 94vw); }
.account-name { margin: -2px 0 2px; color: var(--muted); font-size: 13px; }
.account-menu {
  position: sticky;
  top: 58px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px,1fr));
  gap: 8px;
  padding: 9px;
  margin: 0 0 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(10px);
}
.account-menu-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  background: #111720;
  color: var(--muted);
}
.account-menu-button:hover { color: var(--text); border-color: var(--line); }
.account-menu-button.active,
.account-menu-button[aria-selected="true"] {
  color: var(--text);
  border-color: #466a8e;
  background: #172434;
  box-shadow: inset 0 0 0 1px rgba(122,181,239,.12);
}
.account-panel { display: grid; gap: 14px; min-width: 0; }
.account-panel.hidden { display: none !important; }
.account-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #11161e;
}
.account-card h3 { margin: 0; }
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  background: #24364b;
  color: #dcecff;
  font-size: 11px;
  font-weight: 700;
}
.deleted-photos-explainer {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid #31506b;
  border-radius: 9px;
  background: #101d29;
  font-size: 12px;
  line-height: 1.45;
}
.deleted-photos-explainer span { color: var(--muted); }
.deleted-photos-section { display: grid; gap: 10px; }
.deleted-photos-heading { align-items: start; gap: 12px; }
.deleted-photos-heading h3 { margin: 0 0 7px; }
.deleted-photos-heading .compact-note { margin: 0; }
.deleted-photos-list { display: grid; gap: 8px; max-height: 320px; overflow: auto; overscroll-behavior: contain; }
.deleted-photo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 11px; border: 1px solid var(--line-soft); border-radius: 10px; background: #10151c; }
.deleted-photo-meta { min-width: 0; display: grid; gap: 4px; }
.deleted-photo-meta strong { font-size: 13px; }
.deleted-photo-meta code { color: var(--muted); overflow-wrap: anywhere; user-select: all; }
.deleted-photos-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recovery-section {
  display: grid;
  gap: 13px;
  padding: 15px;
  border: 1px solid #73542c;
  border-radius: 11px;
  background: #251d13;
}
.recovery-section h3 { margin: 0; color: #ffd59a; }
.recovery-section strong { color: var(--text); user-select: all; }
.reset-status { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; line-height: 1.45; }
.reset-status.working { border-color: #755b34; background: #251f15; color: #ffd69b; }
.reset-status.ready { border-color: #32664c; background: #10251b; color: #a9ecc9; }
.reset-status.error { border-color: #793b43; background: var(--danger-soft); color: #ffb6bd; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.admin-page { width: min(1280px, 100%); margin: 0 auto; }
.admin-page-heading { display: flex; justify-content: space-between; gap: 18px; align-items: start; margin-bottom: 18px; }
.admin-page-heading h1 { margin: 0 0 5px; }
.admin-page-heading .disk-card { margin-top: 0; min-width: 260px; }
.admin-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  box-shadow: var(--shadow-sm);
}
.admin-card h2 { margin-top: 0; }
.branding-preview { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #10151c; }
.branding-preview img { width: 52px; height: 52px; object-fit: contain; border-radius: 9px; background: #080b0f; }
#appView.admin-session .top-actions { margin-left: auto; }
.compact-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.toggle { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.toggle input { width: auto; }
.disk-card { padding: 13px 14px; border: 1px solid var(--line); background: #11161e; border-radius: 10px; margin-top: 18px; }

.security-warning { margin: 12px 0; padding: 12px 14px; border: 1px solid #9b6b2f; border-radius: 10px; background: #2a2115; color: #ffd9a3; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.danger-zone { margin-top: 4px; padding: 15px; border: 1px solid #793b43; border-radius: 11px; background: var(--danger-soft); }
.danger-zone h3 { margin: 0; color: #ffadb4; }
.danger-zone strong { color: var(--text); user-select: all; }
.toast.error { border-color: #df5c68; }
.toast {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 99;
  max-width: 440px;
  padding: 12px 14px;
  background: rgba(29,36,48,.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}
hr { width: 100%; border: 0; border-top: 1px solid var(--line); }

* { scrollbar-width: thin; scrollbar-color: #3a4557 #0d1117; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .search-wrap { order: 3; flex: 1 0 100%; max-width: none; margin: 0; }
  .top-actions { margin-left: auto; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  body { min-width: 0; }
  button, .file-button, input, select, textarea { min-height: 44px; }
  .center-card { width: calc(100% - 20px); margin: 5vh auto; padding: 21px; }
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: max(9px, env(safe-area-inset-top)) 9px 9px;
  }
  .brand.small { grid-row: 1; justify-self: start; max-width: 100%; }
  .search-wrap { grid-row: 2; order: initial; max-width: none; margin: 0; grid-template-columns: minmax(0,1fr) auto; }
  .top-actions {
    grid-row: 3;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    margin-left: 0;
  }
  .top-actions button { min-width: 0; padding: 9px 4px; font-size: 12px; white-space: nowrap; }
  .admin-mode { grid-row: 2; justify-self: start; margin: 0; }
  #appView.admin-session .top-actions { grid-template-columns: 1fr; }
  main { padding: 9px; }
  .notice { margin: 9px auto 13px; padding: 17px; }
  .notice .row > button, .notice .row > .file-button { flex: 1 1 140px; text-align: center; }
  .gallery-toolbar { justify-content: flex-start; flex-wrap: wrap; margin-bottom: 7px; }
  .gallery { columns: 2 140px; column-gap: 7px; }
  .tile { margin-bottom: 7px; border-radius: 8px; }
  .tile:hover { transform: none; }
  .tile-info { padding: 6px 7px; font-size: 11px; }
  .gallery-footer { padding: 13px 8px 16px; }
  .status-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); text-align: center; transform: translateZ(0); }
  dialog:not(.image-dialog) {
    inset: auto 0 0 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    overscroll-behavior: contain;
  }
  .dialog-card, .dialog-card.wide, .dialog-card.extra-wide { width: 100%; max-width: none; padding: 16px 15px max(18px, env(safe-area-inset-bottom)); gap: 12px; }
  .account-dialog-card { width: 100%; }
  .account-menu { top: 54px; margin-left: -2px; margin-right: -2px; padding: 7px; gap: 6px; }
  .account-menu-button { min-height: 44px; padding: 8px 9px; font-size: 12px; }
  .account-card { padding: 13px; border-radius: 12px; }
  .dialog-sticky-header { margin: -16px -15px 0; padding: 12px 15px; top: 0; }
  .dialog-row { align-items: center; }
  .dialog-row h2 { margin: 0; font-size: 20px; }
  .grid-form, .admin-grid, .compact-form { grid-template-columns: 1fr; }
  .admin-page-heading { flex-direction: column; }
  .admin-page-heading .disk-card { width: 100%; min-width: 0; }
  .admin-card { padding: 13px; }
  .table-wrap { max-height: 55dvh; overscroll-behavior: contain; }
  table { min-width: 620px; }
  .job-card-grid { grid-template-columns: 1fr; gap: 9px; }
  .job-card { padding: 13px; gap: 10px; border-radius: 11px; }
  .job-card-head { gap: 8px; }
  .job-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 7px; }
  .job-actions button { min-height: 46px; width: 100%; font-size: 13px; }
  .job-actions .danger:last-child:nth-child(3) { grid-column: 1 / -1; }
  .job-limit-control { grid-template-columns: 1fr 86px; }
  .job-limit-control button { grid-column: 1 / -1; width: 100%; }
  .search-suggestions { max-height: 42dvh; }
  .recovery-section, .danger-zone { border-radius: 12px; }
  .account-section button[type="submit"], #exportRecovery { width: 100%; }
  .deleted-photos-heading { align-items: stretch; flex-direction: column; }
  .deleted-photo-row { align-items: stretch; flex-direction: column; }
  .deleted-photo-row button, .deleted-photos-actions button { width: 100%; }
  .deleted-photos-list { max-height: 38dvh; }
  .vault-actions { display: grid; grid-template-columns: 1fr; }
  .vault-actions > button, .vault-actions > .file-button { width: 100%; }
  .image-dialog {
    position: fixed;
    inset: auto;
    top: var(--vb-visual-top-offset);
    left: var(--vb-visual-left-offset);
    width: var(--vb-visual-width);
    max-width: var(--vb-visual-width);
    height: var(--vb-visual-height);
    max-height: var(--vb-visual-height);
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .image-layout { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .image-stage { order: 1; flex: 1 1 58%; min-height: 52dvh; }
  .tag-sidebar { order: 2; flex: 0 1 42%; max-height: 42dvh; border-right: 0; border-top: 1px solid var(--line); padding: 12px max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .dialog-floating-close { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  .image-actions { grid-template-columns: 1fr; }
  .toast { left: 8px; right: 8px; top: max(8px, env(safe-area-inset-top)); max-width: none; }
  .danger-zone { padding: 12px; }
}

@media (max-width: 390px) {
  .top-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .top-actions button { font-size: 11px; padding-inline: 3px; }
  .gallery { columns: 2 128px; }
  .job-tags { grid-template-columns: 62px minmax(0,1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* 0.2.1 hybrid post-quantum migration */
.pq-section {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid #385885;
  border-radius: 11px;
  background: linear-gradient(180deg, #142033, #111a28);
}
.pq-section h3 { margin: 0 0 4px; color: #c9dbff; }
.pq-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pq-progress { display: grid; gap: 6px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #0b1018; border: 1px solid #28364a; }
.progress-track > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #658cff, #86b0ff); transition: width .2s ease; }
#pqProtectionBadge.hybrid { color: #a9ecc9; border-color: #32664c; background: #10251b; }
#pqProtectionBadge.legacy { color: #ffd69b; border-color: #755b34; background: #251f15; }

@media (max-width: 680px) {
  .pq-section { padding: 13px; border-radius: 12px; }
  .pq-heading { flex-direction: column; gap: 8px; }
  #pqUpgradeButton { width: 100%; min-height: 48px; }
  .pq-progress { padding-top: 2px; }
}
