Files
chatkit/styles.css
T
CatoandClaude Opus 5.5 ed759a8516 feat: chatkit v0.1 — one chat for every product (#1)
* feat: chatkit v0.1 — one chat for every product

The fleet had 13 chats in 10 repos, each written fresh, each missing what
another had fixed. This extracts loki /loki (composer, thread, messages,
markdown, attachments) and adds heidi's microphone and orangecat's keyboard fix:

- Composer: auto-growing 16px textarea, Enter/Shift+Enter/IME, Send and Stop
  in one slot, attachments with paste, mic always present, every label
  translatable, app-specific controls in slots.
- useDictation: browser recogniser first; missing or SILENT (4 s watchdog,
  bounded permission wait) -> record and transcribe on the server; a dead
  recogniser remembered 30 days; every failure shown in words.
- ChatThread/ChatMessage: stick-to-bottom + jump button, speaker names once two
  agents speak, Copy on answers, Retry on the last one, failed turns visible.
- Markdown with no HTML path; javascript: links stay text.
- styles.css: --ck-* variables defaulting to @bitbaum/design-tokens.
- verify = format, lint, types, build, 18 unit/render tests and 21 browser
  checks (390px + desktop, light + dark, a sentence through a fake mic past a
  silent recogniser). Browser checks mutation-tested (14px input, 60 s
  watchdog) — both fail as they should.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(styles): --ck-* defaults at zero specificity on :root, so an app's own values win

Declared on the chat's elements they overrode any app setting --ck-* at the
root — the opposite of what the README promised. Found preparing loki, whose
colour variables are full OKLCH colours under the design-token names and so
must map them. New browser check: a :root --ck-accent reaches the chat.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 23:14:53 -07:00

690 lines
15 KiB
CSS

/*
* @bitbaum/chatkit — the look of the one chat.
*
* Every colour, radius and face is a --ck-* variable. By default they read
* @bitbaum/design-tokens' HSL-triplet variables, so apps on those tokens match
* without doing anything. An app whose variables are full colours (loki's are
* OKLCH under the same names) maps them once — `:root { --ck-bg:
* var(--surface-base); … }` — and any other app sets --ck-* to keep its own
* look. The BEHAVIOUR is what is shared, and it is not configurable.
*
* Non-negotiable, and why:
* - 16px text in the input and the messages: under 16px iOS zooms the whole
* page when the input is focused (loki globals.css).
* - 44px touch targets on every control (WCAG 2.5.8, loki's audit).
* - Nothing wider than its container at 320px (min-width: 0 on flex rows —
* heidi composer.tsx).
*/
:where(:root) {
/* Defaults at ZERO specificity on the root: an app's own :root (or any
container) rule setting a --ck-* variable always wins. Declaring these on
the chat's elements instead would silently override the app. */
--ck-bg: hsl(var(--surface-base, 0 0% 100%));
--ck-raised: hsl(var(--surface-raised, 0 0% 96%));
--ck-overlay: hsl(var(--surface-overlay, 0 0% 98%));
--ck-fg: hsl(var(--text-primary, 0 0% 10%));
--ck-fg-2: hsl(var(--text-secondary, 0 0% 30%));
--ck-fg-3: hsl(var(--text-tertiary, 0 0% 42%));
--ck-muted: hsl(var(--text-muted, 0 0% 50%));
--ck-line: hsl(var(--border-subtle, 0 0% 90%));
--ck-line-2: hsl(var(--border-default, 0 0% 82%));
--ck-accent: var(--accent-primary, #ff5c00);
--ck-on-accent: hsl(var(--on-accent, 0 0% 8%));
--ck-accent-soft: color-mix(in srgb, var(--ck-accent) 14%, transparent);
--ck-danger: hsl(var(--status-negative, 0 65% 50%));
--ck-danger-soft: color-mix(in srgb, var(--ck-danger) 12%, transparent);
--ck-on-danger: #fff;
--ck-warning: hsl(var(--status-warning, 38 92% 45%));
--ck-radius: 1rem;
--ck-radius-sm: var(--radius-control, 0.5rem);
--ck-font: var(--font-sans, system-ui, -apple-system, "Segoe UI", sans-serif);
--ck-mono: var(--font-mono, ui-monospace, "SF Mono", Menlo, monospace);
--ck-text: 1rem;
--ck-leading: 1.6;
--ck-target: 2.75rem;
}
.ck-composer-wrap,
.ck-thread-wrap,
.ck-starters {
font-family: var(--ck-font);
color: var(--ck-fg);
}
.ck-composer-wrap *,
.ck-thread-wrap *,
.ck-starters * {
box-sizing: border-box;
}
/* ── composer ───────────────────────────────────────────────────────────── */
.ck-composer-wrap {
display: flex;
flex-direction: column;
gap: 0.5rem;
min-width: 0;
}
.ck-composer-frame {
position: relative;
min-width: 0;
}
.ck-composer {
display: flex;
flex-direction: column;
gap: 0.5rem;
min-width: 0;
padding: 0.75rem 0.75rem 0.625rem;
border: 1px solid var(--ck-line);
border-radius: var(--ck-radius);
background: var(--ck-bg);
transition: border-color 0.15s ease;
}
.ck-composer:focus-within {
border-color: var(--ck-line-2);
}
.ck-composer-compact {
gap: 0.375rem;
padding: 0.5rem;
border-radius: calc(var(--ck-radius) * 0.75);
}
.ck-input {
display: block;
width: 100%;
min-height: 2.5rem;
max-height: 15rem;
resize: none;
overflow-y: auto;
padding: 0.375rem 0.25rem;
border: 0;
outline: none;
background: transparent;
color: var(--ck-fg);
font: inherit;
font-size: max(16px, var(--ck-text));
line-height: var(--ck-leading);
}
.ck-input::placeholder {
color: var(--ck-muted);
}
.ck-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
min-width: 0;
}
.ck-tools {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.375rem;
min-width: 0;
}
.ck-submit {
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
.ck-hint {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--ck-muted);
font-size: 0.8125rem;
}
@media (max-width: 480px) {
.ck-hint {
display: none;
}
}
.ck-icon-btn,
.ck-send {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
min-width: var(--ck-target);
min-height: var(--ck-target);
padding: 0;
border-radius: 999px;
font-size: 1.125rem;
cursor: pointer;
transition:
background 0.15s ease,
color 0.15s ease,
border-color 0.15s ease,
opacity 0.15s ease;
}
.ck-icon-btn {
border: 1px solid var(--ck-line);
background: var(--ck-raised);
color: var(--ck-fg-2);
}
.ck-icon-btn:hover:not(:disabled) {
border-color: var(--ck-line-2);
color: var(--ck-fg);
}
.ck-mic-on {
border-color: var(--ck-danger);
background: var(--ck-danger-soft);
color: var(--ck-danger);
}
.ck-send {
border: 0;
background: var(--ck-accent);
color: var(--ck-on-accent);
}
.ck-send:hover:not(:disabled) {
opacity: 0.9;
}
.ck-send:disabled,
.ck-icon-btn:disabled {
cursor: not-allowed;
opacity: 0.45;
}
.ck-send:disabled {
background: var(--ck-raised);
color: var(--ck-muted);
opacity: 1;
}
.ck-send-stop {
background: var(--ck-raised);
color: var(--ck-fg);
border: 1px solid var(--ck-line-2);
}
:where(.ck-composer-wrap, .ck-thread-wrap, .ck-starters) button:focus-visible,
.ck-input:focus-visible {
outline: 2px solid var(--ck-accent);
outline-offset: 2px;
}
.ck-input:focus-visible {
outline: none;
}
.ck-modes {
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
}
.ck-mode {
min-height: 2rem;
padding: 0 0.75rem;
border: 1px solid var(--ck-line);
border-radius: 999px;
background: transparent;
color: var(--ck-fg-2);
font: inherit;
font-size: 0.875rem;
cursor: pointer;
}
.ck-mode[aria-pressed="true"] {
border-color: var(--ck-accent);
background: var(--ck-accent-soft);
color: var(--ck-fg);
}
/* voice: the bar covers the box while a take is live, so what is happening —
and how to keep or throw it away — is unmissable */
.ck-voice-bar {
position: absolute;
inset: 0;
z-index: 2;
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0 0.75rem;
border: 1px solid var(--ck-line-2);
border-radius: var(--ck-radius);
background: var(--ck-bg);
color: var(--ck-fg-2);
}
.ck-voice-dot {
width: 0.625rem;
height: 0.625rem;
flex-shrink: 0;
border-radius: 999px;
background: var(--ck-danger);
animation: ck-pulse 1.2s ease-in-out infinite;
}
.ck-voice-wave {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
gap: 0.25rem;
height: 1.75rem;
min-width: 0;
overflow: hidden;
}
.ck-voice-wave > span {
width: 0.25rem;
height: 100%;
border-radius: 999px;
background: var(--ck-accent);
transform: scaleY(0.3);
animation: ck-wave 1s ease-in-out infinite;
}
.ck-voice-wave > span:nth-child(2n) {
animation-delay: -0.3s;
}
.ck-voice-wave > span:nth-child(3n) {
animation-delay: -0.6s;
}
.ck-voice-wave > span:nth-child(5n) {
animation-delay: -0.8s;
}
.ck-voice-timer {
flex-shrink: 0;
font-size: 0.9375rem;
font-variant-numeric: tabular-nums;
}
.ck-voice-confirm {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: var(--ck-target);
min-height: var(--ck-target);
border: 0;
border-radius: 999px;
background: var(--ck-danger);
color: var(--ck-on-danger);
font-size: 1.125rem;
cursor: pointer;
}
.ck-problem {
display: flex;
align-items: flex-start;
gap: 0.5rem;
margin: 0;
padding: 0.5rem 0.625rem;
border: 1px solid color-mix(in srgb, var(--ck-warning) 40%, transparent);
border-radius: var(--ck-radius-sm);
color: var(--ck-fg-2);
font-size: 0.9375rem;
line-height: 1.45;
}
.ck-problem > span {
flex: 1;
min-width: 0;
}
.ck-problem-x {
display: inline-flex;
flex-shrink: 0;
padding: 0.125rem;
border: 0;
background: transparent;
color: var(--ck-muted);
cursor: pointer;
}
/* attachments */
.ck-attach-strip {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
}
.ck-attach-item {
position: relative;
}
.ck-attach-thumb {
display: block;
width: 3.5rem;
height: 3.5rem;
object-fit: cover;
border: 1px solid var(--ck-line);
border-radius: var(--ck-radius-sm);
}
.ck-attach-file {
display: flex;
align-items: center;
gap: 0.375rem;
max-width: 11rem;
height: 3.5rem;
padding: 0 0.5rem;
border: 1px solid var(--ck-line);
border-radius: var(--ck-radius-sm);
background: var(--ck-raised);
color: var(--ck-fg-2);
font-size: 0.8125rem;
}
.ck-attach-remove {
position: absolute;
top: -0.5rem;
right: -0.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: 1.5rem;
height: 1.5rem;
border: 1px solid var(--ck-line-2);
border-radius: 999px;
background: var(--ck-overlay);
color: var(--ck-fg-2);
font-size: 0.75rem;
cursor: pointer;
}
.ck-attach-remove::after {
content: "";
position: absolute;
inset: -0.625rem;
}
.ck-note {
border: 0;
background: transparent;
color: var(--ck-warning);
font: inherit;
font-size: 0.8125rem;
text-align: left;
cursor: pointer;
}
.ck-truncate {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ── thread ─────────────────────────────────────────────────────────────── */
.ck-thread-wrap {
position: relative;
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
min-width: 0;
}
.ck-thread {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
overflow-y: auto;
overscroll-behavior: contain;
padding: 0.5rem 0;
}
.ck-thread-inner {
display: flex;
flex-direction: column;
gap: 1.25rem;
margin-top: auto;
min-width: 0;
}
.ck-thread-loading {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
color: var(--ck-muted);
}
.ck-turn {
display: flex;
flex-direction: column;
min-width: 0;
}
.ck-turn-user {
align-items: flex-end;
}
.ck-bubble {
max-width: min(85%, 42rem);
padding: 0.625rem 1rem;
border-radius: calc(var(--ck-radius) * 1.25);
background: var(--ck-accent-soft);
color: var(--ck-fg);
font-size: var(--ck-text);
line-height: var(--ck-leading);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.ck-speaker {
margin-bottom: 0.25rem;
color: var(--ck-fg-3);
font-family: var(--ck-mono);
font-size: 0.75rem;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.ck-turn-actions {
display: flex;
gap: 0.25rem;
margin-top: 0.25rem;
}
.ck-action {
display: inline-flex;
align-items: center;
gap: 0.375rem;
min-height: 2.25rem;
padding: 0 0.5rem;
border: 0;
border-radius: var(--ck-radius-sm);
background: transparent;
color: var(--ck-muted);
font: inherit;
font-size: 0.875rem;
cursor: pointer;
}
.ck-action:hover {
background: var(--ck-raised);
color: var(--ck-fg-2);
}
@media (hover: hover) {
.ck-turn-answer .ck-turn-actions {
opacity: 0;
transition: opacity 0.15s ease;
}
.ck-turn-answer:hover .ck-turn-actions,
.ck-turn-answer:focus-within .ck-turn-actions,
.ck-turn-pinned .ck-turn-actions {
opacity: 1;
}
}
.ck-failed {
margin: 0;
padding: 0.625rem 0.875rem;
border: 1px solid color-mix(in srgb, var(--ck-danger) 35%, transparent);
border-radius: var(--ck-radius-sm);
background: var(--ck-danger-soft);
color: var(--ck-fg);
font-size: var(--ck-text);
}
.ck-live {
display: flex;
align-items: center;
gap: 0.5rem;
margin: 0;
color: var(--ck-fg-3);
font-size: var(--ck-text);
}
.ck-dots {
display: inline-flex;
gap: 0.25rem;
}
.ck-dots > span {
width: 0.375rem;
height: 0.375rem;
border-radius: 999px;
background: var(--ck-muted);
animation: ck-dot 1.2s ease-in-out infinite;
}
.ck-dots > span:nth-child(2) {
animation-delay: 0.15s;
}
.ck-dots > span:nth-child(3) {
animation-delay: 0.3s;
}
.ck-stop {
display: inline-flex;
align-items: center;
gap: 0.375rem;
align-self: flex-start;
min-height: 2.25rem;
margin-top: 0.5rem;
padding: 0 0.875rem;
border: 1px solid var(--ck-line);
border-radius: 999px;
background: transparent;
color: var(--ck-fg-3);
font: inherit;
font-size: 0.875rem;
cursor: pointer;
}
.ck-stopped {
margin: 0;
color: var(--ck-muted);
}
.ck-jump {
position: absolute;
bottom: 0.75rem;
left: 50%;
transform: translateX(-50%);
display: inline-flex;
align-items: center;
justify-content: center;
width: var(--ck-target);
height: var(--ck-target);
border: 1px solid var(--ck-line-2);
border-radius: 999px;
background: var(--ck-overlay);
color: var(--ck-fg-2);
font-size: 1.125rem;
cursor: pointer;
box-shadow: 0 6px 20px -8px rgb(0 0 0 / 0.35);
}
/* markdown: 16px, readable measure, no leaked ** or > */
.ck-md {
min-width: 0;
color: var(--ck-fg);
font-size: var(--ck-text);
line-height: var(--ck-leading);
overflow-wrap: anywhere;
}
.ck-md > * {
margin: 0;
}
.ck-md > * + * {
margin-top: 0.75em;
}
.ck-md ul,
.ck-md ol {
padding-left: 1.25em;
}
.ck-md li + li {
margin-top: 0.25em;
}
.ck-md-h {
font-weight: 650;
}
.ck-md blockquote {
padding-left: 0.875em;
border-left: 3px solid var(--ck-line-2);
color: var(--ck-fg-2);
}
.ck-md strong {
font-weight: 650;
}
.ck-code {
padding: 0.1em 0.35em;
border-radius: 0.3em;
background: var(--ck-raised);
font-family: var(--ck-mono);
font-size: 0.875em;
}
.ck-pre {
overflow-x: auto;
padding: 0.75rem 0.875rem;
border: 1px solid var(--ck-line);
border-radius: var(--ck-radius-sm);
background: var(--ck-raised);
font-family: var(--ck-mono);
font-size: 0.875rem;
line-height: 1.55;
}
.ck-pre code {
white-space: pre;
}
.ck-link {
color: inherit;
text-decoration: underline;
text-decoration-color: var(--ck-accent);
text-underline-offset: 0.18em;
}
.ck-cite {
margin-left: 0.15em;
color: var(--ck-muted);
font-size: 0.7em;
cursor: help;
}
/* starters */
.ck-starters {
display: flex;
flex-direction: column;
gap: 0.75rem;
min-width: 0;
}
.ck-starters-title {
color: var(--ck-fg-2);
font-size: var(--ck-text);
}
.ck-starters-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.ck-starter {
min-height: var(--ck-target);
padding: 0.5rem 0.875rem;
border: 1px solid var(--ck-line);
border-radius: calc(var(--ck-radius) * 0.75);
background: var(--ck-bg);
color: var(--ck-fg-2);
font: inherit;
font-size: 0.9375rem;
text-align: left;
cursor: pointer;
}
.ck-starter:hover {
border-color: var(--ck-accent);
color: var(--ck-fg);
}
.ck-spin {
animation: ck-spin 0.9s linear infinite;
}
@keyframes ck-spin {
to {
transform: rotate(360deg);
}
}
@keyframes ck-pulse {
50% {
opacity: 0.35;
}
}
@keyframes ck-wave {
50% {
transform: scaleY(1);
}
}
@keyframes ck-dot {
0%,
80%,
100% {
opacity: 0.3;
}
40% {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.ck-spin,
.ck-voice-dot,
.ck-voice-wave > span,
.ck-dots > span {
animation: none;
}
}