Files
strata-ctl/web/assets/app.css
T
adm 1e13caa4ed Add mobile-first web GUI with a server-side session store (SQLite)
- store: a swappable Store trait + bundled-SQLite implementation (WAL,
  sessions/messages with per-turn token usage, cascade delete). The standard
  /v1 API stays stateless; conversation context lives server-side so
  multi-session, statistics and advanced settings can grow on top. DB path
  configurable (db_path, default ~/.config/strata-ctl/sessions.db).
- api::sessions: session-aware GUI API — session CRUD, history, POST .../chat
  (loads stored context, reuses the completion service, persists new turns with
  usage; streaming accumulates the assistant turn and persists before [DONE]),
  and /api/stats.
- api::web + web/: a mobile-first chat GUI (vanilla ES modules, no build step),
  embedded via rust-embed and served at GET / (same-origin, offline, single
  binary). Off-canvas session drawer on phones, persistent sidebar on wide
  screens; live streaming with a collapsible thinking panel; model output is
  inserted via textContent only.
- router_with_store mounts the GUI + session API only when a store is configured;
  router()/router_with_auth() are unchanged (API-only).
- Fix: a global [hidden]{display:none!important} reset so an author display rule
  (the stats modal's display:flex) cannot defeat the hidden attribute.

7 new tests (2 store unit + 4 session HTTP end-to-end + 1 config); 94 green +
2 ignored; clippy/fmt clean. Validated live on engine 0.1.67 (context retention,
streaming, stats) and via a browser check (modal, send/render, stats open/close).
Future: the Store backend is intended to move to ArangoDB (multi-model).
2026-11-24 20:38:24 +01:00

174 lines
6.1 KiB
CSS

/* strata-ctl web GUI — mobile-first. Single column on phones; a persistent
session sidebar appears on wide screens. Touch-friendly targets, 16px inputs
(avoids iOS focus zoom), safe-area insets for notched phones. */
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1f2430;
--border: #2a3040;
--text: #e6e9ef;
--muted: #9aa4b2;
--accent: #4f8cff;
--accent-press: #3a6fd6;
--user: #2b3a55;
--danger: #e5534b;
--radius: 14px;
--sidebar-w: 280px;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must always win over author `display` rules (e.g. the
stats modal uses display:flex); otherwise toggling .hidden has no effect. */
[hidden] { display: none !important; }
html, body {
margin: 0;
height: 100%;
background: var(--bg);
color: var(--text);
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
font-size: 16px;
line-height: 1.5;
}
#app { display: flex; height: 100dvh; overflow: hidden; }
/* ---- Buttons ---- */
.btn {
appearance: none;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
border-radius: 10px;
padding: 10px 14px;
font-size: 0.95rem;
cursor: pointer;
min-height: 44px;
transition: background 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 8px 12px; font-size: 1.2rem; line-height: 1; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
/* ---- Drawer / sidebar ---- */
#drawer {
position: fixed;
inset: 0 auto 0 0;
width: min(82vw, var(--sidebar-w));
background: var(--panel);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
transform: translateX(-100%);
transition: transform 0.2s ease;
z-index: 30;
padding-top: env(safe-area-inset-top);
}
#drawer.open { transform: translateX(0); }
#scrim {
position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 20;
}
.drawer-head {
display: flex; align-items: center; justify-content: space-between;
gap: 8px; padding: 12px;
border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.3px; }
#session-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
#session-list li {
padding: 12px; border-radius: 10px; cursor: pointer;
color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
min-height: 44px; display: flex; align-items: center;
}
#session-list li:hover { background: var(--panel-2); }
#session-list li.active { background: var(--panel-2); color: var(--text); }
.drawer-foot { padding: 12px; border-top: 1px solid var(--border); }
/* ---- Main column ---- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
#topbar {
display: flex; align-items: center; gap: 10px;
padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
border-bottom: 1px solid var(--border); background: var(--panel);
}
.title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#session-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); font-size: 0.8rem; }
#transcript {
flex: 1; overflow-y: auto; padding: 16px 12px;
display: flex; flex-direction: column; gap: 14px;
scroll-behavior: smooth;
}
.empty { color: var(--muted); text-align: center; margin: auto; max-width: 28ch; }
/* ---- Message bubbles ---- */
.msg { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; }
.msg .role { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
background: var(--user); border-radius: var(--radius) var(--radius) 4px var(--radius);
padding: 10px 14px; max-width: 85%;
}
.msg.assistant .bubble {
background: var(--panel); border: 1px solid var(--border);
border-radius: var(--radius) var(--radius) var(--radius) 4px;
padding: 10px 14px; width: 100%;
}
.bubble .content { white-space: pre-wrap; word-wrap: break-word; }
.bubble .content:empty::after { content: "…"; color: var(--muted); }
details.thinking { margin-bottom: 8px; }
details.thinking summary {
cursor: pointer; color: var(--muted); font-size: 0.85rem; user-select: none;
}
details.thinking .reasoning {
white-space: pre-wrap; word-wrap: break-word; color: var(--muted);
font-size: 0.9rem; border-left: 2px solid var(--border);
padding-left: 10px; margin-top: 6px;
}
.usage { color: var(--muted); font-size: 0.72rem; margin-top: 6px; }
/* ---- Composer ---- */
#composer {
display: flex; gap: 8px; align-items: flex-end;
padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
border-top: 1px solid var(--border); background: var(--panel);
}
#input {
flex: 1; resize: none; max-height: 40dvh;
background: var(--panel-2); color: var(--text);
border: 1px solid var(--border); border-radius: 12px;
padding: 12px 14px; font-size: 16px; font-family: inherit; line-height: 1.4;
}
#input:focus { outline: none; border-color: var(--accent); }
#send { min-width: 52px; font-size: 1.3rem; }
/* ---- Stats modal ---- */
#stats-modal {
position: fixed; inset: 0; z-index: 40;
background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
padding: 20px;
}
.modal-card {
background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
padding: 20px; max-width: 420px; width: 100%;
}
.modal-card h2 { margin: 0 0 12px; font-size: 1.1rem; }
#stats-body { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0 0 16px; }
#stats-body dt { color: var(--muted); }
#stats-body dd { margin: 0; font-variant-numeric: tabular-nums; }
/* ---- Wide screens: persistent sidebar ---- */
@media (min-width: 900px) {
#drawer { position: static; transform: none; width: var(--sidebar-w); flex-shrink: 0; }
#scrim { display: none !important; }
#menu { display: none; }
.msg.user .bubble { max-width: 70%; }
}