* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --bg: #000; --panel: #0e0e12; --line: rgba(255,255,255,.1); --muted: rgba(255,255,255,.6); --accent: #a78bfa; --accent2: #ec4899; }
html, body { height: 100%; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: #fff; line-height: 1.5; -webkit-font-smoothing: antialiased; }
#app { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgba(0,0,0,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
header h1, header .title { flex: 1; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
button, .btn { font: inherit; font-size: 15px; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 44px; cursor: pointer; color: #fff; text-decoration: none; background: linear-gradient(135deg, #7c3aed, var(--accent2)); }
button.ghost { background: transparent; border: 1px solid var(--line); font-weight: 500; }
button.icon { background: transparent; padding: 8px 10px; min-width: 44px; font-size: 20px; }
input, textarea, select { font: inherit; font-size: 16px; width: 100%; color: #fff; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
/* Browser default placeholder grey (#757575) is 4.18:1 on --panel; this is 5.34:1 (Firefox also fades it, hence opacity). */
::placeholder { color: rgba(255,255,255,.5); opacity: 1; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
label { display: block; font-size: 14px; color: var(--muted); margin: 16px 0 6px; }
.pad { padding: 24px 16px; }
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 20px; }
.center h1, .center h2 { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.center p { color: var(--muted); margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stack > * + * { margin-top: 12px; }
.error { color: #fca5a5; font-size: 14px; min-height: 20px; margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.error button { min-height: 36px; padding: 6px 14px; }
/* Action alerts under the list toolbar and next to Sign out take no space until they have something to say. */
.toolbar + .error { margin: 0; padding: 0 16px 8px; }
.toolbar + .error:empty, .signout-error:empty { min-height: 0; margin: 0; padding: 0; }
.typing { display: inline-flex; gap: 5px; align-items: center; width: auto; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; opacity: .7; } }
button:disabled { opacity: .5; cursor: default; }
.note { color: var(--muted); font-size: 13px; }
.not-found { text-align: center; min-height: 100vh; }
.not-found .btn { display: inline-block; }
.center .note a { color: #a78bfa; }
.note.alt { margin: 4px 0; }
.note.alt a { display: inline-block; min-height: 44px; line-height: 44px; padding: 0 4px; }
.pad > a.note { display: inline-block; min-height: 44px; line-height: 44px; }
a.btn { display: inline-block; }
.list { list-style: none; }
.list a { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: #fff; text-decoration: none; }
.list a span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { color: var(--muted); font-size: 13px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.toolbar { display: flex; gap: 8px; padding: 12px 16px; }
.toolbar input { flex: 1; }
.msgs { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #7c3aed; border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #000; border-top: 1px solid var(--line); }
.composer textarea { resize: none; min-height: 44px; max-height: 160px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
/* GM-2: a setting's label fills its row (67px) so the whole row toggles; padding = the old 12px row padding plus label margins, so nothing moves. */
.row > label { flex: 1; align-self: stretch; display: flex; align-items: center; margin: -12px 0; padding: 28px 0 18px; }
.row input[type=time] { width: auto; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.connect-card { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg, transparent); white-space: normal; }
.connect-card button { align-self: flex-start; }
.conn-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.conn-row > div { min-width: 0; overflow-wrap: anywhere; }
details summary { cursor: pointer; margin: 6px 0; padding: 10px 0; }
[inert] { pointer-events: none; }

/* Chat markdown (public/app/markdown.js). */

.md { white-space: normal; min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.md > * { margin: 0; }
.md > * + * { margin-top: 8px; }
.md ul, .md ol { padding-left: 1.3em; }
.md li + li { margin-top: 3px; }
.md li > p, .md li > pre { margin: 0; }
.md li > * + p, .md li > * + pre, .md li > p + ul, .md li > p + ol { margin-top: 6px; }
.md .md-h { font-size: 1.02em; }
.md a { color: #c4b5fd; text-decoration: underline; word-break: break-all; }
.msg.user .md a { color: #fff; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 5px; }
.md pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre; }
.md pre code { background: none; padding: 0; font-size: .85em; white-space: pre; overflow-wrap: normal; }

/* Workspace v2 shell (flagged). Mobile first: 390px gets a scrolling top nav; wider screens get a sidebar. */
.v2-shell { display: flex; flex-direction: column; min-height: 100dvh; }
.v2-nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px; border-bottom: 1px solid #0002; }
.v2-nav a { padding: 8px 12px; border-radius: 8px; white-space: nowrap; text-decoration: none; color: inherit; }
.v2-nav a[aria-current="page"] { background: #0001; font-weight: 600; }
.v2-main { flex: 1; padding: 16px; max-width: 100%; overflow-wrap: anywhere; }
@media (min-width: 768px) { .v2-shell { flex-direction: row; } .v2-nav { flex-direction: column; width: 220px; border-bottom: 0; border-right: 1px solid #0002; } }
.v2-main .v2-thread { display: flex; flex-direction: column; min-height: calc(100dvh - 90px); }
.v2-thread header { display: flex; align-items: center; gap: 8px; }
.v2-thread header h1 { flex: 1; min-width: 0; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2-thread .msgs { flex: 1; }
.v2-thread .composer { position: sticky; bottom: 0; display: flex; gap: 6px; padding: 8px 0 env(safe-area-inset-bottom); background: inherit; }
.v2-thread .composer textarea { flex: 1; min-width: 0; }
.v2-thread .composer select { max-width: 30%; }
.v2-threads input[type=search] { width: 100%; box-sizing: border-box; margin: 8px 0; }
