/* iOS-style theme shared by every page. Loaded after each page's own <style>, so it restyles the
   same classes; `:root body …` selectors exist only to outrank the pages' own rules. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  /* iOS system colours (light) */
  --bg: #f2f2f7;            /* grouped background */
  --card: #ffffff;          /* secondary grouped background */
  --card-2: #f2f2f7;        /* tertiary grouped background */
  --ink: #000000;           /* label */
  --muted: #6c6c70;         /* secondary label */
  --line: #c6c6c8;          /* separator */
  --fill: rgba(118, 118, 128, .12);
  --track: rgba(118, 118, 128, .16);
  --accent: #007aff;
  --green: #34c759; --orange: #ff9500; --red: #ff3b30;
  --known: #248a3d; --unknown: #c93400;  /* text-safe green/orange on light */
  --bar: rgba(249, 249, 249, .78);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 10px rgba(0, 0, 0, .04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --ink: #ffffff; --muted: #98989f;
    --line: #38383a; --fill: rgba(118, 118, 128, .24); --track: rgba(118, 118, 128, .32);
    --accent: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a;
    --known: #30d158; --unknown: #ff9f0a; --bar: rgba(22, 22, 24, .78); --shadow: none;
  }
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; letter-spacing: -.01em; }
main { padding-top: 8px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---- Navigation bar: frosted, sticky; large title + segmented control ---- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--line);
}
.appbar-in { max-width: 1100px; margin: 0 auto; padding: 14px 16px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.appbar h1 { margin: 0; font-size: clamp(1.05rem, 2.2vw, 1.45rem); font-weight: 700; letter-spacing: -.02em; flex: 1 1 320px; }
:root body nav { display: inline-flex; gap: 2px; margin: 0; padding: 2px; background: var(--fill); border-radius: 10px; }
:root body nav a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 16px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: .92rem; font-weight: 500;
  text-decoration: none; transition: background .2s, box-shadow .2s;
}
:root body nav a svg { width: 17px; height: 17px; flex: none; }
:root body nav a[aria-current] { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .14), 0 1px 1px rgba(0, 0, 0, .04); }
@media (prefers-color-scheme: dark) { :root body nav a[aria-current] { background: #636366; } }

.logout { color: var(--accent); font-weight: 500; text-decoration: none; padding: 6px 2px; white-space: nowrap; }
.logout:hover { text-decoration: underline; }

/* Phones: the title scrolls away and the tabs stick to the top of the screen. Not a bar at the
   bottom: mobile browsers' own toolbars and gesture areas can cover that.
   display: contents lets the nav stick to the whole page, not just to the short header. */
@media (max-width: 700px) {
  .appbar, .appbar-in { display: contents; }
  .appbar h1 { padding: 14px 84px 10px 16px; }
  .logout { position: absolute; top: 10px; right: 16px; }
  :root body nav {
    position: sticky; top: 0; z-index: 40; display: flex; padding: 6px 12px; border-radius: 0;
    background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--line);
  }
  :root body nav a { flex: 1; justify-content: center; min-height: 40px; padding: 4px 0; font-size: .85rem; }
  :root body nav a svg { width: 18px; height: 18px; }
}

/* ---- Headings & text ---- */
main h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }
.card h2, main h2 { letter-spacing: -.01em; }
p.sub, .hint, .sum, #count, #status, #pstatus, #vstatus { color: var(--muted); }
:root body .err { color: var(--red); }

/* ---- Grouped cards ---- */
:root body .card, :root body .tile, :root body .tiles .tile { background: var(--card); border: 0; border-radius: 16px; box-shadow: var(--shadow); }

/* ---- Buttons: filled (primary), tinted (ghost) and destructive ---- */
:root body button {
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--accent); color: #fff;
  font: 600 1rem/1 var(--font); letter-spacing: -.01em; cursor: pointer; transition: opacity .15s, transform .15s, background .2s;
}
:root body button:hover { filter: brightness(1.06); }
:root body button:active { opacity: .7; transform: scale(.98); }
:root body button:disabled { opacity: .4; cursor: default; transform: none; }
:root body button.ghost { background: var(--fill); color: var(--accent); }
:root body button.danger { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
:root body .btn-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border: 0; border-radius: 12px;
  background: var(--fill); color: var(--accent); font-weight: 600; text-decoration: none;
}
/* Small icon buttons inside tables and lists */
:root body #known button { min-height: 32px; padding: 0 10px; background: none; color: var(--red); font-weight: 500; }
:root body .nav-btn { min-height: 44px; border-radius: 999px; background: rgba(0, 0, 0, .45); backdrop-filter: blur(10px); }

/* ---- Text fields & menus ---- */
:root body input:not([type=checkbox]):not([type=range]):not([type=file]):not([type=radio]),
:root body select, :root body #known input, :root body #known select, :root body .multi summary {
  min-height: 40px; padding: 8px 12px; border: 0; border-radius: 10px; background-color: var(--fill); color: var(--ink);
  font: 400 1rem/1.2 var(--font); box-shadow: none;
}
:root body select, :root body #known select, :root body .multi summary {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
:root body input::placeholder { color: var(--muted); opacity: .8; }
input[type=range] { accent-color: var(--accent); }
input[type=file] { font: inherit; color: var(--muted); }
input[type=file]::file-selector-button { font: 600 .9rem var(--font); border: 0; border-radius: 8px; padding: 8px 12px; margin-right: 10px; background: var(--fill); color: var(--accent); cursor: pointer; }

/* Checkboxes become iOS switches */
:root body input[type=checkbox] {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 46px; height: 28px; margin: 0;
  border-radius: 999px; background: var(--track); cursor: pointer; transition: background .25s;
}
:root body input[type=checkbox]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18), 0 1px 1px rgba(0, 0, 0, .1); transition: transform .25s cubic-bezier(.3, .7, .4, 1.2);
}
:root body input[type=checkbox]:checked { background: var(--green); }
:root body input[type=checkbox]:checked::after { transform: translateX(18px); }
label.chk { gap: 10px !important; }

/* ---- Drop zones ---- */
:root body .drop {
  border: 2px dashed color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 6%, var(--card)); color: var(--accent); font-weight: 500;
  padding: 26px 18px; transition: background .2s, border-color .2s;
}
:root body .drop::before { content: ""; display: block; width: 34px; height: 34px; margin: 0 auto 8px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15V4m0 0L7.5 8.5M12 4l4.5 4.5'/%3E%3Cpath d='M5 13v5a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15V4m0 0L7.5 8.5M12 4l4.5 4.5'/%3E%3Cpath d='M5 13v5a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-5'/%3E%3C/svg%3E") center / contain no-repeat; }
:root body .drop:hover, :root body .drop.over { background: color-mix(in srgb, var(--accent) 12%, var(--card)); border-color: var(--accent); }

/* ---- Upload page: face cards & known people ---- */
:root body .face { border: 0; border-radius: 14px; background: var(--card-2); padding: 10px; }
:root body .face img { border-radius: 10px; }
:root body .face .who { color: var(--known); }
:root body .face .new { color: var(--unknown); }
:root body .face input, :root body .face select { margin-top: 8px; background-color: var(--card); }
.photo { border-top-color: var(--line) !important; }
.photo > img, #pout > img { border-radius: 14px !important; }
#known table { border-collapse: separate; border-spacing: 0; }
#known tr + tr td { border-top: .5px solid var(--line); }
#known td, #known th { padding: 8px 10px 8px 0 !important; }
:root body #known select { min-width: 8.5em; }
:root body #known input { min-width: 9em; }

/* ---- Gallery ---- */
:root body .filters { gap: 14px; }
:root body .filters label { color: var(--muted); font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; }
/* Buttons centre their content vertically; photo cards must start at the top instead */
:root body .tile:is(button) { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; border: 0; border-radius: 16px; padding: 0; box-shadow: var(--shadow); text-align: left; color: var(--ink); font: inherit; transition: transform .2s; min-height: 0; background: var(--card); }
:root body .tile:is(button):hover { transform: translateY(-2px); filter: none; }
:root body .tile:is(button):active { transform: scale(.98); opacity: 1; }
:root body .tile img { border-radius: 16px 16px 0 0; }
:root body .chip { border: 0; padding: 2px 9px; font-weight: 500; }
:root body .chip.known { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--known); }
:root body .chip.unknown { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--unknown); }
:root body .chip.none { background: var(--fill); color: var(--muted); }
:root body dialog { border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); overflow: hidden; }
:root body dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }

/* ---- Dashboard ---- */
:root body .tiles .tile .v { font-weight: 700; letter-spacing: -.03em; }
:root body .bar .track { height: 8px; border-radius: 999px; background: var(--track); }
:root body .bar .fill { border-radius: 999px; }
:root body a.bar:hover, :root body a.bar:focus-visible { background: var(--fill); }
:root body .group { border: 0; border-radius: 14px; background: var(--card-2); }
:root body .picker select { background-color: var(--card); box-shadow: var(--shadow); }
:root body .memories .mmake { min-height: 44px; }
img.flag { box-shadow: 0 0 0 .5px rgba(0, 0, 0, .2) !important; }

/* ---- Video player ---- */
video { border-radius: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
