/* PrivateLocal.Chat visual system. Tokens come from the brand packet (brand/design-tokens.css); everything below maps the app onto them.
   Light and dark follow data-theme, which the app always sets. Cool paper, dark ink, one restrained blue. System fonts only. */

:root, [data-theme="light"] {
  --plc-background: #F6F8FB; --plc-surface: #FFFFFF; --plc-ink: #182332; --plc-muted: #526174;
  --plc-accent: #285BD4; --plc-accent-hover: #1C45AD; --plc-accent-tint: #EAF0FF; --plc-border: #D6DEE8;
  --plc-success: #21664A; --plc-success-tint: #E8F5EC; --plc-warning: #805100; --plc-warning-tint: #FFF4D6;
  --plc-danger: #AA3038; --plc-danger-tint: #FFF0F1; --plc-on-accent: #FFFFFF; --plc-focus: #285BD4;
  --plc-font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --plc-radius-control: 0.625rem; --plc-radius-panel: 1rem; --plc-chat-max: 48rem; --plc-control-min: 2.75rem;
  --plc-motion-fast: 120ms; --plc-motion-normal: 180ms; --plc-ease: cubic-bezier(.2,.7,.2,1);
  --plc-shadow: 0 1px 2px rgba(24, 35, 50, 0.06), 0 8px 24px rgba(24, 35, 50, 0.08);
  --plc-hairline: color-mix(in srgb, var(--plc-border) 70%, transparent);
  color-scheme: light;
}
[data-theme="dark"] {
  --plc-background: #101820; --plc-surface: #172330; --plc-ink: #EAF0F7; --plc-muted: #AAB8C7;
  --plc-accent: #91B5FF; --plc-accent-hover: #B4CCFF; --plc-accent-tint: #233652; --plc-border: #33465C;
  --plc-success: #92D7AF; --plc-success-tint: #1B392D; --plc-warning: #F3CF83; --plc-warning-tint: #3C321C;
  --plc-danger: #FFAFB4; --plc-danger-tint: #40262D; --plc-on-accent: #101820; --plc-focus: #91B5FF;
  --plc-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
@media (prefers-reduced-motion: reduce) { :root { --plc-motion-fast: 0ms; --plc-motion-normal: 0ms; } }

/* the app's existing variables, pointed at the brand */
:root, [data-theme="light"], [data-theme="dark"] {
  --color-bg: var(--plc-background); --color-text: var(--plc-ink); --color-strong-text: var(--plc-ink); --color-muted-text: var(--plc-muted);
  --color-inverse-text: var(--plc-on-accent); --color-link: var(--plc-accent); --color-link-hover: var(--plc-accent-hover); --color-link-focus: var(--plc-focus);
  --color-border: var(--plc-border); --color-border-strong: color-mix(in srgb, var(--plc-border) 60%, var(--plc-muted));
  --color-sidebar-bg: var(--plc-surface); --color-sidebar-shadow: rgba(16, 24, 32, 0.25);
  --color-surface: var(--plc-surface); --color-surface-alt: var(--plc-background);
  --color-thread-hover: color-mix(in srgb, var(--plc-accent-tint) 60%, transparent); --color-thread-selected: var(--plc-accent-tint); --color-thread-selected-text: var(--plc-ink);
  --color-thread-menu-bg: var(--plc-surface); --color-thread-menu-border: var(--plc-border); --color-thread-menu-hover: var(--plc-accent-tint);
  --color-icon-btn-bg: var(--plc-surface); --color-icon-btn-border: var(--plc-border); --color-icon-btn-hover-bg: var(--plc-accent-tint); --color-icon-btn-hover-border: var(--plc-accent);
  --color-success: var(--plc-success); --color-success-hover: var(--plc-success); --color-secondary: var(--plc-muted); --color-secondary-hover: var(--plc-ink);
  --color-warning-bg: var(--plc-danger-tint); --color-warning-border: var(--plc-danger); --color-warning-text: var(--plc-danger);
  --color-overlay: rgba(16, 24, 32, 0.5); --color-modal-bg: var(--plc-surface); --color-modal-border: var(--plc-border); --color-modal-secondary-bg: var(--plc-surface); --color-modal-secondary-text: var(--plc-accent); --color-modal-fine-print: var(--plc-muted);
  --color-system-prompt-border: var(--plc-border); --color-system-prompt-label: var(--plc-muted);
  --color-messages-bg: var(--plc-background); --color-message-user-bg: var(--plc-accent-tint); --color-message-assistant-bg: transparent;
  --color-message-system-bg: var(--plc-warning-tint); --color-message-system-border: var(--plc-warning);
  --color-form-border: color-mix(in srgb, var(--plc-border) 55%, var(--plc-muted)); --color-form-disabled-bg: var(--plc-background);
  --color-toast-bg: var(--plc-ink); --color-toast-text: var(--plc-background);
  --color-notice-bg: var(--plc-warning-tint); --color-notice-border: var(--plc-warning); --color-notice-text: var(--plc-warning);
  --color-action-text: var(--plc-ink); --color-danger: var(--plc-danger); --color-loading-track: var(--plc-border);
  --color-promo-bg: var(--plc-warning-tint); --color-promo-border: var(--plc-warning); --color-promo-text: var(--plc-warning);
}

/* ---- base ---------------------------------------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--plc-font); font-size: 1rem; line-height: 1.5; background: var(--plc-background); color: var(--plc-ink); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--plc-focus); outline-offset: 2px; border-radius: 6px; }
a { color: var(--plc-accent); text-underline-offset: 2px; }
a:hover { color: var(--plc-accent-hover); }
::selection { background: color-mix(in srgb, var(--plc-accent) 28%, transparent); }
input, select, textarea, button { font-family: inherit; }
input, select, textarea { font-size: 1rem; } /* 16px stops iOS from zooming into a field */
button { -webkit-tap-highlight-color: transparent; }
.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.2em; }
.emoji-icon { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.emoji-icon .ico { width: 1.2em; height: 1.2em; }
.ico-label { white-space: nowrap; }
[aria-busy='true'] { opacity: 0.6; pointer-events: none; cursor: progress; }

/* buttons: three kinds, one shape */
button.primary, button.secondary, .primary, .secondary { min-height: var(--plc-control-min); padding: 0.5rem 1rem; border-radius: var(--plc-radius-control); font-size: 0.95rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; transition: background var(--plc-motion-fast) var(--plc-ease), border-color var(--plc-motion-fast) var(--plc-ease); }
button.primary, .primary { background: var(--plc-accent); border: 1px solid var(--plc-accent); color: var(--plc-on-accent); }
button.primary:hover, .primary:hover { background: var(--plc-accent-hover); border-color: var(--plc-accent-hover); }
button.secondary, .secondary { background: var(--plc-surface); border: 1px solid var(--color-form-border); color: var(--plc-ink); }
button.secondary:hover, .secondary:hover { border-color: var(--plc-accent); background: var(--plc-accent-tint); }
button.danger, .danger.secondary { color: var(--plc-danger); }
.form-group button, .model-actions button, #setupPrivateChat, #freeMemory, .model-actions button { width: auto; }
.form-group button { background: var(--plc-surface); color: var(--plc-ink); border: 1px solid var(--color-form-border); border-radius: var(--plc-radius-control); min-height: var(--plc-control-min); font-weight: 600; }
.form-group button:hover { background: var(--plc-accent-tint); border-color: var(--plc-accent); }
.icon-btn { min-width: var(--plc-control-min); min-height: var(--plc-control-min); border-radius: var(--plc-radius-control); background: transparent; border: 1px solid transparent; color: var(--plc-ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--plc-accent-tint); border-color: transparent; }
.link-btn { color: var(--plc-accent); min-height: 0; }
select, input[type='text'], input[type='search'], input[type='password'], textarea { border-radius: var(--plc-radius-control); }
.form-group select, .form-group input, .form-group textarea { min-height: var(--plc-control-min); padding: 0.5rem 0.75rem; border-radius: var(--plc-radius-control); border: 1px solid var(--color-form-border); }
.form-group label, label { color: var(--plc-ink); }

/* ---- shell ---------------------------------------------------------------------------------------------------------- */
#app { background: var(--plc-background); }
.sidebar { background: var(--plc-surface); border-right: 1px solid var(--plc-border); padding: 0; gap: 0; width: min(88vw, 21rem); box-shadow: var(--plc-shadow); }
@media (min-width: 900px) { .sidebar { width: 19.5rem; max-width: 19.5rem; box-shadow: none; } }
.sidebar-header { padding: 1rem 1rem 0.5rem; margin: 0; }
.brand { display: inline-flex; align-items: center; text-decoration: none; min-height: var(--plc-control-min); }
.brand-logo img { display: block; height: 1.6rem; width: auto; }
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
.sidebar > :not(.sidebar-header) { margin-left: 1rem; margin-right: 1rem; }
.sidebar > .side-footer, .sidebar > details { margin-left: 1rem; margin-right: 1rem; }
.new-chat-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; margin-bottom: 0.75rem; }
.new-chat-row .new-thread-button { flex: 1; width: auto; margin: 0; }
.new-chat-row .icon-btn { flex: none; border-color: var(--color-form-border); background: var(--plc-surface); }
.new-chat-row .icon-btn:hover { border-color: var(--plc-accent); }
.new-chat-row .primary { justify-content: center; }
.chats-section { min-height: 0; margin-top: 0; margin-bottom: 0.5rem; }
textarea::placeholder, input::placeholder { color: var(--plc-muted); opacity: 1; }
.thread-filter { display: flex; background: var(--plc-background); border: 1px solid var(--plc-border); border-radius: var(--plc-radius-control); padding: 2px; gap: 2px; margin-bottom: 0.5rem; }
.thread-filter button { flex: 1; border: 0; background: transparent; color: var(--plc-muted); border-radius: calc(var(--plc-radius-control) - 2px); min-height: 2.25rem; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.thread-filter button[aria-pressed='true'] { background: var(--plc-surface); color: var(--plc-ink); box-shadow: 0 1px 2px rgba(24, 35, 50, 0.12); }
.thread-list li { border-radius: var(--plc-radius-control); padding: 0 0.25rem 0 0.75rem; min-height: var(--plc-control-min); margin: 1px 0; color: var(--plc-ink); position: relative; }
.thread-list li.selected { background: var(--plc-accent-tint); color: var(--plc-ink); box-shadow: inset 3px 0 0 var(--plc-accent); }
.thread-list li:hover { background: var(--color-thread-hover); }
.thread-list li .thread-name { min-height: var(--plc-control-min); display: flex; align-items: center; gap: 0.25rem; font-size: 0.95rem; text-align: left; }
.thread-list li.selected .thread-name { font-weight: 600; }
.thread-list li .pin-mark { font-size: 0.8rem; }
.thread-menu-btn { min-width: 2.25rem; min-height: 2.25rem; color: var(--plc-muted); border-radius: 8px; }
.thread-menu-btn:hover, .thread-list li.selected .thread-menu-btn:hover { background: var(--plc-surface); color: var(--plc-ink); }
.thread-list li.folder-heading { box-shadow: none; background: none; color: var(--plc-muted); min-height: 2rem; }
.thread-list li.folder-heading:hover { background: none; }
.chats-section .thread-list { max-height: min(42vh, 26rem); }
.settings-group { border-top: 1px solid var(--plc-border); padding: 0.25rem 0; margin-bottom: 0; }
.settings-group > * { padding-left: 0.25rem; padding-right: 0.25rem; }
#localModelPanel h3 { display: none; }
.setup-card { border: 1px solid var(--plc-border); border-radius: var(--plc-radius-panel); background: var(--plc-background); padding: 0.75rem; margin: 0.5rem 0 0.75rem; }
.readiness { gap: 0.4rem; font-size: 0.9rem; }
.readiness li { display: flex; align-items: center; gap: 0.5rem; }
.readiness li::before { content: ''; width: 0.9rem; height: 0.9rem; border-radius: 50%; border: 2px solid var(--plc-border); flex: none; }
.readiness li.yes::before { content: '\2713'; background: var(--plc-success); color: var(--plc-surface); border-color: var(--plc-success); font-size: 0.6rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.readiness li.yes { color: var(--plc-ink); }
.readiness li.no { color: var(--plc-muted); }
.readiness li.no::before { border-color: var(--plc-border); color: inherit; content: ''; }
#setupPrivateChat { width: 100%; margin-top: 0.5rem; }
.model-actions { gap: 0.5rem; margin: 0.5rem 0; }
.model-actions button { flex: 1 1 auto; font-size: 0.9rem; }
#modelDetails, #modelStatus { font-size: 0.85rem; color: var(--plc-muted); margin: 0.25rem 0; }
#modelStatus[data-error='true'] { color: var(--plc-danger); }
.actions { margin: 0.25rem 0 0.5rem; }
.action-group { background: transparent; }
.side-footer { margin-top: auto; padding: 0.75rem 0 1rem; border-top: 1px solid var(--plc-border); }
.side-footer .hint-text { margin: 0.35rem 0; font-size: 0.8rem; }
#reloadApp { width: 100%; }
.hint-text, .muted { color: var(--plc-muted); }
.threads-header { margin: 0; }

/* ---- chat header ---------------------------------------------------------------------------------------------------- */
.chat-area { background: var(--plc-background); }
.chat-header { background: var(--plc-surface); border-bottom: 1px solid var(--plc-border); padding: 0.5rem 0.75rem; gap: 0.5rem; min-height: 3.5rem; }
.chat-header .thread-title { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; font-size: 1.05rem; font-weight: 600; color: var(--plc-ink); min-height: var(--plc-control-min); padding: 0 0.5rem; text-overflow: ellipsis; }
.chat-header .thread-title:hover { border-color: var(--plc-border); }
.chat-header .thread-title:focus { background: var(--plc-background); border-color: var(--plc-accent); outline: none; }
.header-tools { display: flex; gap: 0.25rem; }
.mode-badge { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.25rem; padding: 0 0.85rem; border-radius: 999px; border: 0; font-size: 0.85rem; font-weight: 600; cursor: pointer; white-space: nowrap; max-width: 14rem; }
.mode-badge .mode-badge-text { overflow: hidden; text-overflow: ellipsis; }
.mode-badge.local { background: var(--plc-success-tint); color: var(--plc-success); }
.mode-badge.connected { background: var(--plc-warning-tint); color: var(--plc-warning); }
.mode-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: currentColor; flex: none; }
#generationStatus { margin: 0.5rem 1rem 0; padding: 0.4rem 0.75rem; border: 0; border-radius: var(--plc-radius-control); background: var(--plc-accent-tint); color: var(--plc-ink); font-size: 0.85rem; max-height: 2.6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-notice { margin: 0.5rem 1rem 0; border-radius: var(--plc-radius-control); }
.system-prompt-container { background: var(--plc-surface); border-bottom: 1px solid var(--plc-border); padding: 0 0.75rem; }
.system-prompt-container > summary { min-height: 2.5rem; display: flex; align-items: center; font-size: 0.85rem; font-weight: 600; color: var(--plc-muted); }
.system-prompt-container textarea { min-height: 5rem; font-size: 1rem; }
.preset-row select { min-height: var(--plc-control-min); }
.temp-banner { margin: 0.5rem auto; max-width: var(--plc-chat-max); }

/* ---- conversation ---------------------------------------------------------------------------------------------------- */
.messages { padding: 1.25rem 1rem 0.5rem; background: var(--plc-background); }
.message { max-width: var(--plc-chat-max); margin: 0 auto 1.25rem; padding: 0; background: transparent; border: 0; border-radius: 0; }
.message.user, .message.assistant { background: transparent; }
.message .speaker { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; color: var(--plc-muted); margin: 0 0 0.3rem 0.1rem; }
.message.user .message-body { background: var(--plc-accent-tint); border-radius: var(--plc-radius-panel); padding: 0.75rem 1rem; display: block; }
.message.user { margin-left: auto; margin-right: auto; }
.message.user .speaker { text-align: left; }
.message.assistant .message-body { padding: 0.1rem 0.1rem; line-height: 1.6; }
.message.system { background: var(--plc-warning-tint); border: 1px solid var(--plc-warning); border-radius: var(--plc-radius-control); padding: 0.75rem 1rem; }
.message.excluded { opacity: 0.6; border: 0; }
.message.excluded .message-body { outline: 1px dashed var(--plc-border); outline-offset: 2px; }
.message-model { margin-top: 0.4rem; font-size: 0.78rem; color: var(--plc-muted); }
.message-meta { margin-top: 0.4rem; font-size: 0.82rem; color: var(--plc-muted); }
.message-meta .badge { border-radius: var(--plc-radius-control); border: 0; background: var(--plc-warning-tint); color: var(--plc-warning); padding: 0.3rem 0.65rem; display: inline-block; }
.message-meta.failed .badge { background: var(--plc-danger-tint); color: var(--plc-danger); }
.message-actions { gap: 0.15rem; margin-top: 0.25rem; opacity: 1; }
.message-actions .act, .message-actions button { border: 0; background: transparent; color: var(--plc-muted); border-radius: 8px; padding: 0 0.6rem; min-height: 2.25rem; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-weight: 500; }
.message-actions .act:hover, .message-actions button:hover, .message-actions button:focus-visible { background: var(--plc-accent-tint); color: var(--plc-ink); border-color: transparent; }
.message-actions button[aria-pressed='true'] { color: var(--plc-accent); background: var(--plc-accent-tint); }
.version-switch { display: inline-flex; align-items: center; color: var(--plc-muted); font-size: 0.85rem; }
.version-switch button { padding: 0 0.4rem; min-width: 2rem; }
@media (hover: hover) and (pointer: fine) {
  .message:not(:last-child) .message-actions { opacity: 0; transition: opacity var(--plc-motion-fast); }
  .message:hover .message-actions, .message:focus-within .message-actions, .message:last-child .message-actions { opacity: 1; }
}
.message-sources button { border-radius: 999px; border: 1px solid var(--plc-border); background: var(--plc-surface); min-height: 2rem; padding: 0 0.7rem; }
.chip { border-radius: 999px; background: var(--plc-surface); border-color: var(--plc-border); min-height: 2rem; padding: 0 0.6rem; }
.message-attachments .ico { width: 1em; height: 1em; }
.code-block { border-radius: var(--plc-radius-control); border-color: var(--plc-border); background: var(--plc-surface); }
.code-bar { background: var(--plc-background); border-bottom: 1px solid var(--plc-border); }
.code-action { min-height: 2rem; border-radius: 6px; padding: 0 0.6rem; }
.message-body code { background: color-mix(in srgb, var(--plc-muted) 14%, transparent); }
.message-body blockquote { border-left-color: var(--plc-accent); }
.table-wrap th { background: var(--plc-background); }
.edit-box textarea { background: var(--plc-surface); }
.context-divider { max-width: var(--plc-chat-max); border-color: var(--plc-border); }
.jump-latest { background: var(--plc-surface); border: 1px solid var(--plc-border); border-radius: 999px; min-height: 2.5rem; box-shadow: var(--plc-shadow); font-weight: 600; }

/* empty state and welcome */
.empty-state { margin-top: min(10vh, 4rem); }
.empty-state h2 { font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
.empty-state .lede { color: var(--plc-muted); font-size: 1.05rem; margin: 0 0 1.25rem; }
.empty-state .eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; color: var(--plc-accent); margin: 0 0 0.5rem; }
.empty-state.welcome h2 { font-size: clamp(1.9rem, 6vw, 2.75rem); }
.welcome-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin: 1.25rem 0 0.75rem; }

/* ---- composer -------------------------------------------------------------------------------------------------------- */
.context-meter { max-width: var(--plc-chat-max); width: 100%; margin: 0 auto; padding: 0 1rem 0.35rem; }
.message-form { display: block; padding: 0.25rem 1rem max(0.75rem, env(safe-area-inset-bottom)); border: 0; background: transparent; }
.message-form .composer-card, .message-form > .message-attachments, .message-form .accuracy-note { max-width: var(--plc-chat-max); margin-left: auto; margin-right: auto; }
.message-form > .message-attachments { margin-bottom: 0.5rem; }
.composer-card { background: var(--plc-surface); border: 1px solid var(--color-form-border); border-radius: var(--plc-radius-panel); padding: 0.4rem 0.5rem 0.4rem 0.75rem; box-shadow: var(--plc-shadow); transition: border-color var(--plc-motion-fast); }
.composer-card:focus-within { border-color: var(--plc-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--plc-accent) 22%, transparent); }
.composer-card .message-input-wrapper { display: block; }
.message-form .composer-card textarea { width: 100%; border: 0; background: transparent; box-shadow: none; outline: none; resize: none; padding: 0.4rem 0; min-height: 2.75rem; max-height: 40vh; font-size: 1rem; line-height: 1.5; color: var(--plc-ink); display: block; }
.message-form .composer-card textarea:disabled { background: transparent; opacity: 0.6; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding-top: 0.15rem; }
.composer-tools { display: flex; gap: 0.15rem; }
.tool-btn { width: var(--plc-control-min); height: var(--plc-control-min); border-radius: var(--plc-radius-control); border: 0; background: transparent; color: var(--plc-muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.tool-btn:hover, .tool-btn:focus-visible { background: var(--plc-accent-tint); color: var(--plc-ink); }
.tool-btn[aria-pressed='true'] { background: var(--plc-accent); color: var(--plc-on-accent); }
.tool-btn .ico { width: 1.35rem; height: 1.35rem; }
.composer-actions { display: flex; gap: 0.5rem; }
.message-form .composer-actions button { margin: 0; min-height: var(--plc-control-min); border-radius: var(--plc-radius-control); padding: 0 1rem; font-weight: 600; font-size: 0.95rem; border: 0; display: inline-flex; align-items: center; gap: 0.5rem; }
.message-form .send-btn { background: var(--plc-accent); color: var(--plc-on-accent); }
.message-form .send-btn:hover { background: var(--plc-accent-hover); }
.message-form .stop-btn { background: var(--plc-danger-tint); color: var(--plc-danger); }
.message-form .stop-btn:hover { background: var(--plc-danger-tint); filter: brightness(0.97); }
.accuracy-note { margin: 0.5rem 0 0; text-align: center; font-size: 0.78rem; color: var(--plc-muted); }
.chat-area.drop-target { outline-color: var(--plc-accent); }
.message-form.disabled { opacity: 1; }

/* ---- menus, dialogs, notices ----------------------------------------------------------------------------------------- */
.thread-menu { background: var(--plc-surface); border: 1px solid var(--plc-border); border-radius: var(--plc-radius-control); box-shadow: var(--plc-shadow); padding: 0.25rem; min-width: 13rem; z-index: 4500; }
.thread-menu button { min-height: var(--plc-control-min); border-radius: 8px; padding: 0 0.75rem; display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; border: 0; background: transparent; color: var(--plc-ink); font-size: 0.95rem; cursor: pointer; }
.thread-menu button:hover, .thread-menu button:focus-visible { background: var(--plc-accent-tint); }
.thread-menu button.delete { color: var(--plc-danger); }
.app-dialog .sheet, .modal .sheet { border-radius: var(--plc-radius-panel); border: 1px solid var(--plc-border); box-shadow: var(--plc-shadow); background: var(--plc-surface); }
.app-dialog .sheet h2, .modal h2 { font-size: 1.25rem; letter-spacing: -0.005em; }
.modal .lede { color: var(--plc-muted); margin-top: -0.25rem; }
.app-dialog .dialog-actions button, .modal .cta-row button { min-height: var(--plc-control-min); }
.app-dialog .list-row { padding: 0.5rem 0; }
.toast { background: var(--plc-ink); color: var(--plc-background); border-radius: var(--plc-radius-control); max-width: min(calc(100vw - 128px), 36rem); z-index: 5000; }
.toast-action { color: inherit; font-weight: 700; min-height: 2.25rem; }
.lock-screen { background: var(--plc-background); }
.lock-screen h2 { margin: 0 0 0.5rem; }
.lock-screen input { min-height: var(--plc-control-min); padding: 0 0.75rem; border: 1px solid var(--color-form-border); background: var(--plc-surface); color: var(--plc-ink); }
.canvas-pane { background: var(--plc-surface); }

/* ---- phones and touch ------------------------------------------------------------------------------------------------ */
@media (max-width: 899px) {
  .messages { padding: 1rem 0.75rem 0.5rem; }
  .message-form { padding: 0.25rem 0.75rem max(0.5rem, env(safe-area-inset-bottom)); }
  .context-meter { padding: 0 0.75rem 0.25rem; }
  .composer-bar .btn-label { display: none; }
  .message-form .composer-actions button { padding: 0; width: var(--plc-control-min); justify-content: center; }
  .chat-header .thread-title { font-size: 1rem; }
  .mode-badge { max-width: 9.5rem; padding: 0 0.7rem; }
  .accuracy-note { font-size: 0.72rem; }
  .jump-latest { bottom: 0.5rem; }
}
@media (max-width: 380px) { .mode-badge-text { max-width: 5.5rem; } }
@media (pointer: coarse) {
  .message-actions .act, .message-actions button { min-height: var(--plc-control-min); padding: 0 0.7rem; }
  .code-action { min-height: var(--plc-control-min); }
  .thread-menu-btn { min-width: var(--plc-control-min); min-height: var(--plc-control-min); }
  .thread-filter button { min-height: var(--plc-control-min); }
  .message-sources button, .chip button, .thread-menu button { min-height: var(--plc-control-min); }
  .toast-action { min-height: var(--plc-control-min); }
  .code-bar { padding: 4px 8px; }
}
@media (max-height: 520px) {
  .accuracy-note { display: none; }
  .chat-header { min-height: 3rem; padding-top: 0.25rem; padding-bottom: 0.25rem; }
  .empty-state { margin-top: 0.5rem; }
  .empty-state .lede { margin-bottom: 0.5rem; }
}

.new-thread-button, .new-thread-button .btn-label { text-transform: none; letter-spacing: 0; }

/* ---- refinements from review ---------------------------------------------------------------------------------------- */
@media (min-width: 900px) { .sidebar-close { display: none !important; } }
.system-prompt-container { border-bottom: 1px solid var(--plc-border); background: var(--plc-surface); padding: 0 1rem; }
.system-prompt-container > summary { font-weight: 500; }
.system-prompt-container[open] { padding-bottom: 0.75rem; }
#generationStatus { margin: 0 auto 0.35rem; max-width: var(--plc-chat-max); padding: 0 1rem; background: transparent; color: var(--plc-muted); text-align: left; font-size: 0.8rem; max-height: 1.4rem; width: 100%; }
#generationStatus[hidden] { display: none; }
.composer-tools .tool-btn { border: 0; background: transparent; padding: 0; }
.composer-tools .tool-btn:hover { background: var(--plc-accent-tint); }
.mode-badge-provider { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 599px) { .mode-badge-provider { display: none; } }
.context-meter meter { height: 6px; border: 0; border-radius: 3px; background: var(--plc-border); }
.context-meter meter::-webkit-meter-bar { background: var(--plc-border); border: 0; height: 6px; border-radius: 3px; }
.context-meter meter::-webkit-meter-optimum-value { background: var(--plc-accent); border-radius: 3px; }
.context-meter meter::-webkit-meter-suboptimum-value { background: var(--plc-warning); border-radius: 3px; }
.context-meter meter::-webkit-meter-even-less-good-value { background: var(--plc-danger); border-radius: 3px; }
.context-meter meter::-moz-meter-bar { background: var(--plc-accent); border-radius: 3px; }
.context-meter.warn { color: var(--plc-warning); }
.message { position: relative; }
@media (hover: hover) and (pointer: fine) {
  .message:not(:last-child) { margin-bottom: 2.25rem; }
  .message:not(:last-child) .message-actions { position: absolute; left: 0; bottom: -2.1rem; margin: 0; z-index: 2; background: var(--plc-surface); border: 1px solid var(--plc-border); border-radius: 10px; box-shadow: var(--plc-shadow); }
  .message.user:not(:last-child) .message-actions { left: auto; right: 0; }
}
@media (hover: none), (pointer: coarse) {
  .message:not(:last-child) .message-actions { display: none; }
  .message.show-actions .message-actions { display: flex; }
}
.message-actions [data-action='more'], .message-actions [data-action='prev-version'], .message-actions [data-action='next-version'] { min-width: 2.25rem; justify-content: center; }
@media (pointer: coarse) { .message-actions [data-action='more'], .message-actions [data-action='prev-version'], .message-actions [data-action='next-version'] { min-width: var(--plc-control-min); } }

/* ---- dialogs on small screens: stack the storage rows instead of squeezing three columns ---------------------------------- */
.icon-action { min-width: 2.25rem; min-height: 2.25rem; border: 0; background: transparent; border-radius: 8px; color: var(--plc-muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.icon-action:hover { background: var(--plc-accent-tint); color: var(--plc-ink); }
@media (max-width: 599px) {
  .app-dialog { padding: 0; align-items: flex-end; }
  .app-dialog .sheet { width: 100%; max-height: 92dvh; border-radius: var(--plc-radius-panel) var(--plc-radius-panel) 0 0; padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom)); }
  .app-dialog table, .app-dialog tbody, .app-dialog tr { display: block; }
  .app-dialog tr { padding: 0.75rem 0; border-bottom: 1px solid var(--plc-border); }
  .app-dialog th, .app-dialog td { display: block; border: 0; padding: 0.1rem 0; }
  .app-dialog td:empty { display: none; }
  .app-dialog td button { margin-top: 0.5rem; width: 100%; }
  .app-dialog .dialog-actions { position: sticky; bottom: 0; background: var(--plc-surface); padding-top: 0.5rem; }
  .app-dialog .dialog-actions button { flex: 1; }
}
.modal .modal-body h3 { margin: 1.25rem 0 0.25rem; font-size: 1.05rem; }
.modal .modal-body p { margin: 0.25rem 0 0.75rem; }
.modal .modal-header { border-bottom: 1px solid var(--plc-border); }
.mode-badge-provider { margin-left: -0.4rem; }

.gpu-help { border: 1px solid var(--plc-border); border-left: 3px solid var(--plc-warning); background: var(--plc-warning-tint); color: var(--plc-ink); border-radius: var(--plc-radius-control); padding: 0.75rem; margin: 0.5rem 0; font-size: 0.88rem; }
.gpu-help p { margin: 0 0 0.4rem; }
.gpu-help ol, .gpu-steps { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.gpu-help li, .gpu-steps li { margin: 0.3rem 0; overflow-wrap: anywhere; }
.gpu-steps { text-align: left; max-width: 34rem; margin: 0 auto 1rem; color: var(--plc-muted); }
.gpu-help code, .gpu-steps code { font-size: 0.85em; }

/* ---- getting on-device chat ready ------------------------------------------------------------------------------------ */
.prep-card { border: 1px solid var(--plc-border); border-radius: var(--plc-radius-panel); background: var(--plc-surface); padding: 1rem; max-width: 34rem; text-align: left; box-shadow: var(--plc-shadow); }
.empty-state .prep-card { margin: 1rem auto 0; }
.prep-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.prep-spinner { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2.5px solid var(--plc-border); border-top-color: var(--plc-accent); animation: prep-spin 0.9s linear infinite; flex: none; }
@keyframes prep-spin { to { transform: rotate(360deg); } }
.prep-phase { margin: 0.25rem 0 0.6rem; font-weight: 600; }
.prep-bar { height: 0.6rem; border-radius: 999px; background: var(--plc-border); overflow: hidden; position: relative; }
.prep-fill { height: 100%; width: 0; background: var(--plc-accent); border-radius: 999px; transition: width 0.6s var(--plc-ease); }
.prep-bar.indeterminate .prep-fill { position: absolute; width: 35%; animation: prep-slide 1.4s ease-in-out infinite; }
@keyframes prep-slide { 0% { left: -35%; } 100% { left: 100%; } }
.prep-detail { margin: 0.4rem 0 0; min-height: 1.3em; font-size: 0.88rem; color: var(--plc-muted); font-variant-numeric: tabular-nums; }
.prep-calm { margin: 0.75rem 0 0; font-size: 0.9rem; color: var(--plc-muted); line-height: 1.5; }
.prep-actions { margin-top: 0.5rem; }
.prep-actions .link-btn { min-height: var(--plc-control-min); display: inline-flex; align-items: center; }
.message.preparing .message-body > :last-child::after { content: none; }
@media (prefers-reduced-motion: reduce) { .prep-spinner { animation-duration: 3s; } .prep-bar.indeterminate .prep-fill { animation: none; width: 100%; opacity: 0.4; } }
.message-form .composer-actions #stopGeneration { background: var(--plc-danger-tint); color: var(--plc-danger); }
.message-form .composer-actions #stopGeneration .ico { width: 1.2em; height: 1.2em; }
.message-form:has(.composer-card) ~ .context-meter { display: none; }

.prep-waiting { margin: 0 0 0.5rem; padding: 0.5rem 0.75rem; background: var(--plc-accent-tint); border-radius: var(--plc-radius-control); font-size: 0.92rem; overflow-wrap: anywhere; }
.prep-waiting q { quotes: '\201C' '\201D'; font-weight: 600; }
.prep-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.prep-actions .secondary { min-height: var(--plc-control-min); }

body.voice-on .message-form .composer-card, body.voice-on .message-form .accuracy-note { display: none; }

/* Browsers older than 2022 (iOS before 16.2) cannot mix colours: use plain tokens there so borders and tints do not disappear. */
@supports not (color: color-mix(in srgb, red, blue)) {
  :root, [data-theme="light"], [data-theme="dark"] { --plc-hairline: var(--plc-border); --color-border-strong: var(--plc-muted); --color-thread-hover: var(--plc-accent-tint); --color-form-border: var(--plc-border); }
  ::selection { background: var(--plc-accent-tint); }
  .message-body code { background: var(--plc-accent-tint); }
  .composer-card:focus-within { box-shadow: 0 0 0 3px var(--plc-accent-tint); }
}

/* ---- sharing, transfer and help ------------------------------------------------------------------------------------------- */
/* The conversation and settings regions scroll on their own; the Help & about / Share row below them never leaves the screen. */
.sidebar { overflow: hidden; }
.sidebar > .sidebar-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 0 1rem 0.5rem; display: flex; flex-direction: column; }
.sidebar > .sidebar-scroll > * { flex-shrink: 0; }
.sidebar > .side-footer { flex: 0 0 auto; margin-top: 0; padding-top: 0.5rem; background: var(--plc-surface); }
.flow-icon { display: inline-flex; width: 1.25rem; height: 1.25rem; flex: 0 0 auto; }
.flow-icon svg { width: 100%; height: 100%; }
.side-footer .hint-text { font-size: 0.78rem; }

/* each flow says what it moves in words and with its own icon, so the three are told apart without relying on colour */
.flow-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.flow-entry { border: 1px solid var(--plc-border); border-radius: var(--plc-radius-control); padding: 0.75rem; background: var(--plc-background); }
.flow-entry h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.25rem; font-size: 1rem; }
.flow-entry p { margin: 0 0 0.5rem; }
.flow-entry-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.flow-entry-actions button { min-height: var(--plc-control-min); }
.flow-danger { justify-content: flex-start; }
.pending-token { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--plc-border); }

.flow-scope { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.6rem 0.75rem; border-radius: var(--plc-radius-control); background: var(--plc-accent-tint); color: var(--plc-ink); margin-bottom: 0.75rem; }
.flow-scope p { margin: 0; }
.flow-scope .flow-icon { color: var(--plc-accent); margin-top: 0.1rem; }
.flow-scope.flow-error { background: var(--plc-danger-tint); }
.flow-scope.flow-error .flow-icon { color: var(--plc-danger); }
.danger-notice { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.7rem 0.8rem; margin: 0 0 0.75rem; border: 1px solid var(--plc-danger); border-radius: var(--plc-radius-control); background: var(--plc-danger-tint); color: var(--plc-ink); }
.danger-notice p { margin: 0; }
.danger-notice .flow-icon { color: var(--plc-danger); margin-top: 0.1rem; }
.flow-review { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.9rem; margin: 0 0 0.75rem; }
.flow-review dt { color: var(--plc-muted); }
.flow-review dd { margin: 0; overflow-wrap: anywhere; }
.flow-status { min-height: 1.4em; margin: 0.5rem 0; }
.flow-output-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.flow-output-actions button, .product-share-actions button { min-height: var(--plc-control-min); }
.flow-qr, .product-share-qr { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 0.75rem; margin: 0.5rem 0; background: #fff; border-radius: var(--plc-radius-control); }
.flow-qr-image, .product-share-qr-image { line-height: 0; }
.flow-qr-image img, .flow-qr-image canvas, .product-share-qr-image img, .product-share-qr-image canvas { max-width: 100%; height: auto; }
.product-share-destination { margin: 0; color: #182332; font-size: 0.85rem; overflow-wrap: anywhere; text-align: center; }
.flow-manual { width: 100%; box-sizing: border-box; font: inherit; }
.flow-card { border: 1px solid var(--plc-border); border-radius: var(--plc-radius-control); padding: 0.9rem; margin: 0 0 1rem; }
.flow-card h3 { margin: 0 0 0.5rem; }
.flow-included { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.flow-included li { padding: 0.15rem 0; }
.flow-included li.excluded { color: var(--plc-muted); }
.flow-changes { margin: 0 0 0.75rem; padding-left: 1.2rem; }
.flow-import h3 { font-size: 1rem; margin: 0.5rem 0 0.25rem; }
.product-share { display: flex; flex-direction: column; gap: 0.5rem; }
.product-share-copy { margin: 0; }
.product-share-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.product-share-actions .primary { background: var(--plc-accent); color: var(--plc-on-accent); border-color: var(--plc-accent); }
.product-share-status { min-height: 1.4em; margin: 0; color: var(--plc-accent); }
.product-share-address { width: 100%; box-sizing: border-box; font: inherit; }
.help-links { list-style: none; padding: 0; margin: 0 0 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.help-links a { display: inline-flex; align-items: center; min-height: var(--plc-control-min); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 0.75rem; }
.dialog-body { overflow-y: auto; }
.app-dialog .sheet { max-height: 92dvh; display: flex; flex-direction: column; }
.app-dialog .sheet .dialog-body { flex: 1 1 auto; min-height: 0; }
@media (max-width: 899px) { .flow-review { grid-template-columns: 1fr; } .flow-review dd { margin-bottom: 0.4rem; } }
.flow-check { display: flex; align-items: center; gap: 0.6rem; min-height: var(--plc-control-min); padding: 0.25rem 0; }
.flow-check input[type='checkbox'] { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; margin: 0; }
.side-footer #releaseInfo, .side-footer #offlineStatus { margin: 0.1rem 0; font-size: 0.75rem; }

/* ---- voice call: it looks and behaves like a phone call ---------------------------------------------------------------------- */
.tool-btn.call-start { background: #1f8f55; color: #fff; border-radius: 50%; }
.tool-btn.call-start:hover, .tool-btn.call-start:focus-visible { background: #17794a; color: #fff; }
.tool-btn.call-start[aria-pressed='true'] { background: #c9262f; }
.call { box-sizing: border-box; width: calc(100% - 1.5rem); max-width: 26rem; margin: 0 auto max(0.5rem, env(safe-area-inset-bottom)); padding: 1.25rem 1rem 1.1rem; border-radius: 1.5rem; color: #fff; background: linear-gradient(180deg, #0e1a27 0%, #17314a 100%); box-shadow: var(--plc-shadow); display: flex; flex-direction: column; align-items: center; gap: 0.6rem; text-align: center; }
.call[hidden] { display: none; }
.call-top { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.call-name { margin: 0; font-size: 1.2rem; font-weight: 650; letter-spacing: 0.01em; }
.call-status { margin: 0; color: #b8c7d9; font-size: 0.95rem; min-height: 1.4em; }
.call-timer { margin: 0; font-size: 1.6rem; font-weight: 600; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.call[data-state='connecting'] .call-timer { visibility: hidden; }
.call[data-state='error'] .call-timer { display: none; }
.call-avatar { position: relative; width: 8.5rem; height: 8.5rem; display: grid; place-items: center; margin: 0.25rem 0; }
.call-face { position: relative; z-index: 1; width: 5.5rem; height: 5.5rem; border-radius: 50%; background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.28); display: grid; place-items: center; }
.call-face img { width: 3rem; height: 3rem; }
.call-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(127, 176, 255, 0.6); opacity: 0; transform: scale(0.65); }
/* the rings say who is "talking": rippling outward while it rings or speaks, a slow swell while it listens, a turning dashed ring while it thinks */
.call[data-state='connecting'] .call-ring, .call[data-state='speaking'] .call-ring { animation: call-ripple 1.8s ease-out infinite; }
.call-ring.r2 { animation-delay: 0.6s !important; }
.call-ring.r3 { animation-delay: 1.2s !important; }
.call[data-state='listening'] .call-ring.r1 { opacity: 0.55; animation: call-swell 2.6s ease-in-out infinite; }
.call[data-state='thinking'] .call-ring.r1 { opacity: 0.7; transform: scale(0.95); border-style: dashed; animation: call-turn 3.2s linear infinite; }
.call[data-state='paused'] .call-ring.r1, .call[data-state='ended'] .call-ring.r1, .call[data-state='error'] .call-ring.r1 { opacity: 0.25; transform: scale(0.9); }
.call-captions { width: 100%; min-height: 3.6rem; }
.call-who { margin: 0; min-height: 1em; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: #8fa6c0; }
.call-caption { margin: 0.1rem 0 0; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; max-height: 6.5rem; overflow-y: auto; }
.call-hint { margin: 0; color: #b8c7d9; font-size: 0.85rem; }
.call-hint:empty { display: none; }
.call-link { min-height: var(--plc-control-min); padding: 0 0.75rem; background: none; border: 0; color: #9cc2ff; text-decoration: underline; font: inherit; cursor: pointer; }
.call-link[hidden], .call-pill[hidden] { display: none; }
.call-pill { min-height: var(--plc-control-min); padding: 0 1.4rem; border: 0; border-radius: 999px; background: #fff; color: #0e1a27; font: inherit; font-weight: 600; cursor: pointer; }
.call-controls { display: flex; justify-content: center; gap: 1.4rem; margin-top: 0.4rem; }
.call-control { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; min-width: 4.5rem; }
.call-control[hidden] { display: none; }
.call-btn { width: 4rem; height: 4rem; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: #fff; display: grid; place-items: center; cursor: pointer; }
.call-btn .ico, .call-btn svg { width: 1.7rem; height: 1.7rem; }
.call-btn:hover { background: rgba(255, 255, 255, 0.26); }
.call-btn[aria-pressed='true'] { background: #fff; color: #0e1a27; }
.call-btn:focus-visible, .call-pill:focus-visible, .call-link:focus-visible { outline: 3px solid #9cc2ff; outline-offset: 3px; }
.call-btn.call-end { background: #c9262f; color: #fff; }
.call-btn.call-end:hover { background: #a81d26; }
.call-control-label { font-size: 0.8rem; color: #d3deea; }
.call[data-state='ended'] .call-controls { visibility: hidden; }
@keyframes call-ripple { 0% { opacity: 0.6; transform: scale(0.65); } 100% { opacity: 0; transform: scale(1.15); } }
@keyframes call-swell { 0%, 100% { transform: scale(0.82); } 50% { transform: scale(0.98); } }
@keyframes call-turn { to { transform: rotate(360deg) scale(0.95); } }
@media (prefers-reduced-motion: reduce) {
  .call-ring { animation: none !important; }
  .call[data-state='connecting'] .call-ring.r1, .call[data-state='speaking'] .call-ring.r1 { opacity: 0.6; transform: scale(0.95); }
  .call[data-state='connecting'] .call-ring.r2, .call[data-state='speaking'] .call-ring.r2 { opacity: 0.35; transform: scale(1.08); }
}
/* on a phone the call takes the whole screen, like a real call */
@media (max-width: 899px) {
  .call { position: fixed; inset: 0; z-index: 3500; width: auto; max-width: none; margin: 0; border-radius: 0; box-shadow: none; padding: max(2.25rem, env(safe-area-inset-top)) 1.25rem max(1.75rem, env(safe-area-inset-bottom)); }
  .call-avatar { width: 11rem; height: 11rem; margin: auto 0; }
  .call-face { width: 7rem; height: 7rem; }
  .call-face img { width: 3.8rem; height: 3.8rem; }
  .call-name { font-size: 1.35rem; }
  .call-timer { font-size: 1.9rem; }
  .call-captions { min-height: 5rem; }
  .call-btn { width: 4.5rem; height: 4.5rem; }
}

/* ---- voice notes ---------------------------------------------------------------------------------------------------------- */
.voice-note-holder { margin: 0.25rem 0 0.5rem; }
.voice-note { max-width: 24rem; padding: 0.6rem 0.75rem 0.45rem; border: 1px solid var(--plc-border); border-radius: 1.1rem; background: var(--plc-accent-tint); color: var(--plc-ink); }
.vn-line { display: flex; align-items: center; gap: 0.6rem; }
.vn-play { flex: 0 0 auto; width: var(--plc-control-min); height: var(--plc-control-min); border: 0; border-radius: 50%; background: var(--plc-accent); color: var(--plc-on-accent); display: grid; place-items: center; cursor: pointer; padding: 0; }
.vn-play:hover { background: var(--plc-accent-hover); }
.vn-icon { width: 0; height: 0; margin-left: 0.2rem; border-left: 0.75rem solid currentColor; border-top: 0.5rem solid transparent; border-bottom: 0.5rem solid transparent; }
.voice-note[data-state='playing'] .vn-icon { width: 0.9rem; height: 1rem; margin: 0; border: 0; border-left: 0.3rem solid currentColor; border-right: 0.3rem solid currentColor; box-sizing: border-box; }
.vn-wave { flex: 1 1 auto; min-width: 0; height: 2.1rem; display: flex; align-items: center; gap: 2px; cursor: pointer; border-radius: 0.4rem; }
.vn-wave:focus-visible, .vn-play:focus-visible, .vn-speed:focus-visible, .vn-text-toggle:focus-visible { outline: 3px solid var(--plc-focus, var(--plc-accent)); outline-offset: 2px; }
.vn-bar { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--plc-muted); opacity: 0.45; }
.vn-bar.played { background: var(--plc-accent); opacity: 1; }
.vn-clock { flex: 0 0 auto; min-width: 4.2rem; text-align: right; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--plc-muted); }
.vn-speed { flex: 0 0 auto; min-width: 2.75rem; min-height: 2rem; border: 1px solid var(--plc-border); border-radius: 999px; background: var(--plc-surface); color: var(--plc-ink); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.vn-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.15rem; font-size: 0.8rem; color: var(--plc-muted); }
.vn-text-toggle { min-height: 2rem; padding: 0 0.25rem; border: 0; background: none; color: var(--plc-accent); font: inherit; font-size: 0.8rem; text-decoration: underline; cursor: pointer; }
.voice-note-message .message-body[hidden] { display: none; }
.voice-badge { margin: 0.1rem 0 0.35rem; font-size: 0.8rem; color: var(--plc-muted); }

.vn-recorder { box-sizing: border-box; width: calc(100% - 1.5rem); max-width: var(--plc-chat-max); margin: 0 auto max(0.5rem, env(safe-area-inset-bottom)); padding: 0.9rem 1rem; border: 1px solid var(--plc-border); border-radius: var(--plc-radius-panel); background: var(--plc-surface); box-shadow: var(--plc-shadow); }
.vn-recorder[hidden] { display: none; }
.vnr-top { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
.vnr-dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: #c9262f; animation: vnr-pulse 1.2s ease-in-out infinite; }
.vn-recorder[data-state='review'] .vnr-dot { animation: none; background: var(--plc-muted); }
.vnr-timer { margin-left: auto; font-variant-numeric: tabular-nums; }
.vnr-text { margin: 0.6rem 0; min-height: 3rem; max-height: 9rem; overflow-y: auto; overflow-wrap: anywhere; color: var(--plc-ink); }
.vnr-edit { width: 100%; box-sizing: border-box; margin: 0.6rem 0; font: inherit; }
.vnr-error { margin: 0.25rem 0; min-height: 1.2em; color: var(--plc-danger); }
.vnr-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.vnr-actions button { min-height: var(--plc-control-min); }
@keyframes vnr-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .vnr-dot { animation: none; } }

/* ---- Roberta: the voicemail thread, the incoming call and the call -------------------------------------------------------- */
.roberta-card { box-sizing: border-box; width: 100%; max-width: 30rem; margin: 0 auto 1.25rem; padding: 1rem; border: 1px solid var(--plc-border); border-radius: 1.25rem; background: var(--plc-surface); box-shadow: var(--plc-shadow); text-align: left; }
.roberta-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; }
.roberta-avatar { display: inline-grid; place-items: center; flex: 0 0 auto; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--plc-accent); color: var(--plc-on-accent); font-weight: 700; }
.roberta-avatar.big { position: relative; width: 6rem; height: 6rem; background: transparent; }
.roberta-face { position: relative; z-index: 1; display: grid; place-items: center; width: 4.2rem; height: 4.2rem; border-radius: 50%; background: var(--plc-accent); color: var(--plc-on-accent); font-size: 1.7rem; font-weight: 700; }
.roberta-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--plc-accent); opacity: 0; transform: scale(0.7); animation: call-ripple 2s ease-out infinite; }
.roberta-ring.r2 { animation-delay: 0.65s; } .roberta-ring.r3 { animation-delay: 1.3s; }
.roberta-who { display: flex; flex-direction: column; min-width: 0; }
.roberta-tag { color: var(--plc-muted); font-size: 0.85rem; margin: 0; }
.roberta-badge { margin-left: auto; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--plc-accent-tint); color: var(--plc-accent); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.roberta-feed { max-height: 18rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; padding: 0.25rem 0; }
.roberta-msg.you { align-self: flex-end; }
.roberta-you { display: inline-block; padding: 0.35rem 0.8rem; border-radius: 1rem; background: var(--plc-accent); color: var(--plc-on-accent); font-size: 0.9rem; }
.roberta-note .voice-note { max-width: 100%; }
.roberta-transcript { margin: 0.35rem 0 0; font-size: 0.9rem; color: var(--plc-ink); }
.roberta-transcript[hidden] { display: none; }
.roberta-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.roberta-chip { display: inline-flex; align-items: center; gap: 0.45rem; min-height: var(--plc-control-min); padding: 0 0.8rem 0 0.4rem; border: 1px solid var(--plc-border); border-radius: 999px; background: var(--plc-surface); color: var(--plc-ink); font: inherit; font-size: 0.9rem; cursor: pointer; }
.roberta-chip:hover { background: var(--plc-accent-tint); }
.roberta-chip-key { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--plc-accent-tint); color: var(--plc-accent); font-weight: 700; }
.roberta-pending { background: var(--plc-accent); color: var(--plc-on-accent); padding-left: 0.9rem; }
.roberta-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.75rem; }
.roberta-call-btn, .roberta-answer { min-height: var(--plc-control-min); padding: 0 1.1rem; border: 0; border-radius: 999px; background: #1f8f55; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.roberta-call-btn:hover, .roberta-answer:hover { background: #17794a; }
.roberta-link { min-height: var(--plc-control-min); padding: 0 0.5rem; border: 0; background: none; color: var(--plc-muted); font: inherit; text-decoration: underline; cursor: pointer; }
.roberta-incoming { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.roberta-incoming-name { margin: 0.4rem 0 0; font-size: 1.4rem; }
.roberta-incoming-note { margin: 0; color: var(--plc-muted); font-size: 0.9rem; max-width: 22rem; }
.roberta-incoming-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin: 0.6rem 0 0.2rem; }
.roberta-voicemail-btn { min-height: var(--plc-control-min); padding: 0 1.1rem; border: 1px solid var(--plc-border); border-radius: 999px; background: var(--plc-surface); color: var(--plc-ink); font: inherit; cursor: pointer; }
.roberta-answer, .roberta-call-btn, .roberta-voicemail-btn, .roberta-chip, .roberta-link { max-width: 100%; }

.rcall-scrim { position: fixed; inset: 0; z-index: 3600; display: grid; place-items: center; background: rgba(8, 14, 22, 0.6); }
.rcall-scrim[hidden] { display: none; }
.rcall { box-sizing: border-box; width: min(34rem, 94vw); max-height: 94dvh; overflow-y: auto; padding: 1.25rem 1.25rem 1rem; border-radius: 1.5rem; color: #fff; background: linear-gradient(180deg, #0e1a27 0%, #17314a 100%); box-shadow: var(--plc-shadow); display: flex; flex-direction: column; align-items: center; gap: 0.6rem; text-align: center; }
.rcall-top { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.rcall-name { margin: 0; font-size: 1.15rem; font-weight: 650; }
.rcall-status { margin: 0; color: #b8c7d9; font-size: 0.9rem; min-height: 1.3em; }
.rcall-timer { margin: 0; font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.rcall-stage { position: relative; width: 100%; display: grid; place-items: center; min-height: 9rem; border-radius: 1rem; background: rgba(255, 255, 255, 0.06); }
.rcall-tile { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.8rem; }
.rcall .roberta-ring { border-color: rgba(127, 176, 255, 0.7); }
.rcall[data-state='speaking'] .roberta-ring, .rcall[data-state='connecting'] .roberta-ring { opacity: 0.6; }
.rcall:not([data-state='speaking']):not([data-state='connecting']) .roberta-ring { animation: none; opacity: 0.25; transform: scale(0.9); }
.rcall-chip { padding: 0.1rem 0.6rem; border-radius: 999px; background: rgba(0, 0, 0, 0.35); font-size: 0.8rem; }
.rcall-self { position: absolute; right: 0.6rem; bottom: 0.6rem; display: grid; place-items: center; width: 4.5rem; height: 3.2rem; border-radius: 0.6rem; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); font-size: 0.75rem; color: #d3deea; }
.rcall[data-state='listening'] .rcall-self { border-color: #7fb0ff; box-shadow: 0 0 0 2px rgba(127, 176, 255, 0.5); }
.rcall-captions { width: 100%; min-height: 4.2rem; }
.rcall-line { margin: 0; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; max-height: 5.5rem; overflow-y: auto; }
.rcall-yours { margin: 0.3rem 0 0; color: #9cc2ff; font-size: 0.9rem; overflow-wrap: anywhere; }
.rcall-hint { margin: 0; min-height: 0; color: #ffd6d9; font-size: 0.85rem; }
.rcall-hint:empty { display: none; }
.rcall-keypad { display: grid; grid-template-columns: repeat(3, 4.4rem); gap: 0.5rem 0.9rem; justify-content: center; margin: 0.25rem 0; }
.rk { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 4.4rem; height: 3.6rem; padding: 0; border: 0; border-radius: 0.9rem; background: rgba(255, 255, 255, 0.14); color: #fff; font: inherit; cursor: pointer; }
.rk:hover { background: rgba(255, 255, 255, 0.24); }
.rk[data-active='false'] { opacity: 0.55; }
.rk-digit { font-size: 1.3rem; font-weight: 600; line-height: 1.1; }
.rk-sub { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: #c7d5e6; max-width: 4.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcall-controls { display: flex; justify-content: center; gap: 1.1rem; margin-top: 0.3rem; }
.rcall-control { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; min-width: 4rem; }
.rcall-control[hidden] { display: none; }
.rcall-btn { width: 3.6rem; height: 3.6rem; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 1.4rem; display: grid; place-items: center; cursor: pointer; padding: 0; }
.rcall-btn:hover { background: rgba(255, 255, 255, 0.26); }
.rcall-btn[aria-pressed='true'] { background: #fff; color: #0e1a27; }
.rcall-btn.rcall-end { background: #c9262f; }
.rcall-btn.rcall-end:hover { background: #a81d26; }
.rcall-btn:focus-visible, .rk:focus-visible { outline: 3px solid #9cc2ff; outline-offset: 3px; }
.rcall-control-label { font-size: 0.78rem; color: #d3deea; }
body.roberta-call-open { overflow: hidden; }
@media (max-width: 899px) {
  .rcall-scrim { background: transparent; }
  .rcall { position: fixed; inset: 0; z-index: 3600; width: auto; max-height: none; border-radius: 0; box-shadow: none; padding: max(1.5rem, env(safe-area-inset-top)) 1.1rem max(1.25rem, env(safe-area-inset-bottom)); justify-content: space-between; }
  .rcall-stage { flex: 1 1 auto; min-height: 7rem; }
}
@media (prefers-reduced-motion: reduce) { .roberta-ring { animation: none; opacity: 0.3; } }

.vn-wave { overflow: hidden; gap: 1.5px; }
.vn-bar { min-width: 1.5px; }
.vn-clock { min-width: 3.6rem; }

/* ---- Polish pass ------------------------------------------------------------------------------------------------------------
   Spacing, hierarchy and readability fixes found by looking at every screen on a phone and a desktop in both themes. */

/* The backup reminder in the sidebar: an icon, a heading and a sentence, then two equal buttons. */
.backup-nudge { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; align-items: start; margin: 0.25rem 0 0.75rem; padding: 0.9rem; border: 1px solid var(--plc-border); border-radius: var(--plc-radius-panel); background: var(--plc-accent-tint); }
.backup-nudge[hidden] { display: none; }
.backup-nudge-icon { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--plc-surface); color: var(--plc-accent); }
.backup-nudge-icon svg { width: 1.1rem; height: 1.1rem; }
.backup-nudge-text strong { display: block; font-size: 0.95rem; line-height: 1.3; color: var(--plc-ink); }
.backup-nudge-text p { margin: 0.2rem 0 0; font-size: 0.85rem; line-height: 1.45; color: var(--plc-muted); }
.backup-nudge-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.5rem; }
.backup-nudge-actions button { min-height: 2.5rem; padding: 0 0.25rem; font-size: 0.85rem; white-space: nowrap; justify-content: center; min-width: 0; }

/* Chat list: long titles end in an ellipsis instead of being cut off mid-letter. */
.thread-list li .thread-name { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: var(--plc-control-min); padding-right: 0.25rem; }

/* Sidebar footer: quiet links and one calm status line. */
.side-footer #releaseInfo, .side-footer #offlineStatus { color: var(--plc-muted); }

/* "Instructions for this chat": a quiet disclosure row with a chevron. */
.system-prompt-container > summary { list-style: none; cursor: pointer; justify-content: space-between; gap: 0.5rem; }
.system-prompt-container > summary::-webkit-details-marker { display: none; }
.system-prompt-container > summary::after { content: '›'; font-size: 1.3rem; line-height: 1; color: var(--plc-muted); transition: transform var(--plc-motion-fast); }
.system-prompt-container[open] > summary::after { transform: rotate(90deg); }

/* Help & about: the links are a tidy list of rows, then the two actions, then the small print. */
.help-links { gap: 0; margin: 0.75rem 0; border: 1px solid var(--plc-border); border-radius: var(--plc-radius-control); overflow: hidden; background: var(--plc-surface); }
.help-links li + li { border-top: 1px solid var(--plc-border); }
.help-links a { display: flex; justify-content: space-between; padding: 0 0.9rem; color: var(--plc-ink); font-weight: 500; text-decoration: none; }
.help-links a::after { content: '›'; font-size: 1.3rem; color: var(--plc-muted); }
.help-links a:hover, .help-links a:focus-visible { background: var(--plc-accent-tint); }
.help-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }
.help-actions button { flex: 1 1 14rem; min-height: var(--plc-control-min); justify-content: center; }
.help-fineprint .hint-text { margin: 0 0 0.4rem; line-height: 1.45; }

@media (max-width: 599px) {
  /* Message actions: one tidy row of icons (the words stay for screen readers). */
  .message-actions { flex-wrap: nowrap; gap: 0; justify-content: flex-start; }
  .message-actions .act, .message-actions button { padding: 0; min-width: var(--plc-control-min); justify-content: center; }
  .message-actions .act .ico-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* Code blocks: small buttons, so the bar does not dwarf the code. */
  .code-bar { padding: 0.25rem 0.5rem; }
  .code-action { min-height: 2.25rem; padding: 0 0.75rem; }
  /* Context meter: the sentence on its own line, the bar underneath. */
  .context-meter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
  .context-meter > span { flex: 1 1 100%; }
  .context-meter meter { flex: 1 1 100%; width: 100%; }
}

/* Roberta: the card starts near the top so its chips are visible, the feed fits the screen, and the jump button stays out of the way. */
.empty-state:has(.roberta-thread) { margin-top: 0.5rem; }
.roberta-feed { max-height: min(18rem, 38dvh); }
body:has(.empty-state .roberta-thread) .jump-latest { display: none; }
.rcall-btn .ico { width: 1.6rem; height: 1.6rem; }
/* The line she is saying: whole sentences, ending in an ellipsis rather than being cut off mid-word. */
.rcall-line { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6; overflow: hidden; max-height: none; }

/* Dialog notices: clear but calm. The red is in the icon and the tint, not a heavy outline on every card. */
.danger-notice { border-color: color-mix(in srgb, var(--plc-danger) 35%, var(--plc-border)); font-size: 0.92rem; line-height: 1.45; }
/* Focus rings inside sheets sit inside the button so a sheet's edge never clips them. */
.app-dialog .sheet button:focus-visible { outline-offset: -3px; }

/* Checkbox rows (for example "Use memory in new questions"): the box sits next to its words, not in the middle of the row. */
label.list-row:has(> input[type='checkbox']) { display: flex; align-items: center; justify-content: flex-start; gap: 0.75rem; cursor: pointer; }
label.list-row > input[type='checkbox'], .app-dialog label.list-row > input[type='checkbox'] { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; margin: 0; }
/* Storage and backups: the action buttons line up in one column. */
@media (min-width: 600px) { .app-dialog td button { min-width: 11.5rem; } }

/* ---- the call screen says what is going on ---------------------------------------------------------------------------------------------------------------
   The orb has a different movement for each thing the app does:
   listening: a slow calm swell · thinking: a turning dashed ring and a slow glow · writing the reply: quick pulses like typing
   preparing the voice (making the sound): a shimmering violet ring · speaking: rings rippling outward */
.call[data-state='thinking'][data-phase='thinking'] .call-face { animation: call-glow 2.4s ease-in-out infinite; }
.call[data-state='thinking'][data-phase='writing'] .call-ring.r1, .call[data-state='thinking'][data-phase='writing'] .call-ring.r2 { opacity: 0.8; border-style: solid; border-color: rgba(255, 196, 94, 0.85); animation: call-type 0.9s ease-in-out infinite; }
.call[data-state='thinking'][data-phase='writing'] .call-ring.r2 { animation-delay: 0.3s !important; }
.call[data-state='thinking'][data-phase='writing'] .call-face { border-color: rgba(255, 196, 94, 0.8); animation: call-type-face 0.9s ease-in-out infinite; }
.call[data-state='speaking'][data-phase='preparing'] .call-ring { animation: none; }
.call[data-state='speaking'][data-phase='preparing'] .call-ring.r1 { opacity: 0.9; transform: scale(0.95); border-style: dashed; border-width: 3px; border-color: rgba(190, 150, 255, 0.9); animation: call-turn 1.1s linear infinite; }
.call[data-state='speaking'][data-phase='preparing'] .call-ring.r2 { opacity: 0.55; transform: scale(1.05); border-style: dotted; border-color: rgba(190, 150, 255, 0.7); animation: call-turn-back 2s linear infinite !important; animation-delay: 0s !important; }
.call[data-state='speaking'][data-phase='preparing'] .call-face { border-color: rgba(190, 150, 255, 0.8); animation: call-glow 1.2s ease-in-out infinite; }
.call[data-state='speaking'][data-phase='playing'] .call-ring { border-color: rgba(120, 220, 160, 0.75); animation: call-ripple 1.1s ease-out infinite; }
.call[data-state='speaking'][data-phase='playing'] .call-ring.r2 { animation-delay: 0.35s !important; }
.call[data-state='speaking'][data-phase='playing'] .call-ring.r3 { animation-delay: 0.7s !important; }
.call[data-state='speaking'][data-phase='playing'] .call-face { border-color: rgba(120, 220, 160, 0.8); animation: call-beat 0.55s ease-in-out infinite alternate; }
@keyframes call-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(127, 176, 255, 0.0); } 50% { box-shadow: 0 0 1.6rem 0.2rem rgba(127, 176, 255, 0.45); } }
@keyframes call-type { 0%, 100% { transform: scale(0.8); } 40% { transform: scale(1.02); } }
@keyframes call-type-face { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.06); } }
@keyframes call-turn-back { to { transform: rotate(-360deg) scale(1.05); } }
@keyframes call-beat { from { transform: scale(1); } to { transform: scale(1.07); } }
/* reduced motion: no movement, but each phase still looks different (ring style and colour) */
@media (prefers-reduced-motion: reduce) {
  .call-face { animation: none !important; }
  .call[data-state='thinking'][data-phase='writing'] .call-ring.r1 { opacity: 0.85; transform: scale(0.95); border-color: rgba(255, 196, 94, 0.85); }
  .call[data-state='speaking'][data-phase='preparing'] .call-ring.r1 { opacity: 0.9; transform: scale(0.95); border-style: dashed; border-color: rgba(190, 150, 255, 0.9); }
  .call[data-state='speaking'][data-phase='playing'] .call-ring.r1 { opacity: 0.8; transform: scale(0.95); border-color: rgba(120, 220, 160, 0.8); }
}

/* the models in memory */
.call-models { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin-top: 0.25rem; }
.call-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.65rem; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: #d3deea; font-size: 0.74rem; line-height: 1.3; max-width: 100%; }
.call-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-chip-dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #8fa6c0; }
.call-chip[data-state='loaded'] .call-chip-dot, .call-chip[data-state='busy'] .call-chip-dot, .call-chip[data-state='provider'] .call-chip-dot, .call-chip[data-state='system'] .call-chip-dot { background: #6fe0a0; }
.call-chip[data-state='downloaded'] .call-chip-dot { background: transparent; box-shadow: inset 0 0 0 2px #6fe0a0; }
.call-chip[data-state='loading'] .call-chip-dot, .call-chip[data-state='downloading'] .call-chip-dot, .call-chip[data-state='testing'] .call-chip-dot { background: #ffc45e; animation: call-glow-dot 1s ease-in-out infinite; }
.call-chip[data-state='failed'] .call-chip-dot { background: #ff6b6b; }
@keyframes call-glow-dot { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .call-chip-dot { animation: none !important; } }

/* the messages of this call: the newest at the bottom, each older one more transparent */
.call-log { list-style: none; margin: 0.2rem 0 0; padding: 0; width: 100%; max-height: 9.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.35rem; }
.call-log:empty { display: none; }
.call-log-item { display: flex; flex-direction: column; padding: 0.35rem 0.7rem; border-radius: 0.8rem; font-size: 0.88rem; line-height: 1.3; overflow-wrap: anywhere; transition: opacity 0.4s ease; }
.call-log-item.you { align-self: flex-end; background: rgba(120, 170, 255, 0.22); max-width: 88%; }
.call-log-item.them { align-self: flex-start; background: rgba(255, 255, 255, 0.1); max-width: 92%; }
.call-log-who { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: #9fb4cc; }
.call-log-item.live .call-log-text::after { content: '▍'; opacity: 0.7; animation: call-glow-dot 0.9s steps(2) infinite; }
.call-notice { margin: 0.3rem 0 0; padding: 0.45rem 0.7rem; border-radius: 0.7rem; background: rgba(255, 107, 107, 0.16); border: 1px solid rgba(255, 107, 107, 0.45); color: #ffd3d3; font-size: 0.85rem; line-height: 1.35; }
.call-notice[hidden] { display: none; }
@media (max-width: 899px) { .call-avatar { margin: 0.4rem 0; } .call-log { max-height: 30vh; } }

/* a confirmation that deletes something: a red button with white text, not red text on the blue primary button */
.app-dialog .dialog-actions button.primary.danger, .app-dialog .dialog-actions button.danger.primary { background: var(--color-danger, #c9262f); border-color: var(--color-danger, #c9262f); color: #fff; }
.app-dialog .dialog-actions button.primary.danger:hover { filter: brightness(0.92); }

/* The unlock screen: the same card-and-pill language as Settings */
.lock-screen form { width: min(26rem, 92vw); gap: 10px; padding: 28px 24px 22px; border: 1px solid var(--plc-border, var(--color-border)); border-radius: var(--plc-radius-panel, 18px); background: var(--color-surface); box-shadow: var(--plc-shadow, 0 8px 28px rgba(15, 23, 42, .08)); }
.lock-screen .lock-note { text-align: center; margin: 0 0 6px; }
.lock-screen h2 { font-size: 1.3rem; line-height: 1.3; }
.lock-screen button.secondary { min-height: var(--plc-control-min, 44px); border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font-weight: 600; cursor: pointer; }
.lock-screen button.secondary:hover { background: var(--color-thread-hover); }
.lock-screen .lock-erase { display: grid; gap: 8px; margin-top: 4px; padding: 12px; border: 1px solid var(--color-danger); border-radius: 12px; }
.lock-screen .lock-erase p { margin: 0; font-size: .85rem; }
.lock-screen .lock-erase button.danger { min-height: 40px; border-radius: 999px; border: 1px solid var(--color-danger); background: transparent; color: var(--color-danger); font-weight: 600; cursor: pointer; }

/* ---- the picture in the middle of the orb changes with what the call is doing ---- */
.call-face { color: #cfe0ff; }
.call-face img { transition: opacity 0.25s ease; }
.call-glyphs { position: absolute; inset: 0; display: grid; place-items: center; }
.call-glyph { position: absolute; width: 56%; height: 56%; opacity: 0; transform: scale(0.85); transition: opacity 0.25s ease, transform 0.25s ease; }
.call[data-glyph='listen'] .g-listen, .call[data-glyph='think'] .g-think, .call[data-glyph='write'] .g-write, .call[data-glyph='prepare'] .g-prepare, .call[data-glyph='play'] .g-play,
.call[data-glyph='muted'] .g-muted, .call[data-glyph='hold'] .g-hold, .call[data-glyph='error'] .g-error { opacity: 1; transform: scale(1); }
.call[data-glyph]:not([data-glyph='mark']) .call-face img { opacity: 0; }
.call[data-glyph='listen'] .call-face { color: #9ec3ff; } .call[data-glyph='think'] .call-face { color: #9ec3ff; } .call[data-glyph='write'] .call-face { color: #ffcf7a; }
.call[data-glyph='prepare'] .call-face { color: #c9a8ff; } .call[data-glyph='play'] .call-face { color: #86e3ad; } .call[data-glyph='muted'] .call-face, .call[data-glyph='hold'] .call-face { color: #a9b8cb; }
.call[data-glyph='error'] .call-face { color: #ff8b8b; }
/* listening: the bars breathe at different speeds, and all jump when words arrive */
.g-listen .b { transform-box: fill-box; transform-origin: center; animation: glyph-breathe 2.4s ease-in-out infinite; }
.g-listen .b1 { animation-delay: -0.2s; } .g-listen .b2 { animation-delay: -0.9s; } .g-listen .b3 { animation-delay: -1.5s; } .g-listen .b4 { animation-delay: -0.5s; } .g-listen .b5 { animation-delay: -1.2s; }
.call.call-heard .g-listen .b { animation: glyph-jump 0.5s ease-out 1, glyph-breathe 2.4s ease-in-out 0.5s infinite; }
/* thinking: three dots circle a small core */
.g-think .orbit { transform-box: view-box; transform-origin: 32px 32px; animation: glyph-turn 2.2s linear infinite; }
.g-think .core { transform-box: fill-box; transform-origin: center; animation: glyph-core 1.1s ease-in-out infinite alternate; }
/* writing the reply: the lines are drawn one after another, a caret blinks after them */
.g-write .ln { stroke-dasharray: 1; stroke-dashoffset: 1; animation: glyph-write 2.1s ease-in-out infinite; }
.g-write .l2 { animation-delay: 0.45s; } .g-write .l3 { animation-delay: 0.9s; }
.g-write .caret { animation: glyph-caret 0.8s steps(2) infinite; }
/* making the sound: a waveform assembled bar by bar */
.g-prepare .b { transform-box: fill-box; transform-origin: center; animation: glyph-build 1.5s ease-in-out infinite; }
.g-prepare .b1 { animation-delay: 0s; } .g-prepare .b2 { animation-delay: 0.12s; } .g-prepare .b3 { animation-delay: 0.24s; } .g-prepare .b4 { animation-delay: 0.36s; } .g-prepare .b5 { animation-delay: 0.48s; } .g-prepare .b6 { animation-delay: 0.6s; }
/* speaking: sound rippling out of the speaker */
.g-play .w { opacity: 0.15; animation: glyph-wave 1.1s ease-out infinite; }
.g-play .w2 { animation-delay: 0.2s; } .g-play .w3 { animation-delay: 0.4s; }
.g-hold line { animation: glyph-hold 2.4s ease-in-out infinite; }
.g-muted .slash { stroke: #ff8b8b; }
@keyframes glyph-breathe { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
@keyframes glyph-jump { 0% { transform: scaleY(0.4); } 35% { transform: scaleY(1.35); } 100% { transform: scaleY(0.7); } }
@keyframes glyph-turn { to { transform: rotate(360deg); } }
@keyframes glyph-core { from { transform: scale(0.8); } to { transform: scale(1.25); } }
@keyframes glyph-write { 0% { stroke-dashoffset: 1; } 35%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -1; } }
@keyframes glyph-caret { 50% { opacity: 0; } }
@keyframes glyph-build { 0%, 100% { transform: scaleY(0.2); opacity: 0.45; } 50% { transform: scaleY(1); opacity: 1; } }
@keyframes glyph-wave { 0% { opacity: 0.1; } 40% { opacity: 1; } 100% { opacity: 0.1; } }
@keyframes glyph-hold { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .call-glyph *, .call-glyph { animation: none !important; }
  .g-listen .b { transform: scaleY(0.7); } .g-listen .b2, .g-listen .b4 { transform: scaleY(1); }
  .g-write .ln { stroke-dashoffset: 0; } .g-prepare .b { transform: scaleY(0.7); } .g-play .w { opacity: 0.8; }
}

/* the orb is a button: what a tap does depends on what it shows (the label says it) */
button.call-avatar { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.call-avatar:focus-visible { outline: 3px solid #9ec3ff; outline-offset: 6px; border-radius: 50%; }
button.call-avatar:active .call-face { transform: scale(0.96); }
/* the chat model coming into memory, and the voice: a progress ring around the orb (the model outside, the voice inside) */
.call-face::before, .call-face::after { content: ''; position: absolute; border-radius: 50%; opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); }
.call-face::before { inset: -12px; background: conic-gradient(#ffc45e calc(var(--model-p, 0) * 1%), rgba(255, 255, 255, 0.14) 0); }
.call-face::after { inset: -21px; background: conic-gradient(#c9a8ff calc(var(--voice-p, 0) * 1%), rgba(255, 255, 255, 0.14) 0); }
.call[data-model-state='downloading'] .call-face::before, .call[data-model-state='loading'] .call-face::before, .call[data-voice-state='downloading'] .call-face::after, .call[data-voice-state='loading'] .call-face::after { opacity: 1; }
.call[data-model-state='loading'] .call-face::before { background: conic-gradient(#ffc45e 25%, rgba(255, 255, 255, 0.14) 0); animation: glyph-turn 1.2s linear infinite; }
.call[data-voice-state='loading'] .call-face::after { background: conic-gradient(#c9a8ff 25%, rgba(255, 255, 255, 0.14) 0); animation: glyph-turn 1.6s linear infinite reverse; }
.call[data-glyph='load'] .g-load { opacity: 1; transform: scale(1); }
.call[data-glyph='load'] .call-face { color: #ffcf7a; }
.call[data-glyph='load'] .call-face img { opacity: 0; }
.g-load .arrow { animation: glyph-drop 1.2s ease-in infinite; }
@keyframes glyph-drop { 0% { transform: translateY(-10px); opacity: 0; } 40% { opacity: 1; } 100% { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .call-face::before, .call-face::after, .g-load .arrow { animation: none !important; } }

/* ---- the padlock: a blue case with a bevel and a lit keyhole, a steel bar, a soft shadow; it snaps shut, opens in green and shakes (chat/lock/padlock.mjs) ---- */
.padlock { --pl-top: #6a97f5; --pl-mid: #3f69d4; --pl-bottom: #2a4eb0; --pl-steel-a: #eef2f8; --pl-steel-b: #9eabc2; --pl-halo: rgba(90, 141, 238, 0.42); --pl-keylight: rgba(150, 195, 255, 0.95); overflow: visible; filter: drop-shadow(0 8px 12px rgba(20, 40, 100, 0.22)); }
[data-theme='dark'] .padlock { --pl-top: #78a2ff; --pl-mid: #4a74e0; --pl-bottom: #3158c4; --pl-steel-a: #dfe6f2; --pl-steel-b: #8b9ab3; --pl-halo: rgba(110, 160, 255, 0.4); filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55)); }
.padlock .pl-shine { opacity: 0.2; }
.padlock .pl-hole { fill: #0b1633; }
.padlock .pl-keyglow { opacity: 0.55; }
.padlock .pl-body-ok { opacity: 0; transition: opacity 0.35s ease; }
.padlock .pl-glow { transform-box: view-box; transform-origin: 32px 46px; opacity: 0.75; }
.padlock .pl-ground { transform-box: view-box; transform-origin: 32px 68px; }
.padlock .pl-shackle { transform-box: view-box; transform-origin: 43px 34px; transition: transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1); }
.padlock .pl-body, .padlock .pl-body-ok, .padlock .pl-edge, .padlock .pl-shine, .padlock .pl-key { transform-box: view-box; transform-origin: 32px 66px; }
/* the reminder's open padlock: bar lifted, warm case */
.padlock.open { --pl-top: #f8c76c; --pl-mid: #e9a23c; --pl-bottom: #cf8420; --pl-halo: rgba(242, 180, 86, 0.45); --pl-keylight: rgba(255, 220, 150, 0.95); }
.padlock.open .pl-shackle { transform: translateY(-7px) rotate(-26deg); }
.padlock.open .pl-hole { fill: #4a2d05; }
/* locking: the bar drops and snaps into the case, the case thunks, the halo pulses once */
.locking .padlock .pl-shackle { animation: pl-snap 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) 0.45s both; } /* the bar waits open for a beat, so the screen is seen before it closes */
.locking .padlock .pl-body, .locking .padlock .pl-edge, .locking .padlock .pl-shine, .locking .padlock .pl-key { animation: pl-thunk 0.35s ease-out 0.95s both; }
.locking .padlock .pl-ground { animation: pl-thunk 0.35s ease-out 0.95s both; }
.locking .padlock .pl-glow { animation: pl-pulse 0.9s ease-out 0.9s both; }
/* unlocking: the case turns green, the bar swings open, a ring of light spreads out */
.unlocking .padlock .pl-body-ok { opacity: 1; }
.unlocking .padlock .pl-shackle { transform: translateY(-8px) rotate(-28deg); }
.unlocking .padlock { --pl-halo: rgba(95, 214, 155, 0.55); --pl-keylight: rgba(170, 255, 205, 0.95); }
.unlocking .padlock .pl-hole { fill: #07351f; }
.unlocking .padlock .pl-glow { animation: pl-burst 0.8s ease-out both; }
.lock-screen.leaving { animation: pl-away 0.45s ease-in both; } /* after the lock has opened, the screen fades */
/* a wrong passphrase: the whole lock shakes and flushes red */
.denied .padlock { animation: pl-shake 0.5s ease-in-out both; --pl-top: #ef8d8d; --pl-mid: #cf5252; --pl-bottom: #a43b3b; --pl-halo: rgba(217, 100, 100, 0.55); --pl-keylight: rgba(255, 170, 170, 0.95); }
@keyframes pl-snap { 0% { transform: translateY(-9px) rotate(-28deg); } 55% { transform: translateY(2px) rotate(0deg); } 100% { transform: translateY(0) rotate(0deg); } }
@keyframes pl-thunk { 0% { transform: scale(1); } 40% { transform: scale(1.06, 0.94); } 100% { transform: scale(1); } }
@keyframes pl-pulse { 0% { transform: scale(0.8); opacity: 0.2; } 60% { opacity: 0.9; } 100% { transform: scale(1.25); opacity: 0.7; } }
@keyframes pl-burst { 0% { transform: scale(0.8); opacity: 0.9; } 100% { transform: scale(2); opacity: 0; } }
@keyframes pl-away { to { opacity: 0; transform: scale(1.03); } }
@keyframes pl-shake { 0%, 100% { transform: translateX(0); } 18% { transform: translateX(-7px); } 36% { transform: translateX(6px); } 54% { transform: translateX(-4px); } 72% { transform: translateX(3px); } }
@media (prefers-reduced-motion: reduce) {
  .locking .padlock *, .unlocking .padlock .pl-glow, .lock-screen.leaving, .denied .padlock { animation: none !important; }
  .padlock .pl-shackle { transition: none; }
}

/* a bigger padlock on the lock screens */
.lock-screen .lock-icon .padlock { width: 10.5rem; height: 11.5rem; }
.lock-screen .lock-icon canvas.padlock3d { margin: -0.4rem 0 -0.6rem; }
.lock-screen .lock-icon { margin-bottom: 0.25rem; }

/* the 3D padlock is drawn on a canvas: no flat-drawing effects on it */
canvas.padlock3d { filter: none !important; animation: none !important; display: block; }
