/* fixer gallery theme. Colours and type from the fixer gallery brand kit v1.1: Safelight red belongs
   to the logo (and the favourite heart); everything else is ink, paper and neutrals. */
@font-face { font-family: "Fraunces"; src: url("/assets/fonts/Fraunces-Variable.woff2") format("woff2-variations"), url("/assets/fonts/Fraunces-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/Inter-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/Inter-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/Inter-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --red: #C8412E; --red-press: #A8351F; --safelight: #C8412E;
  --logo-gallery: #6F655B; --logo-tile-line: transparent;
  --bg: #F4F0E8; --page: #FAF7F1; --surface: #FFFFFF; --surface2: #EFE9DE;
  --border: #E2D9CA; --border2: #D3C8B6; --hair: #ECE5D9;
  --ink: #1A1715; --ink2: #3D3631; --muted: #6B635B;
  --link: #A8351F; --acc-soft: #E6DED1; --acc-ink: #1A1715;
  --primary: #1A1715; --primary-press: #3D3631; --on-primary: #F4F0E8;
  --ok-bg: #E2ECDD; --ok-fg: #2F5D2A; --warn-bg: #FDF3DC; --warn-fg: #7A4F00; --bad-bg: #F6DED8; --bad-fg: #8E2A18;
  --chip: #E8E0D2; --hover: #EDE6DA; --focus: #A8351F;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #141210; --page: #100E0D; --surface: #1F1B18; --surface2: #27221E;
  --border: #332C27; --border2: #443B34; --hair: #2A2420;
  --ink: #F4F0E8; --ink2: #D9D0C4; --muted: #B5ACA2;
  --link: #F08A76; --acc-soft: #312A25; --acc-ink: #F4F0E8;
  --primary: #F4F0E8; --primary-press: #FFFFFF; --on-primary: #1A1715;
  --ok-bg: #1E2B1C; --ok-fg: #A6D69A; --warn-bg: #3A2E12; --warn-fg: #F2C66B; --bad-bg: #3D1C19; --bad-fg: #F4A196;
  --chip: #332C27; --hover: #2A2420; --focus: #F08A76;
  --logo-gallery: #A39789; --logo-tile-line: #3A332D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
form { margin: 0; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, .display { font-family: Fraunces, Georgia, serif; font-weight: 700; font-variation-settings: "SOFT" 50; letter-spacing: -0.01em; line-height: 1.1; margin: 0; }
h1 { font-size: 36px; } h2 { font-size: 21px; letter-spacing: -0.005em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }

/* Logo */
.logo { display: inline-flex; align-items: center; color: var(--ink); line-height: 0; }
.logo svg { display: block; flex: none; }
.logo .mark-sym { display: none; }
.logo-tile { stroke: var(--logo-tile-line); stroke-width: 2; }

/* App shell */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 220px; max-width: 250px; min-width: 210px; background: var(--surface); border-right: 1px solid var(--border); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; }
.side .brand { padding: 0 8px; text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--ink2); text-decoration: none; font-size: 14px; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--acc-soft); color: var(--acc-ink); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: var(--muted); padding: 0 8px; }
.main { flex: 999 1 560px; min-width: 0; padding: clamp(22px, 2.2vw, 40px) clamp(18px, 2.6vw, 56px) 56px; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 700px) { .side { max-width: none; border-right: 0; border-bottom: 1px solid var(--border); } .main { padding: 22px 18px 40px; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--border2); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-press); border-color: var(--primary-press); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.danger { color: var(--bad-fg); border-color: var(--bad-fg); background: transparent; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; padding: 0; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink2); }
.input, select.input, textarea.input { height: 42px; padding: 0 12px; border: 1px solid var(--border2); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; width: 100%; }
textarea.input { height: auto; padding: 10px 12px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Cards, labels, tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.pad { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat .n { font-family: Fraunces, Georgia, serif; font-weight: 700; font-variation-settings: "SOFT" 50; font-size: 36px; line-height: 1; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.p-live { background: var(--ok-bg); color: var(--ok-fg); } .p-draft { background: var(--chip); color: var(--ink2); } .p-archived { background: var(--warn-bg); color: var(--warn-fg); }
.p-bad { background: var(--bad-bg); color: var(--bad-fg); }
.table-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--hair); font-size: 14px; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl a.row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.tbl a.row-link:hover { text-decoration: underline; }
.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.notice { padding: 12px 16px; border-radius: 10px; font-size: 14px; }
.notice.ok { background: var(--ok-bg); color: var(--ok-fg); } .notice.bad { background: var(--bad-bg); color: var(--bad-fg); } .notice.warn { background: var(--warn-bg); color: var(--warn-fg); }

/* Gallery editor */
.editor { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.editor .photos { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.editor .settings { flex: 0 1 380px; min-width: 300px; display: flex; flex-direction: column; gap: 24px; }
.drop { border: 2px dashed var(--border2); border-radius: 12px; padding: 26px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--page); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--primary); background: var(--acc-soft); }
.queue { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.queue .item { display: flex; gap: 10px; align-items: center; }
.queue .bar { flex: 1; height: 6px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.queue .bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.queue .name { width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(130px, 11vw, 240px), 1fr)); gap: clamp(8px, .6vw, 12px); }
.tile { position: relative; aspect-ratio: 1; background: var(--surface2); border-radius: 8px; overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .meta { position: absolute; inset: auto 0 0 0; padding: 22px 8px 6px; background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; font-size: 11px; display: flex; gap: 6px; align-items: flex-end; opacity: 0; transition: opacity .15s; }
.tile:hover .meta, .tile:focus-within .meta { opacity: 1; }
.tile .meta .fn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .meta button { border: 0; border-radius: 4px; background: rgba(255,255,255,.92); color: #1A1715; font: inherit; font-size: 11px; padding: 3px 7px; cursor: pointer; }
.tile .badge { position: absolute; top: 8px; left: 8px; }

.locked { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.locked .card { max-width: 560px; }

/* Folder tree in the sidebar */
/* Library tree: see "Sidebar" at the end. */

/* Library cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(180px, 14vw, 300px), 1fr)); gap: clamp(12px, 1vw, 20px); }
.item-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; color: var(--ink); text-decoration: none; }
.item-card:hover { border-color: var(--border2); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.item-card .cover { position: relative; aspect-ratio: 4 / 3; background: var(--surface2); display: block; }
.item-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-card .cover-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.item-card .kind { position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 5px; background: rgba(20,18,16,.62); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.item-card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.item-card .body strong { font-size: 14px; }

/* Popover forms */
details.pop { position: relative; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 300px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }

.copy-row { display: flex; gap: 8px; align-items: stretch; }
.tile .marks { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.tile .marks span { background: rgba(20,18,16,.7); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.activity-row { display: flex; gap: 14px; font-size: 14px; border-bottom: 1px solid var(--hair); padding: 7px 0; }
.activity-row:last-child { border-bottom: 0; }
.tbl td.wrap { white-space: normal; min-width: 160px; }
h3.sub { font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0 8px; text-transform: none; font-family: Inter, sans-serif; }
.mark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.mark-grid figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mark-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--surface2); display: block; }
.mark-grid figcaption { font-size: 11px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mark-grid .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.mark-grid .note { color: var(--ink2); font-style: italic; }
.agreement-text p { margin: 0; line-height: 1.6; }
[hidden] { display: none !important; }
.queue:empty { display: none; }

/* Account menu at the foot of the sidebar */
details.account { margin-top: auto; position: relative; }
details.account > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
details.account > summary::-webkit-details-marker { display: none; }
details.account > summary:hover, details.account[open] > summary { background: var(--hover); border-color: var(--border); }
.account-text { display: flex; flex-direction: column; min-width: 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.account-text b { color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-caret { margin-left: auto; color: var(--muted); flex-shrink: 0; transition: transform .15s; }
details.account:not([open]) .account-caret { transform: rotate(180deg); }
.account-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; z-index: 30; }
.account-menu a, .account-menu button { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 6px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; text-decoration: none; text-align: left; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: var(--hover); }
.account-menu a[aria-current="page"] { color: var(--acc-ink); font-weight: 600; }
.account-menu .sign-out { color: var(--bad-fg); border-top: 1px solid var(--hair); border-radius: 0 0 6px 6px; margin-top: 4px; }
.studio-initial { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 19px; flex-shrink: 0; }
.studio-badge { width: 34px; height: 34px; border-radius: 8px; background: var(--surface2); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; padding: 3px; }
.studio-badge img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Studio profile: logo slots */
.logo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.logo-slot { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.logo-preview { width: 100%; height: 120px; border-radius: 10px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; padding: 20px; }
.logo-preview.light { background: #F4F0E8; }
.logo-preview.dark { background: #141210; border-color: #332C27; }
.logo-preview.dark .muted { color: #B5ACA2; }
.logo-preview img { max-width: 100%; max-height: 72px; object-fit: contain; }
.logo-upload { display: flex; gap: 8px; width: 100%; flex-wrap: wrap; }
.input.file { flex: 1; min-width: 0; height: 42px; padding: 5px 6px; font-size: 13px; line-height: 30px; }
.input.file::file-selector-button { height: 30px; margin: 0 10px 0 0; padding: 0 12px; border: 1px solid var(--border2); border-radius: 4px; background: var(--surface2); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; vertical-align: top; }

/* Full-screen photo viewer, shared by the admin and client galleries */
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
/* Viewer */
.lb { position: fixed; inset: 0; z-index: 50; background: #0d0c0b; color: #f4f0e8; display: flex; flex-direction: column; }
.lb[hidden] { display: none; }
.lb-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; font-size: 13px; color: #b5aca2; }
.lb-top .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-top .lb-count { margin-left: auto; white-space: nowrap; }
.lb-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; touch-action: none; overflow: hidden; cursor: zoom-in; }
.lb-stage.zoomed { cursor: grab; }
.lb-stage.zoomed:active { cursor: grabbing; }
.lb-stage img { transform-origin: center; will-change: transform; touch-action: none; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 99px; border: 0; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
@media (max-width: 600px) { .lb-nav { display: none; } }
.lb-bottom { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; padding: 12px 14px 16px; }
.lb-btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 99px; border: 1px solid rgba(255,255,255,.22); background: transparent; color: #f4f0e8; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
.lb-btn:hover { background: rgba(255,255,255,.08); }
.lb-btn[aria-pressed="true"].lb-fav { background: #fff; color: var(--red); border-color: #fff; }
.lb-btn[aria-pressed="true"].lb-fav .i { fill: currentColor; }
.lb-btn[aria-pressed="true"].lb-pick { background: #F4F0E8; color: #1A1715; border-color: #F4F0E8; }
.lb-close { width: 40px; height: 40px; padding: 0; justify-content: center; }
.lb-note { flex-basis: 100%; display: flex; justify-content: center; }
.lb-note[hidden] { display: none; }
.lb-note input { width: min(520px, 100%); height: 40px; border-radius: 99px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); color: #fff; padding: 0 16px; font: inherit; font-size: 14px; }
.lb-note input::placeholder { color: #8d847b; }

.lb-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-btn[aria-pressed="true"] { background: #f4f0e8; color: #1A1715; border-color: #f4f0e8; }
.lb-danger { color: #F4A196; border-color: rgba(244,161,150,.4); }
.lb-danger:hover { background: rgba(244,161,150,.12); }

/* Admin photo grid: viewing and selecting */
.photo-bar { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; min-height: 52px; padding: 8px 12px; margin: -8px 0; background: var(--bg); border-radius: 10px; }
.photo-bar.selecting { background: var(--surface); border: 1px solid var(--border2); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.photo-bar .pb-idle, .photo-bar .pb-selecting { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; }
.photo-bar .pb-selecting, .photo-bar.selecting .pb-idle { display: none; }
.photo-bar.selecting .pb-selecting { display: flex; }
.photo-bar .pb-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.photo-bar form { display: contents; }
.tile-open { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.tile-open:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.grid.selecting .tile-open { cursor: pointer; }
.tile-check { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 99px; border: 2px solid #fff; background: rgba(20,18,16,.35); color: transparent; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; opacity: 0; transition: opacity .12s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.tile-check svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tile:hover .tile-check, .tile:focus-within .tile-check, .grid.selecting .tile-check { opacity: 1; }
@media (hover: none) { .tile-check { opacity: 1; } }
.tile.selected { outline: 3px solid var(--primary); outline-offset: -3px; }
.tile.selected .tile-check { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tile.selected img { opacity: .82; }
.tile .badge { left: 42px; top: 10px; }
.tile .meta { pointer-events: none; }
.tile { margin: 0; }

/* The sidebar stays in view while the page scrolls (wide screens). */
@media (min-width: 701px) {
  .shell { flex-wrap: nowrap; }
  .side { position: sticky; top: 0; height: 100vh; align-self: flex-start; }
  /* Only the navigation scrolls; the logo stays at the top and the account menu at the bottom. */
  .side .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
  .side .tree-wrap { max-height: none; overflow: visible; }
  details.account { flex-shrink: 0; margin-top: 0; }
}

/* Admin dialogs */
dialog.dialog { border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: min(520px, calc(100% - 32px)); background: var(--surface); color: var(--ink); }
dialog.dialog::backdrop { background: rgba(0,0,0,.5); }
dialog.dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog.dialog p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Wide screens: the side column of the gallery and folder pages stays put while photos scroll. */
@media (min-width: 1200px) {
  .editor { flex-wrap: nowrap; }
  .editor .photos { flex: 1 1 auto; }
}
/* Pages made of forms (settings, studio, agreements) read best at a measured width. */
.main > form.card, .main > section.card[style*="max-width"] { width: 100%; }

/* Phones: the sidebar becomes a compact bar across the top. */
@media (max-width: 700px) {
  .shell { flex-direction: column; flex-wrap: nowrap; }
  .side { flex: none; min-width: 0; max-width: none; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; position: sticky; top: 0; z-index: 25; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .brand { padding: 0; }
  .side .brand .wordmark { display: none; }
  .side .nav { order: 3; flex: 1 0 100%; flex-direction: row; gap: 4px; overflow-x: auto; }
  .side .nav a { padding: 7px 12px; white-space: nowrap; }
  .side .tree-wrap { display: none; }
  details.account { margin: 0 0 0 auto; }
  details.account > summary { padding: 4px; }
  .account-text, .account-caret { display: none; }
  .account-menu { left: auto; right: 0; bottom: auto; top: calc(100% + 6px); width: 220px; }
  .main { padding: 18px 14px 40px; }
  .editor .settings { min-width: 0; flex: 1 1 100%; }
  .page-head .actions { margin-left: 0; }
  .photo-bar { top: 104px; }
}
/* Medium screens: settings sit below the photos, spread across the width. */
@media (max-width: 1199px) {
  .editor { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .editor .photos { flex: none; }
  .editor .settings { flex: none; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
}

/* Dropdowns: our own arrow, inset by the same 12 px as the text, in both themes. */
:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233D3631' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
[data-theme="dark"] { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23D9D0C4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
select.input { appearance: none; -webkit-appearance: none; padding: 0 40px 0 12px; background-image: var(--chevron); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; text-overflow: ellipsis; }
select.input::-ms-expand { display: none; }
/* Buttons beside a field match its height. */
.copy-row .btn, .logo-upload .btn { height: 42px; }
.logo-slot > .muted { min-height: 3em; }

/* One top line: the sidebar logo and the first thing on every page start at the same height,
   and the account menu sits as far from the bottom as the logo sits from the top. */
:root { --edge: 32px; }
@media (min-width: 701px) {
  .side { padding: calc(var(--edge) + 3px) 14px; gap: 24px; }
  .main { padding-top: var(--edge); }
  .side .brand { display: block; line-height: 0; }
}

/* Library views */
.view-list { display: none; }
[data-view="list"] .view-grid { display: none; }
[data-view="list"] .view-list { display: block; }
.seg { display: inline-flex; border: 1px solid var(--border2); border-radius: 6px; overflow: hidden; height: 42px; }
.seg button { width: 42px; border: 0; background: var(--surface); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border2); }
.seg button[aria-pressed="true"] { background: var(--acc-soft); color: var(--acc-ink); }
.tbl .thumb-col { width: 56px; padding-right: 0; }
.list-thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--surface2); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); }
.list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.list-name svg { color: var(--muted); flex-shrink: 0; }
.tbl th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button:hover { color: var(--ink); }
.tbl th button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tbl th button[data-dir="asc"]::after { content: "▲"; font-size: 9px; }
.tbl th button[data-dir="desc"]::after { content: "▼"; font-size: 9px; }

/* Folder cover */
.cover-preview { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--surface2); display: flex; align-items: center; justify-content: center; text-align: center; padding: 0; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
dialog.cover-picker { width: min(880px, calc(100% - 32px)); }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 56vh; overflow-y: auto; min-height: 120px; font-size: 14px; color: var(--muted); }
.cover-pick { padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; aspect-ratio: 1; cursor: pointer; background: var(--surface2); }
.cover-pick:hover, .cover-pick:focus-visible { border-color: var(--primary); outline: none; }
.cover-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Phones and tablets: 16 px text in fields, so iPhone and iPad don't zoom the page when a
   field is tapped (they do for anything smaller), and the layout stays put. */
@media (max-width: 900px), (pointer: coarse) {
  .input, select.input, textarea.input, .lb-note input, input, select, textarea { font-size: 16px; }
}

/* Navigation icons */
.nav a .nav-icon, .account-menu .nav-icon { flex-shrink: 0; opacity: .8; }
.nav a[aria-current="page"] .nav-icon, .nav a:hover .nav-icon, .account-menu a:hover .nav-icon { opacity: 1; }
.nav > a { gap: 12px; }
@media (max-width: 700px) { .nav a .nav-icon { width: 18px; height: 18px; } }

/* File name token list */
details.tokens > summary { cursor: pointer; width: fit-content; }
details.tokens ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 2px; }
details.tokens p { margin: 6px 0 0; }

/* ---------- Sidebar: resizable, collapsible to icons, and a roomier library tree ---------- */
:root { --side-w: 272px; --side-collapsed: 76px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 0 10px; }
.side .brand-row .brand { padding: 0; }
.side-toggle { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.side-toggle:hover { background: var(--hover); color: var(--ink); }
.side-toggle:focus-visible, .side-resize:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.side-toggle-arrow { transition: transform .18s; transform-origin: 14.5px 12px; }
.side-resize { display: none; }

/* Top-level links */
.nav { gap: 4px; }
.nav > a { gap: 12px; padding: 10px 12px; font-size: 15px; min-height: 44px; }
.nav > a > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The tree. Every row has the same columns: a caret slot, a 16 px icon, the name. */
.tree-wrap { margin: 2px 0 10px 12px; }
ul.tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
ul.tree ul.tree { margin: 2px 0 0 10px; padding-left: 8px; border-left: 1px solid var(--hair); }
ul.tree li { margin: 0; }
ul.tree details > summary { list-style: none; display: flex; align-items: center; cursor: pointer; border-radius: 8px; }
ul.tree details > summary::-webkit-details-marker { display: none; }
ul.tree .leaf { display: flex; align-items: center; padding-left: 20px; }
.tree-caret { flex: none; width: 20px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.tree-caret::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-left: -2px; }
ul.tree details[open] > summary > .tree-caret::before { transform: rotate(45deg); margin: -3px 0 0 0; }
ul.tree details > summary:hover .tree-caret { color: var(--ink); }
ul.tree a { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 10px 6px 8px; border-radius: 8px; color: var(--ink2); text-decoration: none; font-size: 14px; line-height: 1.3; min-width: 0; }
ul.tree a svg { flex: none; width: 16px; height: 16px; opacity: .8; }
ul.tree a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
ul.tree a:hover { background: var(--hover); color: var(--ink); }
ul.tree a:hover svg, ul.tree a[aria-current="page"] svg { opacity: 1; }
ul.tree a[aria-current="page"] { background: var(--acc-soft); color: var(--acc-ink); font-weight: 600; }

@media (min-width: 701px) {
  .side { flex: none; width: var(--side-w); min-width: 0; max-width: none; position: sticky; padding-left: 16px; padding-right: 16px; transition: width .18s ease; }
  .resizing .side, .resizing .side * { transition: none !important; }
  .resizing, .resizing * { cursor: col-resize !important; user-select: none !important; }
  .side-resize { display: block; position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 5; }
  .side-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
  .side-resize:hover::after, .resizing .side-resize::after { background: var(--primary); }

  /* Collapsed: icons only, names as tooltips. */
  [data-nav="collapsed"] .side { width: var(--side-collapsed); padding-left: 12px; padding-right: 12px; }
  [data-nav="collapsed"] .brand-row { flex-direction: column; gap: 14px; padding: 0; }
  [data-nav="collapsed"] .side .wordmark { display: none; }
  [data-nav="collapsed"] .side-toggle-arrow { transform: scaleX(-1); }
  [data-nav="collapsed"] .nav > a { justify-content: center; padding: 10px 0; }
  [data-nav="collapsed"] .nav > a > span, [data-nav="collapsed"] .tree-wrap { display: none; }
  [data-nav="collapsed"] details.account > summary { justify-content: center; padding: 6px 0; }
  [data-nav="collapsed"] .account-text, [data-nav="collapsed"] .account-caret { display: none; }
  [data-nav="collapsed"] .account-menu { right: auto; width: 230px; }
  [data-nav="collapsed"] .nav > a[data-tip] { position: relative; }
  [data-nav="collapsed"] .nav > a[data-tip]:hover::after, [data-nav="collapsed"] .nav > a[data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; padding: 5px 9px; border-radius: 6px; white-space: nowrap; z-index: 40; pointer-events: none;
  }
  [data-nav="collapsed"] .side .nav { overflow: visible; }
}
@media (max-width: 700px) { .side-toggle { display: none; } }

/* Toolbar under the breadcrumbs: actions for the page, above its title. */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; padding: 10px; min-width: 0; }
.toolbar > * { flex: none; }
/* Every control in the toolbar is the same height. */
.toolbar .btn, .toolbar .seg { height: 40px; }
.toolbar .seg button { width: 40px; }
.toolbar .btn { gap: 8px; }
.toolbar .tb-icon { flex: none; }
.toolbar > form { margin: 0; }
.toolbar .toolbar-end { margin-left: auto; display: flex; gap: 10px; }
.toolbar .pop-body { left: 0; right: auto; }
.toolbar label.btn { cursor: pointer; }

/* One line, always: when the toolbar itself gets narrow (a phone, or a tablet with the sidebar
   open) labels get shorter, then secondary buttons become icons. */
.toolbar { container: toolbar / inline-size; position: relative; }
.toolbar .narrow-only { display: none; }
@container toolbar (max-width: 640px) {
  .toolbar .wide-only, .toolbar .tb-label { display: none; }
  .toolbar .narrow-only { display: inline; }
  .toolbar .btn:has(.tb-label) { width: 40px; padding: 0; }
}
@container toolbar (max-width: 420px) {
  .toolbar .btn { padding: 0 12px; }
  /* The New folder form opens under the whole toolbar instead of under its button. */
  .toolbar details.pop { position: static; }
  .toolbar .pop-body { left: 8px; right: 8px; width: auto; }
}
@media (max-width: 560px) { .toolbar { gap: 8px; padding: 8px; } }

/* Gallery photos as a list: tick, thumbnail, name, dimensions, size. */
.tile .meta .dim, .tile .meta .sz { display: none; }
[data-view="list"] .grid { grid-template-columns: 1fr; gap: 6px; }
[data-view="list"] .tile { aspect-ratio: auto; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 116px; background: var(--surface); border: 1px solid var(--border); }
[data-view="list"] .tile-open { position: absolute; inset: 0; width: auto; height: auto; z-index: 1; border-radius: 8px; }
[data-view="list"] .tile-open img { position: absolute; left: 50px; top: 6px; width: 52px; height: 50px; border-radius: 6px; }
[data-view="list"] .tile-check { opacity: 1; top: 50%; left: 14px; transform: translateY(-50%); z-index: 2; border-color: var(--border2); background: transparent; box-shadow: none; }
[data-view="list"] .tile.selected .tile-check { background: var(--primary); border-color: var(--primary); }
[data-view="list"] .tile.selected { outline-width: 2px; outline-offset: -2px; }
[data-view="list"] .tile .meta { position: static; order: 1; flex: 1 1 auto; min-width: 0; opacity: 1; background: none; padding: 0; color: var(--ink); font-size: 14px; gap: 16px; align-items: center; }
[data-view="list"] .tile .meta .dim, [data-view="list"] .tile .meta .sz { display: inline; flex: none; color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
[data-view="list"] .tile .meta .dim { width: 110px; }
[data-view="list"] .tile .meta .sz { width: 72px; }
[data-view="list"] .tile .marks, [data-view="list"] .tile .badge { position: static; order: 2; flex: none; }
[data-view="list"] .tile:hover { background: var(--hover); }
@media (max-width: 560px) { [data-view="list"] .tile .meta .dim { display: none; } }

/* Foldable side cards. The heading is a full-width button: title left, chevron right, inside the
   card's own padding, so a folded card has the same space above and below its title. */
.card.foldable { gap: 0; }
.card.foldable > h2 { margin: 0; }
.card-fold { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: calc(100% + 16px); margin: -6px -8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; line-height: inherit; }
.card-fold:hover { background: var(--hover); }
.card-fold:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.card-chevron { flex: none; color: var(--muted); transition: transform .18s ease; }
.card-fold:hover .card-chevron { color: var(--ink); }
.card.folded .card-chevron { transform: rotate(-90deg); }
.card-body { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; }
.card-body[hidden] { display: none; }


/* One control height everywhere in the admin: every button, toggle and single-line field is
   40 px. Small buttons only use smaller text and padding. */
:root { --control-h: 40px; }
.btn, .btn.sm, .seg, .icon-btn, .copy-row .btn, .logo-upload .btn, .toolbar .btn, .toolbar .seg, .lb-btn { height: var(--control-h); }
.btn.sm { padding: 0 14px; }
.seg button, .toolbar .seg button { width: var(--control-h); }
input.input, select.input, .input.file { height: var(--control-h); }
.input.file { line-height: 28px; padding: 5px 6px; }
.input.file::file-selector-button { height: 28px; }

/* Secondary buttons get their own fill and a firmer edge, so they read as the same full-height
   shape as a filled primary button, on cards and on the page. */
:root, [data-theme="light"] { --btn-bg: #F6F2EA; --btn-border: #CDBFAA; --btn-hover: #EDE6DA; }
[data-theme="dark"] { --btn-bg: #2B2622; --btn-border: #4E443C; --btn-hover: #352E29; }
.btn:not(.primary):not(.danger) { background: var(--btn-bg); border-color: var(--btn-border); }
.btn:not(.primary):not(.danger):hover { background: var(--btn-hover); }
.seg { border-color: var(--btn-border); }
.seg button { background: var(--btn-bg); }
.seg button + button { border-left-color: var(--btn-border); }
.seg button[aria-pressed="true"] { background: var(--acc-soft); }

/* ---------- Phones and narrow windows: a top bar with a menu button; the sidebar slides in. ---------- */
.topbar, .menu-backdrop, .menu-close { display: none; }
@media (max-width: 700px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar .brand { display: inline-flex; line-height: 0; text-decoration: none; }
  .menu-btn, .menu-close { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; flex: none; }
  .menu-btn:hover, .menu-close:hover { background: var(--hover); }
  .menu-btn:focus-visible, .menu-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }

  /* The sidebar, as a drawer: same contents as on a computer. */
  .side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(320px, 86vw); height: 100vh; height: 100dvh; max-width: none; min-width: 0;
          display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 20px; padding: 16px 14px 18px;
          border-right: 1px solid var(--border); border-bottom: 0; overflow: hidden; transform: translateX(-102%); transition: transform .22s ease; visibility: hidden; }
  [data-menu="open"] .side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .side .brand-row { padding: 0 0 0 8px; }
  .side .brand .wordmark { display: block; }
  .menu-close { display: inline-flex; color: var(--muted); }
  .side .nav { order: 0; flex: 1 1 auto; min-height: 0; flex-direction: column; flex-wrap: nowrap; gap: 4px; overflow-y: auto; overflow-x: hidden; margin: 0 -6px; padding: 0 6px; }
  .side .nav > a { padding: 10px 12px; white-space: nowrap; flex: none; justify-content: flex-start; }
  .side .nav > a > span { position: static; width: auto; height: auto; clip: auto; }
  .side .tree-wrap { display: block; }
  details.account { margin: 0; flex-shrink: 0; }
  details.account > summary { padding: 8px; }
  .account-text { display: flex; }
  .account-caret { display: block; }
  .account-menu { left: 0; right: 0; top: auto; bottom: calc(100% + 6px); width: auto; }

  .menu-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .22s; }
  [data-menu="open"] .menu-backdrop { opacity: 1; pointer-events: auto; }
  [data-menu="open"] body { overflow: hidden; }
  .main { padding: 18px 14px 40px; }
  .photo-bar { top: 56px; }
}
@media (max-width: 700px) and (prefers-reduced-motion: reduce) { .side, .menu-backdrop { transition: none; } }

/* Collapsed sidebar: the icon alone, with its even bath. */
@media (min-width: 701px) {
  [data-nav="collapsed"] .side .logo .mark-arc { display: none; }
  [data-nav="collapsed"] .side .logo .mark-sym { display: block; }
}

/* Sidebar logo: as large as the sidebar allows (44 px tall at the default width), smaller when the
   sidebar is dragged narrower, and the even-bath icon alone when it's collapsed.
   327.83 is the name's width in logo units, where the icon is 120; the gap is 30 (src/shared/brand.tsx). */
.side .brand .logo { --lh: min(44px, calc((var(--side-w) - 84px) / 4.0)); gap: calc(var(--lh) * 30 / 120) !important; }
.side .brand .logo .mark { width: var(--lh); height: var(--lh); }
.side .brand .logo .wordmark { height: var(--lh); width: calc(var(--lh) * 327.83 / 120); }
@media (min-width: 701px) { [data-nav="collapsed"] .side .brand .logo { --lh: 40px; } }
@media (max-width: 700px) { .side .brand .logo { --lh: 40px; } }

/* Delete buttons: always outlined, with a bin icon, so they never read as the brand red. */
.btn.danger svg, .lb-danger svg { flex: none; }
