/* Phone UI: conversation first, quiet chrome, readable bundled typography. */
@font-face {
  font-family: "Herdr Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/source-sans-3-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Herdr Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/source-sans-3-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Herdr Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/source-sans-3-latin-700-normal.woff2") format("woff2");
}
:root, [data-theme="dark"] { --on-accent: #08131f; --user-bg: #1b334b; --user-text: #edf5ff; --focus: #5fb0ff; }
[data-theme="light"] { --on-accent: #ffffff; --user-bg: #e7f0fc; --user-text: #163152; --focus: #1668d8; }
html, body { font-family: "Herdr Sans", Arial, sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font-family: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.btn.primary { color: var(--on-accent); }
.icon-btn {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
  background: transparent; color: var(--text); text-decoration: none; cursor: pointer;
}
.icon-btn:active { background: var(--panel-2); }
.phone-menu { position: relative; flex: none; }
.phone-menu summary { list-style: none; }
.phone-menu summary::-webkit-details-marker { display: none; }
.phone-menu[open] > summary { background: var(--panel-2); }
.menu-items {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 5;
  min-width: 200px; padding: 6px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel);
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
}
.menu-items button, .menu-items a {
  display: flex; align-items: center; width: 100%; min-height: 44px;
  padding: 10px 12px; border: 0; border-radius: 8px; text-align: left;
  font-size: 16px; text-decoration: none; color: var(--text); background: transparent; cursor: pointer;
}
.menu-items button:hover, .menu-items a:hover { background: var(--panel-2); }
.session-header { flex: none; padding: 8px 12px; gap: 10px; padding-top: max(8px, env(safe-area-inset-top)); }
.session-heading { flex: 1; min-width: 0; }
.session-heading h1 { font-size: 18px; line-height: 1.25; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.session-status { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.session-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--idle); }
.session-status[data-status="working"]::before { background: var(--working); }
.session-status[data-status="blocked"]::before { background: var(--blocked); }
.session-status[data-status="done"]::before { background: var(--done); }
.session-notice { flex: none; padding: 7px 20px; background: var(--panel-2); color: var(--blocked); font-size: 14px; }
.conversation { display: flex; flex: 1; min-height: 0; position: relative; }
.chat {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: 20px max(20px, calc((100% - 740px) / 2)); display: flex; flex-direction: column;
  gap: 26px; background: var(--panel); overflow-anchor: none; scrollbar-width: thin;
}
.chat-row { flex: none; min-width: 0; width: 100%; }
.chat-row.user { align-self: flex-end; width: fit-content; max-width: 90%; }
.user-message { padding: 12px 16px; border-radius: 18px 18px 5px 18px; background: var(--user-bg); color: var(--user-text); font-size: 17px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-row.assistant { display: flex; flex-direction: column; gap: 12px; }
.prose { color: var(--text); font-size: 17px; line-height: 1.65; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 1em; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { line-height: 1.3; margin: 1.5em 0 .65em; font-weight: 600; }
.prose h1 { font-size: 25px; }
.prose h2 { font-size: 22px; }
.prose h3 { font-size: 19px; }
.prose h4, .prose h5, .prose h6 { font-size: 17px; }
.prose ul, .prose ol { padding-left: 1.4em; margin: .6em 0 1em; }
.prose li { padding-left: .15em; margin: .3em 0; }
.prose li > p { margin: .3em 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose strong { font-weight: 700; }
.prose blockquote { margin: 1em 0; padding: .2em 0 .2em 16px; border-left: 3px solid var(--line); color: var(--muted); }
.prose hr { margin: 1.5em 0; border: 0; border-top: 1px solid var(--line); }
.prose code, .chat-detail pre { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: .85em; }
.prose :not(pre) > code { padding: 2px 5px; border-radius: 4px; background: var(--panel-2); overflow-wrap: anywhere; }
.prose pre { padding: 14px 16px; border-radius: 10px; background: var(--panel-2); margin: 1em 0; line-height: 1.55; overflow: auto; white-space: pre; max-width: 100%; }
.prose pre code { background: none; padding: 0; font-size: 14px; }
.table-scroll { max-width: 100%; overflow-x: auto; margin: 1em 0; }
.prose table { border-collapse: collapse; font-size: 15px; width: 100%; }
.prose th, .prose td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); min-width: 110px; }
.prose th { font-weight: 600; background: var(--panel-2); }
.chat-detail { min-width: 0; padding: 0; font-size: 14px; color: var(--muted); }
.chat-detail summary { display: flex; gap: 8px; align-items: center; list-style: none; min-height: 44px; cursor: pointer; border-radius: 8px; padding: 5px 0; }
.chat-detail summary::-webkit-details-marker { display: none; }
.chat-detail summary::after { content: "›"; font-size: 22px; margin-left: auto; transform: rotate(90deg); flex: none; }
.chat-detail[open] summary::after { transform: rotate(-90deg); }
.chat-detail summary svg { width: 17px; height: 17px; flex: none; }
.tool-hint { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; min-width: 0; font-size: 12px; opacity: .85; }
.tool-state { font-size: 12px; margin-left: auto; white-space: nowrap; }
.tool-state.failed, .message-error { color: var(--danger); }
.message-error { font-size: 17px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 3px solid var(--danger); padding-left: 12px; }
.chat-detail pre { padding: 12px; border-radius: 8px; max-height: 350px; overflow: auto; background: var(--panel-2); font-size: 13px; line-height: 1.5; margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reasoning .prose { font-size: 15px; color: var(--muted); padding: 8px 0 8px 24px; }
.chat-meta { font-size: 13px; color: var(--muted); text-align: center; padding: 8px; }
.attachment { display: block; font-size: 14px; color: var(--muted); }
.latest-btn { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 14px; cursor: pointer; }
.text-btn { border: 0; background: transparent; color: var(--accent); min-height: 44px; font-size: 14px; cursor: pointer; flex: none; }
.session-composer { flex: none; margin: 0; padding: 12px max(12px, calc((100% - 740px) / 2)) max(8px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.composer-input { display: flex; align-items: flex-end; gap: 8px; padding: 4px 6px 4px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); }
.composer-input:focus-within { border-color: var(--accent); }
.composer-input textarea { display: block; flex: 1; min-width: 0; width: 100%; min-height: 48px; max-height: 160px; resize: none; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 17px; line-height: 1.45; padding: 12px 0; }
.composer-input textarea::placeholder { color: var(--muted); }
.composer-send { width: 44px; height: 44px; margin: 2px 0; background: var(--accent); color: var(--on-accent); border-radius: 14px; }
.composer-send:active { background: var(--accent); filter: brightness(.92); }
.composer-send[data-mode="stop"] { background: var(--danger); color: white; }
.composer-options { display: flex; align-items: center; gap: 10px; padding-top: 4px; min-width: 0; }
.composer-options button { display: flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--text); font-size: 14px; min-height: 40px; padding: 6px; max-width: 62%; min-width: 0; cursor: pointer; }
.composer-options #sess-model { flex: 1; }
.composer-options #sess-think { flex: none; }
.composer-options button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-options #sess-model span { white-space: normal; overflow-wrap: anywhere; text-align: left; line-height: 1.3; }
.composer-options svg { width: 14px; height: 14px; flex: none; }
.composer-error { font-size: 14px; color: var(--danger); padding: 4px 8px 10px; }
.phone-sheet { position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 560px); max-height: 82dvh; padding: 16px 20px max(20px, env(safe-area-inset-bottom)); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; overflow: auto; overscroll-behavior: contain; }
.phone-sheet::backdrop { background: rgba(0,0,0,.4); }
.phone-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.phone-sheet h2 { font-size: 21px; line-height: 1.3; margin: 0; font-weight: 600; }
.phone-sheet p { font-size: 16px; line-height: 1.55; }
.sheet-search { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.sheet-search input { width: 100%; min-height: 48px; font-size: 17px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.choice-list { display: flex; flex-direction: column; max-height: 50dvh; overflow: auto; }
.choice-row { width: 100%; min-height: 52px; flex: none; padding: 12px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--line); text-align: left; font-size: 17px; cursor: pointer; }
.choice-row span { min-width: 0; overflow-wrap: anywhere; }
.choice-row strong { display: block; font-weight: 600; }
.choice-row small { display: block; color: var(--muted); font-size: 13px; }
.choice-row[aria-pressed="true"] { color: var(--accent); }
.choice-row:hover { background: var(--panel-2); }
.sheet-warning { color: var(--danger); }
.phone-sheet .btn { min-height: 48px; font-size: 16px; width: 100%; }
.sessions-header { justify-content: space-between; padding: 12px 16px; }
.sessions-header h1 { font-size: 22px; font-weight: 600; }
.sessions-list { padding: 16px; gap: 20px; }
.session-group { display: flex; flex-direction: column; flex: none; }
.session-group h2 { color: var(--muted); font-size: 14px; font-weight: 600; margin: 0 0 8px 4px; }
.session-group .card { border-radius: 0; border-width: 0 0 1px; min-height: 80px; padding: 14px 16px; }
.session-group .card:first-of-type { border-radius: 14px 14px 0 0; }
.session-group .card:last-of-type { border-radius: 0 0 14px 14px; border-bottom: 0; }
.session-group .card:only-of-type { border-radius: 14px; }
.session-group .card-name { font-size: 18px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.session-group .card-where { font-size: 13px; margin-top: 4px; }
.session-group .badge { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; padding: 4px 9px; }
.session-group .card.shell { opacity: 1; }
@media (max-width: 350px) { .chat { padding-inline: 16px; } .session-header { padding-inline: 8px; } .composer-options { gap: 2px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
