/* Kwil phone app. Warm neutrals, one clay accent, the system font.
   Light by default, dark when the phone is (prefers-color-scheme). */
:root {
  --bg: #faf9f5; --surface: #ffffff; --surface-2: #f0eee6; --surface-3: #e6e3d8;
  --text: #1f1e1d; --text-2: #4d4c48; --muted: #7b7a73; --line: #1f1e1d1a; --line-strong: #1f1e1d2e;
  --accent: #c96442; --accent-strong: #b4532f; --accent-ink: #a8492b; --on-accent: #fff;
  --accent-soft: #c964421f; --mark: #c9644233;
  --me: #f0eee6; --ok: #3f7d4f; --ok-soft: #3f7d4f1f; --bad: #b3382c; --bad-ink: #a33a2e; --bad-soft: #b3382c17;
  --warn: #f7ecdc; --warn-ink: #6b4a1f; --warn-line: #e7d2b2;
  --shadow-1: 0 1px 2px #1f1e1d14, 0 1px 1px #1f1e1d0a;
  --shadow-2: 0 10px 30px -8px #1f1e1d33, 0 2px 6px #1f1e1d14;
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --pad: 1.25rem;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --surface: #30302e; --surface-2: #383835; --surface-3: #44433f;
    --text: #f5f4ee; --text-2: #d3d1c7; --muted: #9c9a91; --line: #ffffff14; --line-strong: #ffffff26;
    --accent: #d97757; --accent-strong: #c96442; --accent-ink: #eb9a7c; --on-accent: #fff;
    --accent-soft: #d977572b; --mark: #d9775759;
    --me: #383835; --ok: #6fbf86; --ok-soft: #6fbf8626; --bad: #c4463a; --bad-ink: #f08a7e; --bad-soft: #e5675a26;
    --warn: #3b3124; --warn-ink: #f1d9b3; --warn-line: #574630;
    --shadow-1: 0 1px 2px #0006;
    --shadow-2: 0 14px 40px -8px #000a, 0 2px 8px #0006;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 17px/1.47 var(--font); letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1 { font-size: 1.0625rem; font-weight: 600; margin: 0; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { border: 0; border-radius: var(--r-md); background: var(--surface-2); color: var(--text);
  padding: .65em 1.15em; min-height: 44px; cursor: pointer; font-weight: 500;
  transition: background-color .15s, transform .12s, opacity .15s, box-shadow .15s; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
code { font: .88em ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-2);
  padding: .1em .35em; border-radius: 6px; }
input[type=text], input[type=password], input[type=url], select, textarea {
  width: 100%; min-height: 48px; padding: .7em .95em; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  -webkit-appearance: none; appearance: none; transition: border-color .15s, box-shadow .15s; }
::placeholder { color: var(--muted); opacity: 1; }
select { padding-right: 2.4em; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23878580' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1em center; background-size: .75em; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
:is(button, summary, a, [tabindex]):focus { outline: none; }
:is(button, summary, a, [tabindex]):focus-visible { outline: none; box-shadow: var(--ring); }

/* iOS-style switches for every on/off setting */
input[type=checkbox] { -webkit-appearance: none; appearance: none; flex: none; margin: 0;
  width: 51px; height: 31px; border-radius: var(--r-pill); background: var(--surface-3);
  position: relative; cursor: pointer; transition: background-color .2s; }
input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 4px #0003, 0 0 1px #0003; transition: transform .2s; }
input[type=checkbox]:checked { background: var(--ok); }
input[type=checkbox]:checked::after { transform: translateX(20px); }
input[type=checkbox]:disabled { opacity: .45; }
input[type=checkbox]:focus-visible { outline: none; box-shadow: var(--ring); }
@media (prefers-color-scheme: dark) { input[type=checkbox]:checked { background: #4e9a64; } }

.primary, .login button[type=submit] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.primary:active:not(:disabled), .login button[type=submit]:active { background: var(--accent-strong); }
.error { color: var(--bad-ink); font-size: .9375rem; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: .8125rem; line-height: 1.4; margin: .5rem 0 0; }

/* ---------- sign-in ---------- */
.login { min-height: 100%; max-width: 26rem; margin: 0 auto; display: flex; flex-direction: column;
  justify-content: center; text-align: center;
  padding: calc(2rem + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right))
           calc(2rem + env(safe-area-inset-bottom)) calc(var(--pad) + env(safe-area-inset-left)); }
.login-icon { width: 72px; height: 72px; margin: 0 auto 1.25rem; border-radius: 18px; box-shadow: var(--shadow-2); }
.login h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.login > p { color: var(--text-2); font-size: .9375rem; margin: .6rem 0 0; }
.login form { display: grid; gap: .75rem; margin-top: 1.75rem; }
.login input { text-align: center; font-size: 1.0625rem; }
.login button[type=submit] { min-height: 50px; border-radius: var(--r-md); font-size: 1.0625rem; }
.login .login-more { margin-top: 1.5rem; font-size: .9375rem; }
.login .login-more a { color: var(--accent-ink); }
.login .error { margin: 1rem 0 0; padding: .7rem .9rem; border-radius: var(--r-md); background: var(--bad-soft); }

/* ---------- main chat ---------- */
.app { display: flex; flex-direction: column; height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.app > header { display: flex; align-items: center; gap: .25rem; min-height: 52px;
  padding: .25rem .5rem .25rem var(--pad); }
.app > header h1 { margin-right: auto; display: flex; align-items: center; gap: .4rem; font-size: 1.25rem;
  font-weight: 700; letter-spacing: -.025em; white-space: nowrap; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; display: grid; place-items: center;
  min-width: 44px; min-height: 44px; border-radius: 50%; color: var(--text-2); transition: background-color .15s; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary svg, .icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.menu[open] summary { background: var(--surface-2); color: var(--text); }
.menu-body { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 5; width: min(19rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 6rem - env(safe-area-inset-top)); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); padding: .4rem 0; display: grid; animation: pop .16s ease-out; transform-origin: top right; }
.menu-body > label { display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  min-height: 52px; padding: .35rem 1rem; font-size: 1rem; cursor: pointer; }
.menu-body > label + label, .menu-body > label + fieldset { border-top: 1px solid var(--line); }
.menu-body > label input[type=checkbox] { order: 2; }
.menu-body > button { background: none; border-radius: 0; text-align: left; padding: 0 1rem; min-height: 50px;
  font-weight: 400; border-top: 1px solid var(--line); }
.menu-body > button:active { background: var(--surface-2); transform: none; }
.menu-body > #logout { margin-top: .4rem; border-top-width: 8px; border-top-color: var(--surface-2); }
.menu-body > #logout-all { color: var(--bad-ink); }
/* family invites (family.js): the owner's list; a family member has no owner tabs */
.family { border-top: 1px solid var(--line); padding: 0 0 .4rem; display: grid; }
.family > button { background: none; border-radius: 0; text-align: left; padding: 0 1rem; min-height: 50px; font-weight: 400; }
.invite-form { display: grid; gap: .5rem; padding: .25rem 1rem .5rem; }
.invite-form label { display: grid; gap: .25rem; font-size: .9375rem; }
.family .hint, #invite-link { margin: 0 1rem; }
.family-list { list-style: none; margin: 0; padding: 0 1rem; display: grid; gap: .35rem; }
.family-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.family-list button { min-height: 36px; padding: 0 .7rem; font-weight: 400; }
.family-list .danger { color: var(--bad-ink); }
/* a family member's own "Download my data" / "Delete my account" (family.js) */
.account-self > .danger { color: var(--bad-ink); }
.account-self form .danger { background: var(--bad); color: #fff; }
#app[data-account="family"] .tabs { display: none; }
/* a family member's own Anthropic key (family.js setupKey) */
.api-key { border-top: 1px solid var(--line); padding: .35rem 1rem .6rem; display: grid; gap: .4rem; }
.api-key-title { margin: .35rem 0 0; font-size: 1rem; }
.api-key .hint { margin: 0; }
.api-key-form { display: grid; gap: .4rem; }
.api-key-row { display: flex; gap: .4rem; }
.api-key-row button { min-height: 36px; padding: 0 .7rem; font-weight: 400; }
.api-key-row .danger { color: var(--bad-ink); }
.api-key-link { user-select: all; -webkit-user-select: all; }
/* reply-voice picker (voice-picker.js) */
.voice-picker { border-top: 1px solid var(--line); padding: .35rem 1rem .5rem; display: grid; gap: .45rem; }
.voice-picker > label { display: grid; gap: .3rem; font-size: 1rem; }
.voice-picker select { min-height: 40px; max-width: 100%; }
.voice-picker-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.voice-picker-row input { flex: 1; min-width: 8rem; }
.voice-picker button { min-height: 36px; padding: 0 .8rem; font-weight: 400; }
.voice-picker .hint { margin: 0; }
.tag { font-size: .75rem; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }

.log { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 1rem var(--pad) 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.msg { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .22s ease-out; }
.msg.me { align-self: flex-end; max-width: 82%; padding: .6rem 1rem; border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg);
  background: var(--me); color: var(--text); }
.msg.claude { align-self: stretch; padding: 0 .1rem; color: var(--text); font-size: 1.0625rem; line-height: 1.55; }
.msg.claude:empty::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%;
  background: var(--accent); vertical-align: middle; animation: breathe 1.1s ease-in-out infinite; }
.msg.note { align-self: center; max-width: 92%; text-align: center; padding: .45rem .9rem; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: .8125rem; line-height: 1.4; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
#log:empty { justify-content: center; align-items: center; text-align: center; }
#log:empty::before { content: "How can I help?"; font-size: 1.625rem; font-weight: 600; letter-spacing: -.03em;
  color: var(--text); }
#log:empty::after { content: "Hold the mic to talk, or type below. Try \201CWhat\2019s on my calendar tomorrow?\201D";
  max-width: 17rem; margin-top: .5rem; color: var(--muted); font-size: .9375rem; line-height: 1.45; }
.status { min-height: 1.4em; margin: 0; padding: 0 var(--pad); color: var(--muted); font-size: .8125rem;
  text-align: center; }

.confirm { margin: 0 var(--pad) .75rem; padding: 1rem; border-radius: var(--r-lg); background: var(--warn);
  border: 1px solid var(--warn-line); color: var(--warn-ink); animation: rise .2s ease-out; }
.confirm p { margin: 0 0 .85rem; font-weight: 600; color: var(--text); }
.confirm .hint { margin: .7rem 0 0; font-weight: 400; color: var(--warn-ink); opacity: .8; text-align: center; }
.confirm-buttons { display: flex; gap: .6rem; }
.confirm-buttons button { flex: 1; min-height: 50px; font-size: 1.0625rem; font-weight: 600; border-radius: var(--r-md); }
.yes { background: var(--accent); color: var(--on-accent); }
.no { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

.app > footer { padding: .5rem var(--pad) calc(.85rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; }
#text-form { display: flex; align-items: center; gap: .25rem; width: 100%; margin-bottom: 1.25rem;
  padding: 3px 3px 3px 1.1rem; border-radius: var(--r-pill); background: var(--surface);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-1); transition: border-color .15s, box-shadow .15s; }
#text-form:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
#text-form input { flex: 1; min-width: 0; min-height: 44px; padding: 0; border: 0; background: none; box-shadow: none; }
#text-form button { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); }
#text-form button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; }
.mic { position: relative; width: 84px; height: 84px; min-height: 0; border-radius: 50%; padding: 0;
  display: grid; place-items: center; isolation: isolate;
  background: radial-gradient(circle at 50% 30%, #e0876a, var(--accent) 60%, var(--accent-strong));
  box-shadow: 0 8px 22px -6px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 #ffffff40, inset 0 -2px 6px #0000001f;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .18s cubic-bezier(.3,1.4,.5,1), box-shadow .2s; }
.mic svg { width: 38px; height: 38px; pointer-events: none; fill: none; stroke: #fff; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 1px #0000002e); }
.mic svg rect { fill: #fff; }
.mic::before, .mic::after { content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -1;
  background: var(--accent); opacity: 0; pointer-events: none; }
.mic:active:not(:disabled) { transform: scale(.94); }
.mic.recording { transform: scale(1.06); background: radial-gradient(circle at 50% 30%, #e46d5d, var(--bad) 65%, #8f2a20);
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--bad) 75%, transparent); }
.mic.recording::before, .mic.recording::after { background: var(--bad); animation: ripple 1.8s cubic-bezier(.2,.6,.4,1) infinite; }
.mic.recording::after { animation-delay: .9s; }
.mic:disabled { opacity: .45; filter: saturate(.4); }
.mic:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent-ink), 0 8px 22px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
#text-form button:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--accent-ink); }
/* "+" (attachments.js): left of the field; chips for the picked files above it */
#text-form { padding-left: 3px; }
#text-form input { padding-left: .25rem; }
#text-form .attach-btn { background: none; color: var(--text-2); }
#text-form .attach-btn svg { width: 22px; height: 22px; stroke-width: 2; }
#text-form .attach-btn:active:not(:disabled) { background: var(--surface-2); }
#text-form .attach-btn:disabled { opacity: .35; }
.attach-chips { display: flex; gap: .5rem; width: 100%; margin-bottom: .5rem; overflow-x: auto; padding: 2px; }
.attach-chips[hidden] { display: none; }
.attach-chip { position: relative; flex: none; display: flex; align-items: center; height: 56px; max-width: 12rem;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-strong); overflow: hidden; }
.attach-chip img { width: 56px; height: 56px; object-fit: cover; display: block; }
.attach-chip.image:not(:has(img))::before { content: ""; width: 56px; height: 56px; background: var(--surface-2); }
.attach-name { padding: 0 2.4rem 0 .75rem; font-size: .8125rem; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove { position: absolute; top: 0; right: 0; width: 44px; height: 44px; min-height: 0;
  display: grid; place-items: start end; padding: 4px 6px 0 0; background: none; color: var(--text);
  font-size: 1.1rem; line-height: 1; }
.attach-chip img + .attach-remove { color: #fff; text-shadow: 0 0 3px #000a; }
@keyframes ripple { from { opacity: .35; transform: scale(1); } to { opacity: 0; transform: scale(1.75); } }
#mic-hint { margin-top: .6rem; }
@media (max-height: 700px) {
  .app > header { min-height: 48px; }
  .log { gap: .85rem; padding-top: .75rem; }
  #text-form { margin-bottom: .75rem; }
  .mic { width: 72px; height: 72px; }
  .mic svg { width: 32px; height: 32px; }
  #mic-hint { margin-top: .4rem; }
  .voice-open-btn { margin-top: .5rem; }
  .confirm { padding: .85rem; }
  .confirm p { margin-bottom: .7rem; }
  .confirm .hint { margin-top: .5rem; }
}
.voice-open-btn { margin-top: .7rem; display: inline-flex; align-items: center; gap: .5rem; border-radius: var(--r-pill);
  padding: 0 1.2rem; background: var(--surface-2); color: var(--text); font-size: .9375rem; }
.voice-open-btn::before { content: ""; width: 18px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 14'%3E%3Cg stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 5v4M5 2v10M9 4v6M13 1v12M17 5v4'/%3E%3C/g%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 18 14'%3E%3Cg stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 5v4M5 2v10M9 4v6M13 1v12M17 5v4'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  color: var(--accent); }

/* ---------- header bits shared with history ---------- */
.icon-btn { background: none; padding: 0; border-radius: 50%; line-height: 0; color: var(--text-2);
  min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; }
.icon-btn:active:not(:disabled) { background: var(--surface-2); }
.badge { font-size: .6875rem; font-weight: 600; letter-spacing: .02em; padding: .2em .6em;
  border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); }
.backend-badge { padding: .25em .7em; border-radius: var(--r-pill); font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.backend-badge::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: .4em;
  border-radius: 50%; background: currentColor; vertical-align: middle; }
.backend-badge[data-role=pi] { color: var(--ok); background: var(--ok-soft); }
.backend-badge[data-role=pc] { color: #3d6fa8; background: #3d6fa81f; }
.backend-badge[data-role=cloud] { color: var(--accent-ink); background: var(--accent-soft); }
.backend-badge[data-role=offline] { color: var(--bad-ink); background: var(--bad-soft); }
@media (prefers-color-scheme: dark) { .backend-badge[data-role=pc] { color: #8db6e8; background: #8db6e826; } }
.backends { margin: 0; border: 0; border-top: 1px solid var(--line); padding: .75rem 1rem; display: grid; gap: .6rem; }
.backends legend { float: left; width: 100%; padding: 0; font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.backends label { display: grid; gap: .3rem; font-size: .875rem; color: var(--text-2); }
.backends input, .backends select { min-height: 44px; font-size: .9375rem; }
.backends .hint { margin: 0; }
#backends-save { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.backend-status { margin: 0; padding-left: 1.1rem; font-size: .8125rem; color: var(--muted); }
.backend-status:empty { display: none; }

/* ---------- history and transcript (history.js) ---------- */
.history, .transcript { display: flex; flex-direction: column; height: 100%; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.bar { display: flex; align-items: center; gap: .25rem; min-height: 52px; padding: .25rem .375rem; position: sticky; top: 0;
  z-index: 2; background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); }
.bar h1 { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar h1:focus { outline: none; }
.bar .icon-btn { color: var(--accent-ink); }
.bar .icon-btn svg { width: 24px; height: 24px; stroke-width: 2; }
.bar-spacer { width: 44px; flex: none; }
.search { padding: .25rem var(--pad) .5rem; position: sticky; top: 52px; z-index: 2;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); }
input[type=search] { width: 100%; min-height: 44px; padding: .5em .9em .5em 2.3em; border-radius: var(--r-md); border: 0;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg fill='none' stroke='%23878580' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='6'/%3E%3Cpath d='M13 13l5 5'/%3E%3C/g%3E%3C/svg%3E") no-repeat .85em center / 1em;
  -webkit-appearance: none; appearance: none; }
input[type=search]:focus { outline: none; box-shadow: var(--ring); }
.chips { display: flex; gap: .45rem; overflow-x: auto; margin: 0 calc(-1 * var(--pad)); padding: .6rem var(--pad) .15rem;
  scrollbar-width: none; scroll-padding: 0 var(--pad); }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 44px; padding: 0 1.05em; border-radius: var(--r-pill); font-size: .9375rem;
  background: var(--surface); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chips button[aria-checked="true"] { background: var(--text); color: var(--bg); box-shadow: none; font-weight: 600; }

.conv-list { padding: 0 0 1rem; }
.conv-list[aria-busy="true"]:empty { min-height: 12rem;
  background: linear-gradient(var(--bg) 0 0) top / 100% 0 no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 1rem, var(--surface-2) 1rem 4.25rem, transparent 4.25rem 5.25rem)
    var(--pad) 0 / calc(100% - 2 * var(--pad)) 100% no-repeat; animation: shimmer 1.2s ease-in-out infinite alternate; }
@keyframes shimmer { from { opacity: .55; } to { opacity: 1; } }
.conv-group h2 { font-size: .9375rem; font-weight: 600; color: var(--text); letter-spacing: -.01em;
  margin: 0; padding: 1.1rem var(--pad) .35rem; }
.conv-items { margin: 0 .75rem; border-radius: var(--r-lg); background: var(--surface); overflow: hidden;
  box-shadow: var(--shadow-1); }
.conv { position: relative; display: flex; align-items: stretch; overflow: hidden; touch-action: pan-y; }
.conv + .conv::before { content: ""; position: absolute; top: 0; left: 4.1rem; right: 0; border-top: 1px solid var(--line); z-index: 1; }
.conv-main { flex: 1; display: flex; gap: .8rem; align-items: flex-start; text-align: left; background: var(--surface);
  border-radius: 0; padding: .8rem .25rem .8rem .85rem; min-width: 0; font-weight: 400; transition: transform .22s ease, background-color .15s; }
.conv-main:active:not(:disabled) { transform: none; background: var(--surface-2); }
.conv-more { background: var(--surface); border-radius: 0; color: var(--muted); transition: transform .22s ease; }
.conv-icon { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); font-size: 1.15rem; line-height: 1; }
.conv-body { flex: 1; min-width: 0; padding-top: .05rem; }
.conv-top { display: flex; gap: .4rem; align-items: baseline; }
.conv-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-pin { font-size: .75rem; }
.conv-time { color: var(--muted); font-size: .8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.conv-snippet { margin: .1rem 0 0; color: var(--muted); font-size: .9375rem; line-height: 1.4; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: var(--mark); color: var(--text); border-radius: 3px; padding: 0 .1em; }
.conv-actions { position: absolute; right: 0; top: 0; bottom: 0; display: flex; transform: translateX(100%);
  transition: transform .22s ease; }
.conv-actions button { border-radius: 0; padding: 0 1rem; min-width: 4.6rem; font-size: .875rem; font-weight: 600;
  background: var(--surface-3); color: var(--text); }
.conv-actions button:active { transform: none; }
.conv-actions .danger { background: var(--bad); color: #fff; }
.conv.open .conv-actions { transform: translateX(0); }
.conv.open .conv-main, .conv.open .conv-more { transform: translateX(-14rem); }
.more-btn { margin: .75rem auto 1.5rem; display: block; border-radius: var(--r-pill); background: var(--surface-2);
  color: var(--text-2); font-size: .9375rem; }
.status.center { padding: 1.5rem var(--pad); font-size: .9375rem; line-height: 1.45; }
/* ---------- memory (memory.js) ---------- */
.mem-head { display: flex; align-items: baseline; gap: .5rem; padding-right: var(--pad); }
.mem-head h2 { flex: 1; }
.mem-delete-week, .mem-delete { background: none; padding: 0 .5rem; min-height: 44px; font-size: .875rem;
  font-weight: 600; color: var(--bad-ink); }
.mem-item { padding: .7rem 1rem .8rem; }
.mem-item + .mem-item { border-top: 1px solid var(--line); }
.mem-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.mem-when { flex: 1; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.mem-untrusted { background: var(--bad-soft); color: var(--bad-ink); }
.mem-text { margin: .25rem 0 0; font-size: .9375rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.status.center:empty { display: none; }
.conv-list:empty + .status.center:not(:empty) { padding-top: 4.5rem; color: var(--text-2); }
.conv-list:empty + .status.center:not(:empty)::before { content: ""; display: block; width: 52px; height: 52px; margin: 0 auto 1rem;
  border-radius: 50%; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7M3 4v4h4M12 7v5l3 2' fill='none' stroke='%23878580' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 26px no-repeat; }

.transcript .meta { color: var(--muted); font-size: .8125rem; margin: 0; padding: 0 var(--pad); text-align: center; }
.transcript .summary { margin: 1rem var(--pad) 0; padding: .85rem 1rem; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-1); font-size: .9375rem; color: var(--text-2); }
.transcript .summary:empty { display: none; }
.transcript .summary::before { content: "Summary"; display: block; font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--accent-ink); margin-bottom: .25rem; }
.transcript .log { flex: none; overflow: visible; padding-top: 1.25rem; }
.msg .tools { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .3rem; white-space: normal; }
.msg .tag { color: var(--muted); font-size: .8125rem; }
.transcript-footer { position: sticky; bottom: 0; margin-top: auto; padding: .75rem var(--pad)
  calc(.75rem + env(safe-area-inset-bottom)); text-align: center; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); }
.transcript-footer .primary { width: 100%; min-height: 50px; border-radius: var(--r-md); }
.transcript-footer .hint:empty { display: none; }

/* ---------- sheets and dialogs ---------- */
dialog.sheet { border: 0; padding: 0; background: none; color: var(--text); overflow: visible;
  width: min(28rem, calc(100% - 1rem)); max-width: none; margin: auto auto calc(.5rem + env(safe-area-inset-bottom)); }
dialog.sheet[open] { animation: sheet-in .24s cubic-bezier(.2,.9,.3,1); }
dialog.sheet::backdrop { background: #1f1e1d66; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
dialog.sheet form { display: grid; gap: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface);
  box-shadow: var(--shadow-2); overflow: hidden; }
dialog.sheet h2 { font-size: .8125rem; font-weight: 600; color: var(--muted); text-align: center; margin: 0;
  padding: .9rem 1.25rem .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.sheet p { margin: 0; padding: 0 1.25rem 1rem; text-align: center; color: var(--text-2); font-size: .9375rem; }
dialog.sheet button { background: none; border-radius: 0; text-align: center; min-height: 54px; font-size: 1.0625rem;
  font-weight: 400; color: var(--text); border-top: 1px solid var(--line); }
dialog.sheet button:active { transform: none; background: var(--surface-2); }
dialog.sheet .danger { color: var(--bad-ink); }
dialog.sheet .cancel { color: var(--text); font-weight: 600; }
dialog.sheet form > .cancel { margin-top: .5rem; border-top: 0; box-shadow: 0 -.5rem 0 var(--bg); }
dialog.sheet .row { display: flex; gap: 0; margin: 0; border-top: 1px solid var(--line); }
dialog.sheet .row button { flex: 1; border-top: 0; }
dialog.sheet .row button + button { border-left: 1px solid var(--line); }
dialog.sheet .row .primary { background: none; color: var(--accent-ink); font-weight: 600; }
dialog.sheet .row .danger { background: none; color: var(--bad-ink); font-weight: 600; }
dialog.sheet input { margin: 0 1.25rem 1rem; width: calc(100% - 2.5rem); }
#rename-dialog h2, #delete-dialog h2 { font-size: 1.0625rem; color: var(--text); padding-top: 1.1rem; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; }
  .mic.recording::before { opacity: .25; transform: scale(1.25); }
  .mic.recording::after { opacity: 0; }
  .msg.claude:empty::before { opacity: .7; }
}

/* Mic level meter (push-to-talk and voice conversation): how much sound is
   coming in; the bar turns the accent colour while it hears speech. */
.mic-meter { width: 9rem; height: 6px; margin: .7rem auto 0; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, currentColor 14%, transparent); }
.mic-meter[hidden] { display: none; }
.mic-meter span { display: block; height: 100%; width: calc(var(--mic, 0) * 100%); border-radius: inherit;
  background: color-mix(in srgb, currentColor 45%, transparent); transition: width 60ms linear; }
.mic-meter.hearing span { background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .mic-meter span { transition: none; } }

/* First-run guide for a family member's own app (i18n.js renderGuide) */
.guide { margin: .75rem 1rem; padding: .9rem 1rem; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.guide[hidden] { display: none; }
.guide-text { margin: 0 0 .7rem; white-space: pre-line; line-height: 1.5; }

/* The owner's health banner: an app down, checks stopped (ui.js renderHealth) */
.health-banner { margin: .5rem 1rem 0; padding: .6rem .85rem; border-radius: 12px;
  background: var(--warn); color: var(--warn-ink); border: 1px solid var(--warn-line);
  white-space: pre-line; line-height: 1.45; font-size: .92rem; }
.health-banner[hidden] { display: none; }

/* The study brief a notification opens (brief.js): its text and a Play button */
.brief .meta { color: var(--muted); font-size: .8125rem; margin: 1rem 0 0; padding: 0 var(--pad); text-align: center; }
.brief .summary { margin: .75rem var(--pad) 0; padding: .85rem 1rem; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-1); font-size: 1rem; color: var(--text-2);
  line-height: 1.45; white-space: pre-line; }
.brief .summary:empty { display: none; }
.brief .primary { margin: 1rem var(--pad) 0; min-height: 50px; border-radius: var(--r-md); }
.brief .primary[hidden] { display: none; }
