#screen-companion { position: relative; min-height: calc(100dvh - var(--tabbar-h) - var(--safe-b)); padding: calc(16px + var(--safe-t)) 18px calc(var(--tabbar-h) + var(--safe-b) + 84px); overflow: hidden; }
.cp-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 0 18px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.cp-thread::-webkit-scrollbar { width: 5px; }
.cp-thread::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
.cp-empty { max-width: 330px; margin: min(21vh, 148px) auto 0; text-align: center; }
.cp-greeting { margin: 0; color: var(--ink); font: 400 clamp(31px, 9vw, 42px)/1 var(--serif); letter-spacing: -.025em; }
.cp-intro { margin: 15px auto 0; color: var(--muted); font: 14px/1.55 var(--sans); }
.cp-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 25px; }
.cp-chip { min-height: 40px; padding: 8px 13px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font: 13px var(--sans); cursor: pointer; transition: border-color 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease); }
.cp-chip:hover { color: var(--ink); border-color: var(--muted); }
.cp-form { display: flex; align-items: center; gap: 9px; min-height: 54px; padding: 6px 7px 6px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 8px 22px var(--scrim); }
.cp-input { min-width: 0; flex: 1; color: var(--ink); background: transparent; border: 0; outline: 0; font: 16px/1.35 var(--sans); }
.cp-input::placeholder { color: var(--muted); opacity: 1; }
.cp-input:focus-visible { outline: 0; }
.cp-send { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 50%; cursor: pointer; }
.cp-send:disabled { opacity: .45; cursor: wait; }
.cp-send .icon { width: 18px; height: 18px; }
.cp-ref { padding: 0; color: inherit; background: none; border: 0; border-bottom: 1px solid currentColor; font: inherit; cursor: pointer; }
.cp-remembered { display: flex; align-items: center; gap: 10px; width: fit-content; margin: 8px 0 4px; max-width: 88%; padding: 9px 14px 9px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); animation: cp-mem-in .45s var(--ease-out) both; }
.cp-remembered-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; color: var(--saved); background: color-mix(in srgb, var(--saved) 14%, transparent); }
.cp-remembered-icon .icon { width: 14px; height: 14px; }
.cp-remembered strong, .cp-remembered small { display: block; }
.cp-remembered strong { color: var(--ink); font: 600 12px var(--sans); }
.cp-remembered small { margin-top: 1px; color: var(--muted); font: 400 12px/1.4 var(--sans); }
@keyframes cp-mem-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .cp-remembered { animation: none; } }
.cp-notice { max-width: 90%; margin: 14px auto; padding: 13px 15px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--r); text-align: center; font: 13px/1.45 var(--sans); }
.cp-notice p { margin: 0; }
.cp-notice-action { min-height: 36px; margin-top: 10px; padding: 0 13px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: var(--r-sm); font: 600 12px var(--sans); cursor: pointer; }
.cp-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: no-preference) { .cp-empty { animation: cp-rise 360ms var(--ease) both; } @keyframes cp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } } }
@media (min-width: 700px) { #screen-companion { padding-left: 24px; padding-right: 24px; } .cp-empty { margin-top: min(18vh, 150px); } }
/* the light (js/orb.js): small in the header, large on the empty screen */
.cp-stage { display: none; flex: none; width: 150px; height: 150px; margin: -6px auto -14px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 150ms var(--ease-out); }
.cp-stage canvas { display: block; width: 100%; height: 100%; }
.cp-stage:active { transform: scale(.97); }
.cp-chatting .cp-head-buddy { display: block; }   /* chatting: the blob sits small in the header, the messages get the room */
.cp-chatting .cp-thread { mask-image: none; padding-top: 16px; }
.cp-chatting .cp-thread { padding-top: 14px; }   /* no top fade: it blacked out the first lines */
.cp-orb { display: block; width: 220px; height: 220px; margin: -40px auto 4px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 150ms var(--ease-out); }
.cp-orb canvas { display: block; width: 100%; height: 100%; }
.cp-orb:active { transform: scale(.97); }
.cp-orb:focus-visible { outline: 2px solid var(--muted); outline-offset: -30px; }
.cp-empty { margin-top: min(9vh, 70px); }

/* thinking line, like Claude Code: turning star, a shimmering word, seconds + how to stop */
.cp-think { display: flex; align-items: baseline; gap: 8px; min-height: 25px; margin-top: 4px; color: var(--muted); font: 500 14px/1.4 var(--sans); }
.cp-think-glyph { width: 1em; color: var(--ink); text-align: center; }
.cp-think-word { color: transparent; background: linear-gradient(90deg, var(--muted) 35%, var(--ink) 50%, var(--muted) 65%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; animation: cp-shimmer 2.2s linear infinite; }
.cp-think-meta { font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }
@keyframes cp-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.cp-send.is-stop .icon { width: 14px; height: 14px; }
.cp-notice-stopped { border: 0; padding: 4px; font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .cp-think-word { animation: none; color: var(--ink-2); background: none; } }

/* header: history · buddy + name + status · new chat. The main area fills what's left, so nothing squeezes the buddy */
#screen-companion { display: flex; flex-direction: column; height: 100dvh; min-height: 0; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);   /* padding already clears the bar; subtracting it from height too left a big gap */ }
.cp-header { display: grid; grid-template-columns: 88px 1fr 88px; align-items: center; width: min(100%, var(--app-w)); margin: 0 auto; padding: 0 0 10px; border-bottom: 1px solid var(--line); flex: none; }
.cp-hist, .cp-new { width: 44px; height: 44px; color: var(--ink); }
.cp-hist .icon, .cp-new .icon, .cp-pray .icon { width: 22px; height: 22px; }
.cp-title { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.cp-title { padding: 4px 10px; color: inherit; background: none; border: 0; border-radius: 14px; cursor: pointer; transition: background-color 150ms ease, transform 150ms var(--ease-out); }
.cp-title:active { transform: scale(.96); background: var(--surface-2); }
.cp-name .icon { display: inline-block; width: 13px; height: 13px; vertical-align: -1px; margin-left: 2px; color: var(--muted); }
.cp-title .cp-name { display: block; white-space: nowrap; margin: 0; color: var(--ink); font: 600 16px/1.15 var(--sans); letter-spacing: -.01em; text-align: center; }
.cp-status { margin: 1px 0 0; color: var(--muted); font: 12px/1.2 var(--sans); text-align: center; }
.cp-head-buddy { display: none; width: 46px; height: 46px; margin: -8px -2px -8px -12px; }
.cp-main { flex: 1; min-height: 0; display: flex; flex-direction: column; width: min(100%, var(--app-w)); margin: 0 auto; }
.cp-stage, .cp-orb { flex-shrink: 0; }
/* short screens: the buddy moves into the header while chatting, and the empty-screen one shrinks */
@media (max-height: 760px) {
  .cp-orb { width: 160px; height: 160px; margin: -24px auto 0; }
  .cp-empty { margin-top: 2vh; }
}
@media (max-height: 600px) { .cp-orb { width: 120px; height: 120px; } .cp-greeting { margin-top: 0; } }
/* conversations sheet */
.cp-hist-memory { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; margin-bottom: 8px; padding: 10px 12px; color: var(--ink); background: var(--surface-2); border: 0; border-radius: var(--r); text-align: left; cursor: pointer; }
.cp-hist-memory > .icon { width: 20px; height: 20px; flex: none; } .cp-hist-memory > .icon:last-child { width: 16px; color: var(--muted); }
.cp-hist-memory span, .cp-hist-open { display: grid; gap: 3px; flex: 1; min-width: 0; }
.cp-hist-memory strong, .cp-hist-open strong { font: 500 14px/1.3 var(--sans); }
.cp-hist-memory small, .cp-hist-open small { color: var(--muted); font: 12px/1.3 var(--sans); }
.cp-hist-row { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.cp-hist-open { padding: 12px 4px; color: var(--ink); background: none; border: 0; text-align: left; cursor: pointer; }
.cp-hist-open strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cp-hist-row.is-current .cp-hist-open small::after { content: ' · open now'; }
.cp-hist-del { flex: none; color: var(--muted); }
.cp-hist-empty { margin: 18px 0 6px; color: var(--muted); font: 13px var(--sans); text-align: center; }
@media (hover: hover) and (pointer: fine) { .cp-hist-row:hover, .cp-hist-memory:hover { background: var(--surface-2); } .cp-hist-del:hover { color: var(--danger); } }
#screen-companion[hidden] { display: none; }

/* round 8: first-meeting chips, companion settings sheet */
.cp-set-hero { display: flex; flex-direction: column; align-items: center; margin: -6px 0 6px; }
.cp-set-hero canvas { width: 96px; height: 96px; }
.cp-set-hero p, .cp-set-h { margin: 0; color: var(--muted); font: 600 12px var(--sans); letter-spacing: .04em; text-transform: uppercase; }
.cp-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 22px; }
.cp-mode { display: grid; gap: 4px; align-content: start; min-height: 84px; padding: 12px 10px; text-align: left; color: var(--ink-2); background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r); font: 12px/1.3 var(--sans); cursor: pointer; transition: border-color 150ms ease, transform 150ms var(--ease-out); }
.cp-mode strong { color: var(--ink); font-size: 14px; }
.cp-mode small { color: var(--muted); font-size: 12px; }
.cp-mode.is-on { border-color: var(--ink); }
.cp-mode:active, .cp-set-link:active { transform: scale(.96); }
.cp-set-h { margin-bottom: 8px; }
.cp-set-card { background: var(--surface-2); border-radius: var(--r); padding: 4px 14px; margin-bottom: 10px; }
.cp-set-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font: 14px var(--sans); color: var(--muted); }
.cp-set-row strong { color: var(--ink); font-weight: 500; text-align: right; }
.cp-set-row:has(.cp-set-input) { align-items: center; padding: 4px 0; cursor: text; }
.cp-set-input { flex: 1; min-width: 0; min-height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: 500 14px var(--sans); text-align: right; }
.cp-set-input:hover { border-color: var(--line); }
.cp-set-input:focus { outline: none; border-color: var(--ink); background: var(--bg); text-align: left; }
.cp-set-link { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0; color: var(--ink); background: none; border: 0; font: 500 14px var(--sans); cursor: pointer; transition: transform 150ms var(--ease-out); }
.cp-set-link .icon { width: 16px; height: 16px; margin-left: auto; color: var(--muted); }
.cp-set-link small { color: var(--muted); font-size: 13px; }
.cp-set-mem { padding: 0 14px; background: var(--surface-2); border-radius: var(--r); }
.wk .cp-chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Wake-up: first meeting, full screen, can't be skipped */
.wk { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 20px calc(24px + var(--safe-b, 0px)); overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 93%, transparent); backdrop-filter: blur(10px); animation: wk-in 500ms var(--ease) both; }
.wk-leaving { opacity: 0; transition: opacity 420ms var(--ease); }
.wk-orb { width: 260px; height: 260px; flex: none; transition: transform 750ms cubic-bezier(.16,1,.3,1), width 700ms var(--ease), height 700ms var(--ease); }
.wk-orb canvas { display: block; width: 100%; height: 100%; }
.wk-waking canvas { animation: wk-wobble 1.3s var(--ease) both; }
.wk-orb.wk-small { width: 150px; height: 150px; }
.wk-form { display: grid; gap: 16px; width: min(100%, 400px); animation: wk-up 380ms var(--ease) both; }
.wk-sub { margin: -6px 0 0; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.45; }
.wk-dots { display: flex; justify-content: center; gap: 6px; }
.wk-dots span { width: 28px; height: 4px; border-radius: 4px; background: var(--line); transition: background-color 300ms var(--ease); }
.wk-dots span.on { background: var(--ink); }
.wk-q { margin: 0; text-align: center; font: 500 25px/1.2 var(--serif); color: var(--ink); text-wrap: balance; animation: wk-up 380ms var(--ease) both; }
.wk-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.wk-input { min-height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 16px var(--sans); text-align: center; transition: border-color 160ms var(--ease); }
.wk-input:focus { outline: none; border-color: var(--ink-2); }
.wk-nav { display: flex; justify-content: space-between; align-items: center; }
.wk-back { min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--muted); font: 500 14px var(--sans); cursor: pointer; }
.wk-back:hover { color: var(--ink); }
.wk-next { min-width: 120px; }
.wk-next:disabled { opacity: .4; cursor: default; }
@keyframes wk-in { from { opacity: 0; } }
@keyframes wk-up { from { opacity: 0; transform: translateY(8px); } }
@keyframes wk-wobble { 0% { transform: none; } 15% { transform: scale(1.08, .9) rotate(-6deg); } 30% { transform: scale(.94, 1.08) rotate(5deg); } 45% { transform: scale(1.05, .95) rotate(-3deg); } 60% { transform: translateY(-14px) scale(.97, 1.04); } 80% { transform: scale(1.02, .98); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .wk, .wk-form, .wk-q, .wk-waking canvas { animation: none; } .wk-orb { transition: none; } }
