/* ── Variables: the uPix identity (upix-website/index.html, Flutter's
   lib/utils/brand.dart) — sky blue #8bc8f5, navy ink #10324a, white cards,
   pill buttons. Light by default; the dark variant follows the site's own
   privacy page. --brand/--ink stay the same in both: they are the brand. ── */
:root {
  color-scheme: light dark;
  --brand:     #8bc8f5;
  --ink:       #10324a;
  --bg:        #f4f7fa;
  --surface:   #ffffff;
  --surface2:  #eef3f7;
  --border:    #d5e1ea;
  --text:      #17364a;
  --text-sub:  #5b7686;
  --accent:    #10324a;   /* primary buttons, active tab */
  --accent-h:  #1d4d6e;
  --on-accent: #ffffff;
  --link:      #17618f;
  --focus:     #8bc8f5;
  --ok:        #2e7d32;
  --warn-bg:   #fff4e5;  --warn-fg: #5a3b00;  --warn-bd: #ffd8a8;
  --info-bg:   #e3f2fd;  --info-fg: #10324a;  --info-bd: #b6dcfb;
  --err:       #b3261e;
  --danger-bg: #fdecea;  --danger-bd: #f3b8b3;  --danger-h: #fbd9d5;
  --shadow:    0 10px 30px rgba(16, 50, 74, .10);
  --radius:    10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101820;
    --surface:   #17212b;
    --surface2:  #22303c;
    --border:    #2b3b48;
    --text:      #e6edf3;
    --text-sub:  #a9bcc9;
    --accent:    #8bc8f5;
    --accent-h:  #a6d5fb;
    --on-accent: #10324a;
    --link:      #7ec0f0;
    --ok:        #66bb6a;
    --warn-bg:   #3a2f0b;  --warn-fg: #f0c674;  --warn-bd: #5c4a12;
    --info-bg:   #12304a;  --info-fg: #a6d5fb;  --info-bd: #1d4d6e;
    --err:       #f28b82;
    --danger-bg: #3b1715;  --danger-bd: #7a2a25;  --danger-h: #52201c;
    --shadow:    none;
  }
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.hint { font-size: 13px; color: var(--text-sub); }
.error-msg { color: var(--err); font-size: 13px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
button { cursor: pointer; border: none; border-radius: 999px;
  font-size: 13px; font-family: inherit; transition: background .15s, color .15s; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--link); }

.btn-primary { background: var(--accent); color: var(--on-accent); padding: 8px 18px;
  font-weight: 600; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { background: var(--surface2); color: var(--text-sub); cursor: default; }

.btn-ghost { background: var(--surface); color: var(--text); padding: 7px 14px;
  border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); }

.btn-danger { background: var(--danger-bg); color: var(--err); padding: 7px 14px;
  border: 1px solid var(--danger-bd); }
.btn-danger:hover { background: var(--danger-h); }

.btn-link { background: none; color: var(--link); padding: 4px; font-size: 12px;
  text-decoration: underline; }
.btn-link:hover { color: var(--accent-h); }

/* ── Inputs ────────────────────────────────────────────────────────────────── */
input[type="text"], input[type="password"], input[type="email"] {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px;
  font-family: inherit; outline: none; width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus { border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(136, 199, 250, .35); }

/* ── Overlays (onboarding / login / viewer) ───────────────────────────────── */
.overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(8, 24, 36, .72);
  display: flex; align-items: center; justify-content: center; z-index: 100; }

.login-box { background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px 36px; text-align: center; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-sub { color: var(--text-sub); font-size: 13px; }

/* Sign-in page: the landing page itself — sky-blue ground, the logo, a
   card, the site's footer (upix-website/index.html). Always light, like
   that page: the light palette is restated here so dark mode skips it. */
.login-page { color-scheme: light;
  --surface: #ffffff; --surface2: #eef3f7; --border: #d5e1ea;
  --text: #17364a; --text-sub: #5b7686; --accent: #10324a; --accent-h: #1d4d6e;
  --on-accent: #ffffff; --link: #17618f; --err: #b3261e;
  --info-bg: #e3f2fd; --info-fg: #10324a; --info-bd: #b6dcfb; }
.login-page .login-box { color: var(--text); }
.login-page { background: var(--brand); color: var(--ink); flex-direction: column;
  padding: 32px 16px; overflow-y: auto; justify-content: flex-start;
  -webkit-overflow-scrolling: touch; }
/* Centred by auto margins, not `justify-content: center`: on a screen shorter
   than the page (a phone held sideways) the top stays reachable by scrolling
   instead of being cut off. (`safe center` does this too, but Chrome only
   understands it since 115 and drops the whole declaration before.) Margins,
   not flex `gap`, which Safari lacks before 14.1 (REQ-046). */
.login-page > :first-child { margin-top: auto; }
.login-page > :last-child { margin-bottom: auto; }
.login-page > .login-logo { margin-bottom: 24px; }
.login-page > .login-footer { margin-top: 24px; }
.login-page .login-box { border-color: transparent; box-shadow: 0 10px 30px rgba(16, 50, 74, .18); }
.login-logo { display: block; width: 44vw; max-width: 180px; height: auto; flex-shrink: 0; }
@media (max-height: 560px) { .login-logo { width: 22vh; } }
/* Sign in with your phone (REQ-030). The QR keeps its white ground (qr.js). */
.btn-qr { width: 100%; padding: 10px 14px; }
.qr-title { font-size: 17px; font-weight: 600; }
.qr-code { width: 220px; height: 220px; margin: 4px auto; border-radius: 12px;
  overflow: hidden; background: #fff; border: 1px solid var(--border); }
.qr-code svg { display: block; width: 100%; height: 100%; }
.qr-code.qr-expired { opacity: .25; }
#verify-code { text-align: center; font-size: 20px; letter-spacing: .3em; }
.login-switch { font-size: 13px; color: var(--text-sub); margin-top: 4px; }
.login-switch .btn-link { font-size: 13px; padding: 0 2px; font-weight: 600; }
.btn-link:disabled { color: var(--text-sub); text-decoration: none; cursor: default; }
.login-page .btn-primary { padding: 11px 18px; font-size: 14px; }
.login-footer { font-size: 13px; text-align: center; color: var(--ink); }
.login-footer a { color: var(--ink); }

/* ── Top nav ───────────────────────────────────────────────────────────────── */
/* The brand-blue bar in both themes, like the Flutter app's navigation
   rail: navy ink on #8bc8f5, whatever the page below does. */
#topnav { display: flex; align-items: center; gap: 16px;
  background: var(--brand); color: var(--ink);
  padding: 0 24px; height: 60px; position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 0 rgba(16, 50, 74, .15); }
.nav-logo { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.nav-tabs { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.nav-logo img { width: 52px; height: 52px; display: block; }
.nav-version { color: var(--ink); opacity: .7; font-size: 11px; }
.nav-user { color: var(--ink); font-size: 13px; flex: 1; text-align: right; }
#topnav .btn-tab { color: var(--ink); opacity: .75; }
#topnav .btn-tab { display: inline-flex; align-items: center; gap: 6px; }
.tab-icon { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
#topnav .btn-tab:hover { opacity: 1; }
#topnav .btn-tab-active { opacity: 1; border-bottom-color: var(--ink); }
#topnav .btn-primary { background: var(--ink); color: #fff; }
#topnav .btn-primary:hover { background: #1d4d6e; }
#topnav .btn-ghost { background: rgba(255, 255, 255, .55); color: var(--ink);
  border-color: rgba(16, 50, 74, .25); }
#topnav .btn-ghost:hover { background: rgba(255, 255, 255, .85); }
#topnav button:focus-visible { outline-color: var(--ink); }

/* ── Tabs (top nav Gallery/Shared switch, and the Shared sub-tabs) ───────────── */
.btn-tab { background: none; color: var(--text-sub); padding: 7px 4px;
  border-bottom: 2px solid transparent; border-radius: 0; font-weight: 600; }
.btn-tab:hover { color: var(--text); }
.btn-tab-active { color: var(--text); border-bottom-color: var(--accent); }
.tabbar { display: flex; gap: 20px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; }
.tab-panel { padding-top: 4px; }

/* ── Compat banner ─────────────────────────────────────────────────────────── */
.compat-banner { display: flex; align-items: center; justify-content: space-between;
  background: var(--warn-bg); color: var(--warn-fg); border-bottom: 1px solid var(--warn-bd);
  padding: 8px 24px; font-size: 13px; }
.compat-dismiss { background: none; color: var(--warn-fg); font-size: 18px; line-height: 1; padding: 0 6px; }

/* ── Update-available banner (design_versioning.md §7) ───────────────────────
   Deliberately blue, not the amber compat-banner above -- a
   different signal ("a newer release exists") gets a different color, not
   folded into the "may not be compatible" warning styling. */
.update-banner { display: flex; align-items: center; justify-content: space-between;
  background: var(--info-bg); color: var(--info-fg); border-bottom: 1px solid var(--info-bd);
  padding: 8px 24px; font-size: 13px; }
.update-dismiss { background: none; color: var(--info-fg); font-size: 18px; line-height: 1; padding: 0 6px; }

/* ── Upload progress ───────────────────────────────────────────────────────── */
.upload-progress { background: var(--surface2); color: var(--text-sub);
  padding: 8px 24px; font-size: 13px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; }
#upload-progress-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-offer #upload-progress-text { white-space: normal; }
.upload-stopped #upload-progress-text { white-space: normal; }
.upload-busy::before { content: ""; flex-shrink: 0; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.upload-busy #upload-progress-text { white-space: normal; }
.upload-refused-list { max-height: 50vh; overflow: auto; margin: 0; padding-left: 18px; font-size: 13px;
  word-break: break-all; }
#upload-refused-btn, #upload-cancel-btn, #upload-resume-btn, #upload-discard-btn { padding: 4px 12px; font-size: 12px; flex-shrink: 0; }
.upload-menu { left: 0; right: auto; min-width: 260px; }
.upload-warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-bd);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 0; }
.upload-prep-line { display: flex; align-items: center; gap: 14px; }
.upload-prep-line .spinner { flex-shrink: 0; }
.upload-prep-where { margin: 0; min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#gallery-view { position: relative; }
.drop-hint { position: absolute; top: 8px; right: 8px; bottom: 8px; left: 8px; z-index: 20; display: flex; align-items: center;
  justify-content: center; border: 3px dashed var(--brand); border-radius: 16px;
  background: rgba(136, 199, 250, .18); color: var(--text); font-size: 18px; font-weight: 600;
  pointer-events: none; }
.drop-hint span { background: var(--surface); padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); }

/* ── Main / gallery grid ───────────────────────────────────────────────────── */
main { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }

.gallery-grid { display: grid;
  /* --thumb-scale: the thumbnail size control (REQ-039), 1 by default. */
  grid-template-columns: repeat(auto-fill, minmax(calc(160px * var(--thumb-scale, 1)), 1fr));
  gap: 10px; }
.gallery-item { position: relative; aspect-ratio: 1 / 1; background: var(--surface2);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; border: 1px solid var(--border); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item img.thumb-error { opacity: .3; }
/* No preview (REQ-083): the words instead of an empty square; a video keeps
   its badge, which sits above this. */
.gallery-item img.thumb-none { visibility: hidden; }
.no-preview::after { content: attr(data-no-preview); position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 4px; font-size: 12px; color: var(--text-sub); pointer-events: none; }
/* Square cells without aspect-ratio (before iOS 15 / Chrome 88): the classic
   padding box, or the grid collapses to zero-height cells (REQ-046). */
@supports not (aspect-ratio: 1 / 1) {
  .gallery-item::before { content: ''; display: block; padding-top: 100%; }
  .gallery-item img { position: absolute; top: 0; left: 0; }
  .album-cover { display: block; position: relative; height: 0; padding-bottom: 100%; }
  .album-cover-cell { position: absolute; width: calc(50% - 1px); height: calc(50% - 1px); }
  .album-cover-cell:nth-child(1) { top: 0; left: 0; }
  .album-cover-cell:nth-child(2) { top: 0; right: 0; }
  .album-cover-cell:nth-child(3) { bottom: 0; left: 0; }
  .album-cover-cell:nth-child(4) { bottom: 0; right: 0; }
}
.gallery-item:hover { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

#gallery-empty { text-align: center; padding: 60px 0; }
#gallery-sentinel { height: 1px; }
#upload-btn { padding: 6px 16px; }

/* ── Thumbnail size: − slider + (REQ-039) ──────────────────────────────────── */
.thumb-size { display: inline-flex; align-items: center; gap: 6px; }
.thumb-size-btn { width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; }
.thumb-size-btn:disabled { opacity: .4; cursor: default; }
.thumb-size-range { width: 96px; accent-color: var(--accent); cursor: pointer; }

/* ── Gallery toolbar: count, All/Photos/Videos, sort (REQ-028) ─────────────── */
.gallery-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; }
.segmented { display: inline-flex; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; }
.segmented button { background: none; color: var(--text-sub); padding: 5px 14px; font-weight: 600; }
.segmented button:hover { color: var(--text); }
.segmented button.seg-active { background: var(--accent); color: var(--on-accent); }
.sort-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
  color: var(--text-sub); }
select { background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.load-more-wrap { display: flex; justify-content: center; margin-top: 20px; }

/* ── Photo viewer ──────────────────────────────────────────────────────────── */
.viewer-box { width: 100%; height: 100%; display: flex; flex-direction: column;
  background: #0b1219; }
.viewer-toolbar { display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px; }
.viewer-caption { color: var(--text-sub); font-size: 13px; }
.viewer-spacer { flex: 1; }
.viewer-image-wrap { flex: 1; min-height: 0; display: flex; align-items: center;
  justify-content: center; overflow: auto; position: relative; }
.viewer-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* Details overlaid on the media (REQ-059, the app's REQ-C-239): at the
   bottom over a photo, at the top over a video, whose controls are at the
   bottom. Never takes a click. */
.viewer-info { position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none;
  color: #f0f4f8; font-size: 12px; text-align: center; padding: 22px 12px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); }
.viewer-info:empty { display: none; }
.viewer-info.top { top: 0; bottom: auto; padding: 8px 12px 22px;
  background: linear-gradient(rgba(0, 0, 0, 0.6), transparent); }
/* The note's first two lines (REQ-072): the one part of the details that
   takes a click. -webkit-line-clamp works back to iOS 12 and Chrome 61. */
.viewer-note { pointer-events: auto; width: 100%; max-width: 720px;
  margin: 0 auto 6px; padding: 2px 6px; background: none; border: 0; color: #fff;
  font: inherit; font-size: 13px; text-align: left; white-space: pre-wrap; cursor: pointer;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.viewer-note:hover, .viewer-note:focus-visible { text-decoration: underline; }
.viewer-note.hidden { display: none; }
.note-view { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow-y: auto;
  -moz-tab-size: 4; tab-size: 4; user-select: text; }
#note-text { -moz-tab-size: 4; tab-size: 4; }
.note-count { text-align: right; }
/* Annotated cell (REQ-072, the app's badge): top left, clear of the
   video badge and the album's remove button. */
.note-badge { position: absolute; left: 5px; top: 5px; z-index: 2; pointer-events: none;
  width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .55)); }
.note-badge svg { display: block; width: 100%; height: 100%; }
/* The same colours in light and dark: a post-it is yellow either way. */
.note-badge .note-paper { fill: #ffd54f; stroke: #5d4300; stroke-width: 1.2; stroke-linejoin: round; }
.note-badge .note-fold { fill: #f2b800; stroke: #5d4300; stroke-width: 1.2; stroke-linejoin: round; }
.note-badge .note-lines { fill: none; stroke: #5d4300; stroke-width: 1.6; stroke-linecap: round; }

/* ── Item lists (shares, albums, members) ─────────────────────────────────── */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px;
  box-shadow: var(--shadow); }
.item-row-main { flex: 1; min-width: 0; }
.item-row-title { font-size: 14px; }
.item-row-sub { color: var(--text-sub); font-size: 12px; margin-top: 2px; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--text-sub); border: 1px solid var(--border); }
.role-badge-admin { color: var(--link); border-color: var(--link); }

/* ── Album detail / generic side panel overlay ────────────────────────────── */
.panel-box { background: var(--surface); border-radius: 14px; border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: 92vw; max-width: 720px; max-height: 88vh; display: flex; flex-direction: column;
  overflow-y: auto; }
.panel-toolbar { display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border); padding: 14px 20px;
  position: sticky; top: 0; z-index: 1; background: var(--surface); }
.panel-title { font-size: 16px; font-weight: 600; }
.panel-section { padding: 16px 20px; flex-shrink: 0; }
.panel-section-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; }
.panel-section-head h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-sub); font-weight: 600; }

/* ── Albums overview: covers (the app's 2×2 mosaic) or list (REQ-031) ───── */
.album-covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px 14px; }
.album-tile { cursor: pointer; min-width: 0; outline: none; }
.album-cover { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: 2px; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden;
  background: var(--surface2); border: 1px solid var(--border); transition: box-shadow .15s; }
.album-cover-cell { background: var(--border); min-width: 0; min-height: 0; }
.album-cover-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-tile:hover .album-cover, .album-tile:focus-visible .album-cover {
  box-shadow: 0 0 0 3px var(--brand); }
.album-tile-name { font-weight: 600; margin-top: 8px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.album-tile-sub { font-size: 12px; color: var(--text-sub); }
.album-row { cursor: pointer; }
.album-row:hover, .album-row:focus-visible { border-color: var(--brand); outline: none; }

/* ── One album as a page (REQ-032) ────────────────────────────────────────── */
.album-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  flex-wrap: wrap; }
.album-heading { min-width: 0; }
.album-heading h2 { font-size: 22px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
#album-back-btn { font-size: 16px; padding: 6px 14px; }
.cell-action { position: absolute; top: 6px; right: 6px; z-index: 3; padding: 3px 10px;
  font-size: 11px; opacity: 0; transition: opacity .12s; }
.gallery-item:hover .cell-action, .cell-action:focus-visible { opacity: 1; }
@media (hover: none) { .cell-action { opacity: 1; } }

/* ── Album settings panel (REQ-033) ───────────────────────────────────────── */
.album-add-member { margin-top: 12px; }
.album-roles-hint { margin-top: 10px; }
.item-row select { flex-shrink: 0; }

/* ── PixMap (REQ-045) ──────────────────────────────────────────────────────── */
/* While PixMap is shown (body.map-mode, app.js) the app is one screen-high
   column — top bar and banners, then the map filling everything left, edge
   to edge. The page itself does not scroll; the map pans. */
body.map-mode { overflow: hidden; }
body.map-mode #app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
body.map-mode #app > :not(#pixmap-view) { flex-shrink: 0; }
#pixmap-view { position: relative; flex: 1 1 auto; min-height: 0; max-width: none;
  width: 100%; margin: 0; padding: 0; }
/* z-index: 0 makes the map its own stacking context: Leaflet stacks its panes
   and controls at 400–1000, which otherwise rose above every overlay of the
   page (z-index 100) — the region gallery and the viewer opened *behind* the
   map. Contained here, the whole map sits under them. */
.pixmap-map { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 0;
  background: var(--surface2); }
.pixmap-map.pm-selecting { cursor: crosshair; }
/* Floating controls, top right, clear of Leaflet's zoom buttons (top left). */
.pixmap-controls { position: absolute; top: 10px; left: 56px; right: 10px; z-index: 1;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
  pointer-events: none; }
.pixmap-controls > * { pointer-events: auto; }
.pixmap-buttons { display: inline-flex; gap: 8px; }
.pixmap-buttons .btn-ghost { box-shadow: var(--shadow); }
.pixmap-pill, .pixmap-hint, .pixmap-empty { background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 13px;
  box-shadow: 0 2px 10px rgba(16, 50, 74, .18); }
.pixmap-pill:empty { display: none; }
.pixmap-hint { position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%);
  z-index: 1; margin: 0; white-space: nowrap; background: var(--info-bg); color: var(--info-fg); }
.pixmap-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 1; margin: 0; max-width: calc(100% - 32px); border-radius: 14px; text-align: center;
  padding: 12px 16px; }
.pm-icon { background: none; border: none; }
.pm-thumb { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: visible;
  box-shadow: 0 2px 8px rgba(16, 50, 74, .35); border: 2px solid #fff; background: #dfe9f1;
  cursor: pointer; }
.pm-tiles { width: 100%; height: 100%; border-radius: 8px; overflow: hidden; display: grid; gap: 1px;
  grid-template-columns: 1fr; grid-template-rows: 1fr; }
.pm-tiles-2 { grid-template-columns: 1fr 1fr; }
.pm-tiles-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.pm-tiles-3 img:first-child { grid-row: 1 / 3; }
.pm-tiles-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.pm-tiles img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: cover; display: block;
  background: #dfe9f1; }
.pm-thumb:hover { border-color: var(--brand); }
.pm-count { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: #10324a; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.pixmap-region-box { width: 94vw; max-width: 960px; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution a { color: var(--link); }

/* ── Anonymous statistics notice (REQ-041) ─────────────────────────────────── */
.telemetry-notice { gap: 16px; }
.notice-actions { display: inline-flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* ── Top-right menu (REQ-035): folded by default ─────────────────────────── */
.menu-wrap { position: relative; }
.menu-btn { display: inline-flex; align-items: center; gap: 8px; }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 16px; height: 2px;
  background: currentColor; border-radius: 2px; }
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ''; position: absolute; left: 0; }
.menu-icon::before { top: -5px; }
.menu-icon::after { top: 5px; }
.app-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 240px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 50, 74, .22); padding: 6px;
  display: flex; flex-direction: column; }
.app-menu [role="menuitem"] { background: none; color: var(--text); text-align: left;
  border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.app-menu [role="menuitem"]:hover, .app-menu [role="menuitem"]:focus-visible {
  background: var(--surface2); outline: none; }
.app-menu #logout-btn { color: var(--err); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ── Report / feedback / customer service, About (REQ-036, REQ-037) ─────── */
.support-box { width: 94vw; max-width: 560px; }
textarea { background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; font: inherit; font-size: 14px;
  width: 100%; resize: vertical; outline: none; }
textarea:focus, input[type="email"]:focus { border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(136, 199, 250, .35); }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px;
  color: var(--text-sub); cursor: pointer; }
.check-row input { margin-top: 3px; accent-color: var(--accent); }
.support-kinds { align-self: flex-start; flex-wrap: wrap; }
.support-done { color: var(--ok); font-weight: 600; }
.support-actions { margin-top: 4px; }
.about-box { width: 94vw; max-width: 520px; }
.about-body { text-align: center; display: flex; flex-direction: column; gap: 12px; }
.about-logo { width: 96px; height: 96px; margin: 0 auto; }
.about-subtitle { font-weight: 600; font-size: 16px; }
.about-rows { text-align: left; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border); padding: 8px 0; }
.login-notice { background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--info-bd);
  border-radius: var(--radius); padding: 8px 12px; font-size: 13px; }

/* ── Generic picker overlay ───────────────────────────────────────────────── */
.picker-box { width: 360px; max-height: 70vh; }
.picker-list { max-height: 40vh; overflow-y: auto; text-align: left; }
.picker-list .item-row { cursor: pointer; }
.picker-list .item-row { box-shadow: none; }
.picker-list .item-row:hover { border-color: var(--brand); }
.picker-photo { display: flex; align-items: center; gap: 10px; }
.picker-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px;
  background: var(--surface2); flex-shrink: 0; }

/* ── Login divider + Google button spacing ────────────────────────────────── */
.login-divider { display: flex; align-items: center; gap: 10px; color: var(--text-sub);
  font-size: 12px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1;
  height: 1px; background: var(--border); }
#login-google-wrap { display: flex; justify-content: center; }

/* ── Video badge on grid cells (gallery, trash) ───────────────────────────── */
.video-badge { position: absolute; right: 6px; bottom: 6px; z-index: 2;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 4px; pointer-events: none;
  letter-spacing: .02em; }

/* ── Video element in the viewer ───────────────────────────────────────────── */
#viewer-video { max-width: 100%; max-height: 100%; display: block; }

/* ── Trash view ────────────────────────────────────────────────────────────── */
.trash-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.trash-item { cursor: default; }
.trash-meta { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 10px;
  padding: 2px 6px; pointer-events: none; }
.trash-actions { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; background: rgba(13, 17, 23, .82); opacity: 0;
  transition: opacity .12s; }
.trash-item:hover .trash-actions { opacity: 1; }
.trash-actions .btn-ghost, .trash-actions .btn-danger { font-size: 12px; padding: 5px 12px; }

/* ── Account overlay ────────────────────────────────────────────────────────── */
.account-row { display: flex; justify-content: space-between; gap: 16px;
  padding: 4px 0; font-size: 13px; }
.account-row > span:first-child { color: var(--text-sub); }
.account-row > span:last-child { text-align: right; word-break: break-all; }
.account-form-row { display: flex; gap: 8px; align-items: center; }
.account-form-row input { flex: 1; }
.account-form-col { display: flex; flex-direction: column; gap: 8px; }
.quota-bar { height: 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 999px; margin: 8px 0 4px;
  overflow: hidden; }
.quota-fill { height: 100%; background: var(--brand); }
.quota-fill.quota-exceeded { background: var(--err); }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Phones: the top bar wraps into two rows (logo + actions, then the
   destinations) and the grid packs three-ish thumbnails per row. ─────────── */
@media (max-width: 640px) {
  #topnav { flex-wrap: wrap; height: auto; padding: 6px 16px; gap: 8px 12px; }
  .nav-logo { order: 0; }
  .nav-version { display: none; }
  .nav-user { order: 1; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #topnav .menu-wrap { order: 2; }
  .menu-btn { padding: 6px 12px; }
  .menu-label { display: none; }
  /* The destinations get a row of their own, full width, spread out — and
     scrolling sideways on the narrowest phones rather than overflowing. */
  .nav-tabs { order: 3; flex: 1 0 100%; justify-content: space-between; gap: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .btn-tab { flex-shrink: 0; padding: 6px 4px; }
  /* Icon above the label: side by side, the five tabs no longer fit (REQ-068). */
  #topnav .btn-tab { flex-direction: column; gap: 1px; font-size: 12px; line-height: 1.2; }
  .tab-icon { width: 18px; height: 18px; }
  main { padding: 16px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(calc(104px * var(--thumb-scale, 1)), 1fr));
    gap: 6px; }
  .gallery-toolbar { gap: 8px; }
  .album-covers { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 10px; }
  .thumb-size-range { width: 70px; }
  .compat-banner, .update-banner, .upload-progress { padding: 8px 16px; }
  /* The summary on its own line, the buttons under it: beside an explicit
     button label it was cut to a few words (REQ-069). */
  .upload-progress { flex-wrap: wrap; row-gap: 6px; }
  #upload-progress-text { flex-basis: 100%; white-space: normal; }
  .viewer-toolbar { flex-wrap: wrap; padding: 8px 12px; }
}

/* ── Print a photo (REQ-050) ─────────────────────────────────────────────
   The viewer's Print button puts the photo in #print-sheet, adds
   body.printing-photo and calls window.print(): on paper there is only the
   photo, centred and fitted inside a 10 mm margin, never cropped. The page
   orientation (@page size) is set from script for each photo. Without the
   class, printing the page behaves as before. */
#print-sheet { display: none; }
@media print {
  @page { margin: 10mm; }
  body.printing-photo > *:not(#print-sheet) { display: none !important; }
  body.printing-photo {
    height: auto !important; overflow: visible !important; background: #fff !important;
  }
  body.printing-photo #print-sheet {
    display: flex !important; align-items: center; justify-content: center;
    width: 100%; height: 100vh; overflow: hidden; break-inside: avoid;
  }
  body.printing-photo #print-image {
    display: block; max-width: 100%; max-height: 100%; object-fit: contain;
  }
}

/* ── Account deletion and the locked account (REQ-052) ─────────────────── */
.delete-account-box { max-width: 520px; text-align: center; }
.delete-account-sign { font-size: 56px; line-height: 1; color: var(--err); }
.delete-account-text { white-space: pre-line; text-align: left; }
.delete-account-box .check-row, .delete-account-box input[type=password] { text-align: left; margin: 8px 0; width: 100%; }
.delete-account-box .account-form-row { justify-content: center; }
.deletion-pending { position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.deletion-pending-box { max-width: 520px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.deletion-pending-left { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Shared with me: sender and menu (REQ-054) ─────────────────────────── */
.shared-item { position: relative; }
.shared-from { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px;
  font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shared-menu-btn { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px;
  border-radius: 14px; border: none; background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer; }

/* ── My uPix code (REQ-055) ─────────────────────────────────────────────── */
.account-share-qr { width: 200px; max-width: 100%; margin: 8px 0; }
.share-code-text { word-break: break-all; user-select: all; }

.upload-warn.upload-error { background: var(--danger-bg); color: var(--err); border-color: var(--danger-bd); }

/* ── PixSense (REQ-082) ─────────────────────────────────────────────────── */
.ps-conversation { max-width: 860px; margin: 0 auto; padding: 8px 12px; display: flex;
  flex-direction: column; }
.ps-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.ps-head h2 { margin: 0; font-size: 1.2rem; }
.ps-credit { font-size: 0.72rem; }
.ps-list { overflow-y: auto; max-height: calc(100vh - 220px); padding: 8px 0; display: flex;
  flex-direction: column; }
.ps-bubble { max-width: 85%; padding: 8px 12px; margin: 4px 0; border-radius: 14px;
  line-height: 1.4; overflow-wrap: anywhere; }
.ps-left { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 2px; }
.ps-right { align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 2px; }
.ps-error { background: #fde8e8; color: #8a1c1c; }
.ps-understood { font-weight: 600; }
.ps-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.ps-chip { border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 16px; padding: 4px 12px; cursor: pointer; font-size: 0.9rem; }
.ps-chip:hover:not(:disabled) { border-color: var(--accent); }
.ps-chip:disabled { opacity: 0.5; cursor: default; }
.ps-filter::after { content: " \00d7"; color: var(--text-sub); }
.ps-strip { display: flex; gap: 4px; overflow-x: auto; margin-top: 8px; }
.ps-thumb { flex: 0 0 72px; width: 72px; height: 72px; padding: 0; border: 0; border-radius: 6px;
  overflow: hidden; background: var(--border); cursor: pointer; }
.ps-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ps-see-all { margin-top: 6px; }
.ps-spinner { display: inline-block; width: 18px; height: 18px; }
.ps-form { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.ps-form input { flex: 1 1 auto; min-width: 0; }
.ps-open { display: inline-flex; align-items: center; gap: 6px; }
.ps-icon { width: 18px; height: 18px; fill: currentColor; }
.ps-result { padding: 8px 12px; }
.ps-result-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.ps-result-title { font-weight: 600; }
@media (max-width: 600px) { .ps-open span { display: none; } }
