/* Day Pages */
:root {
  --paper: #f6f3ee;
  --card: #fffdf9;
  --ink: #2b2a28;
  --muted: #7d776d;
  --line: #ddd6ca;
  --accent: #58705a;
  --accent-ink: #ffffff;
  --danger: #a4463a;
  --seen: #bfe6ff;
  --fs: 17px;
  color-scheme: light;
}
body.t-dark {
  --paper: #1c1b1a;
  --card: #262422;
  --ink: #ebe6dd;
  --muted: #9a9388;
  --line: #3a3733;
  --accent: #8fae90;
  --accent-ink: #172018;
  --danger: #e08a7d;
  --seen: #0d4f80;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  body.t-auto {
    --paper: #1c1b1a;
    --card: #262422;
    --ink: #ebe6dd;
    --muted: #9a9388;
    --line: #3a3733;
    --accent: #8fae90;
    --accent-ink: #172018;
    --danger: #e08a7d;
    --seen: #0d4f80;
    color-scheme: dark;
  }
}
body.s-s { --fs: 15px; }
body.s-m { --fs: 17px; }
body.s-l { --fs: 20px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--fs);
  line-height: 1.45;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

#cover { display: flex; flex-direction: column; height: 100%; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.title {
  margin: 0; font-size: 22px; font-weight: 650; letter-spacing: 0.01em;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; touch-action: none; cursor: default;
  /* A bigger area to hold than the word itself, with no change to how it looks. */
  padding: 12px 48px 12px 0; margin: -12px 0;
}
.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--muted); }
.icon-btn:active { background: var(--line); }

#main { flex: 1 1 auto; overflow: hidden; position: relative; }
.page { display: none; position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 90px; }
.page.active { display: block; }

.tabs {
  flex: 0 0 auto; display: flex; border-top: 1px solid var(--line); background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs button { flex: 1; padding: 8px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; }
.tabs button.on { color: var(--accent); }
body.focus .tabs, body.focus .top { display: none; }

.search input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  -webkit-appearance: none; appearance: none;
}
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; display: block; width: 100%; text-align: left; }
.item:active { border-color: var(--accent); }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text { color: var(--muted); font-size: 0.9em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.item-meta { color: var(--muted); font-size: 0.78em; margin-top: 6px; display: flex; gap: 10px; }
.empty { color: var(--muted); text-align: center; margin: 48px 20px; }
.group-title { color: var(--muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.06em; margin: 18px 4px 8px; }

.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.page:not(.active) .fab { display: none; }

.daybar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.daylabel { font-weight: 600; padding: 8px 12px; border-radius: 10px; }
.daylabel:active { background: var(--line); }

.editbar { display: flex; justify-content: space-between; align-items: center; margin: -4px -6px 8px; }
.text-btn { padding: 8px 10px; border-radius: 8px; color: var(--accent); font-weight: 600; }
.text-btn:active { background: var(--line); }
.text-btn.danger, .row-btn.danger { color: var(--danger); }
.text-btn.light { color: #fff; }
.text-btn[disabled] { opacity: 0.4; }

.editor input.e-title {
  width: 100%; border: 0; background: transparent; font-size: 1.25em; font-weight: 650; padding: 4px 0 8px; outline: none;
}
.editor textarea.e-body {
  width: 100%; min-height: 34vh; border: 0; background: transparent; resize: none; outline: none; padding: 0; line-height: 1.5;
}
.e-files { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.e-photo { width: 96px; height: 96px; border-radius: 10px; background-size: cover; background-position: center; border: 1px solid var(--line); position: relative; }
.e-voice { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; width: 100%; }
.e-voice audio { flex: 1; height: 36px; min-width: 0; }
.e-x { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 15px; line-height: 26px; text-align: center; flex: 0 0 auto; }
.e-photo .e-x { position: absolute; top: -8px; right: -8px; }
.e-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 0.9em; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { border-color: var(--danger); color: var(--danger); }
.chip input[type="date"] { border: 0; background: transparent; padding: 0; min-width: 0; -webkit-appearance: none; appearance: none; }
.e-saved { color: var(--muted); font-size: 0.78em; margin-top: 10px; min-height: 1.2em; }

.rem-row { display: flex; align-items: flex-start; gap: 12px; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); flex: 0 0 auto; margin-top: 2px; }
.tick.on { background: var(--accent); border-color: var(--accent); }
.rem-body { flex: 1; min-width: 0; text-align: left; }
.done .item-title { text-decoration: line-through; color: var(--muted); }
.late { color: var(--danger); }

#page-camera { padding: 0; background: #000; }
#page-camera video { width: 100%; height: 100%; object-fit: cover; }
.cambar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 22px calc(env(safe-area-inset-bottom, 0px) + 22px); background: linear-gradient(transparent, rgba(0, 0, 0, 0.55)); }
.shutter { width: 68px; height: 68px; border-radius: 50%; background: #fff; border: 4px solid rgba(255, 255, 255, 0.5); background-clip: padding-box; }
.shutter:active { transform: scale(0.94); }
.shutter.rec { background: #d6453b; }
.cam-note { position: absolute; left: 24px; right: 24px; top: 40%; color: #fff; text-align: center; }

.h2 { font-size: 1.3em; margin: 4px 2px 14px; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-btn { display: block; width: 100%; text-align: left; padding: 14px; }
.row-btn:active { background: var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { padding: 6px 10px; font-size: 0.85em; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.about { color: var(--muted); text-align: center; font-size: 0.85em; margin-top: 28px; }

.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.sheet p { margin: 0 0 14px; }
.sheet-btns { display: flex; justify-content: flex-end; gap: 6px; }

/* ---- full-screen layer ---- */
#layer:empty { display: none; }
#layer { position: fixed; inset: 0; z-index: 20; }
.ov { position: absolute; inset: 0; background: var(--paper); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top, 0px) + 18px) 22px calc(env(safe-area-inset-bottom, 0px) + 18px); overflow-y: auto; }
.ov-head { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.ov h2 { font-size: 1.25em; margin: 18px 0 6px; }
.ov p.sub { color: var(--muted); margin: 0 0 18px; }
.ov label { display: block; font-size: 0.85em; color: var(--muted); margin: 14px 0 6px; }
.ov input.f {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); outline: none;
  -webkit-appearance: none; appearance: none;
}
.ov input.f:focus { border-color: var(--accent); }
.ov input.m { -webkit-text-security: disc; }
.ov input.f.bad { border-color: var(--danger); border-width: 2px; }
.ov input.f + .msg { margin-top: 6px; min-height: 0; }
.ov .peek { align-self: flex-start; margin-top: 10px; font-size: 0.9em; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 650; margin-top: 22px; text-align: center; }
.btn[disabled] { opacity: 0.5; }
.btn.alt { background: transparent; color: var(--accent); border: 1px solid var(--line); margin-top: 12px; }
.msg { color: var(--danger); min-height: 1.4em; margin-top: 12px; font-size: 0.9em; }
.codebox { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05em; letter-spacing: 0.04em; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; line-height: 1.9; word-spacing: 0.3em; -webkit-user-select: text; user-select: text; }
.busy { color: var(--muted); text-align: center; margin-top: 30vh; }

.kp { align-items: center; justify-content: center; touch-action: none; overscroll-behavior: contain; }
.kp .btn { touch-action: none; -webkit-user-select: none; user-select: none; }
.kp-dots { display: flex; gap: 12px; height: 18px; margin: 10px 0 34px; min-width: 40px; justify-content: center; }
.kp-dots i { width: 13px; height: 13px; border-radius: 50%; background: var(--ink); display: block; }
.kp-hint { color: var(--muted); min-height: 1.4em; text-align: center; }
.kp-grid { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 22px; }
.kp-grid button { width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 26px; -webkit-user-select: none; user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
.kp-grid button:active { background: var(--line); }
.kp-grid button.plain { border-color: transparent; background: transparent; font-size: 16px; color: var(--muted); }

.pv { padding: 0; }
.pv-top { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 8px 18px; border-bottom: 1px solid var(--line); }
.pv-name { font-weight: 650; }
.pv-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pv-tabs { display: flex; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.pv-tabs button { flex: 1; padding: 12px 4px; color: var(--muted); font-size: 0.85em; }
.pv-tabs button.on { color: var(--accent); font-weight: 650; }
.pv-pane { display: none; }
.pv-pane.on { display: block; flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.pv-pane[data-pane="chat"].on { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.ch-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ch-list > :first-child { margin-top: auto; }
.ch-day { align-self: center; color: var(--muted); font-size: 0.75em; margin: 10px 0 4px; }
.ch-vanish { align-self: center; display: flex; align-items: flex-start; gap: 6px; max-width: 300px; margin: 6px auto 8px; padding: 7px 11px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 0.75em; line-height: 1.35; text-align: center; }
.ch-vanish svg { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.ch-more { align-self: center; color: var(--accent); font-size: 0.85em; padding: 8px 12px; }
.ch-msg { max-width: 82%; padding: 8px 12px 6px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ch-msg.them { align-self: flex-start; border-bottom-left-radius: 5px; }
.ch-msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: transparent; border-bottom-right-radius: 5px; }
.ch-msg.failed { opacity: 0.8; }
.ch-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-text.bad { font-style: italic; opacity: 0.8; }
.ch-meta { display: flex; justify-content: flex-end; gap: 6px; font-size: 0.7em; margin-top: 2px; }
.ch-meta span { opacity: 0.7; }
.ch-meta .late { color: inherit; opacity: 1; font-weight: 650; }
.ch-meta { align-items: center; }
.ch-meta .tick { display: inline-flex; }
.ch-meta .tick.read { opacity: 1; color: var(--seen); }
.ch-err { color: var(--danger); font-size: 0.85em; margin: 0; padding: 4px 14px; }
.ch-err:empty { display: none; }
.ch-bar { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); }
.ch-in { flex: 1; min-width: 0; resize: none; border: 1px solid var(--line); border-radius: 18px; background: var(--card); padding: 9px 14px; max-height: 120px; outline: none; font-size: max(1em, 16px); line-height: 1.35; -webkit-appearance: none; appearance: none; }
.ch-in:focus { border-color: var(--accent); }
.ch-send { padding: 10px 16px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); font-weight: 650; }

.pv-warn { display: none; }
.pv.warned .pv-body, .pv.warned .pv-tabs { display: none; }
.pv.warned .pv-warn { display: block; flex: 1; min-height: 0; overflow-y: auto; padding: 8px 22px 22px; }
.pv-ask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-end; justify-content: center; z-index: 5; }
.ov p.sub.foot { margin-top: 22px; font-size: 0.9em; }
.pv-backup { font-size: 0.85em; margin: 14px 2px 0; color: var(--muted); }

.sheet-btns.tall { flex-direction: column; align-items: stretch; gap: 0; }
.sheet-btns.tall .text-btn { align-self: flex-end; margin-top: 6px; }
.btn.alt.danger { color: var(--danger); }

/* pictures and videos in the conversation */
.ch-add { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--accent); font-size: 24px; line-height: 1; }
.ch-pic { position: relative; max-width: 100%; border-radius: 10px; margin: 0 -4px 2px; background-color: rgba(0, 0, 0, 0.25); background-size: cover; background-position: center; -webkit-touch-callout: none; }
.ch-play { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); }
.ch-play::after { content: ""; position: absolute; left: 18px; top: 13px; border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent #fff; }
.ch-len { position: absolute; right: 6px; bottom: 6px; font-size: 0.7em; color: #fff; background: rgba(0, 0, 0, 0.55); border-radius: 6px; padding: 1px 6px; }

/* camera */
.pv-pane.cm.on { position: relative; padding: 0; overflow: hidden; background: #000; color: #fff; }
.cm-live { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cm-top { position: absolute; left: 0; right: 0; top: 10px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.cm .seg { border-color: rgba(255, 255, 255, 0.5); background: rgba(0, 0, 0, 0.35); }
.cm .seg button { color: #fff; padding: 8px 16px; }
.cm .seg button.on { background: #fff; color: #000; }
.cm-timer { font-variant-numeric: tabular-nums; background: rgba(0, 0, 0, 0.5); border-radius: 8px; padding: 4px 8px; font-size: 0.85em; }
.cm-timer:empty { display: none; }
.cm-timer.late { background: #d6453b; color: #fff; }
.cm-note { position: absolute; left: 24px; right: 24px; top: 38%; text-align: center; margin: 0; }
.cm-said { position: absolute; left: 16px; right: 16px; bottom: 112px; text-align: center; margin: 0; font-size: 0.85em; text-shadow: 0 1px 3px #000; }
.cm-bar { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 16px 22px 20px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); }
.cm-last { width: 52px; height: 52px; border-radius: 10px; border: 2px solid #fff; background-color: #222; background-size: cover; background-position: center; justify-self: start; }
.cm-shoot { grid-column: 2; width: 70px; height: 70px; border-radius: 50%; background: #fff; border: 4px solid rgba(255, 255, 255, 0.5); background-clip: padding-box; }
.cm-shoot:active { transform: scale(0.94); }
.cm-shoot.video { background: #d6453b; }
.cm-shoot.on { border-radius: 18px; transform: scale(0.72); }
.cm-bar .text-btn { grid-column: 3; justify-self: end; }

/* vault */
.vt-head { margin: 0 2px 10px; }
.vt-line { margin: 0 0 2px; font-weight: 650; }
.vt-line.sub { font-weight: 400; color: var(--muted); font-size: 0.82em; }
.vt-line:empty { display: none; }
.vt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.vt-said { color: var(--muted); font-size: 0.85em; margin: 0 2px 8px; }
.vt-said:empty { display: none; }
.vt-pick { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 2px 4px 2px 12px; margin-bottom: 10px; font-size: 0.9em; }
.vt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.vt-cell { position: relative; aspect-ratio: 1; background-color: var(--line); background-size: cover; background-position: center; border-radius: 4px; -webkit-touch-callout: none; }
.vt-cell.chosen { outline: 3px solid var(--accent); outline-offset: -3px; opacity: 0.75; }
.vt-badge { position: absolute; right: 4px; bottom: 4px; font-size: 0.68em; color: #fff; background: rgba(0, 0, 0, 0.6); border-radius: 6px; padding: 1px 5px; }
.vt-mark { position: absolute; right: 5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }

/* looking at one picture or video */
.vw { position: absolute; inset: 0; z-index: 3; background: #000; color: #fff; display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.vw-top { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 6px 8px; }
.vw-title { font-size: 0.8em; opacity: 0.8; }
.vw-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vw-photo { flex: 1; min-height: 0; background-size: contain; background-position: center; background-repeat: no-repeat; }
.vw-video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.vw-controls { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.vw-scrub { flex: 1; min-width: 0; accent-color: #fff; }
.vw-time { font-size: 0.78em; font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: right; }
.vw-note { text-align: center; margin: 0; padding: 4px 16px; font-size: 0.85em; min-height: 1.6em; }
.vw-bar { display: flex; gap: 10px; padding: 4px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.vw-bar .btn { margin-top: 0; }
.vw-bar .btn.alt { border-color: rgba(255, 255, 255, 0.4); }

/* ---- calls ---- */
.pv-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-calls { display: flex; gap: 2px; margin-right: 6px; }
.pv-calls .icon-btn { color: var(--accent); }
.pv-calls .icon-btn[disabled] { opacity: 0.35; }
.ch-call { align-self: center; font-size: 0.8em; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; margin: 6px 0; }
.ch-call.missed { color: var(--danger); }
.ch-left { font-style: italic; }
.cl { position: absolute; inset: 0; z-index: 5; background: #1d2420; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 60px) 20px calc(env(safe-area-inset-bottom, 0px) + 40px); -webkit-user-select: none; user-select: none; }
.cl[hidden] { display: none; }
.cl-head { text-align: center; position: relative; z-index: 2; }
.cl-name { font-size: 1.6em; font-weight: 650; }
.cl-status { margin-top: 8px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.cl-row { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; position: relative; z-index: 2; }
.cl-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #fff; font-size: 0.8em; min-width: 72px; }
.cl-btn i { display: block; width: 66px; height: 66px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.cl-btn.yes i { background: #3f9a52; }
.cl-btn.no i { background: #d6453b; }
.cl-btn.tog.on i { background: #fff; }
.cl-btn[hidden] { display: none; }
.cl-video { padding-top: calc(env(safe-area-inset-top, 0px) + 24px); }
.cl-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: 0; }
.cl-local { position: absolute; right: 14px; top: calc(env(safe-area-inset-top, 0px) + 14px); width: 28%; max-width: 140px; border-radius: 12px; z-index: 1; background: #000; transform: scaleX(-1); }
.cl-local[hidden] { display: none; }
.cl-video .cl-head { text-shadow: 0 1px 4px #000; }
.cl-audio { display: none; }
.cl-btn i { display: flex; align-items: center; justify-content: center; }
.cl-btn i svg { width: 30px; height: 30px; color: #fff; }
.cl-btn.no i svg { transform: rotate(135deg); }

/* ---- settings and the guide ---- */
.sheet p { white-space: pre-line; }
.val-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.val-row .val, .row .val { color: var(--muted); }
.row-btn[hidden] { display: none; }
.row-btn[disabled] { opacity: 0.5; }
.group .row-btn + .row-btn { border-top: 1px solid var(--line); }
.wipe-group { margin-top: 26px; }
.pv-guide { position: absolute; inset: 0; z-index: 6; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.guide { background: var(--card); width: 100%; max-width: 520px; max-height: 92%; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 18px); }
.guide-list { margin: 6px 0 0; padding-left: 1.3em; }
.guide-list li { margin-bottom: 12px; }
.guide-list strong { display: block; }
.guide-list span { color: var(--muted); }

/* links, voice notes */
.ch-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; -webkit-touch-callout: none; }
.ch-voice { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 2px 0 2px; }
.ch-vplay { display: flex; align-items: center; justify-content: center; padding: 0; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.12); color: inherit; -webkit-tap-highlight-color: transparent; }
.ch-msg.me .ch-vplay { background: rgba(255, 255, 255, 0.22); }
.ch-vbar { flex: 1; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.15); overflow: hidden; }
.ch-msg.me .ch-vbar { background: rgba(255, 255, 255, 0.3); }
.ch-vbar i { display: block; height: 100%; width: 0; background: currentColor; border-radius: 2px; }
.ch-vtime { font-size: 0.8em; min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.ch-mic { display: flex; align-items: center; justify-content: center; padding: 0; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--accent); }
.ch-rec { display: none; flex: 1; align-items: center; gap: 10px; min-width: 0; }
.ch-bar.rec > :not(.ch-rec) { display: none; }
.ch-bar.rec .ch-rec { display: flex; }
.ch-recbin { padding: 10px 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); color: var(--danger); font-weight: 600; }
.ch-recdot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: ch-blink 1s infinite; }
.ch-rectime { font-variant-numeric: tabular-nums; font-weight: 600; }
.ch-reclabel { flex: 1; color: var(--muted); font-size: 0.9em; }
@keyframes ch-blink { 50% { opacity: 0.25; } }

/* adding from the phone's own photos: a real file box, kept out of sight, with a label as the button */
.pick-box { position: fixed; left: -200px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.vt-add, .ov label.vt-add { display: flex; margin: 0; font-size: 1em; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 650; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.vt-add::before { content: "+"; font-size: 1.35em; line-height: 1; font-weight: 500; }
.vt-add:active { opacity: 0.85; }
.vt-addnote { color: var(--muted); font-size: 0.8em; text-align: center; margin: 6px 0 12px; }

/* replies, reactions and the message menu */
.ch-msg { position: relative; transition: transform 0.18s ease; touch-action: pan-y; }
.ch-msg.held { filter: brightness(0.92); }
.ch-msg.to-reply::before { content: "↩"; position: absolute; left: -34px; top: 50%; margin-top: -0.6em; font-size: 1.1em; color: var(--accent); }
.ch-msg.glow { animation: ch-glow 1.4s ease; }
@keyframes ch-glow { 0%, 40% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.ch-msg.reacted { margin-bottom: 16px; }
.ch-reacts { position: absolute; bottom: -15px; display: inline-flex; gap: 1px; padding: 1px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 15px; line-height: 1.45; color: var(--ink, inherit); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.ch-msg.them .ch-reacts { left: 10px; }
.ch-msg.me .ch-reacts { right: 10px; }
.ch-quote { border-left: 3px solid currentColor; background: rgba(0, 0, 0, 0.07); border-radius: 8px; padding: 4px 8px; margin: 0 -4px 5px; font-size: 0.85em; cursor: pointer; }
.ch-msg.me .ch-quote { background: rgba(255, 255, 255, 0.16); }
.ch-quote-who { font-weight: 650; }
.ch-quote-who:empty { display: none; }
.ch-quote-what { opacity: 0.85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ch-reply { display: flex; align-items: center; gap: 8px; margin: 0 10px; padding: 6px 6px 6px 10px; border-left: 3px solid var(--accent); background: var(--card); border-radius: 8px 8px 0 0; border-top: 1px solid var(--line); }
.ch-reply[hidden] { display: none; }
.ch-reply-body { flex: 1; min-width: 0; font-size: 0.85em; }
.ch-reply-who { font-weight: 650; color: var(--accent); }
.ch-reply-what { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-reply-x { width: 34px; height: 34px; border-radius: 50%; font-size: 22px; color: var(--muted); }
.ch-toast { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.78); color: #fff; padding: 7px 14px; border-radius: 999px; font-size: 0.85em; z-index: 4; max-width: 86%; text-align: center; }
.ch-toast[hidden] { display: none; }
.pv-pane[data-pane="chat"].on { position: relative; }
.ch-quick { display: flex; justify-content: space-between; gap: 4px; padding: 0 0 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.ch-emo { width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
.ch-emo:active { transform: scale(1.15); }
.ch-emo.on { background: var(--line); }
.ch-emo.more { font-size: 24px; color: var(--muted); border: 1px solid var(--line); }
.ch-picker { max-height: 70%; display: flex; flex-direction: column; padding-top: 12px; }
.ch-picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ch-picker-scroll { overflow-y: auto; min-height: 0; flex: 1; -webkit-overflow-scrolling: touch; }
.ch-picker-group { color: var(--muted); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.05em; margin: 10px 2px 4px !important; }
.ch-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
.pv-ask .sheet-btns.tall .row-btn { cursor: pointer; }
.ov label.row-btn { display: block; margin: 0; font-size: 1em; color: inherit; }
.ch-msg.swiping { transition: none; }

/* the gallery: swipe through, pinch to zoom, swipe down to close */
.vw-stage { position: relative; overflow: hidden; touch-action: none; }
.vw-slide { position: absolute; inset: 0; display: flex; flex-direction: column; will-change: transform; }
.vw-slide.moving, .vw-photo.moving { transition: transform 0.25s ease-out; }
.vw-slide .vw-photo { flex: 1; min-height: 0; transform-origin: center center; }
.vw-playmark { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); pointer-events: none; }
.vw-playmark::after { content: ""; position: absolute; left: 25px; top: 19px; border-style: solid; border-width: 13px 0 13px 21px; border-color: transparent transparent transparent #fff; }
.vw-slide.playing .vw-playmark, .vw-slide.playing > .vw-photo { display: none; }
.vw-videobox { position: absolute; inset: 0; display: flex; flex-direction: column; background: #000; }
.vw-gone { margin: auto; opacity: 0.8; }
.vw-mid { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.vw-count { font-size: 0.75em; opacity: 0.7; }
.vw-count:empty { display: none; }
.vw-spacer { width: 56px; }
.vw-top, .vw-bar, .vw-note { transition: opacity 0.2s; position: relative; z-index: 2; }
.vw.bare .vw-top, .vw.bare .vw-bar, .vw.bare .vw-note { opacity: 0; pointer-events: none; }
.vw.zoomed .vw-bar, .vw.zoomed .vw-note { opacity: 0; pointer-events: none; }
.vw-arrow { display: none; position: absolute; top: 50%; margin-top: -26px; width: 44px; height: 52px; border-radius: 10px; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 34px; line-height: 1; z-index: 2; }
.vw-arrow.prev { left: 8px; }
.vw-arrow.next { right: 8px; }
@media (hover: hover) and (pointer: fine) { .vw-arrow { display: block; } .vw-arrow[hidden] { display: none; } }

/* GIF search */
.ch-gifs { height: 85%; max-height: 85%; }
.ch-gifs .ch-picker-head { gap: 8px; margin-bottom: 8px; }
.ch-gif-find { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--paper); font-size: 16px; -webkit-appearance: none; appearance: none; }
.ch-gif-said { color: var(--muted); font-size: 0.85em; margin: 0 2px 6px !important; min-height: 1.2em; }
.ch-gif-said:empty { display: none; }
.ch-gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ch-gif { position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: 8px; overflow: hidden; background: var(--line); -webkit-tap-highlight-color: transparent; }
.ch-gif img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ch-gif.busy { opacity: 0.5; }
.ch-gif-more { display: block; margin: 8px auto; }
.ch-gif-by { color: var(--muted); font-size: 0.7em; text-align: center; margin: 6px 0 0 !important; }
.ch-meta .ch-edited { font-style: italic; }

/* Leaving the app: the private screens vanish in one step, before anything else is tidied. */
html.veiled #layer { display: none !important; }
