:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #5f6672;
  --line: #e3e6ea;
  --card: #f6f8fa;
  --accent: #2f6fde;
  --accent-fg: #ffffff;
  --danger: #c62828;
  --ok: #2e7d32;
  --tile: #eceff3;
  --topbar-h: 56px;
  --bottombar-h: 0px;
  --tile-min: 150px; /* thumbnail size; pinch / ctrl+wheel changes it */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --fg: #e6e8eb;
    --muted: #9aa3ad;
    --line: #2a2f35;
    --card: #1b1f24;
    --accent: #7aa7ff;
    --accent-fg: #0b1220;
    --danger: #ff6b6b;
    --ok: #66bb6a;
    --tile: #1e2228;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { min-height: 100vh; }
a { color: var(--accent); }
button, input { font: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; }
[hidden] { display: none !important; }

/* ---- top bar / navigation ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--fg); text-decoration: none; font-weight: 700; letter-spacing: .08em;
}
/* All buttons sit together on the right; Search looks like the others. */
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav { display: flex; gap: 4px; }
.nav a, .search-link {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover, .search-link:hover { background: var(--card); }
.nav a.active, .search-link.active { color: var(--accent); background: var(--card); }

@media (max-width: 640px) {
  :root { --bottombar-h: 60px; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    justify-content: space-around; background: var(--bg); border-top: 1px solid var(--line);
  }
  /* Six buttons share a phone's width evenly; long labels shorten. */
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; border-radius: 12px; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a.active { background: none; }
}

main { padding: 8px 16px calc(24px + var(--bottombar-h)); outline: none; }
.banner { background: #8a6d00; color: #fff; padding: 8px 16px; text-align: center; }

/* ---- states ---- */
.state { color: var(--muted); text-align: center; padding: 64px 16px; }
.state h2 { color: var(--fg); margin: 0 0 8px; font-weight: 600; }
.error { color: var(--danger); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-weight: 500; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- timeline ---- */
.day { margin: 18px 0 8px; font-size: 15px; font-weight: 600; }
.grid {
  display: grid; gap: 3px;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
}
@media (max-width: 640px) { :root { --tile-min: 96px; } .grid { gap: 2px; } }
.tile { position: relative; aspect-ratio: 1; background: var(--tile); overflow: hidden; }
.tile-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer; background: none; color: inherit; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.tile:hover img { transform: scale(1.03); }
.tile-open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile .badge, .tile .fav, .tile .days { pointer-events: none; }
.tile .days {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px;
}
.tile .badge {
  position: absolute; right: 6px; top: 6px; display: flex; align-items: center; gap: 2px;
  padding: 1px 6px 1px 2px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px;
}
.tile .badge svg { width: 18px; height: 18px; }
.placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .05em; gap: 4px;
}
.placeholder svg { width: 32px; height: 32px; opacity: .6; }
.sentinel { height: 1px; }
.loading-more { text-align: center; color: var(--muted); padding: 16px; }

/* ---- viewer ---- */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  display: grid; grid-template-columns: auto 1fr auto auto; grid-template-rows: auto 1fr;
}
.viewer-bar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: linear-gradient(rgba(0,0,0,.6), transparent);
}
.viewer-bar button, .viewer-bar a, .viewer-nav {
  background: none; border: 0; color: #fff; cursor: pointer; padding: 8px; border-radius: 50%; display: flex;
}
.viewer-bar button:hover, .viewer-bar a:hover, .viewer-nav:hover { background: rgba(255,255,255,.12); }
.viewer-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; opacity: .85; }
.viewer-nav { align-self: center; margin: 0 4px; }
.viewer-nav:disabled { visibility: hidden; }
.viewer-stage { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; touch-action: none; overflow: hidden; }
.viewer-stage img { cursor: zoom-in; user-select: none; -webkit-user-drag: none; }
.viewer-stage.zoomed img { cursor: grab; }
.viewer-stage.panning img { cursor: grabbing; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: calc(100vh - 64px); object-fit: contain; }
.viewer-stage .placeholder, .viewer-stage .note { color: #bbb; text-align: center; padding: 24px; }
.viewer-info {
  width: 320px; max-width: 85vw; overflow-y: auto; background: var(--bg); color: var(--fg);
  padding: 16px 20px; border-left: 1px solid var(--line);
}
.viewer-info h3 { margin: 4px 0 16px; font-size: 18px; }
.viewer-info dl { margin: 0; }
.viewer-info dt { color: var(--muted); font-size: 12px; margin-top: 14px; text-transform: uppercase; letter-spacing: .05em; }
.viewer-info dd { margin: 2px 0 0; word-break: break-word; }
.section-move { margin-top: 6px; padding: 5px 12px; font-size: 13px; }
.mode-choice { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
/* Each choice is a box you can tap anywhere; the chosen one is outlined. */
.mode-choice label {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.mode-choice label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-choice input { margin-top: 3px; accent-color: var(--accent); }
.mode-choice .muted.small { line-height: 1.4; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--card); color: var(--muted); margin-left: 6px; }
@media (max-width: 640px) {
  .viewer { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .viewer-nav { display: none; }
  .viewer-info { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: 55vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
}

/* ---- settings / setup ---- */
.page { max-width: 880px; margin: 0 auto; }
.page h1 { font-size: 24px; margin: 16px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 16px 0; }
.card h2 { font-size: 17px; margin: 0 0 12px; }
.card p { margin: 8px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 4px; }
.field { display: flex; flex-wrap: wrap; gap: 10px; }
.field input[type=text] {
  flex: 1; min-width: 220px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-all; }
th { color: var(--muted); font-weight: 500; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--danger); border-color: var(--danger); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.review-item { border-top: 1px solid var(--line); padding: 10px 0; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.review-item:first-of-type { border-top: 0; }

/* ---- search ---- */
@media (max-width: 900px) { .nav a span, .search-link span { display: none; } }
@media (max-width: 640px) { .nav a span, .search-link span { display: inline; } }
/* Search takes over the top bar (the bottom bar stays on phones). */
body.searching .topbar .brand, body.searching .search-link, body.searching .signout-btn { display: none; }
@media (min-width: 641px) { body.searching .topnav { display: none; } }
.topsearch {
  flex: 1; display: flex; align-items: center; gap: 6px; max-width: 760px; margin: 0 auto;
  height: 42px; padding: 0 4px 0 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
}
.topsearch:focus-within { border-color: transparent; }
.topsearch-icon { display: flex; color: var(--muted); }
.topsearch input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--fg); font-size: 16px; padding: 8px 4px;
}
.topsearch input::-webkit-search-cancel-button { display: none; }
.topsearch-close {
  display: flex; padding: 7px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
}
.topsearch-close:hover { background: var(--line); color: var(--fg); }
.topsearch-close:focus-visible { outline: 2px solid var(--accent); }
@media (max-width: 640px) { .topbar { gap: 12px; } }

/* ---- toolbar & selection ---- */
.toolbar {
  position: sticky; top: var(--topbar-h); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 0; background: var(--bg);
}
.toolbar .grow { flex: 1; }
.toolbar h1 { margin: 0; font-size: 22px; }
.tile.selected img, .tile.selected .placeholder { transform: scale(.86); border-radius: 6px; }
/* The tick starts selection. It appears on hover (always, faintly, on touch
   screens) and stays visible on every tile while selecting. */
.tile .check {
  position: absolute; left: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid #fff; background: rgba(0,0,0,.3); box-shadow: 0 0 3px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .15s;
}
.tile:hover .check, .tile .check:focus-visible, .selecting .tile .check { opacity: 1; }
.tile .check:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
@media (hover: none) { .tile .check { opacity: .8; } }
.tile.selected .check { background: var(--accent); border-color: var(--accent); }
.tile.selected .check::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tile .fav { position: absolute; left: 6px; bottom: 6px; color: #fff; filter: drop-shadow(0 0 2px rgba(0,0,0,.7)); display: flex; }
.tile .fav svg { width: 18px; height: 18px; }

/* ---- viewer favourite ---- */
[data-act=fav] .fav-solid { display: none; }
[data-act=fav][aria-pressed=true] .fav-solid { display: inline; fill: #ff5a6e; }
[data-act=fav][aria-pressed=true] .fav-outline { display: none; }

/* ---- albums ---- */
.albums { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 12px; }
.album-card { display: block; color: var(--fg); text-decoration: none; }
.album-card .cover { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--tile); }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-card .name { font-weight: 600; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-card .count { color: var(--muted); font-size: 13px; }
.album-desc { color: var(--muted); margin: 0 0 8px; white-space: pre-wrap; }

/* ---- dialog & toast ---- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--fg); padding: 0; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.5); }
.picker { padding: 18px 20px; }
.picker h2 { margin: 0 0 12px; font-size: 18px; }
.picker-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.picker-list button {
  text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer;
}
.picker-list button:hover { border-color: var(--accent); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--bottombar-h)); z-index: 60;
  background: #323232; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* ---- upload ---- */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + var(--bottombar-h) + env(safe-area-inset-bottom)); z-index: 20;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 12px 20px 12px 16px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-fg); font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.fab:hover { filter: brightness(1.08); }
.fab:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }
.upload-panel {
  position: fixed; right: 20px; bottom: calc(84px + var(--bottombar-h) + env(safe-area-inset-bottom)); z-index: 20;
  width: min(360px, calc(100vw - 32px)); max-height: 50vh; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.upload-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line); }
.upload-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 50%; display: flex; }
.upload-close:hover { background: var(--card); }
.upload-close:disabled { visibility: hidden; }
.upload-list { list-style: none; margin: 0; padding: 4px 16px 10px; overflow-y: auto; font-size: 13px; }
.upload-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.upload-list li:last-child { border-bottom: 0; }
.upload-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .progress { margin: 6px 0 2px; height: 4px; }
@media (max-width: 640px) {
  .fab { right: 16px; bottom: calc(16px + var(--bottombar-h) + env(safe-area-inset-bottom)); }
  .upload-panel { right: 16px; bottom: calc(76px + var(--bottombar-h) + env(safe-area-inset-bottom)); }
}

/* ---- sign-in & devices ---- */
body.signed-out .nav, body.signed-out .search-link { display: none !important; }
.page.narrow { max-width: 460px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-form input, .field input[type=password] {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 15px;
}
.field input[type=password] { flex: 1; min-width: 160px; }
.auth-form .btn { align-self: flex-start; }
code { font-family: ui-monospace, monospace; font-size: .92em; }

/* ---- AI assistant ---- */
.review-item .grow { flex: 1; min-width: 0; }
.ai-box:empty { display: none; }
.ai-box { margin-top: 8px; }
.ai-proposal { border-left: 3px solid var(--accent); padding: 6px 10px; margin: 6px 0; background: var(--bg); border-radius: 0 8px 8px 0; }
.ai-proposal ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.payload { max-height: 260px; overflow: auto; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; white-space: pre-wrap; word-break: break-all; }
.share-list { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 8px; }
#app input[aria-label="Model override"], #app select[aria-label="AI provider"] { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }

/* ---- tags ---- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-link {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px;
  background: var(--card); border: 1px solid var(--line); color: var(--fg); text-decoration: none;
}
.tag-link:hover { border-color: var(--accent); color: var(--accent); }

/* ---- album wizard ---- */
dialog.wizard { width: min(520px, 92vw); }
.wizard-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.wizard-body h2 { margin: 0; font-size: 18px; }
.wizard-body > input[type=text] {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 15px;
}
.wizard-body .field input[type=text] { flex: 1; min-width: 160px; }
.wizard-option {
  display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font: inherit;
}
.wizard-option:hover { border-color: var(--accent); }
.wizard-option.chosen { border: 2px solid var(--accent); padding: 11px 13px; }
.wizard-suggest { max-height: 140px; overflow-y: auto; }
.wizard-match select { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.wizard-actions { margin-top: 6px; justify-content: flex-end; }
/* ---- reset wizard ---- */
.wizard-steps { display: flex; align-items: center; gap: 6px; }
.wizard-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.wizard-dot.past { background: var(--muted); }
.wizard-dot.on { background: var(--danger); width: 22px; border-radius: 4px; }
.wizard-steps .muted { margin-left: 6px; }
.reset-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reset-lists ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.reset-lists > div { padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.reset-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.reset-check input { margin-top: 3px; }
.reset-wizard input[type=text] { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
@media (max-width: 520px) { .reset-lists { grid-template-columns: 1fr; } }
.tag-link.chosen { border-color: var(--accent); color: var(--accent); cursor: pointer; }
button.tag-link { font: inherit; font-size: 13px; cursor: pointer; }
.album-rule { color: var(--accent); margin-top: 2px; }

/* ---- roles ---- */
/* Admin accounts hold no photos: only the Admin page. */
body.role-admin .nav a:not([data-view=settings]), body.role-admin .search-link { display: none; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 0; }
.row.tight { margin: 0; gap: 6px; flex-wrap: nowrap; }
.card h3.small { margin: 16px 0 6px; }

/* ---- built-in albums ---- */
.album-card .cover { position: relative; }
.album-badge {
  position: absolute; left: 8px; top: 8px; display: flex; padding: 5px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
}
.album-badge svg { width: 18px; height: 18px; }
.album-card.system .name { color: var(--accent); }
.back-link { display: inline-block; margin-top: 6px; text-decoration: none; }

/* The admin's Sign out button in the top bar (looks like the nav buttons). */
.signout-btn {
  display: none; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; margin-left: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg); font: inherit; font-weight: 500; cursor: pointer;
}
.signout-btn:hover { border-color: var(--danger); color: var(--danger); }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head .grow { flex: 1; }
.page-head h1 { margin: 16px 0; }
body.role-admin .signout-btn { display: flex; }
body.signed-out .signout-btn { display: none !important; }

/* ---- context menu ---- */
.menu {
  position: fixed; z-index: 70; min-width: 200px; padding: 6px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
}
.menu-item {
  display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 12px 8px 6px; border: 0; border-radius: 8px;
  background: none; color: var(--fg); font: inherit; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--card); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-check { width: 16px; text-align: center; color: var(--accent); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---- album cards: options button, bin icon ---- */
.album-cell { position: relative; }
.card-more {
  position: absolute; right: 8px; top: 8px; display: flex; padding: 4px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.card-more svg { width: 20px; height: 20px; }
.album-cell:hover .card-more, .card-more:focus-visible { opacity: 1; }
@media (hover: none) { .card-more { opacity: .9; } }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); cursor: pointer; }
.icon-btn.primary:hover { filter: brightness(1.08); color: var(--accent-fg); }
.icon-btn.primary svg { width: 26px; height: 26px; }
.icon-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-count {
  position: absolute; top: -4px; right: -6px; min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.btn svg { width: 18px; height: 18px; }

/* ---- date scrubber (right edge of the timelines) ---- */
.scrubber {
  position: fixed; right: 0; z-index: 15; width: 40px;
  top: calc(var(--topbar-h) + 64px); bottom: calc(88px + var(--bottombar-h) + env(safe-area-inset-bottom));
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: ns-resize; outline: none;
}
.scrub-years { position: absolute; inset: 0; pointer-events: none; }
.scrub-year {
  position: absolute; right: 10px; transform: translateY(-50%);
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap;
  color: var(--muted); background: var(--bg); box-shadow: 0 0 0 1px var(--line);
  opacity: 0; transition: opacity .2s;
}
.scrub-mark { position: absolute; left: 0; right: 0; height: 0; pointer-events: none; }
.scrub-handle {
  position: absolute; right: 4px; top: -20px; width: 8px; height: 40px; border-radius: 4px;
  background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.3); opacity: 0; transition: opacity .2s, width .15s;
}
/* While dragging: a line across the edge with the date beside it. */
.scrub-line { position: absolute; right: 0; left: -24px; top: -1px; height: 2px; background: var(--accent); display: none; }
.scrub-bubble {
  position: absolute; right: calc(100% + 28px); top: 0; transform: translateY(-50%);
  padding: 8px 14px; border-radius: 999px; white-space: nowrap; font-weight: 600; font-size: 14px;
  background: var(--fg); color: var(--bg); box-shadow: 0 4px 14px rgba(0,0,0,.3); display: none;
}
.scrubber.active .scrub-year, .scrubber:hover .scrub-year, .scrubber:focus-visible .scrub-year,
.scrubber.active .scrub-handle, .scrubber:hover .scrub-handle, .scrubber:focus-visible .scrub-handle { opacity: 1; }
.scrubber.dragging .scrub-handle, .scrubber:hover .scrub-handle { width: 12px; }
.scrubber.dragging .scrub-line, .scrubber.dragging .scrub-bubble { display: block; }
.scrubber:focus-visible .scrub-handle { outline: 2px solid var(--fg); outline-offset: 2px; }
@media (hover: none) { .scrubber { width: 36px; } }

/* ---- drag and drop upload ---- */
.drop-zone {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 60, 140, .35); backdrop-filter: blur(2px); pointer-events: none;
  outline: 4px dashed var(--accent); outline-offset: -16px;
}
.drop-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 40px; border-radius: 18px;
  background: var(--bg); color: var(--fg); box-shadow: 0 10px 40px rgba(0,0,0,.35); font-size: 18px;
}
.drop-card svg { width: 44px; height: 44px; color: var(--accent); }

/* ---- search before typing: albums row, then recent ---- */
.search-heading { margin: 16px 0 8px; font-size: 17px; }
.toolbar .search-heading { margin: 0; }
.search-albums { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.album-card.mini { flex: 0 0 132px; min-width: 0; }
.album-card.mini .cover { border-radius: 10px; }
.album-card.mini .name { margin-top: 6px; font-size: 14px; }
.album-card.mini .count { font-size: 12px; }

/* ---- change password pop-up ---- */
.pw-field { display: flex; flex-direction: column; gap: 4px; }
.pw-field input { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
.pw-field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---- phones: Settings / Admin ---- */
body[data-view=settings] .fab, body[data-view=settings] .upload-panel:empty { display: none; }
@media (max-width: 640px) {
  main { padding-left: 12px; padding-right: 12px; }
  .page h1, .page-head h1 { font-size: 22px; margin: 12px 0; }
  .page-head .btn { padding: 6px 14px; }
  .card { padding: 14px; margin: 12px 0; border-radius: 12px; }
  .card h2 { font-size: 16px; margin-bottom: 8px; }
  .card p, .card li { font-size: 14px; }
  .card .row { margin-top: 10px; }
  .kv { gap: 4px 12px; font-size: 14px; }
  .field input[type=text], .field input[type=password] { flex: 1 1 100%; min-width: 0; }
  .section-title { margin-top: 20px; font-size: 13px; }
  .mode-choice label { padding: 9px 10px; }
}

/* ---- phones: albums as a compact grid, three across ---- */
@media (max-width: 640px) {
  .albums { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 8px; margin-top: 8px; }
  .album-card .cover { border-radius: 10px; }
  .album-card .name { font-size: 13px; margin-top: 5px; }
  .album-card .count { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .album-card .placeholder { font-size: 10px; }
  .album-card .placeholder svg { width: 22px; height: 22px; }
  .album-badge { left: 5px; top: 5px; padding: 3px; }
  .album-badge svg { width: 14px; height: 14px; }
  .card-more { right: 4px; top: 4px; padding: 2px; }
  .card-more svg { width: 18px; height: 18px; }
}
