/* ---------- Shared page frame (gate, sessions) ---------- */
.page {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: var(--s6) 20px;
}
.page-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 44px; }
.page-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--s12) 0; }
.wordmark { height: 28px; width: auto; }
.screen-enter { animation: screen-in var(--d-long) var(--ease) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Gate ---------- */
.gate { width: 100%; max-width: 400px; }
.gate h1 { margin-bottom: var(--s2); }
.gate p { color: var(--gray); margin-bottom: var(--s8); }
.gate form .btn { margin-top: var(--s6); }

/* ---------- Session picker ---------- */
.sessions { width: 100%; max-width: 640px; }
.sessions-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s8); flex-wrap: wrap; }
.sessions-head p { color: var(--gray); margin-top: var(--s2); }
.session-list { display: flex; flex-direction: column; gap: var(--s3); list-style: none; margin: 0; padding: 0; }
.session-row {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s4) var(--s4) var(--s6);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card);
  transition: border-color var(--d-micro) var(--ease);
}
.session-row:hover { border-color: var(--line-hover); }
.session-info { flex: 1; min-width: 0; }
.session-name { font-weight: 700; font-size: 18px; line-height: 1.3; }
.session-meta { font-size: 13px; line-height: 1.5; color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-stage { display: inline-flex; align-items: center; gap: var(--s1); }
.session-stage .ti { font-size: 16px; }
.session-stage.done { color: var(--ok-text); }
.session-stage.done .ti { color: var(--ok); }
.session-stage.active .ti { color: var(--info); }
.session-actions { display: flex; align-items: center; gap: var(--s2); }
.session-skeleton { height: 82px; border-radius: var(--r-lg); }
@media (max-width: 599px) {
  .page-main { align-items: flex-start; padding-top: var(--s8); }
  .session-row { padding-left: var(--s4); }
  .session-meta { white-space: normal; }
  .session-actions .btn { padding: var(--s3) var(--s4); }
}

/* ---------- Onboarding ---------- */
.ob { min-height: 100dvh; display: flex; flex-direction: column; }
.ob-head { padding: var(--s4) var(--s6) 0; }
/* Wide screens: logo shares the row with the step indicator */
@media (min-width: 1100px) {
  .ob { position: relative; }
  .ob .ob-head { position: absolute; top: 22px; left: var(--s6); padding: 0; }
  .ob .ob-steps { padding-top: var(--s6); }
}
.ob-steps { width: 100%; max-width: 680px; margin: 0 auto; padding: var(--s3) 20px var(--s8); }
.ob-main {
  flex: 1; width: 100%; max-width: 480px; margin: 0 auto;
  padding: var(--s4) 20px var(--s4);
  display: flex; flex-direction: column;
}
.ob-step { animation: screen-in var(--d-long) var(--ease) both; }
.ob-title { margin-bottom: var(--s2); }
.ob-title:only-child, .ob-title + .field-stack { margin-bottom: 0; }
.ob-title + .field-stack { margin-top: var(--s6); }
.ob-lede { color: var(--gray); margin-bottom: var(--s6); }
.ob-actions { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s6); }
.ob-actions .btn-primary { margin-left: auto; }
@media (max-width: 599px) {
  .ob-head { padding: var(--s4) 20px 0; }
  .ob-steps { padding: var(--s4) 20px var(--s6); }
  .step-label { display: none; }
  .ob-main { padding-top: var(--s4); }
  .ob-actions {
    position: sticky; bottom: 0; margin: auto -20px 0; padding: var(--s4) 20px calc(var(--s4) + env(safe-area-inset-bottom));
    background: rgba(242,241,237,.94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  }
  .ob-actions .btn-primary { flex: 1; }
}

.welcome-core { color: var(--ink); margin-bottom: var(--s6); }
.core-icon { display: inline-flex; }
.core-icon svg { display: block; width: auto; }

/* Verify */
.camera {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  background: var(--thunder); border-radius: var(--r-lg); overflow: hidden;
  margin-bottom: var(--s4);
}
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-frame { position: absolute; left: 10%; right: 10%; top: 25%; bottom: 25%; pointer-events: none; }
.camera-frame span { position: absolute; width: 24px; height: 24px; border: 3px solid rgba(255,255,255,.9); transition: border-color var(--d-short) var(--ease); }
.camera-frame span:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: var(--r-md); }
.camera-frame span:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: var(--r-md); }
.camera-frame span:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: var(--r-md); }
.camera-frame span:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: var(--r-md); }
.camera[data-state="ok"] .camera-frame span { border-color: var(--ok); }
.camera[data-state="warn"] .camera-frame span { border-color: var(--warn); }
.camera-overlay {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s6) 15%; text-align: center; color: #fff;
  background: rgba(35,39,46,.55);
  animation: fade-in var(--d-short) var(--ease) both;
}
.camera-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.camera-icon .ti { font-size: 24px; }
.camera-icon.tone-ok { background: var(--ok); color: #fff; }
.camera-icon.tone-warn { background: var(--warn); color: var(--ink); }
.camera-icon.tone-info { background: rgba(255,255,255,.14); color: #fff; }
.camera-overlay .spinner { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.camera-text { font-size: 14px; line-height: 1.45; max-width: 300px; }
.camera[data-state="ok"] .camera-text { font-size: 20px; font-weight: 700; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.camera-action {
  display: inline-flex; align-items: center; gap: var(--s1); min-height: 36px; margin-top: var(--s1);
  padding: 0 var(--s4); border-radius: var(--r-pill); border: 1px solid rgba(255,255,255,.4);
  background: transparent; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: border-color var(--d-micro) var(--ease), background-color var(--d-micro) var(--ease);
}
.camera-action:hover { border-color: #fff; background: rgba(255,255,255,.08); }
.camera-action .ti { font-size: 16px; }
.camera-pill {
  position: absolute; left: 50%; bottom: var(--s3); transform: translateX(-50%); z-index: 1;
  display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap;
  padding: 6px var(--s3); border-radius: var(--r-pill);
  background: rgba(35,39,46,.72); color: #fff; font-size: 13px;
}
.camera-pill .spinner { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.serial-input { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- App shell (Stage 8) ---------- */
.shell { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--panel); border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; gap: var(--s3); width: calc(100% - var(--s4)); min-height: 60px;
  margin: var(--s4) var(--s2) var(--s2); padding: var(--s2) var(--s3);
  border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink); text-align: left; cursor: pointer;
  transition: background-color var(--d-micro) var(--ease);
}
.sidebar-head:hover { background: var(--panel-pressed); }
.sidebar-device { flex: none; width: 24px; display: grid; place-items: center; color: var(--ink); }
.sidebar-unit { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-head .unit-name { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray); }
.unit-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sidebar-new { padding: var(--s1) var(--s4) var(--s4); }
.sidebar-new .btn { width: 100%; justify-content: flex-start; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 var(--s2) var(--s4); }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  min-height: 44px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md);
  background: transparent; text-align: left; cursor: pointer; color: var(--ink);
  transition: background-color var(--d-micro) var(--ease);
}
.nav-item .ti { font-size: 20px; flex: none; }
.nav-item:hover { background: var(--panel-pressed); }
.nav-item[aria-current="page"] { background: var(--card); font-weight: 700; box-shadow: var(--e1); }
.nav-item .nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section { padding: var(--s6) var(--s3) var(--s2); color: var(--gray); }
.recents-empty { padding: var(--s2) var(--s3); font-size: 13px; color: var(--gray); }
.sidebar-foot { border-top: 1px solid var(--hairline); padding: var(--s2); }
.account-row {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 52px;
  padding: var(--s2) var(--s2) var(--s2) var(--s3); border: 0; border-radius: var(--r-md);
  background: transparent; text-align: left; cursor: pointer; color: var(--ink);
  transition: background-color var(--d-micro) var(--ease);
}
.account-row:hover { background: var(--panel-pressed); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--thunder); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.account-text { flex: 1; min-width: 0; }
.account-text div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text .t-caption { color: var(--gray); }

.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--page); }
.topbar {
  display: flex; align-items: center; gap: var(--s2); min-height: 64px; padding: 0 var(--s3);
  border-bottom: 1px solid var(--hairline); flex: none;
}
.topbar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: var(--s2); }
.topbar-title.editable {
  flex: 0 1 auto; margin-right: auto; padding: 6px var(--s2); border-radius: var(--r-sm); cursor: text;
  transition: background-color var(--d-micro) var(--ease);
}
.topbar-title.editable:hover { background: var(--panel); }
.topbar-title.editing { flex: 1; padding: 0; overflow: visible; }
.title-input {
  width: 100%; font: inherit; letter-spacing: inherit; color: var(--ink);
  padding: 5px var(--s2); border: 1px solid var(--ink); border-radius: var(--r-sm); background: var(--card);
  box-shadow: inset 0 0 0 1px var(--ink); outline: none;
}
.topbar .menu-btn { display: none; }

.view { flex: 1; min-height: 0; overflow-y: auto; }
.view-inner { max-width: 720px; margin: 0 auto; padding: var(--s8) 20px; }

/* Overlay sidebar: always below 900px, and on desktop when chosen */
.shell[data-sidebar="overlay"] .topbar .menu-btn { display: inline-flex; }
.shell[data-sidebar="overlay"] .sidebar,
.shell .sidebar.is-overlay {
  position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
  box-shadow: var(--e3); border-right: 0;
  transform: translateX(-100%); visibility: hidden;
  transition: transform var(--d-medium) var(--ease), visibility 0s linear var(--d-medium);
}
.shell[data-sidebar="overlay"].drawer-open .sidebar {
  transform: none; visibility: visible;
  transition: transform var(--d-medium) var(--ease), visibility 0s;
}
.shell[data-sidebar="overlay"].drawer-open .scrim {
  display: block; position: fixed; inset: 0; z-index: 55; background: var(--scrim);
  animation: fade-in var(--d-short) var(--ease) both;
}
@media (max-width: 899px) {
  .shell .topbar .menu-btn { display: inline-flex; }
  .shell .sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(var(--sidebar-w), 86vw);
    box-shadow: var(--e3); border-right: 0;
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--d-medium) var(--ease), visibility 0s linear var(--d-medium);
  }
  .shell.drawer-open .sidebar { transform: none; visibility: visible; transition: transform var(--d-medium) var(--ease), visibility 0s; }
  .shell.drawer-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: var(--scrim);
    animation: fade-in var(--d-short) var(--ease) both;
  }
}

/* ---------- Conversation ---------- */
.thread { max-width: 720px; margin: 0 auto; padding: var(--s8) 20px var(--s6); display: flex; flex-direction: column; gap: var(--s6); }
.msg { max-width: 680px; }
.msg-howard { align-self: flex-start; width: 100%; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }

.msg-user { align-self: flex-end; max-width: min(80%, 560px); background: var(--panel); border-radius: var(--r-lg); padding: var(--s3) var(--s4); }
.msg-reveal { animation: screen-in var(--d-long) var(--ease) both; }
.thread-status { padding-left: 0; }
.thread-empty { min-height: 60vh; }

/* ---------- Composer: two shapes for side-by-side comparison ---------- */
.composer { flex: none; }
.composer-inner { display: flex; align-items: flex-end; gap: var(--s1); }
.composer textarea {
  display: block; width: 100%; min-height: 44px; max-height: 240px; resize: none; overflow-y: auto;
  /* 12/8 padding optically centers DM Sans on the 48px button circles */
  border: 0; background: transparent; padding: 12px 0 8px; font-size: 16px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--gray-muted); }
.composer textarea:focus { outline: none; }
/* Standalone circles either side of the field, same height as a one-line field */
.attach-btn {
  width: 48px; height: 48px; color: var(--ink); background: var(--card); border: 1px solid var(--line);
}
.attach-btn .ti { font-size: 22px; }
.attach-btn:hover { background: var(--card); border-color: var(--line-hover); }
.attach-btn[aria-expanded="true"] { background: var(--panel); border-color: var(--line-hover); }
.send-btn {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%;
  background: var(--action); color: #fff; display: grid; place-items: center; cursor: pointer;
  transition: background-color var(--d-micro) var(--ease), opacity var(--d-micro) var(--ease);
}
.send-btn .ti { font-size: 20px; }
.send-btn:hover:not(:disabled) { background: var(--action-hover); }
.send-btn:active:not(:disabled) { background: var(--action-active); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-box { max-width: 720px; margin: 0 auto; display: flex; align-items: flex-end; gap: var(--s2); }
.composer-shell {
  flex: 1; min-width: 0; min-height: 48px; display: flex; flex-direction: column; justify-content: center;
  background: var(--card); border: 1px solid var(--line); padding: 0 var(--s4);
  transition: border-color var(--d-micro) var(--ease), border-radius var(--d-short) var(--ease);
}

/* Attachment tray inside the message bar */
.composer-tray { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s3) 0 var(--s1); margin-right: calc(var(--s4) * -1); padding-right: var(--s4); }
.tray-item { position: relative; flex: none; animation: fade-in var(--d-short) var(--ease) both; }
.tray-remove {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--card); background: var(--thunder); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.tray-remove::before { content: ""; position: absolute; inset: -11px; } /* 44px touch target */
.tray-remove .ti { font-size: 12px; }

/* Full-width bar */
.shell[data-composer="bar"] .composer {
  border-top: 1px solid var(--hairline); background: var(--page);
  padding: var(--s3) 20px calc(var(--s3) + env(safe-area-inset-bottom));
}
.shell[data-composer="bar"] .composer-shell { border-radius: var(--r-md); }
.shell[data-composer="bar"] .composer-shell:focus-within { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* Floating inset pill (default) */
.shell[data-composer="pill"] .composer {
  padding: 0 20px calc(var(--s6) + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(242,241,237,0), var(--page) 40%);
}
.shell[data-composer="pill"] .composer-shell { border-radius: 24px; box-shadow: var(--e2); }
.shell[data-composer="pill"] .attach-btn, .shell[data-composer="pill"] .send-btn { box-shadow: var(--e2); }
.shell[data-composer="pill"] .composer-shell:focus-within { border-color: var(--ink); box-shadow: var(--e2), inset 0 0 0 1px var(--ink); }
.shell[data-composer="pill"] .composer-shell.multiline { border-radius: var(--r-lg); }

/* Drop files onto the chat */
.main.dropping::after {
  content: "Drop to attach"; position: absolute; inset: var(--s3); z-index: 20;
  display: grid; place-items: center; border: 2px dashed var(--action); border-radius: var(--r-lg);
  background: rgba(242,241,237,.9); color: var(--action); font-weight: 700; font-size: 18px; pointer-events: none;
}

/* Attachments (tray + sent messages) */
.att { border-radius: var(--r-md); overflow: hidden; }
.att-image img { display: block; max-width: 240px; max-height: 240px; border-radius: var(--r-md); object-fit: cover; }
.att-image.compact img { width: 64px; height: 64px; }
.att-file {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3) var(--s2) var(--s2);
  background: var(--card); border: 1px solid var(--hairline); max-width: 280px;
}
.att-file.compact { height: 64px; max-width: 220px; background: var(--page); }
.att-icon { width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--thunder); color: #fff; }
.att-icon .ti { font-size: 20px; }
.att-meta { min-width: 0; display: flex; flex-direction: column; }
.att-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 13px; color: var(--gray); }
.msg-user-wrap { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); max-width: min(80%, 560px); }
.msg-user-wrap .msg-user { max-width: 100%; }
.msg-atts { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: var(--s2); }

/* ---------- Security: trusted phone + code ---------- */
.phone-row { display: grid; grid-template-columns: 112px 1fr; gap: var(--s3); align-items: start; }
.phone-row > .field + .field { margin-top: 0; }
.style-options.two { grid-template-columns: repeat(2, 1fr); }
.code-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2); max-width: 360px; }
.code-box {
  width: 100%; height: 56px; text-align: center;
  font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--d-micro) var(--ease), box-shadow var(--d-micro) var(--ease), background-color var(--d-short) var(--ease);
}
.code-box:hover:not(:focus) { border-color: var(--line-hover); }
.code-box:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.code-box[aria-invalid="true"] { border-color: var(--err); box-shadow: inset 0 0 0 1px var(--err); }
.code-box.ok { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); background: var(--ok-tint); }
.code-boxes + .error { margin-top: var(--s2); }
.code-ok { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3); color: var(--ok-text); font-weight: 700; }
.code-ok .ti { font-size: 20px; color: var(--ok); }
.code-links { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s3); margin-left: calc(var(--s1) * -1); }
.code-links .link-btn:disabled { color: var(--gray-muted); cursor: default; }

/* ---------- Name preview ---------- */
.name-preview { margin-top: var(--s6); }
.preview-label { color: var(--gray-muted); margin-bottom: var(--s2); }
.preview-card {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); background: var(--card);
  border: 1px solid var(--hairline); border-radius: var(--r-lg); box-shadow: var(--e2);
}
.preview-card img { flex: none; margin-top: 2px; }
.preview-content { flex: 1; min-width: 0; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.preview-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-time { font-size: 13px; color: var(--gray-muted); flex: none; }
.preview-body { font-size: 15px; color: var(--ink); }

/* ---------- Preferences: migrate memory ---------- */
.field-head .btn-sm { margin: -6px 0 -6px auto; }
.migrate-steps { margin: 0 0 var(--s3); padding-left: 20px; color: var(--ink); }
.migrate-steps li + li { margin-top: var(--s1); }
.prompt-box {
  margin: 0; max-height: 150px; overflow: auto; white-space: pre-wrap;
  padding: var(--s3) var(--s4); background: var(--page); border: 1px solid var(--hairline); border-radius: var(--r-md);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink);
}
.migrate-copy { display: flex; justify-content: flex-end; margin: var(--s3) 0 var(--s4); }
.btn.copied { border-color: var(--ok); color: var(--ok-text); }
.btn.copied .ti { color: var(--ok); }

/* ---------- Sidebar chat rows ---------- */
.chat-row { position: relative; display: flex; align-items: center; border-radius: var(--r-md); }
.chat-row .chat-link { flex: 1; min-width: 0; padding-left: 20px; padding-right: 40px; }
.chat-row .unread-dot {
  position: absolute; left: 7px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border-radius: 50%; background: var(--action); opacity: 0; transform: scale(.4);
  transition: opacity var(--d-short) var(--ease), transform var(--d-short) var(--ease);
}
.chat-row.unread .unread-dot { opacity: 1; transform: none; }
.chat-row.unread .nav-text { font-weight: 700; }
.chat-row .row-more {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; color: var(--gray); opacity: 0;
  transition: opacity var(--d-micro) var(--ease), background-color var(--d-micro) var(--ease);
}
.chat-row .row-more .ti { font-size: 18px; }
.chat-row:hover .row-more, .chat-row.active .row-more, .chat-row .row-more:focus-visible,
.chat-row .row-more[aria-expanded="true"] { opacity: 1; }
.chat-row .row-more:hover, .chat-row .row-more[aria-expanded="true"] { background: var(--panel-pressed); color: var(--ink); }
@media (hover: none) { .chat-row .row-more { opacity: 1; } }
.rename-input { min-height: 40px; padding: 8px 12px; font-size: 15px; }
.chat-row.renaming { padding: 2px 0; }

/* ---------- Add to project ---------- */
.project-options { display: flex; flex-direction: column; gap: var(--s2); }
.project-option {
  position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); color: var(--ink); cursor: pointer;
}
.project-option input { position: absolute; opacity: 0; pointer-events: none; }
.project-option:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.project-option:has(input:checked) .choice-dot { border-color: var(--ink); }
.project-option:has(input:checked) .choice-dot::after { transform: scale(1); }
.project-option:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Projects (provisional) ---------- */
.projects { display: flex; flex-direction: column; gap: var(--s8); }
.project-name { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.project-name .ti { font-size: 20px; color: var(--gray); }
.project-chats { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
.project-chats li + li { border-top: 1px solid var(--hairline); }
.project-chat {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 0 var(--s4);
  border: 0; background: transparent; text-align: left; color: var(--ink); cursor: pointer;
}
.project-chat .nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-chat .ti { color: var(--gray-muted); font-size: 18px; }
.project-chat:hover { background: var(--page); }

/* ---------- Settings (iPad-style) ---------- */
.view.view-settings { overflow: hidden; }
.settings { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
.settings-nav { border-right: 1px solid var(--hairline); overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.settings-search-wrap { position: relative; }
.settings-search-wrap .lead { position: absolute; left: 12px; top: 12px; font-size: 20px; color: var(--gray-muted); pointer-events: none; }
.settings-search { padding-left: 40px; border-radius: var(--r-pill); background: var(--panel); border-color: transparent; }
.settings-search::-webkit-search-cancel-button { cursor: pointer; }
.settings-list { display: flex; flex-direction: column; gap: var(--s4); }
.settings-card { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
.settings-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 0 var(--s3);
  border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; position: relative;
  transition: background-color var(--d-micro) var(--ease);
}
.settings-item + .settings-item::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; border-top: 1px solid var(--hairline); }
.settings-item:hover { background: var(--page); }
.settings-item.active { background: var(--action); color: #fff; }
.settings-item.active .srow-chev { color: rgba(255,255,255,.8); }
.settings-item.active + .settings-item::before, .settings-item.active::before { border-color: transparent; }
.settings-item-label { flex: 1; }
.nav-tile {
  width: 28px; height: 28px; flex: none; border-radius: 7px; display: grid; place-items: center;
  background: var(--thunder); color: #fff;
}
.nav-tile .ti { font-size: 18px; }
.nav-tile .core-icon { color: #fff; }
.settings-item.active .nav-tile { background: rgba(255,255,255,.18); }
.settings-card .settings-item { min-height: 72px; }
.settings-card:first-child .settings-item { padding: var(--s3); }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; margin-bottom: var(--s2); }
.settings-account { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.settings-account-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-account-sub { font-size: 13px; opacity: .75; }
.settings-list .settings-card + .settings-card .settings-item { min-height: 48px; }
.settings-noresults { color: var(--gray); padding: var(--s4); text-align: center; }

.settings-pane { overflow-y: auto; }
.settings-pane-inner { max-width: 640px; margin: 0 auto; padding: var(--s6) 20px var(--s12); animation: fade-in var(--d-short) var(--ease) both; }
.spage-title { margin: var(--s2) 0 var(--s6); }
.settings-back { display: inline-flex; align-items: center; gap: 2px; padding-left: 0; margin-left: -4px; }
.settings-back .ti { font-size: 20px; }
.settings-back.mobile-only { display: none; }
.spage-hero { display: flex; flex-direction: column; align-items: center; gap: var(--s1); text-align: center; margin: var(--s4) 0 var(--s8); }
.device-hero { color: var(--ink); margin-bottom: var(--s2); }
.spage-actions { display: flex; justify-content: flex-end; margin-top: var(--s6); }

.sgroup { margin-bottom: var(--s8); }
.sgroup-head { margin: 0 0 var(--s2) var(--s4); font-size: 13px; font-weight: 400; color: var(--gray); text-transform: uppercase; letter-spacing: 0.04em; }
.sgroup-foot { margin: var(--s2) var(--s4) 0; font-size: 13px; line-height: 1.45; color: var(--gray); }
.scard { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
.scard-pad { padding: var(--s6); }
.srow {
  position: relative; display: flex; align-items: center; gap: var(--s3); width: 100%;
  min-height: 48px; padding: var(--s2) var(--s4); background: transparent; border: 0; text-align: left; color: var(--ink);
}
.srow + .srow::before { content: ""; position: absolute; top: 0; left: var(--s4); right: 0; border-top: 1px solid var(--hairline); }
.srow-btn { cursor: pointer; transition: background-color var(--d-micro) var(--ease); }
.srow-btn:hover { background: var(--page); }
.srow-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.srow-sub { font-size: 13px; color: var(--gray); }
.srow-right { color: var(--gray); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow-right:has(.switch, .btn, .segmented, select, .icon-btn) { overflow: visible; }
.srow-chev { color: var(--gray-muted); font-size: 18px; flex: none; }
.srow-lead { flex: none; }
.srow-action { color: var(--action); font-weight: 700; justify-content: flex-start; }
.srow-action.danger { color: var(--err-text); }
.srow-action:disabled { color: var(--gray); cursor: default; }
.srow-action .spinner { margin-right: var(--s1); }
.srow-memory .srow-label { white-space: pre-wrap; overflow-wrap: anywhere; }
.srow-buttons { display: flex; align-items: center; gap: var(--s2); }
.srow-select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--gray);
  font-size: 16px; text-align: right; text-align-last: right; cursor: pointer; padding: var(--s2) 22px var(--s2) var(--s2); min-height: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E6D69' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 9l4-4 4 4M16 15l-4 4-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 2px center;
}
.srow-select:hover { color: var(--ink); }
.service-logo { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--page); border: 1px solid var(--hairline); }
.service-logo .ti { font-size: 20px; }
.status-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--ok-text); }
.status-ok .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.srow-storage { flex-direction: column; align-items: stretch; gap: var(--s2); padding: var(--s3) var(--s4); }
.storage-head { display: flex; justify-content: space-between; }
.storage-bar { height: 8px; border-radius: var(--r-pill); background: var(--panel); overflow: hidden; }
.storage-bar span { display: block; height: 100%; background: var(--action); border-radius: var(--r-pill); }

@media (max-width: 899px) {
  .settings { grid-template-columns: 1fr; }
  .settings-nav { border-right: 0; }
  .settings .settings-pane { display: none; }
  .settings.show-pane .settings-nav { display: none; }
  .settings.show-pane .settings-pane { display: block; }
  .settings-back.mobile-only { display: inline-flex; }
  .settings-item.active { background: transparent; color: var(--ink); }
  .settings-item.active .nav-tile { background: var(--thunder); }
  .settings-item.active .srow-chev { color: var(--gray-muted); }
}

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important;
}

/* ---------- Howard's replies: formatted text ---------- */
.msg-howard .msg-text.md { white-space: normal; }
/* Space between blocks; :not(:first-child) outranks the element resets below */
.md > :not(:first-child) { margin-top: var(--s4); }
.md p, .md ul, .md ol { margin-bottom: 0; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: var(--s1); }
.md li::marker { color: var(--gray); }
.md strong { font-weight: 700; }
.md code { font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel); padding: 1px 5px; border-radius: 4px; }
.md pre { margin: 0; padding: var(--s3) var(--s4); background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0; padding-left: var(--s3); border-left: 3px solid var(--line); color: var(--gray); }
.md a { color: var(--action); text-decoration: underline; text-underline-offset: 2px; }
.md > .md-heading:not(:first-child) { margin-top: var(--s6); }
/* Blinking-free caret while a reply types in */
.md.typing > :last-child:not([hidden])::after,
.md.typing li:last-child::after {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%;
  background: var(--ink); vertical-align: middle; opacity: .7;
}
.md.typing li:not(:last-child)::after { display: none; }

/* ---------- Reply actions (copy, feedback, share, try again, more) ---------- */
.msg-actions {
  display: flex; align-items: center; gap: 2px; margin: var(--s2) 0 0 -8px;
  opacity: 0; transition: opacity var(--d-micro) var(--ease);
}
.msg-howard:hover .msg-actions, .msg-howard.latest .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-howard:not(.latest) .msg-action.retry { display: none; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-action {
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--gray); cursor: pointer; position: relative;
  transition: background-color var(--d-micro) var(--ease), color var(--d-micro) var(--ease);
}
.msg-action::before { content: ""; position: absolute; inset: -6px -2px; } /* 44px touch target */
.msg-action .ti { font-size: 18px; }
.msg-action:hover, .msg-action[aria-expanded="true"] { background: var(--panel); color: var(--ink); }
.msg-action.on { color: var(--action); background: var(--info-tint); }
.msg-action.done { color: var(--ok-text); }
.animate-in { animation: fade-in var(--d-short) var(--ease) both; }

/* ---------- Howard cards (reservation, flight, event, email, reminder, options) ---------- */
.hcard {
  max-width: 460px; background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  padding: var(--s4); box-shadow: var(--e1); display: flex; flex-direction: column; gap: var(--s3);
}
.hcard-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.hcard-type { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: 0.04em; }
.hcard-type .ti { font-size: 16px; }
.hcard-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; background: var(--panel); color: var(--gray); }
.hcard-status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.hcard-status.tone-ok { background: var(--ok-tint); color: var(--ok-text); }
.hcard-status.tone-ok .dot { background: var(--ok); }
.hcard-status.tone-warn { background: var(--warn-tint); color: var(--warn-text); }
.hcard-status.tone-warn .dot { background: var(--warn); }
.hcard-status.tone-err { background: var(--err-tint); color: var(--err-text); }
.hcard-status.tone-err .dot { background: var(--err); }
.hcard-title { font-size: 18px; font-weight: 700; line-height: 1.3; }
.hcard-rows { display: flex; flex-direction: column; gap: 6px; }
.hcard-rows:empty { display: none; }
.hcard-row { display: flex; align-items: flex-start; gap: var(--s2); font-size: 15px; color: var(--ink); }
.hcard-row .ti { font-size: 18px; color: var(--gray-muted); margin-top: 1px; flex: none; }

/* Flight route */
.hcard-route { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; }
.hcard-leg { flex: none; min-width: 72px; }
.hcard-leg:last-child { text-align: right; }
.hcard-code { font-size: 28px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.1; }
.hcard-city { font-size: 13px; color: var(--gray); }
.hcard-time { font-size: 15px; font-weight: 700; margin-top: 2px; }
.hcard-path { flex: 1; display: flex; align-items: center; gap: 6px; position: relative; color: var(--gray-muted); }
.hcard-path .line { flex: 1; height: 0; border-top: 2px dashed var(--line); }
.hcard-path .ti { font-size: 18px; transform: rotate(45deg); }
.hcard-duration { position: absolute; left: 0; right: 0; top: 18px; text-align: center; font-size: 12px; color: var(--gray); }

/* Email */
.hcard-fields { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.hcard-fields .k { display: inline-block; width: 64px; color: var(--gray); }
.hcard-subject { font-weight: 700; }
.hcard-email-body {
  white-space: pre-wrap; font-size: 15px; line-height: 1.5; color: var(--ink);
  padding-top: var(--s3); border-top: 1px solid var(--hairline); max-height: 240px; overflow-y: auto;
}

/* Buttons */
.hcard-actions { display: flex; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s1); }
.hcard-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 700; cursor: pointer; position: relative;
  transition: border-color var(--d-micro) var(--ease), background-color var(--d-micro) var(--ease);
}
.hcard-btn::before { content: ""; position: absolute; inset: -4px 0; } /* 44px touch target */
.hcard-btn .ti { font-size: 16px; }
.hcard-btn:hover { border-color: var(--line-hover); background: var(--page); }

/* Options: tappable choices */
.hcard-choices { display: flex; flex-direction: column; margin: 0 calc(var(--s4) * -1) calc(var(--s4) * -1); border-top: 1px solid var(--hairline); }
.hcard-choice {
  display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s4);
  border: 0; background: transparent; text-align: left; color: var(--ink); cursor: pointer;
  transition: background-color var(--d-micro) var(--ease);
}
.hcard-choice + .hcard-choice { border-top: 1px solid var(--hairline); }
.hcard-choice:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.hcard-choice:hover { background: var(--page); }
.hcard-choice-text { flex: 1 1 auto; min-width: 55%; display: flex; flex-direction: column; gap: 2px; }
.hcard-choice-title { font-weight: 700; }
.hcard-choice-sub { font-size: 13px; color: var(--gray); }
.hcard-choice-detail { flex: 0 1 auto; max-width: 35%; font-weight: 700; color: var(--ink); text-align: right; overflow-wrap: anywhere; }
.hcard-choice-note { font-size: 14px; line-height: 1.4; color: var(--ink); margin-top: 2px; }
.hcard-choice .ti { flex: none; }
.hcard-choice .ti { color: var(--gray-muted); font-size: 18px; }
.hcard-options .hcard-type { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }

/* Math (KaTeX) */
.md .math-block { overflow-x: auto; overflow-y: hidden; padding: var(--s1) 0; }
.md .math-block .katex-display { margin: 0; text-align: left; }
.md .katex { font-size: 1.08em; }
.md .math-fallback { font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--gray); }
