Working chat: auth, connections, streaming, folders
LLeMbas now runs end to end. Register, add an OpenAI-compatible connection, and hold a real streaming conversation organised into folders. Verified against the local llama-swap instance. Streaming is the one genuinely tricky part. Sending a message returns two HTML fragments -- the user bubble and an empty assistant bubble carrying an sse-connect -- and that attribute is the ONLY thing that starts a generation. Rendering an incomplete assistant message as a streaming shell falls out of the same template, which means loading a page whose last reply never finished simply picks it up again. Details worth knowing about, each commented where it matters: - SSE payloads are split across several data: lines. A raw newline in one data: line truncates the event, which shows up the first time a model emits a code block. - Markdown is rendered server-side by the same helper for both the page and the final streamed frame, so the two cannot disagree. The fence renderer is replaced outright rather than using markdown-it's highlight option, which re-wraps output in a second <pre>. - escape_text is html.escape, not nh3.clean_text: it escapes character by character, so escaping stream chunks separately equals escaping the whole string. - The stream opens its own session via session_scope(); it outlives the request handler and the dependency-scoped session may be closed. - Deleting a folder keeps the chats inside it (FK is SET NULL). Losing a conversation to a mis-clicked folder delete is unforgivable. - Login failures use one message for "no such account" and "wrong password" so the form cannot enumerate registered addresses. Also adds deploy/ for the gamebox install at https://chat.lan: system unit, nginx vhost with buffering off (buffering on turns streaming into one lump at the end), and install/update scripts following the same service-user and /srv bind-mount conventions as llama-swap and comfyui. 70 tests, ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
/* Administration screens. */
|
||||
|
||||
.admin-scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border-strong) transparent;
|
||||
}
|
||||
|
||||
.admin-page {
|
||||
max-width: 46rem;
|
||||
margin: 0 auto;
|
||||
padding: var(--sp-6) var(--sp-5) var(--sp-12);
|
||||
}
|
||||
|
||||
.admin-lede {
|
||||
color: var(--ink-muted);
|
||||
font-size: var(--text-sm);
|
||||
line-height: var(--leading-relaxed);
|
||||
margin-bottom: var(--sp-6);
|
||||
max-width: 42rem;
|
||||
}
|
||||
|
||||
.admin-section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
font-size: var(--text-lg);
|
||||
margin: var(--sp-8) 0 var(--sp-4);
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--sp-5);
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
.card__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
font-size: var(--text-md);
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
|
||||
.form-grid { display: block; }
|
||||
.form-grid .field:last-of-type { margin-bottom: 0; }
|
||||
.field--actions { margin-top: var(--sp-5); margin-bottom: 0; }
|
||||
|
||||
.connection__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-3);
|
||||
margin-bottom: var(--sp-4);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.connection__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-3);
|
||||
margin-top: var(--sp-5);
|
||||
padding-top: var(--sp-4);
|
||||
border-top: 1px solid var(--border);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* Reachable status at a glance: green working, red errored, grey disabled. */
|
||||
.status-dot {
|
||||
width: 0.55rem;
|
||||
height: 0.55rem;
|
||||
border-radius: var(--radius-full);
|
||||
flex: none;
|
||||
background: var(--ink-faint);
|
||||
}
|
||||
.status-dot.is-ok { background: var(--success); }
|
||||
.status-dot.is-bad { background: var(--danger); }
|
||||
.status-dot.is-off { background: var(--ink-faint); }
|
||||
|
||||
.model-list { list-style: none; margin: 0; padding: 0; }
|
||||
.model-list__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-2) 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.model-list__item:last-child { border-bottom: 0; }
|
||||
.model-list__id {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.nav-item.is-disabled {
|
||||
opacity: 0.45;
|
||||
cursor: default;
|
||||
}
|
||||
.nav-item.is-disabled:hover { background: none; color: var(--ink-muted); }
|
||||
|
||||
.field__hint code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.92em;
|
||||
padding: 0.05em 0.3em;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--code-bg);
|
||||
border: 1px solid var(--code-border);
|
||||
}
|
||||
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
Application styles.
|
||||
|
||||
Rules here resolve colour, spacing and radius through the variables in
|
||||
tokens.css and never hard-code a value. Layout is flexbox and grid only --
|
||||
no framework, no preprocessor, no build step.
|
||||
*/
|
||||
|
||||
/* --- Reset ---------------------------------------------------------------- */
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-base);
|
||||
line-height: var(--leading-normal);
|
||||
color: var(--ink);
|
||||
background: var(--bg);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 600;
|
||||
line-height: var(--leading-tight);
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
p { margin: 0 0 var(--sp-4); }
|
||||
p:last-child { margin-bottom: 0; }
|
||||
|
||||
a {
|
||||
color: var(--accent);
|
||||
text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
a:hover { color: var(--accent-hover); }
|
||||
|
||||
button, input, textarea, select {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* A single, consistent focus ring. Never remove it without a replacement. */
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
:focus:not(:focus-visible) { outline: none; }
|
||||
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* --- Icons ---------------------------------------------------------------- */
|
||||
.icon {
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
flex: none;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.7;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.icon--sm { width: 1em; height: 1em; }
|
||||
.icon--lg { width: 1.5em; height: 1.5em; }
|
||||
/* The leaf is a filled silhouette, not a stroked pictogram. */
|
||||
.icon--leaf { fill: currentColor; stroke: none; }
|
||||
|
||||
/* --- Buttons -------------------------------------------------------------- */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--sp-2);
|
||||
padding: 0.5rem 0.9rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface-raised);
|
||||
color: var(--ink);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background var(--transition-fast), border-color var(--transition-fast),
|
||||
color var(--transition-fast);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: var(--surface-hover);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
|
||||
.btn--primary {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: var(--accent-ink);
|
||||
}
|
||||
.btn--primary:hover:not(:disabled) {
|
||||
background: var(--accent-hover);
|
||||
border-color: var(--accent-hover);
|
||||
}
|
||||
|
||||
.btn--danger { color: var(--danger); border-color: var(--border); }
|
||||
.btn--danger:hover:not(:disabled) {
|
||||
background: var(--danger-soft);
|
||||
border-color: var(--danger);
|
||||
}
|
||||
|
||||
.btn--ghost { background: transparent; border-color: transparent; }
|
||||
.btn--ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: transparent; }
|
||||
|
||||
.btn--icon {
|
||||
padding: 0.4rem;
|
||||
border-radius: var(--radius);
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
.btn--icon:hover:not(:disabled) { background: var(--surface-hover); color: var(--ink); }
|
||||
|
||||
.btn--block { width: 100%; }
|
||||
.btn--sm { padding: 0.3rem 0.6rem; font-size: var(--text-xs); }
|
||||
|
||||
/* --- Forms ---------------------------------------------------------------- */
|
||||
.field { margin-bottom: var(--sp-4); }
|
||||
.field__label {
|
||||
display: block;
|
||||
margin-bottom: var(--sp-2);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
.field__hint {
|
||||
margin-top: var(--sp-2);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
line-height: var(--leading-normal);
|
||||
}
|
||||
|
||||
.input,
|
||||
.textarea,
|
||||
.select {
|
||||
width: 100%;
|
||||
padding: 0.55rem 0.7rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg-sunken);
|
||||
color: var(--ink);
|
||||
font-size: var(--text-base);
|
||||
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
|
||||
}
|
||||
.input:focus,
|
||||
.textarea:focus,
|
||||
.select:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px var(--accent-soft);
|
||||
}
|
||||
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
|
||||
.textarea { resize: vertical; min-height: 5rem; line-height: var(--leading-normal); }
|
||||
.input--mono { font-family: var(--font-mono); font-size: var(--text-sm); }
|
||||
|
||||
.checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
.checkbox input { accent-color: var(--accent); width: 1rem; height: 1rem; }
|
||||
|
||||
/* --- Alerts --------------------------------------------------------------- */
|
||||
.alert {
|
||||
display: flex;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border: 1px solid var(--border);
|
||||
border-left-width: 3px;
|
||||
border-radius: var(--radius);
|
||||
font-size: var(--text-sm);
|
||||
margin-bottom: var(--sp-4);
|
||||
background: var(--surface);
|
||||
}
|
||||
.alert--error { border-left-color: var(--danger); background: var(--danger-soft); color: var(--ink); }
|
||||
.alert--success { border-left-color: var(--success); background: var(--success-soft); }
|
||||
.alert--warning { border-left-color: var(--warning); background: var(--warning-soft); }
|
||||
.alert__icon { color: var(--danger); flex: none; margin-top: 0.15rem; }
|
||||
|
||||
/* --- Badges --------------------------------------------------------------- */
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-1);
|
||||
padding: 0.1rem 0.45rem;
|
||||
border-radius: var(--radius-full);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 500;
|
||||
background: var(--surface-active);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
.badge--gold { background: var(--gold-soft); color: var(--gold); }
|
||||
.badge--success { background: var(--success-soft); color: var(--success); }
|
||||
.badge--danger { background: var(--danger-soft); color: var(--danger); }
|
||||
|
||||
/* --- Application shell ---------------------------------------------------- */
|
||||
.shell {
|
||||
display: flex;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: var(--sidebar-width);
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--bg-sunken);
|
||||
border-right: 1px solid var(--border);
|
||||
transition: margin-left var(--transition);
|
||||
}
|
||||
.sidebar[hidden] { display: none; }
|
||||
|
||||
.sidebar__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
height: var(--header-height);
|
||||
padding: 0 var(--sp-3);
|
||||
flex: none;
|
||||
}
|
||||
.sidebar__brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
color: var(--ink);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
min-width: 0;
|
||||
}
|
||||
.sidebar__brand:hover { color: var(--ink); }
|
||||
.sidebar__brand .brand-mark { width: 1.6rem; height: 1.6rem; flex: none; }
|
||||
.sidebar__brand .brand-llm { color: var(--gold); }
|
||||
|
||||
.sidebar__actions { padding: 0 var(--sp-3) var(--sp-3); display: flex; gap: var(--sp-2); }
|
||||
|
||||
.sidebar__scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0 var(--sp-2) var(--sp-3);
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border-strong) transparent;
|
||||
}
|
||||
|
||||
.sidebar__footer {
|
||||
flex: none;
|
||||
border-top: 1px solid var(--border);
|
||||
padding: var(--sp-2);
|
||||
}
|
||||
|
||||
.main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-3);
|
||||
height: var(--header-height);
|
||||
flex: none;
|
||||
padding: 0 var(--sp-4);
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
}
|
||||
.topbar__title {
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.topbar__spacer { flex: 1; }
|
||||
|
||||
/* --- Sidebar navigation --------------------------------------------------- */
|
||||
.nav-group { margin-bottom: var(--sp-4); }
|
||||
.nav-group__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--sp-2) var(--sp-2) var(--sp-1);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.07em;
|
||||
color: var(--ink-faint);
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: 0.4rem var(--sp-2);
|
||||
border-radius: var(--radius);
|
||||
color: var(--ink-muted);
|
||||
text-decoration: none;
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
.nav-item:hover { background: var(--surface-hover); color: var(--ink); }
|
||||
.nav-item.is-active { background: var(--surface-active); color: var(--ink); font-weight: 500; }
|
||||
.nav-item__label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
/* Row actions stay hidden until the row is hovered or focused within, so the
|
||||
list reads calmly, but they remain keyboard reachable. */
|
||||
.nav-item__actions {
|
||||
display: flex;
|
||||
gap: 0.1rem;
|
||||
opacity: 0;
|
||||
transition: opacity var(--transition-fast);
|
||||
}
|
||||
.nav-item:hover .nav-item__actions,
|
||||
.nav-item:focus-within .nav-item__actions { opacity: 1; }
|
||||
|
||||
.nav-empty {
|
||||
padding: var(--sp-3) var(--sp-2);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* --- Auth screens --------------------------------------------------------- */
|
||||
.auth {
|
||||
min-height: 100dvh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: var(--sp-6);
|
||||
background:
|
||||
radial-gradient(ellipse 60% 50% at 50% 0%, var(--gold-soft), transparent 70%),
|
||||
var(--bg);
|
||||
}
|
||||
.auth__card {
|
||||
width: 100%;
|
||||
max-width: 25rem;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-xl);
|
||||
padding: var(--sp-8);
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
.auth__brand { display: grid; place-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }
|
||||
.auth__brand .brand-mark { width: 3.5rem; height: 3.5rem; }
|
||||
.auth__title {
|
||||
font-size: var(--text-2xl);
|
||||
font-family: var(--font-display);
|
||||
text-align: center;
|
||||
}
|
||||
.auth__subtitle {
|
||||
text-align: center;
|
||||
color: var(--ink-muted);
|
||||
font-size: var(--text-sm);
|
||||
margin-top: var(--sp-2);
|
||||
}
|
||||
.auth__footer {
|
||||
margin-top: var(--sp-5);
|
||||
padding-top: var(--sp-4);
|
||||
border-top: 1px solid var(--border);
|
||||
text-align: center;
|
||||
font-size: var(--text-sm);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* --- Empty states --------------------------------------------------------- */
|
||||
.empty {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
place-content: center;
|
||||
justify-items: center;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-10);
|
||||
text-align: center;
|
||||
}
|
||||
.empty__mark { width: 4.5rem; height: 4.5rem; opacity: 0.85; }
|
||||
.empty__title { font-size: var(--text-xl); font-family: var(--font-display); }
|
||||
.empty__text {
|
||||
color: var(--ink-muted);
|
||||
font-size: var(--text-sm);
|
||||
max-width: 32rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* --- Utilities ------------------------------------------------------------ */
|
||||
.stack > * + * { margin-top: var(--sp-4); }
|
||||
.row { display: flex; align-items: center; gap: var(--sp-3); }
|
||||
.row--between { justify-content: space-between; }
|
||||
.muted { color: var(--ink-muted); }
|
||||
.faint { color: var(--ink-faint); }
|
||||
.text-sm { font-size: var(--text-sm); }
|
||||
.text-xs { font-size: var(--text-xs); }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
/* --- Small screens -------------------------------------------------------- */
|
||||
@media (max-width: 48rem) {
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
inset: 0 auto 0 0;
|
||||
z-index: 40;
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
.sidebar[data-collapsed="true"] { display: none; }
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
Chat thread, composer, message bodies and code blocks.
|
||||
|
||||
Loaded only on chat pages. Like app.css, every value resolves through
|
||||
tokens.css.
|
||||
*/
|
||||
|
||||
/* --- Thread --------------------------------------------------------------- */
|
||||
.thread-scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
scroll-behavior: smooth;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border-strong) transparent;
|
||||
}
|
||||
|
||||
.thread {
|
||||
max-width: var(--thread-max-width);
|
||||
margin: 0 auto;
|
||||
padding: var(--sp-6) var(--sp-5) var(--sp-8);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-6);
|
||||
}
|
||||
|
||||
.thread__intro {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
gap: var(--sp-3);
|
||||
text-align: center;
|
||||
padding: var(--sp-12) 0 var(--sp-6);
|
||||
}
|
||||
|
||||
/* --- Messages ------------------------------------------------------------- */
|
||||
.msg {
|
||||
display: grid;
|
||||
grid-template-columns: 2rem 1fr;
|
||||
gap: var(--sp-3);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.msg__gutter {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: var(--radius-full);
|
||||
overflow: hidden;
|
||||
}
|
||||
.msg__mark { width: 2rem; height: 2rem; }
|
||||
.msg__initial {
|
||||
width: 2rem; height: 2rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--surface-active);
|
||||
color: var(--ink-muted);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.msg__main { min-width: 0; }
|
||||
|
||||
.msg__meta {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--sp-2);
|
||||
margin-bottom: var(--sp-1);
|
||||
}
|
||||
.msg__author {
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-base);
|
||||
font-weight: 600;
|
||||
}
|
||||
.msg__model {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
font-family: var(--font-mono);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 16rem;
|
||||
}
|
||||
|
||||
.msg__body {
|
||||
line-height: var(--leading-relaxed);
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
/* User turns and mid-stream assistant text are plain text, so newlines and
|
||||
runs of spaces have to survive. */
|
||||
.msg__body--plain,
|
||||
.msg__body--streaming { white-space: pre-wrap; }
|
||||
|
||||
.msg--user .msg__body--plain {
|
||||
background: var(--bubble-user);
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border-radius: var(--radius-lg);
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.msg__error { margin: var(--sp-2) 0; align-items: flex-start; }
|
||||
|
||||
/* --- Streaming indicator -------------------------------------------------- */
|
||||
/* Shown until the first token arrives, then hidden by the sibling selector
|
||||
below -- no JavaScript involved in either direction. */
|
||||
.msg__waiting { padding: var(--sp-2) 0; }
|
||||
.msg__body--streaming:not(:empty) + .msg__waiting { display: none; }
|
||||
|
||||
.dots { display: inline-flex; gap: 0.25rem; align-items: center; }
|
||||
.dots i {
|
||||
width: 0.4rem;
|
||||
height: 0.4rem;
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--ink-faint);
|
||||
animation: dot-pulse 1.3s ease-in-out infinite;
|
||||
}
|
||||
.dots i:nth-child(2) { animation-delay: 0.18s; }
|
||||
.dots i:nth-child(3) { animation-delay: 0.36s; }
|
||||
|
||||
@keyframes dot-pulse {
|
||||
0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
|
||||
30% { opacity: 1; transform: translateY(-2px); }
|
||||
}
|
||||
|
||||
/* A caret trailing the text while it streams. */
|
||||
.msg__body--streaming::after {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 0.45rem;
|
||||
height: 1.05em;
|
||||
margin-left: 1px;
|
||||
vertical-align: text-bottom;
|
||||
background: var(--gold);
|
||||
opacity: 0.75;
|
||||
animation: caret 1.05s steps(1) infinite;
|
||||
}
|
||||
@keyframes caret { 0%, 49% { opacity: 0.75; } 50%, 100% { opacity: 0; } }
|
||||
|
||||
/* --- Message actions ------------------------------------------------------ */
|
||||
.msg__actions {
|
||||
display: flex;
|
||||
gap: var(--sp-1);
|
||||
margin-top: var(--sp-2);
|
||||
opacity: 0;
|
||||
transition: opacity var(--transition-fast);
|
||||
}
|
||||
.msg:hover .msg__actions,
|
||||
.msg:focus-within .msg__actions { opacity: 1; }
|
||||
.msg__actions .is-copied { color: var(--success); }
|
||||
|
||||
/* --- Rendered Markdown ---------------------------------------------------- */
|
||||
.msg__body > :first-child { margin-top: 0; }
|
||||
.msg__body > :last-child { margin-bottom: 0; }
|
||||
|
||||
.msg__body h1, .msg__body h2, .msg__body h3,
|
||||
.msg__body h4, .msg__body h5, .msg__body h6 {
|
||||
margin: var(--sp-5) 0 var(--sp-2);
|
||||
}
|
||||
.msg__body h1 { font-size: var(--text-xl); }
|
||||
.msg__body h2 { font-size: var(--text-lg); }
|
||||
.msg__body h3 { font-size: var(--text-md); }
|
||||
|
||||
.msg__body ul, .msg__body ol { margin: 0 0 var(--sp-4); padding-left: var(--sp-6); }
|
||||
.msg__body li { margin-bottom: var(--sp-1); }
|
||||
|
||||
.msg__body blockquote {
|
||||
margin: 0 0 var(--sp-4);
|
||||
padding: var(--sp-1) var(--sp-4);
|
||||
border-left: 3px solid var(--border-strong);
|
||||
color: var(--ink-muted);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.msg__body hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }
|
||||
|
||||
.msg__body :not(pre) > code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.875em;
|
||||
padding: 0.13em 0.36em;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--code-bg);
|
||||
border: 1px solid var(--code-border);
|
||||
}
|
||||
|
||||
.msg__body table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 0 0 var(--sp-4);
|
||||
font-size: var(--text-sm);
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.msg__body th, .msg__body td {
|
||||
border: 1px solid var(--border);
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
text-align: left;
|
||||
}
|
||||
.msg__body th { background: var(--surface); font-weight: 600; }
|
||||
|
||||
.msg__body img { max-width: 100%; height: auto; border-radius: var(--radius); }
|
||||
|
||||
/* --- Code blocks ---------------------------------------------------------- */
|
||||
.code-block {
|
||||
margin: 0 0 var(--sp-4);
|
||||
border: 1px solid var(--code-border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--code-bg);
|
||||
overflow: hidden;
|
||||
}
|
||||
.code-block__label {
|
||||
padding: var(--sp-1) var(--sp-3);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
border-bottom: 1px solid var(--code-border);
|
||||
background: color-mix(in srgb, var(--code-bg) 60%, var(--surface));
|
||||
}
|
||||
.code-block__pre {
|
||||
margin: 0;
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
overflow-x: auto;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
line-height: 1.55;
|
||||
}
|
||||
.code-block__pre code { font-family: inherit; background: none; border: 0; padding: 0; }
|
||||
|
||||
/*
|
||||
Pygments token colours, mapped onto theme tokens rather than a fixed scheme,
|
||||
so code follows the active theme. classprefix "pg-" is set in markdown.py.
|
||||
*/
|
||||
.pg-c, .pg-c1, .pg-cm, .pg-cs, .pg-cp { color: var(--ink-faint); font-style: italic; }
|
||||
.pg-k, .pg-kn, .pg-kd, .pg-kc, .pg-kr, .pg-kt { color: var(--gold); }
|
||||
.pg-s, .pg-s1, .pg-s2, .pg-sb, .pg-sd, .pg-se, .pg-sh, .pg-si, .pg-sx { color: var(--success); }
|
||||
.pg-m, .pg-mi, .pg-mf, .pg-mh, .pg-mo { color: var(--danger); }
|
||||
.pg-nf, .pg-nd { color: var(--accent); }
|
||||
.pg-nc, .pg-nn { color: var(--accent-hover); font-weight: 600; }
|
||||
.pg-nb, .pg-bp { color: var(--accent); }
|
||||
.pg-nv, .pg-vi, .pg-vg, .pg-vc { color: var(--ink); }
|
||||
.pg-o, .pg-ow, .pg-p { color: var(--ink-muted); }
|
||||
.pg-err { color: var(--danger); }
|
||||
.pg-gd { color: var(--danger); }
|
||||
.pg-gi { color: var(--success); }
|
||||
|
||||
/* --- Composer ------------------------------------------------------------- */
|
||||
.composer {
|
||||
flex: none;
|
||||
padding: var(--sp-3) var(--sp-5) var(--sp-4);
|
||||
border-top: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
}
|
||||
.composer__form {
|
||||
max-width: var(--thread-max-width);
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
gap: var(--sp-2);
|
||||
align-items: flex-end;
|
||||
padding: var(--sp-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-xl);
|
||||
background: var(--surface);
|
||||
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
|
||||
}
|
||||
.composer__form:focus-within {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px var(--accent-soft);
|
||||
}
|
||||
.composer__input {
|
||||
flex: 1;
|
||||
border: 0;
|
||||
background: none;
|
||||
resize: none;
|
||||
padding: var(--sp-2);
|
||||
font-size: var(--text-base);
|
||||
line-height: var(--leading-normal);
|
||||
max-height: 20rem;
|
||||
}
|
||||
.composer__input:focus { outline: none; }
|
||||
.composer__send { border-radius: var(--radius-full); padding: 0.55rem 0.7rem; }
|
||||
.composer__hint {
|
||||
max-width: var(--thread-max-width);
|
||||
margin: var(--sp-2) auto 0;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.select--compact {
|
||||
width: auto;
|
||||
max-width: 16rem;
|
||||
padding: 0.3rem 0.5rem;
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/* --- Folders -------------------------------------------------------------- */
|
||||
.folder__row { padding-right: var(--sp-1); }
|
||||
.folder__toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
.folder__chevron {
|
||||
display: inline-flex;
|
||||
transition: transform var(--transition-fast);
|
||||
}
|
||||
.folder__chevron.is-open { transform: rotate(90deg); }
|
||||
.folder__contents { padding-left: var(--sp-4); }
|
||||
|
||||
.nav-item__link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* --- Theme toggle --------------------------------------------------------- */
|
||||
/* Only the icon for the theme you would switch TO is shown. */
|
||||
:root[data-theme="moria"] .theme-icon--dark { display: none; }
|
||||
:root[data-theme="shire"] .theme-icon--light { display: none; }
|
||||
|
||||
/* Alpine sets x-cloak until it has initialised; without this, collapsed
|
||||
folders flash open on every page load. */
|
||||
[x-cloak] { display: none !important; }
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
Design tokens.
|
||||
|
||||
Every colour, space and radius in the application resolves through a variable
|
||||
declared here. Component CSS must never hard-code a hex value -- that is what
|
||||
makes adding a theme a matter of writing one new block rather than auditing
|
||||
every stylesheet.
|
||||
|
||||
Themes are selected with data-theme on <html>. `moria` is the default and is
|
||||
declared on :root so the page is styled even before the theme script runs.
|
||||
*/
|
||||
|
||||
:root {
|
||||
/* --- Type ------------------------------------------------------------- */
|
||||
--font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Palladio,
|
||||
"URW Palladio L", "Book Antiqua", Baskerville, Georgia, serif;
|
||||
--font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
|
||||
Arial, sans-serif;
|
||||
--font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code",
|
||||
"Cascadia Code", Menlo, Consolas, monospace;
|
||||
|
||||
--text-xs: 0.75rem;
|
||||
--text-sm: 0.8125rem;
|
||||
--text-base: 0.9375rem;
|
||||
--text-md: 1rem;
|
||||
--text-lg: 1.125rem;
|
||||
--text-xl: 1.375rem;
|
||||
--text-2xl: 1.75rem;
|
||||
--text-3xl: 2.25rem;
|
||||
|
||||
--leading-tight: 1.25;
|
||||
--leading-normal: 1.6;
|
||||
--leading-relaxed: 1.75;
|
||||
|
||||
/* --- Space (4px scale) ------------------------------------------------ */
|
||||
--sp-1: 0.25rem;
|
||||
--sp-2: 0.5rem;
|
||||
--sp-3: 0.75rem;
|
||||
--sp-4: 1rem;
|
||||
--sp-5: 1.25rem;
|
||||
--sp-6: 1.5rem;
|
||||
--sp-8: 2rem;
|
||||
--sp-10: 2.5rem;
|
||||
--sp-12: 3rem;
|
||||
--sp-16: 4rem;
|
||||
|
||||
/* --- Radius & shadow -------------------------------------------------- */
|
||||
--radius-sm: 4px;
|
||||
--radius: 8px;
|
||||
--radius-lg: 12px;
|
||||
--radius-xl: 18px;
|
||||
--radius-full: 999px;
|
||||
|
||||
/* --- Layout ----------------------------------------------------------- */
|
||||
--sidebar-width: 17rem;
|
||||
--thread-max-width: 48rem;
|
||||
--header-height: 3.25rem;
|
||||
|
||||
--transition-fast: 120ms ease;
|
||||
--transition: 200ms ease;
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
MORIA (default, dark)
|
||||
|
||||
Deep stone and lamplight: the halls under the mountain. Surfaces are cool and
|
||||
near-neutral so the gold and mithril accents carry all the colour.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
:root,
|
||||
:root[data-theme="moria"] {
|
||||
color-scheme: dark;
|
||||
|
||||
--bg: #101317;
|
||||
--bg-sunken: #0B0E11;
|
||||
--surface: #171B21;
|
||||
--surface-raised: #1E242B;
|
||||
--surface-hover: #232A32;
|
||||
--surface-active: #2A323B;
|
||||
|
||||
--border: #2A313A;
|
||||
--border-strong: #3A434E;
|
||||
|
||||
--ink: #E4E8EC;
|
||||
--ink-muted: #A2ADB8;
|
||||
--ink-faint: #6E7883;
|
||||
--ink-inverse: #0B0E11;
|
||||
|
||||
/* Mithril: the cool primary, used for focus and interactive accents. */
|
||||
--accent: #8FB3CC;
|
||||
--accent-hover: #A9C6DA;
|
||||
--accent-ink: #0B0E11;
|
||||
--accent-soft: rgba(143, 179, 204, 0.14);
|
||||
|
||||
/* Rune gold: the warm accent. Brand colour, and the assistant's mark. */
|
||||
--gold: #E0B252;
|
||||
--gold-hover: #EDC46F;
|
||||
--gold-soft: rgba(224, 178, 82, 0.13);
|
||||
|
||||
/* Ember: destructive actions and errors. */
|
||||
--danger: #E2795A;
|
||||
--danger-hover: #EC8E72;
|
||||
--danger-soft: rgba(226, 121, 90, 0.14);
|
||||
|
||||
--success: #7FB77E;
|
||||
--success-soft: rgba(127, 183, 126, 0.14);
|
||||
--warning: #DFAE58;
|
||||
--warning-soft: rgba(223, 174, 88, 0.14);
|
||||
|
||||
--bubble-user: #232B34;
|
||||
--bubble-assistant: transparent;
|
||||
--code-bg: #0C0F13;
|
||||
--code-border: #262D36;
|
||||
|
||||
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||
--shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
|
||||
--shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.55);
|
||||
|
||||
--scrim: rgba(6, 8, 10, 0.66);
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
SHIRE (light)
|
||||
|
||||
Parchment, ink and moss: warm, low-contrast, easy to read for a long time.
|
||||
Backgrounds are deliberately off-white -- pure #FFF next to the gold accent
|
||||
reads as clinical rather than as paper.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
:root[data-theme="shire"] {
|
||||
color-scheme: light;
|
||||
|
||||
--bg: #F6F1E4;
|
||||
--bg-sunken: #EDE6D4;
|
||||
--surface: #FDFBF5;
|
||||
--surface-raised: #FFFFFF;
|
||||
--surface-hover: #F1EADA;
|
||||
--surface-active: #E7DEC9;
|
||||
|
||||
--border: #DED3BB;
|
||||
--border-strong: #C6B896;
|
||||
|
||||
--ink: #2C2419;
|
||||
--ink-muted: #6A5C48;
|
||||
--ink-faint: #94856D;
|
||||
--ink-inverse: #FDFBF5;
|
||||
|
||||
/* Hobbit-door blue-green: the cool primary. */
|
||||
--accent: #3E6B7A;
|
||||
--accent-hover: #325867;
|
||||
--accent-ink: #FDFBF5;
|
||||
--accent-soft: rgba(62, 107, 122, 0.12);
|
||||
|
||||
--gold: #A8801A;
|
||||
--gold-hover: #8E6B12;
|
||||
--gold-soft: rgba(168, 128, 26, 0.13);
|
||||
|
||||
--danger: #A6432B;
|
||||
--danger-hover: #8C3722;
|
||||
--danger-soft: rgba(166, 67, 43, 0.11);
|
||||
|
||||
--success: #4F7A3F;
|
||||
--success-soft: rgba(79, 122, 63, 0.12);
|
||||
--warning: #98701A;
|
||||
--warning-soft: rgba(152, 112, 26, 0.13);
|
||||
|
||||
--bubble-user: #EDE4CF;
|
||||
--bubble-assistant: transparent;
|
||||
--code-bg: #F2EBD9;
|
||||
--code-border: #DED3BB;
|
||||
|
||||
--shadow-sm: 0 1px 2px rgba(72, 58, 34, 0.09);
|
||||
--shadow: 0 4px 14px rgba(72, 58, 34, 0.11);
|
||||
--shadow-lg: 0 12px 34px rgba(72, 58, 34, 0.16);
|
||||
|
||||
--scrim: rgba(44, 36, 25, 0.4);
|
||||
}
|
||||
|
||||
/* Respect a stated preference for reduced motion everywhere, at once. */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user