/* Ownkin — styled after Apple's Human Interface Guidelines (iOS 18+):
   system colours, SF type scale, translucent bars, inset grouped lists, 44pt touch targets. */

:root {
  --bg: #f2f2f7;               /* systemGroupedBackground */
  --chat-bg: #ffffff;
  --card: #ffffff;             /* secondarySystemGroupedBackground */
  --bar: rgba(249, 249, 249, .82);
  --label: #000000;
  --secondary: rgba(60, 60, 67, .6);
  --tertiary: rgba(60, 60, 67, .3);
  --separator: rgba(60, 60, 67, .29);
  --fill: rgba(120, 120, 128, .12);
  --fill-strong: rgba(120, 120, 128, .2);
  --tint: #007aff;
  --me: #1e6ef4;              /* white text 4.6:1; system blue is 4.0:1 */
  --me-ink: #ffffff;
  --him: #e9e9eb;
  --him-ink: #000000;
  --red: #ff3b30;
  --green: #34c759;
  --orange: #ff9500;
  --yellow-bg: #fff4d6;
  --yellow-ink: #7a5600;
  --scrim: rgba(0, 0, 0, .4);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Arabic", "Geeza Pro", "Noto Sans Arabic",
          "Segoe UI", system-ui, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* design tokens (docs/design-system.md): 4-pt spacing, HIG radii and motion */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --radius-bubble: 18px; --radius-card: 10px; --radius-control: 12px; --radius-button: 14px; --radius-sheet: 12px;
  --dur-fast: .15s; --dur-base: .25s; --dur-slow: .35s;
  --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.2, .9, .25, 1.05);
  --meta: #6c6c70;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --chat-bg: #000000;
    --card: #1c1c1e;
    --bar: rgba(22, 22, 24, .78);
    --label: #ffffff;
    --secondary: rgba(235, 235, 245, .6);
    --tertiary: rgba(235, 235, 245, .3);
    --separator: rgba(84, 84, 88, .6);
    --fill: rgba(118, 118, 128, .24);
    --fill-strong: rgba(118, 118, 128, .32);
    --tint: #0a84ff;
    --me: #1e6ef4;
    --him: #262629;
    --him-ink: #ffffff;
    --red: #ff453a;
    --green: #30d158;
    --orange: #ff9f0a;
    --yellow-bg: #3a2f12;
    --yellow-ink: #ffd56b;
    --scrim: rgba(0, 0, 0, .6);
    --meta: #aeaeb2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--chat-bg);
  color: var(--label);
  font: 17px/1.29 var(--font);
  letter-spacing: -.41px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 55%, transparent); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }
.muted { color: var(--secondary); font-size: 15px; line-height: 1.33; }
code { font-family: var(--mono); font-size: .88em; }

/* Flex column, not grid rows: a hidden banner used to shift the rows, so the composer
   stretched over an empty chat. */
.app {
  display: flex; flex-direction: column;
  height: var(--app-h, 100dvh);
  max-width: 680px;
  margin: 0 auto;
}
.thread { flex: 1; min-height: 0; }

/* ---------- navigation bar (iMessage) ---------- */
.bar {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 96px 1fr 96px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 4px) 8px 6px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--separator);
}
.bar-side { display: flex; align-items: center; }
.actions { justify-content: flex-end; }
.who { display: grid; justify-items: center; gap: 2px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(180deg, #a5abb8, #858994);
  color: #fff; font-weight: 600; font-size: 17px; letter-spacing: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.who-text { text-align: center; min-width: 0; }
.name { font-size: 11px; line-height: 13px; font-weight: 400; letter-spacing: .06px; color: var(--label); }
.status { font-size: 11px; line-height: 13px; min-height: 13px; color: var(--secondary); transition: color .2s; }
.status.typing { color: var(--tint); }
.status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .sim { display: block; font-size: 10px; line-height: 12px; color: var(--tertiary); }
.icon {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center;
}
.icon svg { width: 24px; height: 24px; fill: var(--tint); }
.icon:disabled svg { fill: var(--tertiary); }
.icon:not(:disabled):active { background: var(--fill); }

.mock-banner {
  margin: 8px 16px 0; padding: 10px 14px; border-radius: 12px;
  background: var(--yellow-bg); color: var(--yellow-ink); font-size: 13px; line-height: 18px;
}
/* the AI notice: always on screen, so nobody mistakes the companion for a person */
.ai-notice { padding: 4px 16px 0; text-align: center; font-size: 11px; line-height: 13px; color: var(--meta); }
.stamp.notice { max-width: 280px; text-align: center; }

/* ---------- conversation ---------- */
.thread {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px 16px 12px;
  display: flex; flex-direction: column; gap: 2px;
  scroll-behavior: smooth;
}
.stamp {
  align-self: center; margin: 14px 0 6px; font-size: 11px; line-height: 13px;
  color: var(--meta); letter-spacing: .06px;
}
.stamp b { font-weight: 600; }
.msg {
  max-width: min(75%, 520px); padding: 7px 12px 8px; border-radius: 18px;
  font-size: 17px; line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere;
  unicode-bidi: isolate; text-align: start; /* direction comes from dir= (majority script), not the first letter */
  animation: pop .2s cubic-bezier(.2, .8, .2, 1);
}
/* Arabic needs more leading than Latin at 17 pt (marks above and below the line), and no tracking:
   negative letter-spacing pulls joined letters apart. */
.msg.rtl { line-height: 25px; letter-spacing: 0; }
.field textarea[dir=rtl] { letter-spacing: 0; }
.msg.user { align-self: flex-end; background: var(--me); color: var(--me-ink); }
.msg.assistant { align-self: flex-start; background: var(--him); color: var(--him-ink); }
.msg.user + .msg.assistant, .msg.assistant + .msg.user { margin-top: 8px; }
/* grouped bubbles: tighten the joining corners */
.msg.user:has(+ .msg.user) { border-bottom-right-radius: 6px; }
.msg.user + .msg.user { border-top-right-radius: 6px; }
.msg.assistant:has(+ .msg.assistant), .msg.assistant:has(+ .typing) { border-bottom-left-radius: 6px; }
.msg.assistant + .msg.assistant, .msg.assistant + .typing { border-top-left-radius: 6px; }
.msg.error { align-self: center; background: transparent; color: var(--red); font-size: 13px; line-height: 18px; text-align: center; }
.msg.caption { font-size: 15px; line-height: 20px; opacity: .9; }

/* empty chat (every open) */
.empty {
  margin: auto; padding: var(--space-8) var(--space-6);
  display: grid; justify-items: center; gap: var(--space-2); text-align: center;
  animation: fade var(--dur-slow) var(--ease-out);
}
.empty .avatar.big { width: 72px; height: 72px; font-size: 30px; margin-bottom: var(--space-1); }
.empty-name { font-size: 20px; line-height: 25px; font-weight: 600; letter-spacing: .38px; }
.empty-note { margin: 0; max-width: 260px; font-size: 13px; line-height: 18px; color: var(--secondary); }

.kb-open .composer { padding-bottom: 6px; }

/* receipts and small meta text use a darker gray: 11-12 pt needs 4.5:1 */
.receipt { align-self: flex-end; margin: 2px 4px 4px; font-size: 11px; line-height: 13px; color: var(--meta); font-weight: 500; }
.receipt-act { border: 0; background: none; padding: 0; font: inherit; color: var(--tint); cursor: pointer; }
.cell-input.inline.time { width: auto; min-width: 96px; font-variant-numeric: tabular-nums; -webkit-appearance: none; appearance: none; }
.group-footer.lead { margin: 4px 16px 18px; }

/* not delivered */
.msg.user.failed { opacity: .55; }
.retry {
  align-self: flex-end; margin: 4px 2px 6px; padding: 0; border: 0; background: none;
  color: var(--red); font-size: 12px; line-height: 16px; min-height: 28px;
}

/* his photo didn't come: quiet line under his bubbles */
.photo-note {
  align-self: flex-start; margin: 2px 4px 6px; padding: 0; border: 0; background: none; text-align: start;
  color: var(--meta); font: inherit; font-size: 12px; line-height: 16px; min-height: 28px;
}
button.photo-note { color: var(--tint); }

.typing {
  align-self: flex-start; background: var(--him); border-radius: 18px;
  padding: 12px 14px; display: flex; gap: 5px;
}
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary); animation: blink 1.4s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

/* flagged ("felt like a bot") */
.msg.assistant[data-id] { cursor: pointer; }
.msg.assistant.bot { box-shadow: inset 0 0 0 1.5px var(--red); }
.msg.assistant.bot::after { content: "felt like a bot"; display: block; font-size: 11px; line-height: 13px; color: var(--red); margin-top: 3px; }
.flag-menu {
  align-self: flex-start; margin: 4px 0 8px; min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 18px; background: var(--card); color: var(--red); font-size: 15px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.12);
  animation: pop .15s ease-out;
}

/* ---------- composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
  transition: padding var(--dur-fast) var(--ease-out);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.composer .icon { width: 36px; height: 36px; flex: none; }
/* "/" in the composer: the commands, iMessage-app style, right above the field */
.cmd-hint { padding: 0 12px 4px; background: var(--bar); }
.cmd-hint .cmd {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 12px; background: var(--card); color: var(--label); font: inherit; font-size: 15px; text-align: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 18px rgba(0, 0, 0, .08); animation: fade var(--dur-fast) ease-out;
}
.cmd-hint .cmd svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--tint); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cmd-hint .cmd span { color: var(--secondary); }
.composer .icon svg { fill: var(--secondary); }
.field {
  flex: 1; min-width: 0; display: flex; align-items: flex-end;
  border: 1px solid var(--separator); border-radius: 18px; background: var(--chat-bg);
  padding: 2px 3px 2px 12px; min-height: 36px;
}
.field textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; resize: none; outline: none;
  font-size: 17px; line-height: 22px; padding: 5px 0; max-height: 140px; color: var(--label);
}
.field textarea::placeholder { color: var(--tertiary); }
.send {
  width: 30px; height: 30px; border: 0; border-radius: 50%; flex: none; margin: 0 0 1px 6px;
  background: var(--tint); display: grid; place-items: center; transition: transform .15s, opacity .15s;
}
.send svg { width: 20px; height: 20px; fill: #fff; }
.send:disabled { opacity: 0; transform: scale(.6); pointer-events: none; }
.recording { flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.recording .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; flex: none; }
.icon.rec { background: color-mix(in srgb, var(--red) 15%, transparent); }
.icon.rec svg { fill: var(--red); }
#voice { touch-action: none; user-select: none; -webkit-user-select: none; }

/* voice notes */
.voice-msg { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.vplay { width: 32px; height: 32px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center; background: rgba(127,127,127,.2); }
.vplay svg { width: 16px; height: 16px; fill: currentColor; }
.vplay.playing svg { opacity: .5; }
.vbar {
  --p: 0%; flex: 1; height: 4px; border-radius: 2px; background: rgba(127,127,127,.35);
  background-image: linear-gradient(currentColor, currentColor); background-size: var(--p) 100%; background-repeat: no-repeat;
}
.vlen { font-size: 13px; opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------- action sheet (iOS) ---------- */
.as-scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
  animation: fade var(--dur-base) var(--ease-out);
}
.action-sheet { width: 100%; max-width: 420px; display: grid; gap: 8px; animation: up var(--dur-slow) var(--ease-out); }
.as-scrim.out { opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.as-scrim.out .action-sheet { transform: translateY(110%); transition: transform var(--dur-base) var(--ease-out); }
.as-group, .as-cancel {
  border-radius: 14px; overflow: hidden;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
}
.as-msg { margin: 0; padding: 14px 16px; font-size: 13px; line-height: 18px; color: var(--secondary); text-align: center; }
.as-btn {
  display: block; width: 100%; min-height: 57px; border: 0; background: none;
  font: inherit; font-size: 20px; line-height: 25px; color: var(--tint);
}
.as-go { color: var(--red); border-top: .5px solid var(--separator); }
.as-cancel.as-btn { font-weight: 600; background: color-mix(in srgb, var(--card) 96%, transparent); }
.as-btn:active { background: var(--fill); }

/* ---------- modal sheets (iOS page sheet) ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 10; animation: fade .25s ease-out; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 680px; margin: 0 auto; height: calc(100dvh - env(safe-area-inset-top) - 28px); max-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 12px 12px 0 0;
  box-shadow: 0 -2px 30px rgba(0, 0, 0, .25);
  animation: up .35s cubic-bezier(.2, .9, .25, 1);
}
.picker-sheet { z-index: 12; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--tertiary); margin: 6px auto 0; flex: none; }
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 52px; padding: 0 8px; flex: none;
}
.sheet-head h2 { grid-column: 2; margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.41px; text-align: center; }
.sheet-head .text-btn { grid-column: 3; justify-self: end; }
.text-btn { border: 0; background: none; color: var(--tint); font-size: 17px; font-weight: 600; min-height: 44px; padding: 0 8px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(env(safe-area-inset-bottom) + 24px); }
.outfit-card { margin: 16px 0; padding: 16px; border-radius: 16px; background: var(--card); }
.outfit-card img { display: block; width: min(100%, 300px); max-height: 360px; object-fit: contain; margin: 12px auto; border-radius: 10px; }
.outfit-form { display: grid; gap: 12px; padding: 12px 0; }
.outfit-form label { display: grid; gap: 6px; }
.outfit-form textarea, .outfit-form input:not([type=checkbox]) { width: 100%; max-width: 100%; box-sizing: border-box; font: inherit; padding: 10px; }
.outfit-days, .outfit-times, .outfit-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.outfit-days { padding: 12px; border: 1px solid #7778; border-radius: 8px; }
.outfit-days label { display: flex; align-items: center; min-height: 44px; }
.outfit-actions button, .outfit-form button, #outfitBody summary { min-height: 44px; padding: 10px; cursor: pointer; }
.outfit-times label { flex: 1; min-width: 100px; }

/* inset grouped list */
.group-title {
  font-size: 13px; line-height: 18px; text-transform: uppercase; letter-spacing: -.08px;
  color: var(--secondary); margin: 22px 16px 7px;
}
.group-title:first-child { margin-top: 8px; }
.group { background: var(--card); border-radius: 10px; overflow: hidden; }
.setting { position: relative; padding: 11px 16px 12px; }
.setting + .setting::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--separator);
}
.setting > label { display: block; font-size: 17px; line-height: 22px; font-weight: 400; }
.setting .hint { font-size: 13px; line-height: 18px; color: var(--secondary); margin: 2px 0 9px; }
.fixed .hint { margin-bottom: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row input, .row select, .row .picker {
  flex: 1; min-width: 0; min-height: 44px; font-size: 17px; color: var(--label);
  background: var(--fill); border: 0; border-radius: 10px; padding: 0 12px;
}
.row select { appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--secondary) 50%), linear-gradient(135deg, var(--secondary) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 30px; }
.row button {
  min-height: 44px; border: 0; border-radius: 10px; padding: 0 16px; font-size: 17px; font-weight: 600;
  background: var(--tint); color: #fff;
}
.row button:disabled { background: var(--fill-strong); color: var(--tertiary); }
.row button.ghost { background: var(--fill); color: var(--tint); font-weight: 400; }
.row .picker {
  text-align: left; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--secondary) 50%), linear-gradient(135deg, var(--secondary) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
button.link, .row button.link {
  flex: 0 1 auto; background: none; border: 0; color: var(--tint); font-size: 17px; font-weight: 400;
  padding: 0 2px; min-height: 44px; border-radius: 0;
}
.row button.link + button.link { margin-left: 18px; }
button.link.danger, .row button.link.danger { color: var(--red); }
.row button.ghost.danger { color: var(--red); }
#charText, #charSaved { display: grid; gap: 12px; }
#charText[hidden], #charSaved[hidden] { display: none; }

/* ---------- settings cells (iOS inset grouped rows) ---------- */
.group-wrap { margin-bottom: var(--space-2); }
.group-wrap > .group-title:first-child { margin-top: 26px; }
.profile-card + .group-wrap > .group-title:first-child { margin-top: 8px; }
.group-footer { font-size: 13px; line-height: 18px; color: var(--secondary); margin: 7px 16px 0; }
.cell {
  position: relative; display: block; width: 100%; text-align: left; border: 0; background: var(--card);
  padding: 11px 16px; min-height: 44px; color: var(--label);
}
.group > * { position: relative; }
.group > * + *::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; z-index: 1; border-top: .5px solid var(--separator);
}
.cell-main { display: flex; align-items: center; gap: var(--space-3); min-height: 22px; }
.cell-label { flex: 1; min-width: 0; font-size: 17px; line-height: 22px; }
.cell-ctl { display: flex; align-items: center; gap: var(--space-2); min-width: 0; max-width: 62%; color: var(--secondary); font-size: 17px; }
.cell-value { color: var(--secondary); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.cell-hint { font-size: 13px; line-height: 18px; color: var(--secondary); margin-top: 3px; }
.cell-hint:empty { display: none; }
.cell .note { margin-top: 6px; }
.cell.fixed .cell-ctl { font-size: 15px; }
/* Settings > Costs: the month's total over a bar per day, like Screen Time */
.cost-hero { display: grid; gap: 2px; margin: 8px 0 0; padding: 16px; border-radius: 10px; background: var(--card); }
.cost-label { font-size: 13px; font-weight: 600; color: var(--secondary); text-transform: uppercase; letter-spacing: .02em; }
.cost-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cost-sub { font-size: 15px; color: var(--secondary); font-variant-numeric: tabular-nums; min-height: 20px; }
.cost-chart { display: flex; align-items: flex-end; gap: 3px; height: 96px; margin-top: 14px; }
.cost-bar {
  flex: 1; min-width: 0; height: var(--h); padding: 0; border: 0; border-radius: 3px 3px 1px 1px;
  background: color-mix(in srgb, var(--tint) 45%, transparent); transition: background var(--dur-fast);
}
.cost-bar.today, .cost-bar.picked { background: var(--tint); }
.cost-chart:has(.picked) .cost-bar.today:not(.picked) { background: color-mix(in srgb, var(--tint) 45%, transparent); }
.cost-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--secondary); }
.cell.nav { cursor: pointer; }
.cell.nav:active, .profile-card:active { background: var(--fill); }
.cell.nav.action .cell-label { color: var(--tint); }
.cell.nav.danger .cell-label { color: var(--red); }
.chev { width: 8px; height: 14px; flex: none; fill: none; stroke: var(--tertiary); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-base) var(--ease-out); }
.cell.disclosure.open .chev { transform: rotate(90deg); }
.note.ok { color: var(--green); }

/* value menus: the native select sits on the right like an iOS pop-up button */
select.menu, button.menu {
  appearance: none; -webkit-appearance: none; min-width: 0; max-width: 100%; border: 0; background: none;
  color: var(--secondary); font-size: 17px; text-align: right; text-align-last: right; padding: 0 18px 0 0; min-height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 16'%3E%3Cpath d='M2 6l3-3 3 3M2 10l3 3 3-3' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 10px 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
button.menu.model {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 14'%3E%3Cpath d='M1.5 1.5 6.5 7l-5 5.5' fill='none' stroke='%23c4c4c7' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 8px 14px; padding-right: 20px;
}
.mini-play { width: 32px; height: 32px; flex: none; border: 0; border-radius: 50%; background: var(--fill); display: grid; place-items: center; }
.mini-play svg { width: 14px; height: 14px; fill: var(--tint); }

/* switches: Safari 17.4+ draws the native iOS switch for <input switch>; others get this copy */
input.switch { accent-color: var(--green); width: 51px; height: 31px; margin: 0; flex: none; }
.no-native-switch input.switch {
  appearance: none; -webkit-appearance: none; position: relative; border-radius: 16px; background: var(--fill-strong);
  transition: background var(--dur-base) var(--ease-out); cursor: pointer;
}
.no-native-switch input.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform var(--dur-base) var(--ease-spring);
}
.no-native-switch input.switch:checked { background: var(--green); }
.no-native-switch input.switch:checked::after { transform: translateX(20px); }

/* top of Settings */
.profile-card {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; margin: 8px 0 22px; padding: 12px 16px;
  border: 0; border-radius: var(--radius-card); background: var(--card); color: var(--label); text-align: left;
}
.profile-card .avatar { width: 60px; height: 60px; font-size: 24px; }
.profile-text { flex: 1; min-width: 0; }
.profile-name { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: .35px; }
.profile-sub { font-size: 15px; line-height: 20px; color: var(--secondary); }
.advanced[hidden] { display: none; }
.subcells > * { position: relative; }
.subcells > * + *::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--separator);
}
.cell-input { width: 100%; min-height: 22px; border: 0; background: none; outline: none; font-size: 17px; color: var(--label); padding: 0; }
.cell-input::placeholder { color: var(--tertiary); }
.cell-input.inline { width: 50%; text-align: right; color: var(--secondary); }
.cell.pick { cursor: pointer; }
.cell.pick .cell-main::after { content: ""; width: 20px; flex: none; }
.cell.pick.on .cell-main::after { content: "✓"; color: var(--tint); font-weight: 600; text-align: right; }
.row .play { width: 44px; flex: none; padding: 0; background: var(--fill); color: var(--tint); }
.row .play svg { fill: var(--tint); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; line-height: 16px; padding: 3px 9px; border-radius: 999px; background: var(--fill); color: var(--secondary); }
.chip.ok { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.chip.warn { color: var(--yellow-ink); background: var(--yellow-bg); }
.note { font-size: 13px; line-height: 18px; margin-top: 8px; color: var(--secondary); }
.note:empty { display: none; }
.note.bad { color: var(--red); }
.note.warn { color: var(--yellow-ink); background: var(--yellow-bg); padding: 8px 10px; border-radius: 10px; }

/* model picker */
.picker-search { padding: 0 16px 10px; flex: none; }
.picker-search input {
  width: 100%; min-height: 36px; font-size: 17px; color: var(--label); background: var(--fill);
  border: 0; border-radius: 10px; padding: 0 12px; outline: none;
}
.pick-group { font-size: 13px; text-transform: uppercase; color: var(--secondary); margin: 18px 16px 6px; }
.pick { display: block; width: 100%; text-align: left; border: 0; background: var(--card); padding: 11px 16px; min-height: 44px; }
.pick + .pick { border-top: .5px solid var(--separator); }
.pick:active:not(:disabled) { background: var(--fill); }
.pick.current .pick-name::after { content: " ✓"; color: var(--tint); }
.pick:disabled { opacity: .4; cursor: not-allowed; }
.pick-name { display: block; font-size: 17px; line-height: 22px; }
.pick-sub { display: block; font-size: 13px; line-height: 18px; color: var(--secondary); margin-top: 1px; overflow-wrap: anywhere; }

/* "what he sees" */
.dbg-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.dbg-block { margin: 16px 0; }
.dbg-block h3 { font-size: 13px; line-height: 18px; font-weight: 400; text-transform: uppercase; color: var(--secondary); margin: 0 16px 7px; }
.dbg-block pre {
  margin: 0; padding: 12px 16px; border-radius: 10px; background: var(--card);
  white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
  font: 13px/1.5 var(--mono); letter-spacing: 0;
}
.turn { font-size: 15px; line-height: 20px; padding: 10px 16px; background: var(--card); unicode-bidi: plaintext; }
.turn:first-of-type { border-radius: 10px 10px 0 0; }
.turn:last-child { border-radius: 0 0 10px 10px; }
.turn + .turn { border-top: .5px solid var(--separator); }
.turn b { color: var(--secondary); font-weight: 600; margin-right: 6px; }

/* memories, voices, import lists */
.mem {
  display: flex; gap: 12px; align-items: center; padding: 11px 16px; min-height: 44px;
  background: var(--card); border-bottom: .5px solid var(--separator);
}
.mem:first-of-type { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.mem:last-of-type { border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom: 0; }
.mem-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.mem-kind { font-size: 12px; line-height: 16px; text-transform: uppercase; color: var(--secondary); }
.mem-content { font-size: 17px; line-height: 22px; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.mem-date { font-size: 13px; color: var(--secondary); }
.mem-del {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 0;
  background: var(--fill); color: var(--secondary); font-size: 18px; line-height: 1;
}
.mem-del:hover { color: var(--red); }
.mem-del.use { width: auto; height: 30px; padding: 0 14px; border-radius: 15px; font-size: 15px; font-weight: 600; color: var(--tint); }
.mem .vplay { color: var(--tint); background: var(--fill); }
.pick-mem { cursor: pointer; }
.pick-mem input { width: 22px; height: 22px; flex: none; accent-color: var(--tint); }
#importBody > .muted { margin: 4px 4px 12px; }
#importText, .charform input:not([type=file]):not([type=checkbox]), .charform select, .charform textarea {
  width: 100%; font-size: 17px; line-height: 22px; color: var(--label); background: var(--card);
  border: 0; border-radius: 10px; padding: 11px 16px; resize: vertical; outline: none;
}
#importBody .row { margin: 10px 0 14px; }
#importFile { flex: 1; min-width: 0; font-size: 15px; color: var(--secondary); background: transparent; padding: 0; }
#importStep > p { margin: 10px 4px; }
.inline-btn {
  display: inline-flex; align-items: center; min-height: 36px; margin: 8px 0 0; border: 0; border-radius: 18px;
  padding: 0 16px; background: var(--tint); color: #fff; font-size: 15px; font-weight: 600;
}

/* character form */
.charform { display: grid; gap: 6px; padding-top: 4px; }
.charform > label { display: grid; gap: 6px; font-size: 13px; line-height: 18px; text-transform: uppercase; color: var(--secondary); margin-top: 14px; }
.charform > label > * { text-transform: none; }
.char-top { display: flex; gap: 16px; align-items: center; background: var(--card); border-radius: 10px; padding: 12px 16px; }
.char-top .grow { flex: 1; display: grid; gap: 8px; }
.char-top label { display: grid; gap: 4px; font-size: 13px; color: var(--secondary); }
.char-top input, .char-top select { background: var(--fill) !important; min-height: 40px; padding: 0 12px !important; }
#charAvatar { flex: none; } /* his face comes from His look; nothing is uploaded */
.charform .row { margin-top: 16px; }
.charform .row button { flex: 1; }
.char-group { font-size: 13px; line-height: 18px; text-transform: uppercase; color: var(--secondary); margin: 14px 4px 0; }
.char-group:first-child { margin-top: 4px; }
.char-more { display: grid; gap: 10px; }
.char-more > summary { color: var(--tint); font-size: 17px; line-height: 22px; padding: 11px 0; cursor: pointer; }
.char-more[open] > summary { margin-bottom: 2px; }
.char-more .row { margin-top: 4px; }
.look-box .note:empty, .char-more .note:empty { display: none; }
.fresh-row { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 10px; padding: 11px 16px; margin-top: 14px; }
.fresh-row label { flex: 1; display: grid; gap: 2px; font-size: 17px; line-height: 22px; color: var(--label); }
.fresh-row label span { font-size: 13px; line-height: 18px; color: var(--secondary); }
/* Try him: a throwaway chat inside Settings */
.try-box { display: grid; gap: 8px; }
.try-box[hidden] { display: none; }
.try-log { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.try-log:empty { display: none; }
.try-bubble { max-width: 80%; padding: 7px 12px; border-radius: 18px; font-size: 17px; line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.try-bubble.me { align-self: flex-end; background: var(--me); color: #fff; }
.try-bubble.him { align-self: flex-start; background: var(--him); color: var(--him-ink); }
.try-bubble.rtl { line-height: 25px; }
.try-box .row { margin-top: 0; }
.try-box .row input { flex: 1; min-width: 0; }
.try-box .row button { flex: none; }

/* A/B comparison */
table.ab { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; background: var(--card); border-radius: 10px; overflow: hidden; margin: 4px 0 12px; }
table.ab th, table.ab td { padding: 11px 12px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: .5px solid var(--separator); }
table.ab tr:last-child td { border-bottom: 0; }
table.ab th { font-size: 13px; font-weight: 600; color: var(--secondary); }
table.ab th:first-child, table.ab td:first-child { text-align: left; color: var(--secondary); }

/* ---------- lock / passkey ---------- */
/* covers the whole app (sheets, action sheets, the call screen) until Face ID, and in the app switcher */
.lock {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: grid; place-items: center; padding: 24px 24px calc(env(safe-area-inset-bottom) + 24px);
}
.lock-card { width: 100%; max-width: 360px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.lock-card h1 { margin: 6px 0 0; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .37px; }
.lock-card p { margin: 0; }
.avatar.big { width: 84px; height: 84px; font-size: 36px; }
.app-icon { width: 84px; height: 84px; border-radius: 19px; box-shadow: 0 8px 24px rgba(0,122,255,.28); }
.lock button.link { font-size: 15px; min-height: 44px; }
#setupBox, #unlockBox, #recoverBox, #encryptBox, #savedKeyBox { display: grid; gap: 12px; width: 100%; margin-top: 12px; }
#setupCode, #recoveryInput, #recoveryCheck {
  font-size: 22px; letter-spacing: .12em; text-align: center; color: var(--label);
  background: var(--card); border: 0; border-radius: 12px; min-height: 52px; font-variant-numeric: tabular-nums;
}
#recoveryInput, #recoveryCheck { font-size: 17px; letter-spacing: .04em; }
.recovery-key {
  font: 600 17px/1.5 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; word-break: break-all;
  background: var(--card); border-radius: 12px; padding: 14px; user-select: all; -webkit-user-select: all;
}
.primary {
  width: 100%; min-height: 50px; border: 0; border-radius: 14px; background: var(--tint); color: #fff;
  font-size: 17px; font-weight: 600;
}
.primary:active { opacity: .8; }

/* ---------- call (FaceTime style) ---------- */
.call {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 64px) 24px calc(env(safe-area-inset-bottom) + 36px);
  background: radial-gradient(120% 80% at 50% 0%, #3a3a3c 0%, #1c1c1e 45%, #000 100%);
  color: #fff; text-align: center; letter-spacing: -.41px;
}
.call-top { display: grid; justify-items: center; gap: 6px; }
.call-timer:empty { display: none; }
.call .avatar.big { width: 120px; height: 120px; font-size: 48px; background: linear-gradient(180deg, #a5abb8, #858994); }

/* presence: his voice drives the glow (--him, 0..1), yours a thin ring (--me) */
.call-orb { position: relative; width: 120px; height: 120px; margin-bottom: 22px; --him: 0; --me: 0; }
.call-orb .avatar.big { position: relative; z-index: 1; }
.call-orb .ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.ring.him {
  background: radial-gradient(closest-side, rgba(255,255,255,.34), rgba(255,255,255,.08) 70%, transparent);
  transform: scale(calc(1.08 + var(--him) * .75)); opacity: calc(.15 + var(--him) * 1.4);
  transition: transform 90ms linear, opacity 90ms linear;
}
.ring.me { box-shadow: 0 0 0 2px rgba(255,255,255,.5); transform: scale(calc(1.03 + var(--me) * .18)); opacity: calc(var(--me) * 2.2); transition: transform 90ms linear, opacity 90ms linear; }
.call-orb.speaking .ring.him { animation: breathe 1.8s ease-in-out infinite; }
.call-orb.thinking .ring.him { animation: think 1.1s ease-in-out infinite; }
.call-orb.initializing .ring.him { animation: think 1.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { scale: 1; } 50% { scale: 1.06; } }
@keyframes think { 0%, 100% { opacity: .12; } 50% { opacity: .4; } }
.call-net {
  margin-top: 10px; font-size: 13px; line-height: 18px; padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 159, 10, .2); color: #ffd60a;
}
.call-name { font-size: 34px; line-height: 41px; font-weight: 600; }
.call-status { font-size: 17px; color: rgba(235,235,245,.6); }
.call-timer { font-size: 15px; color: rgba(235,235,245,.6); font-variant-numeric: tabular-nums; }
.call-latency {
  margin-top: 8px; font-size: 13px; padding: 4px 12px; border-radius: 999px;
  background: rgba(255,255,255,.12); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.call-mode, .call-error {
  max-width: 340px; margin-top: 12px; font-size: 15px; line-height: 20px; padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,.1); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.call-error { background: rgba(255,69,58,.18); }
.call-notice { margin-top: 10px; font-size: 13px; line-height: 18px; color: rgba(235,235,245,.6); }
.call-actions { display: flex; justify-content: center; gap: 56px; }
.round-wrap { display: grid; justify-items: center; gap: 8px; font-size: 13px; color: rgba(235,235,245,.85); }
.round {
  width: 72px; height: 72px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255,255,255,.18); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.round svg { width: 30px; height: 30px; fill: #fff; }
.round.off { background: #fff; }
.round.off svg { fill: #000; }
.round.hang { background: #ff3b30; }
.round.go { background: #34c759; }
.call:not(.ended) #callBackWrap, .call.ended #muteWrap { display: none; }
.call-orb.muted .ring.me { opacity: 0; }
.round:active { filter: brightness(.85); }

/* rating after a call */
.rate {
  display: grid; gap: 12px; justify-items: center; margin-top: 18px; width: 100%; max-width: 340px; padding: 18px;
  border-radius: 18px; background: rgba(255,255,255,.1); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.rate-engine { font-size: 17px; line-height: 22px; font-weight: 600; }
.stars { display: flex; gap: 4px; }
.stars button { width: 44px; height: 44px; font-size: 32px; line-height: 1; border: 0; background: none; color: rgba(255,255,255,.25); }
.stars button.on { color: #ffd60a; }
#rateNote {
  width: 100%; font-size: 17px; border-radius: 10px; border: 0; min-height: 44px; padding: 0 12px;
  background: rgba(255,255,255,.14); color: #fff;
}
#rateNote::placeholder { color: rgba(235,235,245,.45); }
.rate-actions { display: flex; gap: 12px; width: 100%; }
.rate-actions button { flex: 1; min-height: 44px; border: 0; border-radius: 12px; font-size: 17px; font-weight: 600; }
#rateSend { background: #fff; color: #000; }
#rateSend:disabled { opacity: .4; }
#rateSkip { background: rgba(255,255,255,.14); color: #fff; }

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  :root { --separator: rgba(60, 60, 67, .6); --secondary: rgba(60, 60, 67, .85); }
}

/* disappearing messages */
.msg.vanishing {
  opacity: 0; height: 0 !important; padding-top: 0; padding-bottom: 0; margin-top: 0 !important; margin-bottom: 0;
  overflow: hidden; filter: blur(2px);
  transition: opacity .5s ease-out, filter .5s ease-out, height .35s .45s var(--ease-out), padding .35s .45s var(--ease-out), margin .35s .45s var(--ease-out);
}
@media (prefers-reduced-motion: reduce) { .msg.vanishing { transition: none; } }

/* his look */
.look-box { display: grid; gap: 10px; margin: 6px 0 14px; }
.preset-list { display: grid; gap: 8px; }
.preset-row { display: flex; align-items: center; gap: 12px; }
.charform .preset-row.row button { flex: none; padding: 0 18px; }
.preset-row .grow { min-width: 0; }
.preset-name { font-weight: 600; }
.preset-blurb { color: var(--secondary); font-size: 13px; line-height: 18px; }
.look-title { font-weight: 600; }
.look-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.look-grid:empty { display: none; }
.look-pick { padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: none; }
.look-pick img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.msg.photo { padding: 0; background: none; overflow: hidden; }
.msg.photo img { display: block; max-width: 220px; width: 100%; border-radius: 18px; }
#charText > label, .char-more > label { display: grid; gap: 6px; font-size: 13px; line-height: 18px; color: var(--secondary); }

/* ---------- gallery (Settings > Photos): like iPhone Photos, and nothing leaves the app ---------- */
.gallery {
  position: fixed; inset: 0; z-index: 13; display: flex; flex-direction: column;
  background: var(--chat-bg); animation: up var(--dur-slow) var(--ease-out);
}
.gallery.closing { transform: translateY(100%); transition: transform var(--dur-base) var(--ease-out); }
/* his photos stay inside the app: no long-press "Save to Photos", no dragging them out */
.gallery img, .msg.photo img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.gal-head {
  flex: none; padding-top: env(safe-area-inset-top); background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--separator); position: relative; z-index: 2;
}
.gal-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; padding: 0 8px; }
.gal-nav > :first-child { justify-self: start; }
.gal-nav > :last-child { justify-self: end; }
.gal-title { display: grid; justify-items: center; line-height: 1.15; }
.gal-title h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.41px; }
.gal-title span { font-size: 12px; color: var(--secondary); min-height: 14px; }
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 4px 16px 8px; padding: 2px;
  border-radius: 9px; background: var(--fill);
}
.seg button {
  border: 0; border-radius: 7px; background: none; color: var(--label); font: inherit; font-size: 13px; font-weight: 500;
  min-height: 30px; padding: 0 4px; white-space: nowrap; transition: background var(--dur-fast);
}
.seg button[aria-selected="true"] { background: var(--card); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); font-weight: 600; }
.gal-scroll {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  touch-action: pan-y; padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}
.gallery.selecting .gal-scroll { padding-bottom: calc(env(safe-area-inset-bottom) + 64px); }
.gal-note { margin: 12px 16px 4px; font-size: 13px; color: var(--secondary); text-align: center; }
.gal-day {
  position: sticky; top: 0; z-index: 1; margin: 0; padding: 14px 16px 8px; font-size: 17px; font-weight: 600;
  background: linear-gradient(var(--chat-bg) 60%, transparent);
}
.gal-grid { --cols: 3; display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 2px; }
.gallery.dense .gal-grid { --cols: 5; }
.gal-flat { padding-top: 2px; }
.gal-tile {
  position: relative; padding: 0; border: 0; border-radius: 0; background: var(--fill); aspect-ratio: 1;
  overflow: hidden; content-visibility: auto; contain-intrinsic-size: 130px 130px;
}
.gal-tile img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--dur-base); }
.gal-tile img.ready { opacity: 1; }
.gal-tile .gal-fav {
  position: absolute; left: 5px; bottom: 5px; width: 15px; height: 15px; display: none;
  fill: #fff; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .55));
}
.gal-tile.fav .gal-fav { display: block; }
.gal-tile .gal-left {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 4px 4px; text-align: center;
  font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .45));
}
.gal-check {
  position: absolute; right: 5px; bottom: 5px; width: 23px; height: 23px; border-radius: 50%;
  border: 1.5px solid #fff; box-shadow: 0 0 3px rgba(0, 0, 0, .45); display: none;
}
.gallery.selecting .gal-check { display: block; }
.gal-tile.picked::after { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .28); }
.gal-tile.picked .gal-check {
  z-index: 1; background: var(--tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1.5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.gallery.dense .gal-check { width: 18px; height: 18px; right: 3px; bottom: 3px; }
.gal-empty { display: grid; justify-items: center; gap: 6px; padding: 96px 32px 0; text-align: center; }
.gal-empty svg { width: 56px; height: 56px; fill: none; stroke: var(--tertiary); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.gal-empty h3 { margin: 6px 0 0; font-size: 22px; font-weight: 700; }
.gal-empty p { margin: 0; font-size: 15px; color: var(--secondary); }
.gal-foot { margin: 16px; text-align: center; font-size: 15px; font-weight: 600; color: var(--label); }
.gal-foot:empty { display: none; }
.gal-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 49px; padding: 0 8px env(safe-area-inset-bottom); background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--separator);
}
.gal-bar > :first-child, .gal-bar > #galleryErase { justify-self: start; }
.gal-bar > :last-child, .gal-bar > #galleryRecover { justify-self: end; }
.gal-bar .gal-count { grid-column: 2; font-size: 13px; font-weight: 600; text-align: center; }
.gal-bar #galleryErase { grid-column: 1; grid-row: 1; }
.gal-bar #galleryRecover { grid-column: 3; grid-row: 1; }
.gal-bar #galleryFav { grid-column: 1; grid-row: 1; }
.gal-bar #galleryDelete { grid-column: 3; grid-row: 1; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: none; color: var(--tint);
}
.icon-btn svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { color: var(--tertiary); }
.icon-btn.on .heart { fill: currentColor; }
.text-btn.danger { color: var(--red); }
.text-btn:disabled { color: var(--tertiary); }
.gal-bar .icon-btn.danger { color: var(--tint); }

/* the photo, full screen: swipe between, pinch or double-tap to zoom, swipe down to close, tap for chrome */
.gal-view { position: absolute; inset: 0; z-index: 3; background: #000; color: #fff; overflow: hidden; }
.gal-view.opening { animation: fade var(--dur-base) ease-out; }
.gv-pager { position: absolute; inset: 0; overflow: hidden; touch-action: none; overscroll-behavior: none; }
.gv-track { display: flex; gap: 20px; height: 100%; will-change: transform; }
.gv-track.settle { transition: transform 320ms cubic-bezier(.25, .9, .3, 1); }
.gv-slide { position: relative; flex: 0 0 100%; height: 100%; overflow: hidden; }
.gv-slide img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0;
  will-change: transform;
}
.gv-slide img.settle { transition: transform var(--dur-base) var(--ease-out); }
.gv-top, .gv-bottom {
  position: absolute; left: 0; right: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 8px; background: rgba(20, 20, 22, .55);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  transition: opacity var(--dur-base);
}
.gv-top { top: 0; min-height: 44px; padding-top: env(safe-area-inset-top); }
.gv-bottom { bottom: 0; min-height: 49px; padding-bottom: env(safe-area-inset-bottom); }
.gal-view.bare .gv-top, .gal-view.bare .gv-bottom { opacity: 0; pointer-events: none; }
.gv-top .text-btn, .gv-bottom .icon-btn, .gv-bottom .text-btn:not(.danger) { color: #fff; }
.gv-top .text-btn svg { width: 12px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.gv-when { display: grid; justify-items: center; line-height: 1.2; }
.gv-when b { font-size: 15px; font-weight: 600; }
.gv-when span { font-size: 12px; color: rgba(255, 255, 255, .7); }
.gv-bottom > :first-child, .gv-bottom #gvErase { grid-column: 1; grid-row: 1; justify-self: start; }
.gv-bottom #gvDelete, .gv-bottom #gvRecover { grid-column: 3; grid-row: 1; justify-self: end; }
.gv-left { grid-column: 2; font-size: 13px; color: rgba(255, 255, 255, .7); }
#gvFav.on { color: #fff; }
#gvFav.pop svg { animation: pop .35s var(--ease-spring); }
@keyframes pop { 40% { transform: scale(1.3); } }
@media (prefers-reduced-motion: reduce) {
  .gallery, .gal-view.opening, #gvFav.pop svg { animation: none; }
  .gallery.closing, .gv-slide img.settle, .gv-track.settle, .gal-tile img { transition: none; }
}
