/* Mantel - graphite pro-tool theme. Photos are the only colour on screen;
   chrome is hairlines, small radii and one quiet accent. */
:root {
  --bg: #0b0b0d;
  --bg-2: #0f0f12;
  --panel: #141418;
  --panel-2: #1a1a1f;
  --line: #222228;
  --line-2: #2c2c34;
  --text: #ececef;
  --text-2: #b4b4bc;
  --muted: #7c7c86;
  --accent: #ff6f55;          /* Mantel coral, from the logo */
  --accent-2: #e0508a;
  --danger: #f0716a;
  --tile: #17171b;
  --r: 6px;
  --r-lg: 10px;
  --tile-size: 168px;
  --row-h: 190px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 12px 40px rgba(0, 0, 0, .55);
  --mono: Inter, system-ui, sans-serif;   /* numbers use tabular figures, not a mono face */
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

button {
  font: inherit; font-weight: 500; color: var(--text-2); background: var(--panel);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
button:hover { color: var(--text); border-color: #3a3a44; background: var(--panel-2); }
button:active { transform: translateY(.5px); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--text); border-color: var(--text); color: #0b0b0d; }
button.primary:hover { background: #fff; border-color: #fff; color: #000; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.icon-btn { padding: 6px; background: transparent; border-color: transparent; color: var(--text-2); }
.icon-btn:hover { background: rgba(255, 255, 255, .06); border-color: transparent; }

input[type=password], input[type=email], input[type=text], input[type=search] {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 8px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd {
  font: 500 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 4px; padding: 3px 5px; background: var(--panel);
}

/* ---------- login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(255, 111, 85, .10), transparent 60%),
    var(--bg);
}
.login form {
  width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 30px 28px 24px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.login .mark { width: 34px; height: 34px; margin-bottom: 6px; }
.login h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.login p.sub { margin: -6px 0 6px; color: var(--muted); }
.login button.primary { justify-content: center; padding: 9px; }
.login .err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 12.5px; }

/* brand mark: a stack of three photos */
.mark {
  display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 4px; position: relative;
  background: linear-gradient(135deg, #8fb0ff, #5b7ff0);
  box-shadow: 3px -3px 0 -1px #2a2f45, 6px -6px 0 -2px #1d2030;
}

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.side {
  border-right: 1px solid var(--line); padding: 14px 10px 10px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px; background: var(--bg-2);
}
.brand {
  display: flex; align-items: center; gap: 11px; font-weight: 600; font-size: 14.5px;
  letter-spacing: -.01em; padding: 8px 10px 18px;
}
.side h3 {
  font-size: 11.5px; font-weight: 500; color: var(--muted);
  margin: 18px 10px 6px;
}
.nav {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 6px 10px; border-radius: var(--r); color: var(--text-2); font-weight: 450;
}
.nav > span:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav > span:first-child .ic { color: var(--muted); }
.nav .n { font: 400 11.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.nav:hover { background: rgba(255, 255, 255, .04); color: var(--text); border: 0; }
.nav.on { background: rgba(255, 255, 255, .07); color: var(--text); }
.nav.on > span:first-child .ic { color: var(--accent); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.nav.out { margin-top: 2px; color: var(--muted); }
.side .grow { flex: 1; min-height: 16px; }
.usage { font: 400 11px var(--mono); color: var(--muted); padding: 10px; }
.usage .bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.usage .bar i { display: block; height: 100%; background: var(--text-2); border-radius: 2px; }

.main { overflow-y: auto; position: relative; scroll-behavior: auto; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 10px 22px; min-height: 56px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top h2 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.top .count { font: 400 12px var(--mono); color: var(--muted); margin-left: 10px; }
.menu-btn { display: none; }

.searchwrap { position: relative; display: flex; align-items: center; width: clamp(170px, 24vw, 300px); }
.top h2 { min-width: 120px; }
@media (max-width: 980px) { .zoom { display: none; } }
.searchwrap .ic { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.searchwrap input { padding-left: 32px; padding-right: 30px; height: 32px; }
.searchwrap kbd { position: absolute; right: 8px; pointer-events: none; }
.searchwrap input:focus ~ kbd, .searchwrap input:not(:placeholder-shown) ~ kbd { display: none; }
input[type=search]::-webkit-search-cancel-button { filter: invert(.6); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); padding: 2px; background: var(--bg-2); }
.seg button { border: 0; background: transparent; padding: 4px 6px; color: var(--muted); border-radius: 4px; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }

.zoom { width: 84px; accent-color: var(--text-2); }
input[type=range].zoom { -webkit-appearance: none; appearance: none; height: 16px; background: transparent; }
.zoom::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line-2); }
.zoom::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--text-2); border: 0; }
.zoom::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-2); }
.zoom::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); border: 0; }

/* ---------- grid ---------- */
.content { padding: 4px 22px 80px; }
.month {
  position: sticky; top: var(--top-h, 56px); z-index: 3; display: flex; align-items: baseline; gap: 10px;
  margin: 0 -22px; padding: 18px 22px 10px; font-size: 13px; font-weight: 600; letter-spacing: -.005em;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.month span { font: 400 11px var(--mono); color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr)); gap: 3px; }

.tile {
  position: relative; aspect-ratio: 1; background: var(--tile); border-radius: 3px;
  overflow: hidden; cursor: pointer; border: 0; padding: 0; display: block; color: inherit;
}
.tile:hover { background: var(--tile); }
.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transform: scale(1.015);
  transition: opacity .45s var(--ease), transform .6s var(--ease), filter .25s;
}
.tile img.in { opacity: 1; transform: none; }
.tile::before {      /* bottom shade, shown on hover so captions read on any photo */
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: linear-gradient(transparent 55%, rgba(0, 0, 0, .65));
  transition: opacity .25s;
}
.tile:hover::before { opacity: 1; }
.tile .cap {
  position: absolute; left: 9px; right: 9px; bottom: 7px; z-index: 2; color: #fff; text-align: left;
  font-size: 11.5px; line-height: 1.3; opacity: 0; transform: translateY(4px);
  transition: opacity .25s, transform .25s var(--ease);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile:hover .cap { opacity: 1; transform: none; }
.tile .ext {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 500; color: var(--muted);
}
.tile .badge {
  position: absolute; right: 7px; top: 7px; z-index: 2; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile .badge .ic { width: 12px; height: 12px; }
.tile .fav { position: absolute; left: 7px; top: 7px; z-index: 2; color: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6)); }
.tile .fav .ic { width: 14px; height: 14px; fill: #fff; }
.tile .why {
  position: absolute; left: 7px; top: 7px; z-index: 2; background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1; padding: 4px 7px; border-radius: 4px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.tile.sel img { transform: scale(.9); border-radius: 3px; }
.tile .tick {
  position: absolute; right: 7px; bottom: 7px; z-index: 2; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .8); background: rgba(0, 0, 0, .25); display: grid; place-items: center; color: transparent;
  transition: background .15s, border-color .15s;
}
.tile .tick .ic { width: 12px; height: 12px; stroke-width: 2.4; }
.tile.sel .tick { background: var(--accent); border-color: var(--accent); color: #fff; }

/* natural (justified) layout: each tile grows in proportion to its aspect ratio */
.grid.natural { display: flex; flex-wrap: wrap; gap: 3px; }
.grid.natural .tile { aspect-ratio: auto; height: var(--row-h); flex-grow: var(--ar); flex-basis: calc(var(--ar) * var(--row-h)); max-width: calc(var(--ar) * var(--row-h) * 1.6); }
.grid.natural::after { content: ''; flex-grow: 9999; }

.empty {
  margin: 80px auto; max-width: 440px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: 14px; padding: 46px 28px; line-height: 1.6;
}
.empty .ic { width: 30px; height: 30px; stroke-width: 1.3; color: var(--text-2); margin-bottom: 12px; }
.empty strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty b { color: var(--text-2); font-weight: 500; }

/* ---------- drop overlay ---------- */
.drop {
  position: fixed; inset: 0; z-index: 50; display: none; place-items: center; pointer-events: none;
  background: rgba(8, 8, 10, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.drop::before { content: ''; position: absolute; inset: 14px; border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 18px; }
.drop.on { display: grid; animation: fade .15s; }
.drop div { display: grid; justify-items: center; gap: 6px; }
.drop .ic { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.4; margin-bottom: 6px; }
.drop b { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.drop span { color: var(--muted); }
@keyframes fade { from { opacity: 0; } }

/* ---------- upload panel ---------- */
.up {
  position: fixed; right: 18px; bottom: 18px; z-index: 40; width: min(340px, calc(100% - 32px));
  background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 12px 14px 12px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: none;
}
.up.on { display: block; animation: rise .25s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.up .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.up .head b { font-weight: 600; font-size: 13px; }
.up .bar { height: 3px; background: var(--line); border-radius: 2px; margin: 10px 0 8px; overflow: hidden; }
.up .bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .25s; }
.up .stats { font: 400 11px/1.5 var(--mono); color: var(--muted); }
.up ul { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; max-height: 140px; overflow-y: auto; }
.up li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--text-2); }
.up li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up li span:last-child { font-family: var(--mono); color: var(--muted); }
.up li.fail span:last-child { color: var(--danger); }

/* ---------- photo viewer: see viewer.css ---------- */

/* ---------- AI panel ---------- */
.ai {
  margin: 8px 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 111, 85, .06), transparent 70%), var(--panel);
  font-size: 12px; color: var(--muted); display: grid; gap: 9px;
}
.ai[hidden] { display: none; }
.ai .hd { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 12.5px; }
.ai .hd .ic { color: var(--accent); }
.ai button { justify-content: center; font-size: 12px; padding: 6px 10px; }
.ai .meta { font: 400 10.5px/1.5 var(--mono); }
.ai .err { color: var(--danger); }
.ai .prog { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ai .prog i { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- cleanup selection bar ---------- */
.selbar {
  position: sticky; top: var(--top-h, 56px); z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 22px; background: color-mix(in srgb, var(--bg-2) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.selbar[hidden] { display: none; }
.selbar .grow { flex: 1; color: var(--muted); font-size: 12.5px; }
.selbar:not([hidden]) ~ .content .month { top: calc(var(--top-h, 56px) + var(--sel-h, 53px)); }

/* ---------- suggestions ---------- */
.sugs { display: grid; gap: 14px; max-width: 920px; margin-top: 18px; }
.sug {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px;
  transition: border-color .2s;
}
.sug:hover { border-color: var(--line-2); }
.sug .t { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; }
.sug .t .ic { color: var(--accent); }
.sug .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.sug .meta .m { font-family: var(--mono); font-size: 11px; }
.sug .strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; border-radius: 6px; overflow: hidden; }
.sug .strip img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--tile); display: block; }
.sug .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sug input { flex: 1; min-width: 160px; width: auto; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30;
    transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow);
  }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; margin-left: -6px; }
  .top { flex-wrap: wrap; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .searchwrap { width: 100%; order: 5; }
  .searchwrap kbd { display: none; }
  .content { padding: 0 2px 80px; }
  .month { margin: 0 -2px; padding: 16px 14px 8px; }
  .selbar { padding: 8px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 2px; }
  .grid.natural .tile { height: 120px; flex-basis: calc(var(--ar) * 120px); max-width: none; }
  .tile { border-radius: 0; }
  .tile .cap { display: none; }
  .top .hide-sm { display: none; }
  .sugs { padding: 0 12px; }
  .sug .strip { grid-template-columns: repeat(4, 1fr); }
  .sug .strip img:nth-child(n+5) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* version label (sidebar footer, login card) */
.ver { font: 400 10.5px var(--mono); color: var(--muted); opacity: .7; padding: 0 10px 4px; margin: 0; }
.login .ver { padding: 0; text-align: center; }

/* ---------- Albums page ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px 16px; padding-top: 20px; }
.album-grid .acard { grid-template-rows: auto auto; }

/* ---------- phone tab bar (mobile first: the main nav lives under the thumb) ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr);
    align-items: center; height: calc(62px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 86%, transparent); border-top: 1px solid var(--line);
    backdrop-filter: saturate(150%) blur(18px); -webkit-backdrop-filter: saturate(150%) blur(18px);
  }
  .tabbar button {
    position: relative; flex-direction: column; justify-content: center; gap: 3px; height: 54px; padding: 0;
    border: 0; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 500; border-radius: 12px;
  }
  .tabbar button .ic { width: 22px; height: 22px; }
  .tabbar button.on { color: var(--text); }
  .tabbar button.on .ic { stroke-width: 2; }
  .tabbar button:hover { background: transparent; }
  .tabbar .add { justify-self: center; width: 48px; height: 48px; border-radius: 50%; background: var(--text); color: var(--bg); }
  .tabbar .add:hover { background: var(--text); color: var(--bg); }
  .tabbar .add .ic { width: 22px; height: 22px; stroke-width: 2.2; }
  .tabbar .tdot { position: absolute; top: 8px; left: calc(50% + 8px); width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
  .tabbar .tdot[hidden] { display: none; }

  /* room for the tab bar; uploads float above it */
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .up { bottom: calc(74px + env(safe-area-inset-bottom)); }
  #pickFolder { display: none; }               /* Add lives in the tab bar */
  .top { min-height: 52px; }
  .top h2 { font-size: 20px; letter-spacing: -.02em; }
  .icon-btn { padding: 9px; }                  /* 36px+ tap targets */
  .icon-btn .ic { width: 18px; height: 18px; }
  .album-grid { grid-template-columns: repeat(2, 1fr); gap: 18px 10px; padding: 16px 8px 0; }
  .selbar button { padding: 9px 12px; }
}

/* ---------- upload activity feed ---------- */
.up { width: min(380px, calc(100% - 32px)); padding: 14px 14px 10px; }
.up .head b { font-size: 13.5px; }
.up.busy .bar i { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #fff), var(--accent)); background-size: 200% 100%; animation: upflow 1.6s linear infinite; }
@keyframes upflow { to { background-position: -200% 0; } }
.up .stats { font-size: 12px; line-height: 1.5; color: var(--muted); }
.up .stats .link { font: inherit; color: var(--text); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.up ul { margin: 10px -4px 0; max-height: 280px; overflow-y: auto; display: grid; gap: 2px; }
.up li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; transition: background .3s, opacity .3s; }
.up li.new { animation: rise .25s var(--ease); }
.up li.st-analysing, .up li.st-uploading { background: rgba(127, 127, 127, .07); }
.up .uth { width: 40px; height: 40px; border-radius: 6px; overflow: hidden; background: var(--tile); display: grid; place-items: center; color: var(--muted); }
.up .uth img { width: 100%; height: 100%; object-fit: cover; display: block; }
.up .ut { min-width: 0; display: grid; gap: 2px; }
.up .ut b { font-weight: 500; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .ut small { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.up li.st-analysing small::after { content: ""; width: 14px; height: 6px; background: radial-gradient(circle, currentColor 1.4px, transparent 1.6px) 0 50% / 5px 6px repeat-x; animation: dots 1s steps(3) infinite; }
@keyframes dots { from { width: 0; } to { width: 15px; } }
.up .seen { color: var(--text); font-weight: 500; }
.up .utags { display: inline-flex; gap: 6px; }
.up .utags i { font-style: normal; color: var(--muted); }
.up .flag { flex-basis: 100%; color: #e0a54a; }
.up li.st-failed small { color: var(--danger); }
.up li.st-exists, .up li.st-resaved, .up li.st-queued { opacity: .65; }

/* ---------- top bar: title | search | View, Add photos ---------- */
.top {
  display: grid; grid-template-columns: auto minmax(160px, 1fr) auto; align-items: center; gap: 18px;
  min-height: 64px; padding: 10px 24px;
}
.top .menu-btn { display: none; }
.top h2 { font-size: 20px; font-weight: 650; letter-spacing: -.02em; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.top .count {
  margin: 0; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500;
  color: var(--text-2); background: rgba(127, 127, 127, .14);
}
.searchwrap { width: 100%; max-width: 560px; justify-self: center; }
.searchwrap input { height: 40px; font-size: 14px; background: var(--panel); border-color: var(--line-2); border-radius: 10px; padding-left: 38px; }
.searchwrap .ic { left: 13px; width: 17px; height: 17px; color: var(--text-2); }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.tb-btn { height: 40px; padding: 0 15px 0 13px; gap: 8px; font-size: 13.5px; font-weight: 550; border-radius: 10px; color: var(--text); border-color: var(--line-2); }
.tb-btn .ic { width: 17px; height: 17px; }
.tb-btn[aria-expanded="true"] { background: var(--panel-2); border-color: var(--muted); }

.pop { position: relative; }
.popmenu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 250px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow);
  animation: rise .18s var(--ease);
}
.popmenu[hidden] { display: none; }
.viewmenu { width: 300px; }
.pm-sec { padding: 8px 8px 10px; }
.pm-sec + .pm-sec { border-top: 1px solid var(--line); }
.pm-h { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.seg.wide { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.seg.wide button { justify-content: center; gap: 7px; padding: 7px 10px; font-size: 13px; }
.viewmenu .zoom { width: 100%; display: block; }
.stylesec { padding: 4px 0 0; }
.stylesec .stylemenu { position: static; width: auto; padding: 0; border: 0; box-shadow: none; background: transparent; animation: none; }
.addmenu { width: 270px; display: grid; gap: 2px; }
.addmenu > button { justify-content: flex-start; gap: 12px; padding: 10px 12px; border: 0; background: transparent; text-align: left; border-radius: 8px; }
.addmenu > button:hover { background: rgba(127, 127, 127, .1); }
.addmenu > button .ic { width: 20px; height: 20px; color: var(--text-2); }
.addmenu b { display: block; font-weight: 600; font-size: 13.5px; color: var(--text); }
.addmenu small { color: var(--muted); font-size: 12px; }
.pm-note { margin: 4px 12px 6px; font-size: 12px; color: var(--muted); }

/* narrower windows: icons only, search keeps the room */
@media (max-width: 1100px) {
  .tb-btn span { display: none; }
  .tb-btn { width: 40px; padding: 0; justify-content: center; }
  .top { gap: 12px; padding: 10px 18px; }
}
/* phones: title row with View, search full width below; Add lives in the tab bar */
@media (max-width: 760px) {
  .top { grid-template-columns: auto 1fr auto; grid-template-areas: "menu title actions" "search search search"; row-gap: 8px; padding: 8px 14px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .top .menu-btn { display: inline-flex; grid-area: menu; }
  .top h2 { grid-area: title; font-size: 22px; }
  .tb-actions { grid-area: actions; }
  .searchwrap { grid-area: search; max-width: none; }
  .add-pop { display: none; }
  .popmenu { position: fixed; left: 12px; right: 12px; top: calc(var(--top-h, 107px) + 6px); width: auto; max-height: calc(100vh - var(--top-h, 107px) - 90px); overflow-y: auto; }
}
:root[data-frame="phone"] .top { padding-top: 40px; }

/* ---------- People ---------- */
.pp { max-width: 1100px; padding-top: 18px; display: grid; gap: 30px; }
.pp-h { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.pp-sub { margin: -6px 0 14px; color: var(--muted); font-size: 13px; }
.pp-intro { border: 1px solid var(--line-2); border-radius: 14px; padding: 22px 24px; background: var(--panel); display: grid; gap: 10px; justify-items: start; max-width: 620px; }
.pp-intro h3 { margin: 0; font-size: 17px; }
.pp-intro p { margin: 0; color: var(--text-2); line-height: 1.55; }
.pp-intro small { color: var(--muted); }
.pp-status { display: grid; gap: 8px; max-width: 520px; color: var(--text-2); font-size: 13px; }
.pp-status.err { color: var(--danger); }
.pp-status .prog { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.pp-status .prog i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.pp-status .link, .pp-stack .link { font: inherit; background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.pp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.face { display: block; width: 56px; height: 56px; border-radius: 50%; background-color: var(--tile); background-repeat: no-repeat; flex: none; box-shadow: 0 0 0 1px var(--line); }
.face.lg { width: 112px; height: 112px; }
.pp-person { display: grid; justify-items: center; gap: 6px; padding: 10px 6px; border: 0; background: transparent; border-radius: 12px; text-align: center; white-space: normal; }
.pp-person:hover { background: rgba(127, 127, 127, .08); }
.pp-person b { color: var(--text); font-size: 14px; }
.pp-person small { color: var(--muted); font-size: 12px; }
.pp-stack { display: grid; justify-items: center; gap: 8px; padding: 14px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.pp-stack.saving { opacity: .5; pointer-events: none; }
.pp-faces { display: flex; }
.pp-faces .face + .face { margin-left: -16px; box-shadow: 0 0 0 2px var(--panel); }
.pp-stack small { color: var(--muted); font-size: 12px; }
.pp-stack input { text-align: center; padding: 7px 10px; font-size: 13px; }
.pp-stack .link.quiet { color: var(--muted); font-size: 12px; }
.pp-ask { display: grid; gap: 8px; max-width: 760px; }
.pp-q { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.pp-q .face { width: 44px; height: 44px; }
.pp-q b { color: var(--text); }
@media (max-width: 760px) {
  .pp { padding: 14px 14px 0; gap: 24px; }
  .pp-grid { grid-template-columns: repeat(2, 1fr); }
  .face.lg { width: 96px; height: 96px; }
}

/* faces on the People page open their photo */
.pp-stack .face[data-faceid], .pp-q .face[data-faceid] { cursor: zoom-in; transition: box-shadow .15s, transform .15s var(--ease); }
.pp-stack .face[data-faceid]:hover, .pp-q .face[data-faceid]:hover { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.06); position: relative; z-index: 1; }

/* hidden faces, restorable */
.pp-hidden { border-top: 1px solid var(--line); padding-top: 18px; }
.pp-hidden summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-2); list-style: none; display: flex; gap: 10px; align-items: baseline; }
.pp-hidden summary::-webkit-details-marker { display: none; }
.pp-hidden summary::before { content: "+"; width: 14px; color: var(--muted); }
.pp-hidden[open] summary::before { content: "\2212"; }
.pp-hidden summary span { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.pp-hidden .pp-sub { margin: 10px 0 14px; }
.hidden-stack .pp-faces { opacity: .7; }
.hidden-stack button[data-pp="restore"] { font-size: 12.5px; padding: 6px 12px; }
.pp-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: flex; gap: 14px; align-items: center;
  padding: 10px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px;
  animation: rise .2s var(--ease);
}
.pp-toast .link { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
@media (max-width: 760px) { .pp-toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }
.lib-toast { bottom: 84px; }
/* on a phone the select bar keeps its words for the count; Download is an icon like the rest */
@media (max-width: 760px) { #selbar .sel-lbl { display: none; } #selbar { gap: 4px; padding-left: 12px; padding-right: 10px; } #selbar button { padding-left: 10px; padding-right: 10px; } }
/* in the viewer the bottom is the action bar and the details sheet: toasts sit under the top bar */
body:has(.lb.on) .pp-toast { bottom: auto; top: calc(54px + env(safe-area-inset-top)); }

/* View menu: sort choices */
.sort-list { display: grid; gap: 1px; }
.sort-opt { width: 100%; justify-content: space-between; gap: 10px; padding: 7px 8px; border: 0; background: transparent; text-align: left; border-radius: 7px; white-space: normal; }
.sort-opt:hover { background: rgba(127, 127, 127, .1); border: 0; }
.sort-opt b { display: block; font-size: 13px; font-weight: 550; color: var(--text); }
.sort-opt small { font-size: 11.5px; color: var(--muted); }
.sort-opt.on { background: rgba(127, 127, 127, .14); }
.sort-opt .ic { color: var(--accent); width: 15px; height: 15px; }
.grid.flat { margin-top: 18px; }
.viewmenu { max-height: calc(100vh - 90px); overflow-y: auto; }
.popmenu { backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%); }
:root[data-theme="cinematic"] .popmenu { background: rgba(18, 18, 22, .92); }

/* while the phone prepares picked files */
.prep { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .2s; }
.prep[hidden] { display: none; }
.prep-card { width: min(360px, 100%); display: grid; justify-items: center; gap: 10px; text-align: center; padding: 26px 24px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.prep-card b { font-size: 16px; }
.prep-card p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.prep-card .link { margin-top: 4px; font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0; padding: 6px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.prep-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* video length on tiles */
.tile .badge.len { width: auto; height: 22px; padding: 0 8px 0 6px; gap: 4px; border-radius: 99px; display: inline-flex; align-items: center; }
.tile .badge.len i { font-style: normal; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* steady panel while uploading: fixed list height, no jumping text widths */
.up.steady ul { height: 280px; }
.up .stats, .up .head b { font-variant-numeric: tabular-nums; }
.up .stats { min-height: 3em; }
#pickTip .prep-card .primary { margin-top: 6px; width: 100%; justify-content: center; padding: 11px; }
/* always opaque, even in styles whose panels are translucent */
.prep-card { background: linear-gradient(var(--panel), var(--panel)), var(--bg-2); }
:root[data-theme="cinematic"] .prep-card { background: #141418; }

/* video length: bottom right normally, bottom left in Cleanup (the select circle is bottom right) */
.tile .badge { left: auto; right: 7px; top: auto; bottom: 7px; }
.tile.vid .cap { bottom: 36px; }
.content.cleanup-view .tile .badge { right: auto; left: 7px; }
/* Cleanup: open larger without selecting */
.tile .expand {
  position: absolute; top: 7px; right: 7px; z-index: 3; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(0, 0, 0, .55); color: #fff; cursor: zoom-in; opacity: 0; transition: opacity .15s, background .15s;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile .expand .ic { width: 15px; height: 15px; }
.tile:hover .expand, .tile .expand:focus-visible { opacity: 1; }
.tile .expand:hover { background: rgba(0, 0, 0, .8); }
@media (hover: none) { .tile .expand { opacity: 1; } }
.cleanup-view .tile .why { max-width: calc(100% - 50px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* View menu: what to show */
.show-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.show-opt { justify-content: space-between; gap: 6px; padding: 7px 9px; font-size: 12.5px; text-align: left; white-space: normal; border-color: var(--line); background: transparent; }
.show-opt span { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.show-opt.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.show-opt.on span { color: var(--bg); opacity: .7; }
/* the active filter, next to the title; tap to clear */
.filter-chip { margin-left: 4px; padding: 3px 6px 3px 10px; gap: 4px; border-radius: 99px; font-size: 12px; font-weight: 500; border-color: var(--line-2); background: var(--panel); color: var(--text-2); letter-spacing: 0; }
.filter-chip .ic { width: 12px; height: 12px; }
.empty .link { font: inherit; color: var(--text); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* upload rows: a status mark at the end */
.up li { grid-template-columns: 40px minmax(0, 1fr) 22px; }
.up .ust { width: 22px; height: 22px; display: grid; place-items: center; }
.up .ust.ok { color: #3ecf8e; }
.up .ust.ok .ic { width: 17px; height: 17px; stroke-width: 2.4; }
.up .ust.fail { color: var(--danger); }
.up .ust.fail .ic { width: 15px; height: 15px; stroke-width: 2.4; }
.up .ust.skip i { font-style: normal; font-size: 10px; font-weight: 600; color: var(--muted); text-transform: none; }
.up .uspin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
/* the whole batch finished */
.up .head { justify-content: flex-start; }
.up .head #upClose { margin-left: auto; }
.updone { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #3ecf8e; color: #08130d; flex: none; animation: rise .3s var(--ease); }
.updone[hidden] { display: none; }
.updone .ic { width: 14px; height: 14px; stroke-width: 2.8; }
.up.done .bar i { background: #3ecf8e; }

/* stack questions and "Same person?" pairs */
.pp-stack-q { grid-template-columns: auto 1fr auto auto; }
.pp-stack-q .pp-faces .face, .pp-same .pp-faces .face { width: 40px; height: 40px; }
.pp-stack-q .pp-faces .face + .face, .pp-same .pp-faces .face + .face { margin-left: -14px; }
.pp-same { grid-template-columns: auto auto auto 1fr auto; }
.pp-same.saving { opacity: .5; pointer-events: none; }
.pp-plus { color: var(--muted); font-weight: 600; }
.pp-same input { padding: 7px 10px; font-size: 13px; min-width: 0; }
@media (max-width: 760px) {
  .pp-same { grid-template-columns: auto auto auto 1fr; }
  .pp-same input { grid-column: 1 / -1; }
  .pp-same button { grid-column: 1 / -1; justify-content: center; }
}

/* naming: a tick to save, lit once there is a name */
.pp-name { display: flex; gap: 6px; width: 100%; min-width: 0; }
.pp-name input { flex: 1; min-width: 0; }
.pp-ok { flex: none; width: 34px; padding: 0; display: grid; place-items: center; border-radius: 9px; border-color: var(--line-2); background: transparent; color: var(--muted); }
.pp-ok .ic { width: 16px; height: 16px; stroke-width: 2.6; }
.pp-name:has(input:not(:placeholder-shown)) .pp-ok { background: #3ecf8e; border-color: #3ecf8e; color: #08130d; }
.pp-same .pp-name { width: auto; }
@media (max-width: 760px) { .pp-same .pp-name { grid-column: 1 / -1; } }

/* "Is this them?": Yes / No / Someone else, which turns into a name box */
.pp-acts { display: flex; align-items: center; gap: 6px; grid-column: 3 / -1; }
.pp-stack-q.naming .pp-acts { min-width: min(300px, 100%); }
.pp-other { display: flex; align-items: center; gap: 10px; width: 100%; }
.pp-other .link.quiet { font: inherit; font-size: 12px; background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.pp-other input { padding: 7px 10px; font-size: 13px; }
.pp-stack-q.saving { opacity: .5; pointer-events: none; }
@media (max-width: 760px) {
  .pp-stack-q { grid-template-columns: auto 1fr; }
  .pp-acts { grid-column: 1 / -1; }
  .pp-acts > button { flex: 1; justify-content: center; }
}

/* "12 screenshots hidden  Show" next to the title */
.filter-chip.soft { padding: 3px 4px 3px 10px; color: var(--muted); background: transparent; }
.filter-chip.soft b { padding: 2px 8px; border-radius: 99px; background: var(--panel-2, var(--panel)); color: var(--text); font-weight: 600; }

/* pencil next to a person's name */
.title-edit { margin-left: 6px; width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; border-color: transparent; background: transparent; color: var(--muted); vertical-align: middle; }
.title-edit:hover { background: var(--panel); color: var(--text); border-color: var(--line); }
.title-edit .ic { width: 16px; height: 16px; }

/* "Who is this?": the likely people as buttons, then Someone else / None */
.pp-stack-q { grid-template-columns: auto auto 1fr; }
.pp-who { color: var(--text-2); font-size: 13.5px; }
.pp-stack-q .pp-acts { grid-column: auto; flex-wrap: wrap; justify-content: flex-end; }
.pp-cand { font-weight: 600; color: var(--text); }
.pp-cand.first { border-color: var(--accent); }
.pp-none { color: var(--muted); }
@media (max-width: 760px) {
  .pp-stack-q { grid-template-columns: auto 1fr; }
  .pp-stack-q .pp-acts { grid-column: 1 / -1; justify-content: stretch; }
  .pp-stack-q .pp-acts > button { flex: 1 1 auto; }
}

/* pencil on a person card: rename without opening them */
/* the pencil hangs off the end of the name, so the name itself stays centred */
.pp-person b { position: relative; }
.pp-edit { position: absolute; left: 100%; top: 50%; margin: -12px 0 0 2px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); opacity: 0; transition: opacity .15s, background .15s; cursor: pointer; }
.pp-edit .ic { width: 13px; height: 13px; }
.pp-person:hover .pp-edit, .pp-edit:focus-visible { opacity: 1; }
.pp-edit:hover { background: rgba(127, 127, 127, .16); color: var(--text); }
@media (hover: none) { .pp-edit { opacity: .8; } }

/* hover buttons on a tile: favourite, move to Cleanup */
.tile .tacts { position: absolute; top: 7px; right: 7px; z-index: 3; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tile:hover .tacts { opacity: 1; }
.tile .tacts > span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .15s; }
.tile .tacts > span:hover { background: rgba(0, 0, 0, .82); }
.tile .tacts .ic { width: 15px; height: 15px; }
.tile .tacts .on .ic { fill: #ffcf5c; color: #ffcf5c; }
@media (hover: none) { .tile .tacts { display: none; } }

/* select mode (camera-roll style) */
#selBtn[hidden] { display: none; }
#selBtn.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.content.selecting .tile { touch-action: pan-y; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.content.selecting .tile img { -webkit-user-drag: none; }
.selbar .grow small { color: var(--muted); font-size: inherit; }
.selbar .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.selbar .primary:disabled { opacity: .45; }
.selbar button .ic { width: 15px; height: 15px; }
@media (max-width: 760px) { .selbar .hide-sm { display: none; } .selbar { gap: 6px; } }
@media (max-width: 760px) { .filter-chip.soft { padding: 3px 9px; } .filter-chip.soft b { display: none; } }
@media (max-width: 760px) { #title:has(.filter-chip) .count { display: none; } }

/* the date a search understood, next to the title */
.when-chip { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: 0; vertical-align: middle; white-space: nowrap; }
.when-chip .ic { width: 12px; height: 12px; }
@media (max-width: 760px) { #title:has(.when-chip) .count { display: none; } .when-chip { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; } }

/* sharing */
.login [hidden] { display: none !important; }
.family-btn { display: grid; gap: 2px; text-align: left; }
.family-btn[hidden] { display: none; }
.family-btn small { color: var(--muted); font-size: 11.5px; padding-left: 26px; }
.fam-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.fam { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px; border-radius: 16px; background: var(--bg-2); border: 1px solid var(--line-2); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); display: grid; gap: 14px; }
.fam-h { display: flex; align-items: center; justify-content: space-between; font-size: 16px; }
.fam-sub { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.fam-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fam-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.fam-av { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2, var(--line)); border: 1px solid var(--line-2); color: var(--text); font-weight: 600; }
.fam-n { flex: 1; min-width: 0; display: grid; gap: 1px; }
.fam-n small { color: var(--muted); font-size: 12px; }
.fam-invite { display: grid; gap: 8px; }
.fam-invite p { margin: 0; font-size: 13px; color: var(--text-2); }
.fam-invite input { font: 12.5px var(--mono); padding: 9px 10px; }
.fam-row { display: flex; gap: 8px; }
.fam .primary, .fam-go { background: var(--accent); border-color: var(--accent); color: #fff; justify-content: center; }

/* Face ID on the sign-in page */
.pk-step { display: grid; gap: 10px; width: 100%; }
.pk-step:empty { display: none; }
.login .or { display: flex; align-items: center; gap: 10px; margin: 2px 0; color: var(--muted); font-size: 12px; }
.login .or::before, .login .or::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.login .link.quiet { font: inherit; font-size: 13px; background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; justify-self: center; }
.fam-h2 { font-size: 13px; font-weight: 600; color: var(--text-2); margin-top: 4px; }
.fam-pk { display: grid; gap: 8px; }
.fam-pk:empty { display: none; }
.login form > .pk-step > button { justify-content: center; }

/* top bar like the iPhone Photos app: a round filter button and a "Select" pill */
#viewBtn { width: 40px; padding: 0; justify-content: center; border-radius: 50%; }
#viewBtn span { display: none; }
#viewBtn .ic { width: 19px; height: 19px; stroke-width: 2.2; }
.tb-btn.pill { width: auto; padding: 0 16px; border-radius: 99px; font-weight: 600; }
.tb-btn.pill span { display: inline !important; }
@media (max-width: 760px) { .tb-btn.pill { width: auto; padding: 0 15px; } }
.tb-actions > #viewPop { order: 1; } .tb-actions > #selBtn { order: 2; } .tb-actions > .pop:not(#viewPop) { order: 3; }

/* scrolling and selecting at phone speed: a picture already on the device shows
   at once (a short fade only for ones still arriving), and ticking a photo
   reacts straight away instead of easing over half a second */
.tile img { transform: none; transition: opacity .16s ease-out, transform .14s ease-out; }
.tile.sel img { transition: transform .14s ease-out; }
.content .grid { contain: layout paint; }

/* sidebar: libraries you can switch between, and your account */
.lib-switch { display: grid; gap: 2px; margin-bottom: 6px; }
.lib-switch[hidden] { display: none; }
.side-h { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 12px 4px; }
.lib-opt.on { background: var(--panel-2, var(--panel)); color: var(--text); }
.lib-opt small { color: var(--muted); font-size: 11.5px; }
.lib-opt.loading { opacity: .5; }
.account-btn { display: flex; align-items: center; gap: 10px; padding-top: 8px; padding-bottom: 8px; text-align: left; }
.account-btn[hidden] { display: none; }
.acct-av { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2, var(--line)); border: 1px solid var(--line-2); color: var(--text); font-weight: 600; font-size: 13px; }
.acct-n { display: grid; min-width: 0; line-height: 1.25; }
.acct-n b { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-n small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#logout[hidden] { display: none; }

/* account and sharing forms */
.fam-form { display: grid; gap: 10px; }
.fam-form label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.fam-form input { padding: 9px 11px; font-size: 14px; }
/* 16px or iOS zooms the whole page in when the field is tapped */
@media (max-width: 760px) { .fam-form input, .fam-invite input { font-size: 16px; } }
.fam-form .link { font: inherit; background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.fam-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 207, 92, .12); color: var(--text); font-size: 13px; line-height: 1.5; border: 1px solid rgba(255, 207, 92, .3); }
.fam-ok { margin: 0; padding: 9px 12px; border-radius: 10px; background: rgba(62, 207, 142, .12); color: #3ecf8e; font-size: 13px; }
.fam-more summary { cursor: pointer; font-size: 13px; color: var(--text-2); padding: 4px 0; }
.fam-more[open] summary { margin-bottom: 8px; }
.fam-libname { align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.fam .err { margin: 0; color: var(--danger); font-size: 12.5px; }
.fam .err:empty { display: none; }
.fam-go.danger { color: var(--danger); }

/* sign-in, sign-up and invite pages */
.login a.mark { display: block; }
.login .alt { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); text-align: center; }
.login .alt a { color: var(--text); font-weight: 600; text-underline-offset: 3px; }
.login .alt[hidden] { display: none; }
.login .fine { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.login .fine a { color: var(--text-2); }
.login a.link.quiet { justify-self: center; font-size: 13px; color: var(--muted); text-underline-offset: 3px; }
.login a.link.quiet[hidden] { display: none; }
#newAcct { display: grid; gap: 10px; }
#newAcct[hidden] { display: none; }

/* account button: the initial centred in its circle, the name right beside it */
.nav.account-btn { justify-content: flex-start; }
.nav.account-btn > .acct-av { display: grid; place-items: center; gap: 0; overflow: visible; line-height: 1; }
.nav.account-btn > .acct-n { text-align: left; }
/* iPhones zoom into any text box under 16px; keep them at 16px on phones */
@media (max-width: 760px) { input[type=password], input[type=email], input[type=text], input[type=search], textarea { font-size: 16px; } }

/* brand mark: the Mantel logo (a shelf with two framed photos) */
.mark { background: url(/favicon.svg) center / contain no-repeat !important; box-shadow: none !important; border-radius: 22%; }

/* the wordmark: lowercase serif "mantel" beside the icon */
.brand .mark { width: 26px; height: 26px; }
.brand-word { font: 600 21px/1 'Fraunces', Georgia, serif; letter-spacing: -.03em; color: var(--text); }

/* sign-in pages: the button to tap is the brand colour, and it changes smoothly */
.login button { justify-content: center; padding: 9px; transition: background .2s, border-color .2s, color .2s, box-shadow .2s; }
.login button.primary { background: linear-gradient(135deg, #ff9a62, #ff6a5c 55%, #e0508a); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgba(255, 106, 92, .28); }
.login button.primary:hover { background: linear-gradient(135deg, #ffa774, #ff7a6b 55%, #e8609a); border-color: transparent; color: #fff; }
.login button.primary:disabled { opacity: .6; box-shadow: none; }

/* pull down to refresh */
.ptr { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 70; transform: translate(-50%, -60px); opacity: 0; pointer-events: none; transition: opacity .15s; }
.ptr.show { opacity: 1; }
.ptr-dot { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2, #1c1c22); border: 1px solid var(--line-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.ptr svg { width: 18px; height: 18px; fill: none; stroke: var(--text-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .12s; }
.ptr.ready svg { stroke: #ff7a5c; }
.ptr.spin svg { display: none; }
.ptr.spin .ptr-dot::after { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2.4px solid var(--line-2); border-top-color: #ff7a5c; animation: spin .7s linear infinite; }

/* selecting (Select mode and Cleanup), the iPhone Photos way: a selected photo
   gets a solid tick and a light veil; unselected ones show nothing; no frames.
   Video lengths move to the left so the tick always has its corner. */
.content.selecting .tile.sel, .content.cleanup-view .tile.sel { box-shadow: none; }
.content.selecting .tile.sel img, .content.cleanup-view .tile.sel img { transform: none; border-radius: 0; }
.content.selecting .tile::after, .content.cleanup-view .tile::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: rgba(255, 255, 255, .28); opacity: 0; transition: opacity .12s;
}
.content.selecting .tile.sel::after, .content.cleanup-view .tile.sel::after { opacity: 1; }
.content.selecting .tile .tick, .content.cleanup-view .tile .tick { z-index: 3; width: 24px; height: 24px; right: 6px; bottom: 6px; opacity: 0; transform: scale(.6); transition: opacity .12s, transform .14s; }
.content.selecting .tile.sel .tick, .content.cleanup-view .tile.sel .tick {
  opacity: 1; transform: none; background: var(--accent); border: 2px solid #fff; color: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.content.selecting .tile .tick .ic, .content.cleanup-view .tile .tick .ic { width: 13px; height: 13px; stroke-width: 3; }
.content.selecting .tile .badge, .content.selecting .tile .badge.len { right: auto; left: 6px; bottom: 6px; }

/* what is narrowing the list (a date, Videos, someone's photos): its own row */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.chips[hidden] { display: none; }
.chips .when-chip, .chips .filter-chip { margin: 0; max-width: 100%; }
.chips .when-chip { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .top { grid-template-areas: "menu title actions" "search search search" "chips chips chips"; }
  .chips { grid-area: chips; }
  .chips .when-chip { max-width: none; white-space: normal; }
}

/* the title: a long name (an album, a person) shortens with an ellipsis, while
   the rename pencil and the count stay whole */
#title { display: flex; align-items: center; min-width: 0; }
#title .title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#title .count, #title .title-edit { flex: none; }
/* on a phone a long title gets smaller and may take two lines rather than lose its words */
@media (max-width: 760px) {
  /* the library name with its pencil leaves no room for the count on a phone */
  #title:has(.title-edit) .count { display: none; }
  #title .title-edit { margin-left: 2px; width: 28px; }
  #title .title-text.long { font-size: 17px; line-height: 1.15; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
}
.fam-plain { justify-content: center; }
.danger-text { color: var(--danger, #e5484d); }

/* main buttons in the app share the sign-in pages' coral gradient */
.selbar .primary, .fam .primary, .fam-go:not(.danger), #pickTip .prep-card .primary { background: linear-gradient(135deg, #ff9a62, #ff6a5c 55%, #e0508a); border-color: transparent; color: #fff; font-weight: 600; }
.selbar .primary:hover, .fam .primary:hover { background: linear-gradient(135deg, #ffa774, #ff7a6b 55%, #e8609a); border-color: transparent; color: #fff; }
.selbar .primary:disabled { opacity: .45; }
/* the selection tick: coral with a white rim and shadow, so it shows on warm photos too */
.content.selecting .tile.sel .tick, .content.cleanup-view .tile.sel .tick { background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .45); }

/* Delete in Select mode, and the album bar */
.selbar .sel-del { color: var(--danger); }
.selbar .sel-del:disabled { color: var(--muted); }
.selbar .danger { color: var(--danger); }
.fam-go.danger { background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); justify-content: center; }

/* People: a name stays on one line (shortened if it must be), pencil beside it */
.pp-person b { white-space: nowrap; max-width: calc(100% - 26px); }
.pp-person { min-width: 0; }
.pp-person b { overflow: visible; }

/* People > Someone else: your people as faces under the name box */
.pp-stack-q.naming .pp-acts { flex-direction: column; align-items: stretch; }
.pp-other-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; margin-top: 8px; max-height: 230px; overflow-y: auto; }
.pp-other-people .fp-person { display: grid; justify-items: center; gap: 4px; padding: 6px 2px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); font-size: 11.5px; line-height: 1.2; white-space: normal; text-align: center; }
.pp-other-people .fp-person[hidden] { display: none; }
.pp-other-people .fp-person:hover { background: rgba(127, 127, 127, .1); }
.pp-other-people .fp-person .face { width: 46px; height: 46px; }
.pp-other-new { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.pp-other-new[hidden] { display: none; }

/* who added it, on photos from someone else in a shared library */
.tile .by-badge, .mtile .by-badge { position: absolute; left: 6px; top: 6px; z-index: 2; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 20, 24, .78); color: #fff; font-size: 11px; font-weight: 700; box-shadow: 0 0 0 1.5px var(--accent), 0 1px 4px rgba(0, 0, 0, .4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); pointer-events: none; }
.tile .by-badge ~ .fav { left: 34px; }
.mtile .by-badge { left: 10px; top: 10px; width: 26px; height: 26px; font-size: 12px; }
.content.selecting .tile .by-badge { opacity: .85; }

/* menus: a title and a close button, so they're never a trap on a phone */
.pm-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.pm-top b { font-size: 14px; font-weight: 600; }
.pm-top .pm-close { width: 32px; height: 32px; }
@media (min-width: 761px) { .viewmenu .pm-top, .addmenu .pm-top { display: none; } }
/* the select bar on a phone: short words, no squeezing */
@media (max-width: 760px) { .selbar .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; } }
@media (max-width: 760px) {
  /* a menu stops above the tab bar and scrolls inside; its title and close stay put */
  .popmenu { max-height: calc(100dvh - var(--top-h, 107px) - 6px - 78px - env(safe-area-inset-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain; }
  .popmenu .pm-top { position: sticky; top: -8px; z-index: 2; background: var(--panel); margin: -8px -8px 4px; padding: 10px 10px 8px; border-radius: 12px 12px 0 0; }

}
/* storage used (there is no cap to count down to) */
.usage b { color: var(--text-2); font-weight: 500; }
.usage small { display: block; margin-top: 3px; font: 400 10.5px var(--sans, inherit); color: var(--muted); }

/* Add to another library: the libraries as a tappable list */
.lib-pick { display: grid; gap: 4px; margin-top: 4px; }
.lib-pick .lib-opt { width: 100%; min-height: 48px; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; }
