/* Eagerness on the phone: the Mac app's look (App/Sources/Visuals.swift), sized for a hand. White,
   one bright blue accent, the blue orb, system fonts; a dark version that follows the phone. */

:root {
  --accent: #2178ff;
  --accent-soft: rgba(33, 120, 255, 0.10);
  --accent-line: rgba(33, 120, 255, 0.35);
  --page: #ffffff;
  --sidebar: #f8f9fb;
  --bubble: #f3f4f6;
  --code: #f6f7f9;
  --line: rgba(0, 0, 0, 0.09);
  --ink: #1d1d1f;
  --ink-2: rgba(60, 60, 67, 0.64);
  --ink-3: rgba(60, 60, 67, 0.34);
  --warn: #e8860c;
  --danger: #ff3b30;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #3b8bff;
    --accent-soft: rgba(59, 139, 255, 0.16);
    --accent-line: rgba(59, 139, 255, 0.45);
    --page: #1c1c1c;
    --sidebar: #242424;
    --bubble: #333333;
    --code: #292929;
    --line: rgba(255, 255, 255, 0.10);
    --ink: #f2f2f4;
    --ink-2: rgba(235, 235, 245, 0.62);
    --ink-3: rgba(235, 235, 245, 0.30);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.filled { fill: currentColor; stroke: none; }

/* The app fills the visible part of the screen (the keyboard's top edge, on a phone). */
#app {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  background: var(--page);
  overflow: hidden;
}

/* --- Top bar ------------------------------------------------------------------------------- */

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--top) + 6px) 10px 6px;
  background: var(--page);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  position: relative;
  z-index: 5;
  transition: border-color 0.2s;
}
.top.scrolled { border-bottom-color: var(--line); }
.top .title { flex: 1; min-width: 0; text-align: center; line-height: 1.2; }
.top .name { font-size: 16.5px; font-weight: 650; letter-spacing: -0.01em; }
.top .status { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; color: var(--ink-2);
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .status span { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
#app[data-phase="ready"] .dot { background: #34c759; }
#app[data-phase="busy"] .dot { background: #34c759; }
#app[data-phase="connecting"] .dot, #app[data-phase="loading"] .dot { background: #ff9f0a; animation: pulse 1.2s ease-in-out infinite; }
#app[data-phase="waking"] .dot { background: #ff9f0a; }
@keyframes pulse { 50% { opacity: 0.35; } }

.icon-button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-button:active { background: var(--bubble); }
.icon-button svg.i { width: 22px; height: 22px; }
.icon-button.small { width: 34px; height: 34px; }
.icon-button.small svg.i { width: 19px; height: 19px; }
#app[data-phase="unpaired"] .top .icon-button, #app[data-phase="revoked"] .top .icon-button { visibility: hidden; }

/* --- The scrolling middle ------------------------------------------------------------------ */

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}

.state {
  margin: auto;
  width: 100%;
  max-width: 460px;
  padding: 18px 24px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.state h1 { font-size: 25px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; margin: 2px 0 8px; }
.state .lead { margin: 0 0 18px; color: var(--ink-2); font-size: 15.5px; }
.state .hint { margin: 0; color: var(--ink-2); font-size: 15px; }
.state .fine { margin: 14px 0 0; color: var(--ink-3); font-size: 13px; }

.orb { width: 190px; height: 190px; display: block; }
.orb.no-webgl { border-radius: 50%; transform: scale(0.45);
                background: radial-gradient(circle at 38% 34%, #d9f0ff 0%, #4d9eff 42%, #2a5cf0 75%, rgba(42, 92, 240, 0) 76%); }
#state-offline .orb.no-webgl, #state-revoked .orb.no-webgl { filter: grayscale(1); opacity: 0.7; }

.steps { list-style: none; margin: 4px 0 0; padding: 16px 18px; text-align: left; display: grid; gap: 14px; width: 100%;
         background: var(--sidebar); border: 1px solid var(--line); border-radius: 18px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.steps b { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px;
           display: grid; place-items: center; margin-top: 0; }
.tips { margin: 0 0 22px; padding: 14px 16px 14px 34px; text-align: left; font-size: 14.5px; color: var(--ink-2); width: 100%;
        background: var(--sidebar); border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 8px; }
.tips strong, .steps strong, .state .hint strong { color: var(--ink); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
        background: var(--page); border: 1px solid var(--line); color: var(--ink); }
.chip svg.i { width: 16px; height: 16px; color: var(--accent); }
.chip:active { background: var(--bubble); }

.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 26px;
           border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; }
.primary:active { opacity: 0.82; transform: scale(0.98); }
.primary svg.i { width: 18px; height: 18px; }
.secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 22px; border-radius: 12px;
             background: var(--bubble); color: var(--ink); font-size: 16px; font-weight: 600; }
.secondary:active { opacity: 0.8; }

/* --- Messages ------------------------------------------------------------------------------ */

#messages { width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 22px; }
#messages:empty { display: none; }

.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-left: 44px; }
.user .row { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.user .bubble { background: var(--bubble); border-radius: 20px; padding: 9px 15px; font-size: 16px; line-height: 1.45;
                white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.user .bubble.pending { opacity: 0.6; }
.user .via { color: var(--ink-3); padding-bottom: 10px; }
.user .via svg.i { width: 14px; height: 14px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 5px 10px; border-radius: 9px;
        border: 1px solid var(--line); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file svg.i { width: 14px; height: 14px; color: var(--accent); }

.assistant { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.appear { animation: appear 0.22s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .appear { animation: none; } }

/* The answer's text. */
.md { font-size: 16.5px; line-height: 1.58; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h2, .md h3, .md h4 { line-height: 1.3; letter-spacing: -0.01em; margin: 20px 0 8px; }
.md h2 { font-size: 20px; font-weight: 650; }
.md h3 { font-size: 18px; font-weight: 650; }
.md h4 { font-size: 16.5px; font-weight: 650; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 4px 0; padding-left: 2px; }
.md li.indent-1 { margin-left: 18px; }
.md li.indent-2 { margin-left: 36px; }
.md li.indent-3 { margin-left: 54px; }
.md li::marker { color: var(--ink-2); }
.md a { color: var(--accent); text-decoration: none; }
.md strong { font-weight: 650; }
.md code { font-family: var(--mono); font-size: 0.86em; background: var(--code); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
.md blockquote { margin: 0 0 12px; padding: 2px 0 2px 14px; border-left: 3px solid var(--line); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md .table { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; }
.md table { border-collapse: collapse; font-size: 14.5px; min-width: 100%; }
.md th, .md td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.md th { font-weight: 600; background: var(--sidebar); }
.md tr:last-child td { border-bottom: 0; }

.codeblock { background: var(--code); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0 0 12px; }
.codehead { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px 7px 13px; font-size: 12.5px;
            color: var(--ink-2); border-bottom: 1px solid var(--line); }
.codehead .copy { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); padding: 3px 7px; border-radius: 7px; }
.codehead .copy svg.i { width: 14px; height: 14px; }
.codehead .copy:active { background: var(--bubble); }
.codeblock pre { margin: 0; padding: 12px 13px; overflow-x: auto; font: 13.5px/1.5 var(--mono); }
.md .codeblock code, .step-details .codeblock code { background: none; border: 0; padding: 0; font-size: inherit; }

/* Tool steps: an icon in a soft blue circle, what it did, and what it found when opened. */
.step { display: flex; flex-direction: column; gap: 8px; }
.step-row { display: flex; align-items: center; gap: 9px; text-align: left; min-height: 28px; max-width: 100%; }
.step-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.step-icon svg.i { width: 14px; height: 14px; stroke-width: 2; }
.step.failed .step-icon { color: var(--warn); }
.step-title { font-size: 14.5px; font-weight: 500; color: var(--ink); opacity: 0.82; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-row .chevron { color: var(--ink-3); transition: transform 0.15s; }
.step-row .chevron svg.i { width: 13px; height: 13px; stroke-width: 2.2; }
.step.open .chevron { transform: rotate(90deg); }
.step-details { padding-left: 35px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--ink-2); }
.step-details a { color: var(--accent); text-decoration: none; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.step-details a .site { color: var(--ink-2); font-size: 12.5px; flex: none; }
.step-details a .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.step-details .excerpt { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Thinking, folded into one line. */
.thought-row { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14.5px; font-weight: 500; align-self: flex-start; }
.thought-row svg.i { width: 15px; height: 15px; }
.thought-row .chevron svg.i { width: 12px; height: 12px; stroke-width: 2.2; }
.thought.open .chevron { transform: rotate(90deg); display: inline-block; }
.thought-text { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--line); color: var(--ink-2); font-size: 14.5px; white-space: pre-wrap; }

/* "Sources", each a numbered link. */
.sources { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sources > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.source { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px 4px 5px; border-radius: 999px; background: var(--bubble);
          font-size: 13px; font-weight: 500; color: var(--ink); text-decoration: none; max-width: 210px; }
.source b { width: 17px; height: 17px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10.5px; display: grid; place-items: center; flex: none; }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.writing { display: flex; gap: 5px; height: 22px; align-items: center; }
.writing i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: dots 1.2s ease-in-out infinite; }
.writing i:nth-child(2) { animation-delay: 0.18s; }
.writing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes dots { 0%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.meta { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12.5px; margin-top: -4px; }
.meta button { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); padding: 4px 6px 4px 0; }
.meta button svg.i { width: 16px; height: 16px; }

/* --- The composer ------------------------------------------------------------------------- */

.dock { flex: none; padding: 6px 12px calc(var(--bottom) + 8px); background: var(--page); position: relative; z-index: 4; }
.dock.keyboard { padding-bottom: 8px; }
.to-bottom { position: absolute; left: 50%; top: -46px; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%;
             background: var(--page); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink-2); display: grid; place-items: center; }
.to-bottom svg.i { width: 18px; height: 18px; }
#notice { max-width: 736px; margin: 0 auto 8px; padding: 10px 13px; border-radius: 12px; background: var(--accent-soft);
          font-size: 14px; line-height: 1.4; display: flex; gap: 9px; align-items: flex-start; }
#notice svg.i { width: 17px; height: 17px; color: var(--accent); margin-top: 1px; }
#notice.warn svg.i { color: var(--warn); }

.composer { max-width: 736px; margin: 0 auto; background: var(--page); border: 1px solid var(--line); border-radius: 24px;
            box-shadow: var(--shadow); padding: 11px 10px 8px 14px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; background: none; color: var(--ink);
                     font: 16px/1.4 var(--font); padding: 2px 2px 0; margin: 0; height: 24px; max-height: 168px; min-height: 24px; overflow-y: auto; }
.composer textarea::placeholder { color: var(--ink-3); }
.controls { display: flex; align-items: center; gap: 6px; min-width: 0; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px 0 9px; border-radius: 999px;
        border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; font-weight: 500; white-space: nowrap; flex: none; }
.pill svg.i { width: 16px; height: 16px; }
.pill[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.pill.static { border-color: transparent; padding: 0 6px; }
.send { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.send svg.i { width: 18px; height: 18px; stroke-width: 2.4; }
.send:disabled { background: var(--ink-3); opacity: 0.55; }
.send.stop { background: var(--ink); color: var(--page); }
.send.stop svg.i { width: 12px; height: 12px; }
.fine-print { text-align: center; color: var(--ink-3); font-size: 11.5px; margin-top: 7px; }
.dock.keyboard .fine-print { display: none; }
#app[data-phase="unpaired"] .dock, #app[data-phase="revoked"] .dock, #app[data-phase="offline"] .dock { display: none; }

/* A phone's width: Think harder becomes its bulb, so the call and send buttons always fit. */
@media (max-width: 440px) {
  #think-toggle .label { display: none; }
  #think-toggle { padding: 0 8px; }
}
@media (max-width: 340px) {
  .pill .label { display: none; }
  .pill { padding: 0 8px; }
}

/* --- Recent chats --------------------------------------------------------------------------- */

.drawer { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.28); animation: fade 0.18s ease-out; }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); background: var(--sidebar);
                padding: calc(var(--top) + 8px) 10px calc(var(--bottom) + 10px); display: flex; flex-direction: column; gap: 6px;
                box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12); animation: slide 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 0 8px; font-weight: 650; font-size: 17px; }
.drawer-new { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border-radius: 12px; background: var(--page);
              border: 1px solid var(--line); font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.drawer-new svg.i { width: 18px; height: 18px; }
#chat-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
#chat-list .group { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 14px 10px 4px; }
#chat-list .chat { display: block; width: 100%; text-align: left; padding: 10px 10px; border-radius: 10px; font-size: 15px;
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-list .chat.current { background: var(--accent-soft); }
#chat-list .chat:active { background: var(--bubble); }
#chat-list .empty { padding: 14px 10px; color: var(--ink-3); font-size: 14px; }
.drawer-foot { font-size: 12.5px; color: var(--ink-3); padding: 8px 10px 0; }
.drawer-foot button { display: block; margin-top: 8px; color: var(--ink-2); font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(-100%); } }

/* --- The approval sheet ------------------------------------------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.32); display: flex; align-items: flex-end; animation: fade 0.18s ease-out; }
.sheet-panel { width: 100%; max-width: 560px; margin: 0 auto; background: var(--page); border-radius: 22px 22px 0 0;
               padding: 8px 20px calc(var(--bottom) + 18px); animation: rise 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { display: flex; align-items: center; gap: 9px; font-size: 19px; margin: 0 0 6px; font-weight: 650; }
.sheet h2 svg.i { color: var(--accent); }
.sheet p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.sheet .warning { color: var(--warn); display: flex; gap: 8px; align-items: flex-start; font-size: 14.5px; }
.sheet .warning svg.i { width: 18px; height: 18px; margin-top: 1px; }
.sheet pre { margin: 0 0 16px; max-height: 38vh; overflow: auto; background: var(--code); border: 1px solid var(--line); border-radius: 12px;
             padding: 12px 13px; font: 13.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-buttons .primary.careful { background: var(--warn); }
@keyframes rise { from { transform: translateY(100%); } }

/* --- A voice call ------------------------------------------------------------------------ */

.call { position: fixed; inset: 0; z-index: 25; background: var(--page); display: flex; flex-direction: column; align-items: center;
        padding: calc(var(--top) + 14px) 24px calc(var(--bottom) + 26px); animation: fade 0.2s ease-out; }
.call-top { font-size: 13px; color: var(--ink-2); min-height: 18px; }
.call-orb { width: min(78vw, 330px); height: min(78vw, 330px); margin-top: auto; touch-action: none; -webkit-user-select: none; user-select: none; }
.hold-toggle { margin-top: 10px; height: 30px; padding: 0 12px; font-size: 13px; }
.call.holding .call-orb { transform: scale(1.04); transition: transform 0.12s; }
.call-status { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-top: 6px; }
.call-captions { width: 100%; max-width: 520px; min-height: 140px; margin: 20px 0 auto; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.call-captions .heard { color: var(--ink-2); font-size: 15.5px; }
.call-captions .said { font-size: 21px; line-height: 1.4; }
.call-controls { display: flex; align-items: center; gap: 18px; }
.round { width: 58px; height: 58px; border-radius: 50%; background: var(--bubble); color: var(--ink-2); display: grid; place-items: center; }
.round svg.i { width: 24px; height: 24px; }
.round.on { color: var(--warn); }
.end { display: inline-flex; align-items: center; gap: 8px; height: 58px; padding: 0 30px; border-radius: 999px; background: var(--danger);
       color: #fff; font-size: 17px; font-weight: 600; }
.end svg.i { width: 18px; height: 18px; stroke-width: 2.4; }
