/* ── Ask Plinth (web/chat.js, web/chat-ui.js) ─────────────────
   The face bubble at the bottom right, the window it opens (or the column docked beside the page), and
   Plinth's face (web/plinth-face.js). Colours are styles.css's tokens, so the theme switch moves it too. */

/* The face */
.pf { display: block; flex: none; border-radius: 50%; overflow: hidden; background: var(--surface-2); color: var(--text); }
.pf svg { display: block; width: 100%; height: 100%; }
.pf-line { fill: none; stroke: currentColor; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.pf-cheek { fill: #E3A08C; opacity: .6; }
.pf-swirl { fill: none; stroke: #fff; stroke-width: 50; stroke-dasharray: 100 120; animation: pf-swirl 2.4s infinite both; }
@keyframes pf-swirl { 0% { stroke-dashoffset: 101; animation-timing-function: cubic-bezier(.65,0,.35,1); } 42% { stroke-dashoffset: 0; animation-timing-function: linear; }
  56% { stroke-dashoffset: 0; animation-timing-function: cubic-bezier(.65,0,.35,1); } 94%, 100% { stroke-dashoffset: -101; } }
.pf-body { animation: pf-bob 4s ease-in-out infinite; }
@keyframes pf-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.pf-happy .pf-body { animation: pf-hop 1.1s cubic-bezier(.3,0,.3,1) infinite; }
@keyframes pf-hop { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(-22px); } 60% { transform: translateY(0); } }
.pf-tilt { transform-box: fill-box; transform-origin: 50% 50%; transition: transform .3s; }
.pf-confused .pf-tilt { transform: rotate(-5deg); }
.pf-look { transition: transform .3s; }
.pf-thinking .pf-look { transform: translate(-6px, -10px); }
.pf-blink { transform-box: fill-box; transform-origin: 50% 50%; animation: pf-blink 4.6s infinite; }
@keyframes pf-blink { 0%, 91%, 97%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }
.pf-eye-r { transform-box: fill-box; transform-origin: 50% 50%; transition: transform .3s; }
.pf-confused .pf-eye-r { transform: scaleY(.5); }
.pf-talk { transform-box: fill-box; transform-origin: 50% 50%; animation: pf-talk .34s ease-in-out infinite alternate; }
@keyframes pf-talk { from { transform: scaleY(.35); } to { transform: scaleY(1); } }

/* The ways in: the bubble (floating), the note beside it, and the top bar's button (docked) */
#ck-bubble { position: fixed; right: 24px; bottom: 24px; z-index: 61; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text); cursor: pointer;
  box-shadow: 0 0 0 1px var(--border-strong), 0 10px 28px rgba(31,27,23,.2); transition: transform .15s, background-color .2s; }
[data-mode="dark"] #ck-bubble { box-shadow: 0 0 0 1px var(--border-strong), 0 10px 28px rgba(0,0,0,.5); }
#ck-bubble:hover { transform: translateY(-2px); }
#ck-bubble:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#ck-bubble[hidden], #ck-peek[hidden], #ck-panel[hidden], .ck-launch[hidden] { display: none; }
#ck-bubble .pf { background: transparent; }
#ck-bubble.open { background: var(--text); color: var(--bg); }
.ck-dot { position: absolute; top: 1px; right: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2.5px var(--bg); }
#ck-peek { position: fixed; right: 92px; bottom: 30px; z-index: 61; max-width: 270px; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 14px 14px 4px 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  font: 13px/1.4 var(--sans); text-align: left; cursor: pointer; animation: ck-rise .3s cubic-bezier(.2,.8,.2,1) both; }
#ck-peek b { font-weight: 600; }
#ck-peek span { color: var(--text-2); }
#ck-peek:hover { border-color: var(--accent); }
.ck-launch { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 4px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: 500 13px/1 var(--sans); cursor: pointer; }
.ck-launch:hover { background: var(--surface-2); }
.ck-launch[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ck-launch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ck-fw { position: relative; width: 28px; height: 28px; flex: none; }
.ck-kbd { padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 5px; font: 400 10.5px/1.4 var(--mono); color: var(--text-3); }

/* The window: floating above the page, or docked as a column beside it */
#ck-panel { display: flex; flex-direction: column; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: var(--fs-body); line-height: 1.5;
  -webkit-font-smoothing: antialiased; flex: 0 0 400px; width: 400px; box-sizing: border-box; position: sticky; top: 53px; height: calc(100vh - 53px);
  border-left: 1px solid var(--border); z-index: 20; }
#ck-panel.ck-float { position: fixed; top: auto; right: 24px; bottom: 96px; height: min(680px, calc(100vh - 150px)); z-index: 60;
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 24px 64px rgba(31,27,23,.18), 0 2px 8px rgba(31,27,23,.08);
  transform-origin: 100% 100%; animation: ck-pop .22s cubic-bezier(.2,.8,.2,1) both; }
[data-mode="dark"] #ck-panel.ck-float { box-shadow: 0 24px 64px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04); }
@keyframes ck-pop { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ck-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#ck-panel * { box-sizing: border-box; }
#ck-panel button, #ck-panel input { font: inherit; color: inherit; }
#ck-panel :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#ck-panel p, #ck-panel h2, #ck-panel ul, #ck-panel ol, #ck-panel dl { margin: 0; }

.ck-head { display: flex; align-items: center; gap: 10px; min-height: 57px; padding: 8px 10px 8px 16px; flex: none; border-bottom: 1px solid var(--border); background: var(--surface); }
.ck-title { flex: 1; font-size: var(--fs-body); font-weight: 600; }
.ck-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ck-who b { font-size: var(--fs-body); font-weight: 600; }
.ck-who span { font-size: var(--fs-meta); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-ib { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; }
.ck-ib:hover { background: var(--surface-2); color: var(--text); }

.ck-thread { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; }
.ck-thread > :first-child { margin-top: auto; }
.ck-thread.hero { gap: 22px; padding: 24px 22px; }
.ck-thread.hero > :last-child { margin-bottom: auto; }
.ck-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.ck-hero h2 { font-size: var(--fs-title); font-weight: 600; letter-spacing: -.02em; }
.ck-hero p { font-size: var(--fs-body); line-height: 1.55; color: var(--text-2); }
.ck-hero p.ck-fresh { font-size: var(--fs-meta); color: var(--text-3); }
.ck-try { display: flex; flex-direction: column; gap: 8px; }
.ck-sugg { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); text-align: left; cursor: pointer; }
.ck-sugg:hover { border-color: var(--accent); }
.ck-sugg svg { color: var(--text-3); flex: none; }

.ck-user { align-self: flex-end; max-width: 85%; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: var(--text); color: var(--bg);
  font-size: var(--fs-body); line-height: 1.45; overflow-wrap: anywhere; }
.ck-new { animation: ck-rise .28s cubic-bezier(.2,.8,.2,1) both; }
.ck-reply { display: flex; flex-direction: column; gap: 12px; }
.ck-say { font-size: var(--fs-body); line-height: 1.55; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ck-say * { min-width: 0; overflow-wrap: anywhere; }
.ck-say ul, .ck-say ol { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.ck-say code { font-family: var(--mono); font-size: var(--fs-meta); padding: 1px 4px; border-radius: 4px; background: var(--surface-2); }
.ck-caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: ck-caret 1s steps(1) infinite; }
@keyframes ck-caret { 50% { opacity: 0; } }
.ck-steps { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ck-steps li { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--text-2); }
.ck-steps li svg { color: var(--ok); flex: none; }
.ck-steps li.now { color: var(--text); }
.ck-steps li.now svg { color: var(--accent); }
.ck-spin g { transform-box: fill-box; transform-origin: 50% 50%; animation: ck-spin .9s linear infinite; }
@keyframes ck-spin { to { transform: rotate(360deg); } }
.ck-src summary { cursor: pointer; font-size: var(--fs-meta); color: var(--text-3); width: fit-content; }
.ck-src p { margin-top: 4px; font-size: var(--fs-meta); color: var(--text-3); }
.ck-err { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: var(--fs-meta); color: var(--danger); }
.ck-link { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; }
.ck-quiet { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--text-3); }
.ck-warn { font-size: var(--fs-meta); font-weight: 500; color: var(--danger); }
/* Names and values from people's data can be one long word: they wrap rather than run off the card. */
.ck-card-summary, .ck-notice, .ck-typed-label, .ck-meta, .ck-card-title { overflow-wrap: anywhere; min-width: 0; }
.ck-notice { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: var(--radius); font-size: var(--fs-meta); line-height: 1.45;
  background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--text); }
.ck-notice svg { color: var(--warn); flex: none; margin-top: 2px; }
.ck-typed-label { font-size: var(--fs-meta); color: var(--text-2); }
.ck-typed { height: 38px; font-size: var(--fs-body); }
.ck-nav { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--text-2); }
.ck-nav svg { color: var(--text-3); flex: none; }
.ck-nav .ck-btn { margin-left: auto; }

.ck-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.ck-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 0; }
.ck-card-pad { display: flex; flex-direction: column; gap: 8px; padding: 8px 14px 12px; }
.ck-done .ck-card-pad { padding-top: 12px; gap: 4px; }
.ck-card-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.ck-done .ck-card-title { font-size: var(--fs-body); font-weight: 500; }
.ck-card-summary { font-size: var(--fs-body); line-height: 1.5; }
.ck-card dl { display: grid; grid-template-columns: 64px 1fr; gap: 6px 10px; font-size: var(--fs-meta); }
.ck-card dt { color: var(--text-3); }
/* Everything an action's tap sends: a long value scrolls in its own box rather than stretching the card. */
.ck-card dl.ck-details { grid-template-columns: minmax(64px, max-content) minmax(0, 1fr); }
.ck-detail { display: block; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow-y: auto; }
.ck-card dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ck-card .muted { color: var(--text-3); }
.ck-card .ck-err { padding: 0 14px 10px; }
.ck-label { font-size: var(--fs-meta); font-weight: 600; color: var(--text-2); }
.ck-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-meta); font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.ck-pd { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ck-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.ck-ok { display: flex; align-items: center; gap: 6px; font-size: var(--fs-meta); font-weight: 600; color: var(--ok); }
.ck-meta { font-size: var(--fs-meta); color: var(--text-3); }
.ck-row { display: flex; gap: 6px; margin-top: 6px; }
.ck-choices { display: flex; flex-direction: column; gap: 6px; padding: 0 14px 12px; }
.ck-choice { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-weight: 500; text-align: left; cursor: pointer; }
.ck-choice:hover { border-color: var(--accent); }
.ck-choice .ck-pd { width: 8px; height: 8px; }

.ck-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-body); font-weight: 500; cursor: pointer; white-space: nowrap; }
.ck-btn:hover { background: var(--surface-2); }
.ck-btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.ck-btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.ck-btn.primary.danger, .ck-btn.primary.danger:hover { background: var(--danger); color: #fff; }
.ck-btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.ck-btn.ghost:hover { background: var(--surface-2); }
.ck-btn.push { margin-left: auto; }
.ck-btn.sm { min-height: 28px; padding: 0 10px; font-size: var(--fs-meta); border-radius: 7px; }
.ck-btn[disabled], .ck-choice[disabled] { opacity: .45; cursor: wait; }

.ck-comp { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.ck-ctx { align-self: flex-start; max-width: 100%; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 2px 0 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-meta); font-weight: 500; }
.ck-ctx > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-ctx button { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; }
.ck-inrow { display: flex; align-items: center; gap: 8px; }
.ck-in { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-body); }
.ck-in::placeholder { color: var(--text-3); }
.ck-in:focus { outline: none; border-color: var(--accent); }
.ck-send { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.ck-send.stop { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.ck-fine { display: flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--text-3); }

/* Dictation (web/chat-voice.js): the mic beside Send, and the line over the box while it listens or writes it down */
.ck-mic { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); cursor: pointer; }
.ck-mic:hover { background: var(--surface-2); color: var(--text); }
/* Pressed: outlined in the accent, so it isn't mistaken for Send beside it; it pulses only while it listens. */
.ck-mic.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); }
.ck-mic.on:not([disabled]) { animation: ck-micpulse 1.4s ease-out infinite; }
.ck-mic[disabled] { opacity: .55; cursor: wait; }
@keyframes ck-micpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.ck-voice { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 6px 6px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
  color: var(--text-2); font-size: var(--fs-body); animation: ck-rise .2s ease both; }
.ck-voice-t { flex: 1; min-width: 0; }
/* The wave follows the mic (--mic-level, set by web/voice.js as it listens): a silent mic shows as still bars. */
.ck-wave { display: flex; align-items: center; gap: 3px; height: 20px; flex: none; }
.ck-wave span { width: 3px; border-radius: 2px; background: var(--accent); height: calc(4px + var(--mic-level, 0) * 16px * var(--k, 1)); transition: height .08s linear; }
.ck-wave span:nth-child(1), .ck-wave span:nth-child(5) { --k: .55; }
.ck-wave span:nth-child(2), .ck-wave span:nth-child(4) { --k: .85; }
.ck-voice-note { display: flex; align-items: flex-start; gap: 6px; color: var(--danger); font-size: var(--fs-meta); }
.ck-voice-note svg { flex: none; margin-top: 1px; }
.ck-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A phone: the window is the whole screen */
@media (max-width: 560px) {
  #ck-panel.ck-float { right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
  #ck-panel:not(.ck-float) { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; }
  #ck-bubble.open { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #ck-panel *, #ck-bubble *, .ck-launch *, #ck-panel, #ck-peek { animation: none !important; transition: none !important; }
}
