/* Phones: the chat at 390 px (composer, agent panel, approval cards), the
   iPhone and Android apps (html.native-mobile, public/mobile-bridge.js) and
   the installed web app, plus dictation, notification settings and App lock.
   Refinements only: the shared components keep their design (DESIGN-FOUNDATION.md). */

/* ---- Dictation (public/voice-input.js): hidden until this device can do it ---- */
.composer-mic {
  display: none; width: 32px; height: 32px; flex: none; padding: 0;
  align-items: center; justify-content: center;
  background: transparent; color: var(--ink-3); border: 0; border-radius: 50%; cursor: pointer;
  transition: color .12s ease, background-color .12s ease;
}
.composer-mic svg { width: 17px; height: 17px; }
.composer-mic:hover { color: var(--ink-1); }
html.voice-ready .composer-mic { display: inline-flex; }
.composer-mic:disabled { opacity: .45; cursor: not-allowed; }
/* Listening is the one coloured state: red means the microphone is on. */
.composer-mic.listening { color: var(--red); background: var(--red-soft); animation: avori-mic 1.4s ease-in-out infinite; }
@keyframes avori-mic { 50% { box-shadow: 0 0 0 4px var(--red-soft); } }
@media (prefers-reduced-motion: reduce) { .composer-mic.listening { animation: none; } }

/* ---- Share to Avori: the draft came from another app ---- */
.share-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; padding: 6px 6px 6px 10px;
  border-radius: 10px; background: var(--raise); color: var(--ink-2); font-size: var(--text-sm, 13px); }
.share-banner .icon-btn { background: transparent; border: 0; color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer; min-width: 32px; min-height: 32px; }

/* ---- Settings › Notifications (public/notifications.js) ---- */
.push-settings { display: grid; gap: var(--space-3, 12px); margin-bottom: var(--space-5, 20px); }
.push-settings h3, .push-email-head { margin: var(--space-3, 12px) 0 0; font-size: var(--text-sm, 13px); font-weight: 600; color: var(--ink-2); }
.push-here { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.push-here-copy { display: grid; gap: 2px; flex: 1 1 200px; min-width: 0; }
.push-kinds, .push-devices { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.push-kind, .push-devices li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; min-height: 44px; cursor: pointer; }
.push-kind + .push-kind, .push-devices li + li { border-top: 1px solid var(--line); }
.push-kind > span, .push-devices li > span { display: grid; gap: 2px; min-width: 0; }
.push-settings > .push-kind { border: 1px solid var(--line-2); border-radius: 12px; }
/* A plain switch: black/white anchors, grey when off. */
.push-kind input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 40px; height: 24px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line-2); cursor: pointer;
  transition: background-color .15s ease;
}
.push-kind input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s ease;
}
.push-kind input[type="checkbox"]:checked { background: var(--ink-1); border-color: var(--ink-1); }
.push-kind input[type="checkbox"]:checked::after { transform: translateX(16px); }
.push-kind input[type="checkbox"]:focus-visible { outline: 2px solid var(--ink-3); outline-offset: 2px; }

/* ---- App lock (the phone apps): covers Avori until Face ID or a fingerprint ---- */
.app-lock {
  position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  background: var(--bg); padding: env(safe-area-inset-top, 0) 16px env(safe-area-inset-bottom, 0);
}
.app-lock img { border-radius: 16px; }

/* ---- The apps and the installed web app: clear the status bar and home indicator ---- */
html.native-mobile .topbar, html.native-mobile .work-panel, html.native-mobile .sidebar { padding-top: env(safe-area-inset-top, 0px); }
@media (display-mode: standalone) {
  .topbar, .sidebar { padding-top: env(safe-area-inset-top, 0px); }
}
/* Sign-in and the other account pages clear the status bar too. */
html.native-mobile .login-wrap { padding-top: calc(env(safe-area-inset-top, 0px) + 16px); }
@media (display-mode: standalone) { .login-wrap { padding-top: calc(env(safe-area-inset-top, 0px) + 16px); } }
html.native-mobile, html.native-mobile body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
html.native-mobile .composer-hint { display: none; }

/* ---- Phones ---- */
@media (max-width: 600px) {
  /* The message box: a calm 1px edge while typing (the doubled ring reads heavy on a phone). */
  .composer-dock .composer:focus-within { box-shadow: none; }
  /* 16px text keeps iOS from zooming into the box; long drafts scroll inside it. */
  .composer .composer-input { font-size: 16px; max-height: 38vh; }
  /* The tools row keeps the model name readable; an owner's admin link gives way first. */
  /* (Home's box and a chat's box alike.) */
  :root .composer :is(#thread-model, #composer-model-slot) { display: flex; min-width: 0; overflow: hidden; align-items: center; }
  :root .composer :is(#thread-model, #composer-model-slot) :is(.model-pill, .model-pick-btn, .composer-model-wrap) { flex-shrink: 0; }
  :root .composer :is(#thread-model, #composer-model-slot) .composer-model-admin { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs, 12px); }
  .composer .composer-tools { min-width: 0; }
  /* Touch targets: 36px for every tool and for Send. */
  .composer-dock .composer-clip, .composer-dock .composer-new-topic, .composer-dock .composer-mic { min-width: 36px; min-height: 36px; }
  .composer-dock .composer-send { width: 36px; height: 36px; }

  /* Approval cards: full-width answers, Approve on the right as the one solid action. */
  .approval-card { border-radius: 16px; }
  .approval-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .approval-card-actions .btn { min-height: 44px; justify-content: center; }
  .approval-card-actions .btn:not(.primary) { background: var(--bg); }
  .approval-write-details pre { max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }

  /* The agent panel is a full-screen sheet: scrolling it never scrolls the chat behind. */
  .work-panel { overscroll-behavior: contain; }
}

/* ==== Phones: ChatGPT/Claude-app sizing (Tray, 2026-10-03) ====
   At phone widths only; the desktop is unchanged. Home and chat lose the
   title bar for floating round buttons; the message box is one compact pill
   with the model as a small chip and the rest behind "+"; assistant replies
   are plain text and the person's messages a light bubble; ~17px body. */
.topbar-new, .composer-more { display: none; }
@media (max-width: 600px) {
  /* -- Floating header (Home and chat) -- */
  :is([data-page="home"], [data-page="chat"]) > .main { position: relative; }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 40; min-height: 0; border: 0; background: none !important; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
    padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px 0; gap: 8px; pointer-events: none; flex-wrap: nowrap;
  }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar > * { pointer-events: auto; }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar::before, :is([data-page="home"], [data-page="chat"]) > .main > .topbar::after { display: none; }
  /* Right side: page actions (Pin) and, on Home, new chat. */
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar > .spacer { display: block !important; flex: 1 1 auto; min-width: 0; }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar :is(h1, .topbar-heading) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar :is(.menu-btn, .topbar-new, .btn) {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-width: 44px; padding: 0;
    border-radius: 50%; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--ink-1); box-shadow: none;
  }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar :is(.menu-btn, .topbar-new, .btn) svg { width: 18px; height: 18px; }
  :is([data-page="home"], [data-page="chat"]) > .main > .topbar .btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  [data-page="home"] > .main > .topbar .topbar-new { display: inline-flex; }
  [data-page="chat"] > .main > .topbar .topbar-new { display: none; }
  [data-page="chat"] > .main > .content { padding-top: env(safe-area-inset-top, 0px); }
  /* The chat's own row (agent chip, panel, more) shares the floating header's line. */
  [data-page="chat"] .thread-top { min-height: 56px; padding: 6px 58px 0 60px; background: none; }
  [data-page="chat"] .thread-top > .grow { display: none; }
  [data-page="chat"] .thread-top .thread-agent-float { position: static; transform: none; margin-right: auto; min-width: 0; flex: 0 1 auto; max-width: none; }
  [data-page="chat"] .thread-top .thread-agent-btn { min-width: 0; }
  [data-page="chat"] .thread-top .thread-agent-btn { max-width: 100%; }
  [data-page="chat"] .thread-top .taf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  [data-page="chat"] .thread-top .work-agent-toggle { display: none; }
  [data-page="chat"] > .main > .topbar .btn { order: 3; }
  [data-page="chat"] .thread-top :is(.icon-btn, .thread-panel-toggle) { width: 44px; height: 44px; }
  /* Chat index (no thread): room for the floating buttons. */
  [data-page="chat"] .chat-empty, [data-page="home"] .chat-empty { padding-top: calc(env(safe-area-inset-top, 0px) + 64px); }

  /* -- Home: a smaller greeting, no logo or tagline -- */
  [data-page="home"] :is(.home-brand-lockup, .home-brand-line, .home-personal-intro, .ce-eyebrow), [data-page="chat"] .ce-eyebrow { display: none; }
  [data-page="home"] .ce-title, [data-page="chat"] .ce-title { font-size: 22px; line-height: 1.25; margin: 0 0 16px; letter-spacing: -.02em; }
  .home-suggestions .premium-card, #home-suggestions > * > * { padding-block: 8px; }

  /* -- Messages -- */
  #chat-msgs { gap: 14px; padding-inline: 14px; }
  .msg .msg-avatar { display: none; }
  .msg.user .who { display: none; }
  .msg.user .msg-body { align-items: flex-end; max-width: 85%; }
  .msg.user .bubble { font-size: 17px; line-height: 1.45; padding: 8px 14px; border-radius: 20px; background: var(--panel-2); border: 0; max-width: none; }
  .msg.agent .bubble, .msg.agent .md { font-size: 17px; line-height: 1.5; padding: 0; background: transparent; border: 0; box-shadow: none; max-width: 100%; }
  .msg.agent .md p, .msg.agent .bubble p { margin: 0 0 .8em; }
  .msg.agent .md > :last-child, .msg.agent .bubble > :last-child { margin-bottom: 0; }
  .msg .who { margin: 0 0 2px; }
  /* Small actions (copy, more): 32px to see, 44px to tap. */
  .message-tools { height: 32px; margin-top: 2px; gap: 4px; }
  .message-tools :is(.message-copy, .message-menu summary) { width: 32px; height: 32px; padding: 7px; position: relative; color: var(--ink-3); }
  .message-tools :is(.message-copy, .message-menu summary)::after { content: ""; position: absolute; inset: -6px; }
  .composer-privacy, .chat-privacy { display: none; }

  /* -- The message box: one compact pill -- */
  .composer-dock { padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .composer, .composer.big { border-radius: 26px; padding: 8px 8px 6px 14px; gap: 2px; min-height: 0; border-color: var(--line-2); box-shadow: none; }
  .composer .composer-input { padding: 4px 0 2px; min-height: 26px; line-height: 1.45; }
  .composer.big .composer-input { min-height: 26px; }
  .composer .composer-tools { gap: 2px; align-items: center; justify-content: flex-start; flex-wrap: nowrap; margin-left: -8px; }
  .composer.tools-open .composer-tools { flex-wrap: wrap; }
  .composer .composer-tools-right { display: contents !important; }
  .composer .composer-tools { width: 100%; }
  /* Touch targets: 44px (Apple's guideline); fewer controls in the row, not smaller ones. */
  .composer .composer-more { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); }
  .composer .composer-more svg { width: 20px; height: 20px; transition: transform .15s ease; }
  .composer.tools-open .composer-more svg { transform: rotate(45deg); }
  /* Behind "+": the agent, approvals, effort, new topic, attach, context. */
  .composer .composer-tools > :is(.agent-pick, .composer-approval-slot, .composer-effort-slot, .composer-new-topic, .composer-agents-slot),
  .composer .composer-tools :is(.composer-clip, .composer-context-slot, .composer-plan-slot, .composer-hint) { display: none !important; }
  .composer.tools-open .composer-tools > :is(.agent-pick, .composer-approval-slot, .composer-effort-slot, .composer-new-topic, .composer-agents-slot),
  .composer.tools-open .composer-tools :is(.composer-clip, .composer-context-slot) { display: inline-flex !important; order: 20 !important; margin: 0 !important; }
  .composer.tools-open .composer-tools > :is(.agent-pick, .composer-approval-slot, .composer-effort-slot, .composer-new-topic, .composer-agents-slot) { order: 20 !important; margin: 0 !important; }
  .composer.tools-open .composer-tools::after { content: ""; order: 19; flex-basis: 100%; height: 0; }
  /* The model: a small chip in the regular font; the owner's admin link stays in Admin. */
  .composer :is(#thread-model, #composer-model-slot) { order: 1 !important; flex: 0 1 auto; margin-left: 0 !important; margin-right: 0 !important; }
  .composer :is(#thread-model, #composer-model-slot) :is(.model-pill, .model-pick-btn, .composer-model-wrap, .model-loading) {
    font-family: inherit; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--ink-2); border: 0; background: transparent; padding: 4px 6px; min-height: 32px; }
  .composer :is(#thread-model, #composer-model-slot) :is(.model-dot, .composer-model-admin) { display: none; }
  /* An owner's "Approve models" link waits behind "+" too, beside the model. */
  .composer.tools-open :is(#thread-model, #composer-model-slot) .composer-model-admin { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; }
  /* Open: + / mic / send stay on the first line; the model (and that link) get their own line, then the rest. */
  .composer.tools-open .composer-mic { order: 2; }
  .composer.tools-open .composer-send { order: 3; }
  .composer.tools-open :is(#thread-model, #composer-model-slot) { order: 18 !important; flex: 1 0 100%; justify-content: flex-start !important; }
  .composer.tools-open .composer-mic { order: 2 !important; }
  .composer.tools-open .composer-send { order: 3 !important; }
  .composer .composer-tools > .composer-more { order: 0 !important; }
  .composer .composer-mic { order: 30 !important; margin-left: auto; width: 44px; height: 44px; min-width: 44px; }
  /* Send: a 36px round button with a 44px touch area. */
  .composer .composer-send { order: 31 !important; width: 44px; height: 44px; min-width: 44px; padding: 4px; border: 0; border-radius: 50%; background-clip: content-box; }
  .composer.tools-open .composer-tools > :is(.agent-pick, .composer-approval-slot, .composer-effort-slot, .composer-new-topic, .composer-agents-slot),
  .composer.tools-open .composer-tools :is(.composer-clip, .composer-context-slot) { min-height: 44px; }
  .composer :is(#thread-model, #composer-model-slot) { min-height: 44px; }
  .composer:not(:has(.composer-mic:not([hidden]))) .composer-send { margin-left: auto; }
  html:not(.voice-ready) .composer .composer-send { margin-left: auto; }

  /* -- Agent panel sheet and lists -- */
  .work-panel .wp-head { padding: 8px 12px 6px; gap: 6px 8px; }
  .work-panel .wp-avatar, .work-panel .wp-avatar .agent-identity { width: 44px; height: 44px; }
  .work-panel .wp-agent-name { font-size: 16px; }
  .work-panel .wp-body { padding: 14px 16px; }
  .chat-rail .rail-item { padding: 8px 6px; }
  .chat-rail .rail-item :is(.agent-identity, .rail-avatar, img) { width: 40px; height: 40px; }
}
