/* App shell: icon rail + sidebar panel, header actions, composer, popovers, settings page, search overlay, Roberta's page.
   Uses the brand tokens from brand.css. Layout follows the familiar chat-app pattern so it is understood on sight. */

body.shell { --rail-w: 52px; --row-h: 36px; --radius-pop: 14px; }
.shell-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--color-muted-text); cursor: pointer; }
.shell-icon-btn:hover, .shell-icon-btn:focus-visible { background: var(--color-thread-hover); color: var(--color-text); }
.shell-icon-btn .ico { width: 20px; height: 20px; }
.shell-icon-btn[hidden], .shell [hidden] { display: none !important; }
.shell .ico { flex: none; }

/* ---- rail ---- */
.shell-rail { display: none; }
@media (min-width: 900px) {
  .shell-rail { display: flex; flex-direction: column; justify-content: space-between; align-items: center; width: var(--rail-w); flex: none; padding: 10px 0; background: var(--color-sidebar-bg); border-right: 1px solid var(--color-border); height: 100%; }
  .shell-rail-top, .shell-rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .rail-btn { width: 40px; height: 40px; border-radius: 12px; }
  .rail-btn.active { background: var(--plc-accent-tint); color: var(--color-text); }
  body.shell-collapsed .sidebar { display: none; }
}
.shell-avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--plc-accent-tint, #eaf0ff); color: var(--plc-accent, #285bd4); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.shell-avatar .ico { width: 18px; height: 18px; }

/* ---- panel ---- */
body.shell .sidebar { padding: 10px 8px; box-shadow: none; }
@media (min-width: 900px) { body.shell .sidebar { width: 288px; max-width: 288px; } }
body.shell .sidebar-header { display: flex; align-items: center; gap: 2px; margin: 0 0 6px; padding: 0 4px; }
body.shell .sidebar-header .brand { flex: 1; min-width: 0; }
body.shell .sidebar-header .brand { padding-left: 6px; }
body.shell .brand-logo img { height: 1.5rem; width: auto; max-width: 100%; }
body.shell .panel-toggle { display: none; }
@media (min-width: 900px) { body.shell .panel-toggle { display: inline-flex; } .drawer-close { display: none !important; } }
@media (max-width: 899px) { .panel-toggle { display: none; } }
.shell-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--row-h); padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--color-text); font: inherit; font-size: 0.95rem; text-align: left; cursor: pointer; }
.shell-row:hover, .shell-row:focus-visible { background: var(--color-thread-hover); }
.shell-row .ico { width: 18px; height: 18px; color: var(--color-muted-text); }
.shell-row .btn-label { flex: 1; }
body.shell .new-chat-row { display: block; margin: 0 0 2px; padding: 0; }
body.shell .new-chat-row .shell-row { background: transparent; border: 0; }
.shell-row.active { background: var(--color-thread-hover); font-weight: 600; }
.shell-nav { display: grid; gap: 1px; margin: 0 0 8px; }
.mobile-only { display: flex; }
@media (min-width: 900px) { .mobile-only { display: none; } }
.shell-dot-avatar { width: 22px; height: 22px; border-radius: 50%; background: #c45a2b; color: #fff; font-size: 0.78rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.shell-dot-avatar.big { width: 40px; height: 40px; font-size: 1.1rem; }
body.shell .chats-section { min-height: 0; flex: 1; }
body.shell .thread-filter { margin: 4px 6px 8px; }
body.shell .thread-filter:has(button[data-view="active"][aria-pressed="true"]) { display: none; }
body.shell .chats-section .thread-list { max-height: none; overflow: visible; padding: 0; margin: 0; list-style: none; }
body.shell .sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; }
body.shell .thread-list li { display: flex; align-items: center; min-height: var(--row-h); padding: 0 4px 0 10px; border-radius: 10px; margin: 0; background: transparent; }
body.shell .thread-list li:hover { background: var(--color-thread-hover); }
body.shell .thread-list li.selected { background: var(--plc-accent-tint); color: var(--color-text); border: 0; box-shadow: none; }
body.shell .thread-list li, body.shell .thread-list li.selected { border-left: 0 !important; }
body.shell .thread-list li .thread-name { font-size: 0.93rem; padding: 6px 0; }
body.shell .thread-list li .thread-menu-btn { opacity: 0; width: 28px; height: 28px; border: 0; background: transparent; color: var(--color-muted-text); border-radius: 8px; }
body.shell .thread-list li:hover .thread-menu-btn, body.shell .thread-list li:focus-within .thread-menu-btn, body.shell .thread-list li.selected .thread-menu-btn { opacity: 1; }
@media (hover: none) { body.shell .thread-list li .thread-menu-btn { opacity: 1; } }
body.shell .thread-list li.list-heading { font-size: 0.78rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--color-muted-text); padding: 14px 10px 4px; min-height: 0; background: none; cursor: default; }
body.shell .thread-list li.list-heading:hover { background: none; }
body.shell .thread-list li.folder-heading { text-transform: none; font-size: 0.93rem; letter-spacing: 0; color: var(--color-text); padding: 0 4px 0 10px; }
body.shell .thread-list li.in-project { padding-left: 28px; }
body.shell .thread-list li.heading-with-action { justify-content: space-between; }
.list-add { border: 0; background: transparent; color: var(--color-muted-text); width: 26px; height: 26px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.list-add:hover { background: var(--color-thread-hover); color: var(--color-text); }
.list-add .ico { width: 16px; height: 16px; }
body.shell .side-footer { display: none; }

/* ---- header ---- */
body.shell .chat-header { border-bottom: 0; padding: 8px 12px; min-height: 52px; gap: 6px; }
body.shell .thread-title { background: transparent; border: 1px solid transparent; font-size: 1rem; font-weight: 600; padding: 6px 8px; border-radius: 10px; min-width: 0; text-overflow: ellipsis; }
body.shell .thread-title:hover, body.shell .thread-title:focus { border-color: var(--color-border); background: var(--color-surface); }
body.shell .mode-badge { border: 0; background: transparent; color: var(--color-muted-text); font-size: 0.82rem; padding: 4px 6px; }
@media (max-width: 599px) { body.shell .mode-badge .mode-badge-provider { display: none; } }
.header-temp.on { color: var(--plc-accent); background: var(--plc-accent-tint); }
.header-temp.on .ico { stroke-dasharray: 3 2; }
body.view-temp .chat-area { background-image: none; }

/* ---- composer ---- */
body.shell .message-form { max-width: 52rem; width: 100%; margin: 0 auto; padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
body.shell .composer-card { border-radius: 26px; padding: 8px 10px 8px 10px; border: 1px solid var(--color-border); background: var(--color-surface); box-shadow: var(--plc-shadow); }
body.shell .message-form textarea { border: 0 !important; background: transparent !important; box-shadow: none !important; min-height: 2.6rem; padding: 8px 8px 4px; }
body.shell .composer-bar { display: flex; align-items: center; justify-content: flex-start; gap: 6px; }
body.shell .composer-bar > .composer-tools, body.shell .composer-bar > .composer-actions { margin: 0; flex: none; }
body.shell .composer-actions { display: flex; align-items: center; gap: 6px; }
body.shell .composer-tools { display: flex; align-items: center; gap: 4px; }
body.shell .composer-tools > :not(#micBtn):not(#voiceModeBtn) { display: none !important; }
.shell-plus { background: transparent !important; color: var(--color-text) !important; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--color-text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; min-height: 36px !important; }
.shell-plus:hover { background: var(--color-thread-hover) !important; }
.shell-plus .ico { width: 22px; height: 22px; }
.shell-model { background: transparent !important; margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: var(--color-muted-text); font: inherit; font-size: 0.9rem; cursor: pointer; max-width: 46vw; min-height: 34px !important; }
.shell-model { color: var(--color-muted-text) !important; }
.shell-model:hover, .shell-model[aria-expanded="true"] { background: var(--color-thread-hover) !important; color: var(--color-text) !important; }
.shell-model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-model .ico { width: 14px; height: 14px; }
.shell-model-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-muted-text); flex: none; }
.shell-model[data-status="ready"] .shell-model-dot, .shell-model[data-status="provider"] .shell-model-dot { background: var(--plc-success); }
.shell-model[data-status="busy"] .shell-model-dot { background: var(--plc-warning); }
.shell-mic { width: 36px; height: 36px; border-radius: 50%; border: 0 !important; background: transparent !important; color: var(--color-muted-text) !important; padding: 0 !important; min-height: 36px !important; display: inline-flex; align-items: center; justify-content: center; }
.shell-mic:hover { background: var(--color-thread-hover) !important; color: var(--color-text) !important; }
.shell-mic[aria-pressed="true"] { background: var(--plc-danger-tint) !important; color: var(--plc-danger) !important; }
.shell-voice { width: 36px; height: 36px; border-radius: 50%; border: 0 !important; background: var(--color-text) !important; color: var(--color-bg) !important; padding: 0 !important; min-height: 36px !important; display: inline-flex; align-items: center; justify-content: center; }
.shell-voice .ico, .shell-mic .ico { width: 20px; height: 20px; }
.shell-voice[aria-pressed="true"] { outline: 3px solid var(--plc-accent); }
body.shell .message-form.has-text #voiceModeBtn { display: none !important; }
body.shell .message-form:not(.has-text) #sendBtn { display: none; }
body.shell .send-btn { width: 36px; height: 36px; min-height: 36px !important; padding: 0 !important; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--color-text); color: var(--color-bg); border: 0; }
body.shell .send-btn .btn-label, body.shell #stopGeneration .btn-label { display: none; }
body.shell .send-btn .ico, body.shell #stopGeneration .ico { width: 18px; height: 18px; }
body.shell #stopGeneration { width: 36px; height: 36px; min-height: 36px !important; padding: 0 !important; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
body.shell .accuracy-note { text-align: center; font-size: 0.75rem; color: var(--color-muted-text); margin: 6px 0 0; }
body.shell .system-prompt-container:not([open]) { display: none; }
body.shell .system-prompt-container { max-width: 52rem; width: 100%; margin: 0 auto; padding: 0 16px; }

/* ---- welcome (empty chat): composer sits in the middle ---- */
body.shell .chat-area.is-empty { justify-content: flex-start; }
body.shell .chat-area.is-empty .messages-wrap { flex: 0 0 auto; margin-top: auto; }
body.shell .chat-area.is-empty .message-form { margin-bottom: auto; }
body.shell .chat-area.is-empty .messages { flex: none; overflow: visible; }
body.shell .chat-area.is-empty .empty-state { margin: 0 auto; }
body.shell .chat-area.is-empty .empty-state h2 { font-size: clamp(1.5rem, 4vw, 1.9rem); font-weight: 600; margin-bottom: 14px; }
body.shell .chat-area.is-empty .empty-state > .lede, body.shell .chat-area.is-empty .empty-state > p.muted { max-width: 34rem; margin-left: auto; margin-right: auto; }
body.shell .chat-area.is-empty .accuracy-note { display: none; }

/* ---- popovers ---- */
.shell-pop { position: fixed; z-index: 3500; min-width: 220px; max-width: min(92vw, 380px); max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; border-radius: var(--radius-pop, 14px); background: var(--color-modal-bg); border: 1px solid var(--color-border); box-shadow: var(--plc-shadow); }
.shell-pop.wide { min-width: 280px; }
.shell-pop-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--color-text); font: inherit; text-align: left; cursor: pointer; min-height: 40px; }
.shell-pop-row:hover, .shell-pop-row:focus-visible { background: var(--color-thread-hover); outline: none; }
.shell-pop-row.danger { color: var(--color-danger); }
.shell-pop-row:disabled { opacity: 0.5; cursor: default; }
.shell-pop-ico { display: inline-flex; color: var(--color-muted-text); }
.shell-pop-ico .ico { width: 18px; height: 18px; }
.shell-pop-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.shell-pop-label { font-size: 0.93rem; }
.shell-pop-desc { font-size: 0.78rem; color: var(--color-muted-text); overflow: hidden; text-overflow: ellipsis; }
.shell-pop-check .ico { width: 16px; height: 16px; }
.shell-pop-sep { height: 1px; background: var(--color-border); margin: 6px 4px; }
.shell-pop-heading { padding: 8px 10px 4px; font-size: 0.75rem; font-weight: 600; color: var(--color-muted-text); }
.shell-pin { display: inline-flex; padding: 4px; border-radius: 6px; color: var(--color-muted-text); opacity: 0.55; }
.shell-pin.on { opacity: 1; color: var(--plc-accent); }
.shell-pin .ico { width: 14px; height: 14px; }
.thread-menu { border-radius: 14px; }

/* ---- settings page ---- */
.settings-page { position: fixed; inset: 0; z-index: 2500; display: flex; background: var(--color-bg); color: var(--color-text); }
.settings-page[hidden] { display: none; }
.settings-nav { width: 280px; flex: none; padding: 14px 10px; border-right: 1px solid var(--color-border); background: var(--color-sidebar-bg); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 8px; font-size: 1.1rem; }
.settings-search { width: 100%; margin: 0 0 8px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font: inherit; }
.settings-nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--color-text); font: inherit; text-align: left; cursor: pointer; min-height: 40px; }
.settings-nav-item:hover { background: var(--color-thread-hover); }
.settings-nav-item.active { background: var(--plc-accent-tint); }
.settings-nav-item .ico { width: 18px; height: 18px; color: var(--color-muted-text); }
.settings-content { flex: 1; overflow-y: auto; padding: 28px clamp(16px, 5vw, 64px) 64px; outline: none; }
.settings-content > div { max-width: 44rem; margin: 0 auto; }
.settings-content h2 { font-size: 1.5rem; margin: 0 0 18px; }
.set-card { border: 1px solid var(--color-border); border-radius: 16px; background: var(--color-surface); overflow: hidden; margin-bottom: 18px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--color-border); }
.set-row:last-child { border-bottom: 0; }
.set-label { font-weight: 600; font-size: 0.95rem; }
.set-desc, .set-note { color: var(--color-muted-text); font-size: 0.82rem; margin-top: 2px; }
.set-about { color: var(--color-muted-text); font-size: 0.8rem; margin: 14px 4px 0; user-select: text; -webkit-user-select: text; }
.set-control { flex: none; display: flex; align-items: center; gap: 8px; }
.set-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface-alt); color: var(--color-text); font: inherit; font-size: 0.88rem; text-decoration: none; cursor: pointer; min-height: 36px; }
.set-btn:hover { background: var(--color-thread-hover); }
.set-btn.danger { color: var(--color-danger); }
.set-btn .ico { width: 16px; height: 16px; }
.set-moved details { border: 0; }
.set-moved .form-group, .set-moved section { margin-bottom: 14px; }
.set-moved label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.set-moved select, .set-moved input[type="text"] { width: 100%; max-width: 100%; }
.set-moved .flow-entry { border: 1px solid var(--color-border); border-radius: 16px; padding: 14px 16px; background: var(--color-surface); margin-bottom: 12px; }
.set-moved .flow-entry h3 { margin: 0 0 4px; }
.set-moved .flow-danger { display: flex; flex-wrap: wrap; gap: 8px; }
.set-foot { margin-top: 8px; color: var(--color-muted-text); }
@media (max-width: 760px) {
  .settings-page { flex-direction: column; }
  .settings-nav { width: 100%; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--color-border); padding: 8px; align-items: center; }
  .settings-nav-head { padding: 0 8px 0 0; }
  .settings-search { display: none; }
  .settings-nav-item { flex: none; white-space: nowrap; }
  .set-row { flex-direction: column; align-items: flex-start; }
}

/* ---- search overlay ---- */
.search-overlay { position: fixed; inset: 0; z-index: 2600; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 12px 12px; background: var(--color-overlay); }
.search-overlay[hidden] { display: none; }
.search-box { width: min(42rem, 100%); max-height: 80vh; display: flex; flex-direction: column; border-radius: 18px; background: var(--color-modal-bg); border: 1px solid var(--color-border); box-shadow: var(--plc-shadow); overflow: hidden; }
.search-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--color-border); }
.search-top > .ico { width: 20px; height: 20px; color: var(--color-muted-text); flex: none; }
.search-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--color-text); font: inherit; font-size: 1.05rem; padding: 8px 4px; }
.search-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
.search-f { display: flex; flex-direction: column; gap: 2px; font-size: 0.75rem; color: var(--color-muted-text); }
.search-f select { font: inherit; font-size: 0.88rem; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); }
.search-f.check { flex-direction: row; align-items: center; gap: 6px; align-self: flex-end; padding-bottom: 6px; }
.search-status { margin: 0; padding: 6px 16px; font-size: 0.78rem; color: var(--color-muted-text); }
.search-list { list-style: none; margin: 0; padding: 4px 6px 8px; overflow-y: auto; }
.search-group { padding: 8px 10px 4px; font-size: 0.75rem; font-weight: 600; color: var(--color-muted-text); }
.search-empty { padding: 20px 12px; color: var(--color-muted-text); text-align: center; }
.search-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 12px; cursor: pointer; }
.search-item.active { background: var(--color-thread-hover); }
.search-item > .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--color-muted-text); flex: none; }
.search-item-text { flex: 1; min-width: 0; }
.search-item-title { font-weight: 600; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item-snip { font-size: 0.82rem; color: var(--color-muted-text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.search-item-meta { display: flex; gap: 6px; align-items: center; font-size: 0.75rem; color: var(--color-muted-text); flex: none; }
.search-tag { padding: 1px 7px; border-radius: 999px; border: 1px solid var(--color-border); }
body.search-open, body.settings-open { overflow: hidden; }

/* ---- Roberta's page ---- */
.roberta-page { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--color-bg); }
.chat-area { position: relative; }
.roberta-page[hidden] { display: none; }
.roberta-page-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 56px; }
.roberta-page-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.roberta-page-title span { font-size: 0.8rem; color: var(--color-muted-text); }
.roberta-call { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--color-text); color: var(--color-bg); font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; }
.roberta-call .ico { width: 18px; height: 18px; }
.roberta-page-body { flex: 1; overflow-y: auto; padding: 8px 16px 32px; }
.roberta-page-body > * { max-width: 44rem; margin-left: auto; margin-right: auto; }

/* ---- cleanup from the phone-size WebKit pass ---- */
body.shell .sidebar > :not(.sidebar-header) { margin-left: 0; margin-right: 0; }
body.shell .sidebar > .sidebar-scroll { padding: 0; }
body.shell .sidebar .sidebar-close { width: 36px; height: 36px; border: 0; border-radius: 10px; color: var(--color-muted-text); }
body.shell .sidebar .sidebar-close:focus:not(:focus-visible) { outline: none; }
.shell-plus, .shell-mic, .shell-voice, .shell-model, .shell-icon-btn { border-radius: 999px !important; }
.shell-icon-btn { border-radius: 10px !important; }
.shell-plus:focus:not(:focus-visible), .shell-model:focus:not(:focus-visible) { outline: none; }
/* quiet status lines: kept for screen readers, only shown when they matter */
body.shell #generationStatus.quiet, body.shell .context-meter:not(.warn) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body.shell #generationStatus { background: none; border: 0; padding: 0 16px; margin: 0 auto 4px; max-width: 52rem; width: 100%; font-size: 0.8rem; color: var(--color-muted-text); }
@media (max-width: 599px) {
  body.shell .message-actions button { padding: 6px 8px; }
  body.shell .message-actions button .ico-label { display: none; }
  .search-overlay { padding: 0; align-items: stretch; }
  .search-box { width: 100%; max-height: 100%; height: 100%; border-radius: 0; border: 0; }
  .settings-nav { display: grid; grid-template-columns: 1fr auto; padding: 8px 8px 0; gap: 0; }
  .settings-nav-head { grid-column: 1 / -1; padding: 4px 6px; }
  .settings-nav > .settings-nav-item { display: none; }
  /* every section is visible at once, in two columns under the title (a scrolling row hid what was there). The tabs' own wrapper steps aside so its items sit in the grid. */
  .settings-nav > .settings-nav-tabs { display: contents; }
  .settings-nav > .settings-nav-tabs .settings-nav-item { display: flex; flex: none; white-space: nowrap; }
  .settings-content { padding: 18px 14px 56px; }
}
.set-moved details { padding: 0; margin: 0; }
.set-moved .flow-list { margin: 0; padding: 0; }
.set-moved > * { margin-left: 0; margin-right: 0; }
.settings-nav-tabs { display: contents; }
@media (min-width: 761px) { .settings-nav-tabs { display: flex; flex-direction: column; gap: 2px; } }
.shell-dot .shell-dot-avatar { width: 20px; height: 20px; font-size: 0.7rem; margin: 0 -1px; }
body.shell .thread-list li.selected, body.shell .thread-list li.selected .thread-name { color: var(--color-text); }
/* the model pill, mic and voice/send sit on the right; "+" stays on the left */
body.shell .composer-bar .shell-model { margin-left: auto !important; }
body.shell .composer-bar .composer-actions:not(:has(> :not([hidden]))) { display: none; }
@media (hover: none) { body.shell .sidebar-close:focus, body.shell .shell-icon-btn:focus, .shell-pop-row:focus { outline: none; } }
.setup-card .hint-text, #setupHint { margin-top: 10px; }
.set-sub { font-size: 0.8rem; font-weight: 600; color: var(--color-muted-text); margin: 18px 4px 8px; text-transform: none; }

/* Finger-sized targets on a touch screen. */
@media (pointer: coarse) {
  .shell-icon-btn, .shell-plus, .shell-mic, .shell-voice, body.shell .send-btn { width: 44px; height: 44px; min-height: 44px !important; }
  .shell-icon-btn .ico { width: 22px; height: 22px; }
}

/* ---- voice picker (beside the model picker) ---- */
.shell-voicepick { margin-left: 0 !important; }
body.shell .composer-bar .shell-voicepick { margin-left: 0 !important; }
/* the dot shows where the voice is: hollow = on the device only, pulsing amber = loading, solid = in memory, ringed = reading */
.shell-voicepick[data-memory="unloaded"] .shell-model-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--plc-success); }
.shell-voicepick[data-memory="loading"] .shell-model-dot, .shell-voicepick[data-memory="unloading"] .shell-model-dot { background: var(--plc-warning); animation: plc-voice-pulse 1s ease-in-out infinite; }
.shell-voicepick[data-memory="speaking"] .shell-model-dot { animation: plc-voice-ring 1.2s ease-out infinite; }
@keyframes plc-voice-pulse { 50% { opacity: .35; } }
@keyframes plc-voice-ring { 0% { box-shadow: 0 0 0 0 var(--plc-success); } 100% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .shell-voicepick .shell-model-dot { animation: none !important; } }
.shell-voicepick[data-status="error"] .shell-model-dot { background: var(--plc-danger); }
.shell-voicepick .shell-model-name { max-width: 9.5em; }
@media (max-width: 520px) { .shell-voicepick .shell-model-name { max-width: 6.5em; } .shell-voicepick[data-status="none"] .shell-model-name, .shell-voicepick[data-status="ready"] .shell-model-name { display: none; } }
.shell-pop-note { margin: 6px 8px; padding: 8px 10px; border-radius: 10px; font-size: 0.82rem; line-height: 1.35; background: var(--plc-warning-tint); color: var(--plc-warning); max-width: 24em; }
.shell-pop-note.error { background: var(--plc-danger-tint); color: var(--plc-danger); }
.set-note.error { color: var(--plc-danger); } .set-note.slow { color: var(--plc-warning); }

/* a phone has room for the model name only if it may shrink (with an ellipsis) beside the voice pill, the mic and the call button */
@media (max-width: 520px) {
  body.shell .composer-bar .shell-model:not(.shell-voicepick) { min-width: 0; flex: 0 1 auto; }
  body.shell .composer-bar .shell-model:not(.shell-voicepick) .shell-model-name { min-width: 0; }
  body.shell .composer-bar .shell-voicepick { flex: none; }
}

/* the offer to turn on "One model at a time" after a model fails (chat/models/memory-offer.mjs) */
.memory-offer { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 9000; max-width: 34rem; margin: 0 auto; padding: 14px 16px; border-radius: 14px; background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border-strong, #8896a8); box-shadow: 0 8px 28px rgba(0,0,0,.35); font: 15px/1.4 system-ui, sans-serif; }
.memory-offer p { margin: 0 0 10px; }
.memory-offer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.memory-offer-btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--color-border-strong, #8896a8); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.memory-offer-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }

/* the chat model pill uses the same dot words as the voice pill: hollow = on the device, not in memory; pulsing amber = downloading or loading; solid = in memory */
#modelPill[data-status="idle"] .shell-model-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--plc-success); }
#modelPill[data-status="busy"] .shell-model-dot { animation: plc-voice-pulse 1s ease-in-out infinite; }

/* Settings > Models: one page, one kind of row (chat/shell/models-page.mjs) */
.set-models section { margin-bottom: 1.4rem; }
.set-models .set-sub { margin: 1.2rem 0 .4rem; }
.set-seg { display: inline-flex; gap: 0; border: 1px solid var(--color-border, #c9d2de); border-radius: 10px; overflow: hidden; }
.set-seg .set-btn { border: 0; border-radius: 0; min-height: 40px; }
.set-seg .set-btn[aria-pressed="true"] { background: var(--plc-accent, #2563eb); color: #fff; }
.set-inuse { margin-left: .5rem; padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--plc-success-tint, rgba(34,160,90,.15)); color: var(--plc-success, #1a7f45); vertical-align: middle; }
.model-row progress { display: block; width: 100%; margin-top: 6px; }
.model-row .set-control { flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.set-models .set-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: .5rem 0; }
.set-models .set-btn.primary { background: var(--plc-accent, #2563eb); color: #fff; border-color: transparent; }
.set-models .set-btn.danger { color: var(--plc-danger, #b42318); }
.set-models #advancedModels pre { max-height: 14rem; overflow: auto; font-size: .75rem; }
.set-models .set-note[data-error="true"] { color: var(--plc-danger, #b42318); }
/* the provider form sits in a card like every other group on the page */
.set-models #apiSettings:not([hidden]) { border: 1px solid var(--color-border, #d4dbe5); border-radius: 12px; padding: 12px 16px; margin-top: 8px; }
.set-models #apiSettings .form-group { margin: 10px 0; }
.set-models #apiSettings label { font-weight: 600; font-size: .9rem; }

/* a model row in a composer menu: the same state dot words as the pills and Settings */
.shell-pop-dot { flex: none; width: 10px; height: 10px; margin-right: 10px; border-radius: 50%; background: var(--color-muted-text); align-self: center; }
.shell-pop-dot[data-state="downloaded"] { background: transparent; box-shadow: inset 0 0 0 2px var(--plc-success); }
.shell-pop-dot[data-state="loaded"], .shell-pop-dot[data-state="busy"], .shell-pop-dot[data-state="ready"] { background: var(--plc-success); }
.shell-pop-dot[data-state="downloading"], .shell-pop-dot[data-state="testing"], .shell-pop-dot[data-state="loading"] { background: var(--plc-warning); animation: plc-voice-pulse 1s ease-in-out infinite; }
.shell-pop-dot[data-state="failed"] { background: var(--plc-danger); }
.shell-pop-inuse { margin-left: .5rem; padding: 1px 8px; border-radius: 999px; font-size: .72rem; background: var(--plc-success-tint, rgba(34,160,90,.15)); color: var(--plc-success, #1a7f45); }
.shell-pop-text progress { display: block; width: 100%; margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .shell-pop-dot { animation: none !important; } }

/* ---- connection pill and the offline checklist (offline plan, phase 3) ---- */
.shell-conn[hidden] { display: none; }
.shell-conn .shell-model-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--color-muted-text); }
.shell-conn[data-state="offline"][data-mode="local"] .shell-model-dot { box-shadow: inset 0 0 0 2px var(--plc-success); }
.shell-conn[data-state="offline"][data-mode="internet"] .shell-model-dot { background: var(--plc-warning); box-shadow: none; }
.shell-conn[data-state="back"] .shell-model-dot { background: var(--plc-success); box-shadow: none; animation: plc-conn-in .6s ease-out 1; }
@keyframes plc-conn-in { from { transform: scale(2.2); opacity: .3; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .shell-conn .shell-model-dot { animation: none !important; } }
@media (max-width: 520px) { .shell-conn .shell-model-name { max-width: 6em; } }
.shell-pop-dot[data-state="partial"] { background: var(--plc-warning); }
.shell-pop-note.ok { background: var(--plc-success-tint); color: var(--plc-success); }
.off-list { list-style: none; margin: 0; padding: 0; }
.off-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.off-item:last-child { border-bottom: 0; }
.off-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--color-muted-text); }
.off-dot[data-state="loaded"] { background: var(--plc-success); }
.off-dot[data-state="partial"] { background: var(--plc-warning); }
.off-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.off-label { font-weight: 600; }
.off-state { font-size: .8125rem; color: var(--color-muted-text); }
.off-item[data-state="ready"] .off-state { color: var(--plc-success); }
.off-item[data-state="partial"] .off-state { color: var(--plc-warning); }
.off-detail { flex-basis: 100%; font-size: .875rem; color: var(--color-muted-text); }
.off-summary { margin: 0 0 10px; }
.shell-pop-right { margin-left: auto; padding-left: 12px; white-space: nowrap; font-weight: 600; color: var(--color-primary, var(--plc-accent, #2557d6)); }
body.shell .composer-bar .shell-conn { margin-left: 0 !important; flex: none !important; min-width: auto !important; max-width: none; }
body.shell .composer-bar .shell-conn .shell-model-name { max-width: none; overflow: visible; }
.shell-conn[data-state="offline"][data-mode="device"] .shell-model-dot, .shell-conn[data-state="offline"][data-mode="network"] .shell-model-dot { box-shadow: inset 0 0 0 2px var(--plc-success); }
.off-note { margin-bottom: 14px; }
.off-note[hidden] { display: none; }
/* a row with an action label on its right wraps it under the text when there is no room (narrow screens, large text) */
.shell-pop-row:has(.shell-pop-right) { flex-wrap: wrap; row-gap: 2px; }
.shell-pop-row:has(.shell-pop-right) .shell-pop-text { flex: 1 1 10em; min-width: 0; }
.shell-pop-row:has(.shell-pop-right) .shell-pop-right { flex: none; margin-left: auto; padding-left: 22px; }

/* ---- it should feel like an app, not a page (phones) ----
   The page itself never scrolls or rubber-bands: only the message list, the side panel and the settings content scroll, each on its own and without chaining to the page. */
html, body { overscroll-behavior: none; }
body.shell { height: 100dvh; }
.settings-content, .roberta-page-body, .sidebar-scroll, #messages, .shell-pop, .search-results { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.settings-page { height: 100dvh; max-height: 100dvh; }
.settings-content { min-height: 0; }
@media (max-width: 760px) { .settings-page { padding-top: env(safe-area-inset-top, 0px); } .settings-content { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); } }

/* ---- Security dialogs (passcode, encryption and lock): the Settings vocabulary inside a dialog ---- */
.app-dialog .dialog-body .sec-lead { margin: 2px 0 16px; line-height: 1.5; }
.app-dialog .dialog-body .set-card { margin: 0 0 14px; }
.app-dialog .dialog-body .set-sub { margin: 18px 2px 8px; }
.app-dialog .dialog-body .set-sub:first-child { margin-top: 2px; }
.app-dialog .dialog-body .set-row { flex-direction: row; padding: 12px 16px; } /* a phone rule elsewhere stacks rows; inside a dialog they stay label | control */
.app-dialog .dialog-body .set-row .set-control { flex: none; }
.app-dialog .dialog-body .set-row select { width: auto; min-width: 11.5rem; max-width: 100%; }
.app-dialog .dialog-body .set-row input[type="checkbox"] { width: 22px; height: 22px; margin: 0; accent-color: var(--plc-accent, #2563eb); cursor: pointer; }
.app-dialog .dialog-body label.set-row { display: flex; align-items: center; cursor: pointer; font-weight: inherit; font-size: inherit; margin: 0; }
.app-dialog .dialog-body .set-field { display: grid; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.app-dialog .dialog-body .set-field:last-child { border-bottom: 0; }
.app-dialog .dialog-body .set-field label { margin: 0; font-weight: 600; font-size: 0.9rem; }
.app-dialog .dialog-body .set-field input { margin: 0; }
.app-dialog .dialog-body .sec-note { margin: 0 4px 12px; line-height: 1.5; }
.app-dialog .dialog-body .sec-note:empty { display: none; }
.app-dialog .dialog-body .sec-note.danger { color: var(--color-danger); }
.app-dialog .dialog-body .sec-msg { margin: 0 4px 10px; min-height: 0; }
.app-dialog .dialog-body .sec-msg:empty { display: none; }
.app-dialog .dialog-body .face-box:empty { display: none; }
@media (max-width: 520px) {
  .app-dialog .dialog-body .set-row { flex-wrap: wrap; align-items: flex-start; }
  .app-dialog .dialog-body .set-row .set-control { width: 100%; }
  .app-dialog .dialog-body .set-row select { width: 100%; }
  .app-dialog .dialog-body label.set-row { flex-wrap: nowrap; align-items: center; }
  .app-dialog .dialog-body label.set-row .set-control { width: auto; flex: none; }
}

/* While a dialog is open, a toast must not sit on top of its buttons and swallow the tap (it covered "Remove it" on a phone). Elsewhere a toast still holds while it is touched. */
body:has(.app-dialog) #toast, body:has(.app-dialog) .toast { pointer-events: none; }
