/* LLM Router console.

   A light, quiet workspace: a fixed sidebar carries the signed-in user and
   the navigation, and every page is a centered column of white cards on a
   white page. Prose, labels, and controls are set in the system sans; only
   machine values that an operator copies or compares (ids, keys, commands,
   payloads) are set in mono. Blue marks links, progress, and completed
   steps; the primary action is near-black; status colours stay soft. */

:root {
    color-scheme: light;

    --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
    --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;

    --bg: #ffffff;
    --sidebar-bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f7f7f8;
    --surface-3: #efeff1;
    --line: #e6e6ea;
    --line-soft: #efeff2;
    --line-strong: #d6d6dc;
    --text: #2b2b30;
    --text-strong: #131316;
    --muted: #6d6d75;
    --faint: #8f8f97;

    --signal: #2f6bed;
    --signal-soft: rgb(47 107 237 / 10%);
    --signal-ink: #2258d1;
    --signal-hover: #2a60d6;
    --on-signal: #ffffff;
    --primary: #17171a;
    --primary-hover: #2c2c31;
    --on-primary: #ffffff;
    --ok: #1f9d55;
    --warn: #c4831a;
    --danger: #d9434e;
    --violet: #7c5cbf;
    --ok-ink: #17804a;
    --warn-ink: #9a6410;
    --danger-ink: #b8323c;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgb(16 16 20 / 4%);
    --shadow-lg: 0 18px 44px -18px rgb(16 16 20 / 22%), 0 1px 2px rgb(16 16 20 / 5%);
}

.composer-attachment-icon {
    display: inline-flex;
    width: 3.25rem;
    height: 3.25rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--muted);
}

.composer-attachment-icon svg {
    width: 1.35rem;
    height: 1.35rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--signal-ink);
    text-decoration: none;
}

a:hover {
    color: var(--signal-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 2px;
    border-radius: 4px;
}

h1,
h2,
h3 {
    color: var(--text-strong);
    font-weight: 600;
    letter-spacing: -.015em;
}

p {
    margin: 0 0 .75rem;
}

code {
    font-family: var(--font-mono);
    font-size: .88em;
    background: var(--surface-3);
    border-radius: 5px;
    padding: .1rem .35rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* App shell ------------------------------------------------------------- */

.app {
    display: flex;
    min-height: 100dvh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex: none;
    flex-direction: column;
    width: 280px;
    height: 100dvh;
    padding: .9rem .75rem .75rem;
    background: var(--sidebar-bg);
    overflow-y: auto;
}

.workspace {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
    padding: .35rem .5rem .9rem;
}

.avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: .5rem;
    background: var(--surface-3);
    color: var(--text-strong);
    font-size: .82rem;
    font-weight: 600;
}

.workspace-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.workspace-name,
.workspace-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-name {
    color: var(--text-strong);
    font-size: .95rem;
    font-weight: 600;
}

.workspace-meta {
    color: var(--muted);
    font-size: .78rem;
}

.sidenav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidenav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    padding: .62rem .75rem;
    margin: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
    color: var(--text-strong);
    font: inherit;
    font-size: .95rem;
    font-weight: 450;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.sidenav-link .icon {
    flex: none;
    color: var(--text);
}

.sidenav-link:hover {
    background: var(--surface-3);
    color: var(--text-strong);
    text-decoration: none;
}

.sidenav-link:hover .icon {
    color: var(--text-strong);
}

.sidenav-link[aria-current="page"] {
    background: #ebebee;
    color: var(--text-strong);
}

.sidenav-link[aria-current="page"] .icon {
    color: var(--text-strong);
}

.sidenav-label {
    display: block;
    margin: 1.6rem .75rem .5rem;
    color: var(--muted);
    font-size: .88rem;
    font-weight: 450;
}

/* Sidebar sessions: the member's recent cloud agents under the navigation,
   plain titles with a dot only on the ones that need a glance. */

.sidebar-sessions {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-top: 0;
}

.sidebar-sessions .sidenav-label {
    margin-top: 1.6rem;
}

.sidebar-sessions-empty {
    margin: 0;
    padding: .3rem .7rem;
    color: var(--faint);
    font-size: .88rem;
}

.sidebar-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.session-link {
    padding-block: .55rem;
    color: var(--text-strong);
    font-weight: 400;
}

.session-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-dot {
    flex: none;
    width: .45rem;
    height: .45rem;
    margin-inline: .1rem .05rem;
    border-radius: 50%;
    background: var(--faint);
}

.session-dot.is-running {
    background: var(--signal);
    animation: pulse 1.8s ease-in-out infinite;
}

.session-dot.is-completed {
    background: var(--ok);
}

.session-dot.is-failed {
    background: var(--danger);
}

.session-dot.is-attention {
    background: var(--warn);
    animation: pulse 1.8s ease-in-out infinite;
}

.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    margin-top: auto;
    padding-top: 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .65rem;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: var(--text-strong);
    text-decoration: none;
}

.sidebar-brand .brand-mark {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: .35rem;
}

.sidebar-brand .brand-mark svg {
    width: .8rem;
    height: .8rem;
}

.main {
    flex: 1;
    min-width: 0;
}

.content {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2.75rem clamp(1rem, 4vw, 3rem) 6rem;
}

.icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

/* Brand ------------------------------------------------------------------ */

.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: var(--text-strong);
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -.015em;
    text-decoration: none;
}

.brand:hover {
    color: var(--text-strong);
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: .45rem;
    background: var(--primary);
    color: #ffffff;
}

.brand-mark svg {
    width: 1rem;
    height: 1rem;
}

/* Page scaffolding ------------------------------------------------------- */

.page-head {
    margin-bottom: 1.5rem;
}

.page-head h1 {
    margin: 0 0 .35rem;
    font-size: 1.5rem;
    letter-spacing: -.02em;
}

.lede {
    max-width: 66ch;
    margin: 0;
    color: var(--muted);
}

.lede.mono {
    font-family: var(--font-mono);
    font-size: .85rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-bottom: .9rem;
    font-size: .9rem;
    font-weight: 500;
}

.page-section {
    margin-top: 2.5rem;
}

.section-head {
    margin-bottom: 1rem;
}

.section-head h2 {
    margin: 0 0 .2rem;
    font-size: 1.15rem;
}

/* Sessions list: the member's cloud agents as a task board ---------------
   Sessions waiting on an approval come first in an amber group; the rest
   stack day by day as rows — status dot, prompt, vitals, and how long ago
   the session moved. The whole row is the link. */

.sessions-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.sessions-new {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: .4rem;
}

.sessions-new .icon {
    width: 15px;
    height: 15px;
}

.session-board {
    display: flex;
    flex-direction: column;
    gap: 1.7rem;
}

.session-group-title {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .55rem;
    padding-inline: .25rem;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.session-group-title .icon {
    width: 14px;
    height: 14px;
}

.session-group.is-attention .session-group-title {
    color: var(--warn-ink);
}

.session-rows {
    margin: 0;
    padding: 0;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    list-style: none;
    overflow: hidden;
}

.session-rows > li + li {
    border-top: 1px solid var(--line-soft);
}

.session-group.is-attention .session-rows {
    border-color: color-mix(in oklab, var(--warn) 35%, transparent);
    background: color-mix(in oklab, var(--warn) 4%, var(--surface));
}

.session-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .8rem 1rem;
    color: inherit;
    text-decoration: none;
    transition: background .12s ease;
}

.session-row:hover {
    background: var(--surface-2);
    color: inherit;
    text-decoration: none;
}

.session-group.is-attention .session-row:hover {
    background: color-mix(in oklab, var(--warn) 8%, var(--surface));
}

.session-state {
    flex: none;
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--faint);
}

.session-state.is-running {
    background: var(--signal);
    animation: pulse 1.8s ease-in-out infinite;
}

.session-state.is-completed {
    background: var(--ok);
}

.session-state.is-failed {
    background: var(--danger);
}

.session-state.is-attention {
    background: var(--warn);
    animation: pulse 1.8s ease-in-out infinite;
}

.session-row-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: .12rem;
    min-width: 0;
}

.session-row-title {
    overflow: hidden;
    color: var(--text-strong);
    font-weight: 550;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .2rem .45rem;
    color: var(--muted);
    font-size: .78rem;
}

.session-row-meta > * + *::before {
    content: "·";
    margin-right: .45rem;
    color: var(--faint);
}

.session-meta.is-mono {
    font-family: var(--font-mono);
    font-size: .74rem;
}

.session-flag {
    font-weight: 600;
}

.session-flag.is-running {
    color: var(--signal-ink);
}

.session-flag.is-failed {
    color: var(--danger-ink);
}

.session-flag.is-attention {
    color: var(--warn-ink);
}

.session-row-time {
    flex: none;
    color: var(--faint);
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
}

.session-row-caret {
    display: inline-flex;
    flex: none;
    color: var(--faint);
}

.session-row-caret .icon {
    width: 15px;
    height: 15px;
}

.session-row:hover .session-row-caret {
    color: var(--muted);
}

.sessions-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: 4rem 1.5rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    text-align: center;
}

.sessions-empty-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.7rem;
    height: 2.7rem;
    margin-bottom: .5rem;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--muted);
}

.sessions-empty-mark svg {
    width: 1.35rem;
    height: 1.35rem;
}

.sessions-empty h2 {
    margin: 0;
    font-size: 1.05rem;
}

.sessions-empty p {
    max-width: 42ch;
    margin: 0 0 1rem;
    color: var(--muted);
}

@media (max-width: 640px) {
    .session-row {
        gap: .7rem;
        padding: .75rem .85rem;
    }

    .session-row-caret {
        display: none;
    }
}

/* Hero: the connect card at the top of the overview ---------------------- */

.hero {
    max-width: 46rem;
    margin: 1.5rem auto 2.75rem;
}

.hero-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.4rem;
}

.hero-brand .brand {
    gap: .7rem;
    font-size: 1.65rem;
}

.hero-brand .brand-mark {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: .65rem;
}

.hero-brand .brand-mark svg {
    width: 1.35rem;
    height: 1.35rem;
}

.hero-card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
}

.hero-card-body {
    padding: 1.4rem 1.5rem 1.3rem;
}

.hero-card-label {
    margin: 0 0 .85rem;
    color: var(--text-strong);
    font-size: .95rem;
    font-weight: 600;
}

.hero-card .command {
    font-size: .9rem;
    padding: .95rem 5rem .95rem 2.3rem;
    border-radius: var(--radius);
}

.hero-card .command::before {
    left: 1.05rem;
}

.hero-card .command-wrap .copy-btn {
    top: .6rem;
    right: .6rem;
}

.hero-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1.5rem;
    background: var(--surface-2);
    border-top: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: .88rem;
}

.hero-note {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.hero-note .icon {
    flex: none;
    width: 16px;
    height: 16px;
}

.hero-card-foot > a {
    flex: none;
    font-weight: 500;
}

.connect-card {
    margin-bottom: 1.5rem;
}

/* Composer: the prompt card that starts a cloud agent session ------------
   The prompt grows with what is typed, the effort and model pickers read
   as quiet chips, and the only strong control is the round submit. */

.composer {
    max-width: 46rem;
    margin: 1.5rem auto 2.75rem;
}

.composer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.composer-head .brand {
    margin: 0;
    gap: .7rem;
    font-size: 1.45rem;
}

.composer-head .brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: .6rem;
}

.composer-head .brand-mark svg {
    width: 1.25rem;
    height: 1.25rem;
}

.composer-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.composer-card:focus-within {
    border-color: var(--line-strong);
}

.composer-input {
    display: block;
    min-height: 5.5rem;
    max-height: 60vh;
    padding: 1.15rem 1.35rem .5rem;
    border: 0;
    border-radius: 18px 18px 0 0;
    background: transparent;
    box-shadow: none;
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.55;
    resize: none;
    overflow-y: auto;
}

.composer-input:focus-visible {
    border: 0;
    box-shadow: none;
}

.composer-input:disabled {
    color: var(--muted);
    cursor: not-allowed;
}

.composer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .55rem .7rem .7rem 1rem;
}

.composer-attach {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.composer-attach:hover,
.composer-attach:focus-within {
    background: var(--surface-3);
    color: var(--text-strong);
}

.composer-attach.is-disabled {
    color: var(--faint);
    cursor: not-allowed;
}

.composer-attach input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.composer-attachments {
    display: grid;
    gap: .45rem;
    margin: .8rem 1rem 0;
}

.composer-attachment {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.composer-attachment img {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 8px;
    object-fit: cover;
}

.composer-attachment-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: .1rem;
}

.composer-attachment-copy strong {
    overflow: hidden;
    color: var(--text-strong);
    font-size: .84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-attachment-copy span {
    color: var(--faint);
    font-size: .75rem;
}

.composer-attachment-remove {
    width: 2rem;
    height: 2rem;
    padding: 0;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
}

.composer-attachment-remove:hover {
    background: var(--surface-3);
    color: var(--text-strong);
}

.composer-error {
    margin: 0 1.35rem .25rem;
    color: var(--danger);
    font-size: .8rem;
}

.composer-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    min-width: 0;
}

.composer-submit {
    flex: none;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    justify-content: center;
    border-color: var(--primary);
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
}

.composer-submit:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: var(--on-primary);
}

.composer-submit:disabled {
    border-color: var(--surface-3);
    background: var(--surface-3);
    color: var(--faint);
    cursor: not-allowed;
}

.composer-submit .icon {
    width: 18px;
    height: 18px;
}

.composer-note {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin: 1rem .35rem 0;
    color: var(--muted);
    font-size: .86rem;
}

.composer-note .icon {
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: .15rem;
}

/* The reply box under a transcript: the same sheet as the new-session
   composer (see .composer-sheet in the console stylesheet). */

.composer-reply {
    max-width: 46rem;
    margin: 1.25rem auto 0;
}

.composer-reply .composer-error {
    margin: 0 1.25rem .25rem;
}

.composer-hint {
    margin-right: auto;
    min-width: 0;
    color: var(--faint);
    font-size: .8rem;
}

/* Session page: a full-height chat --------------------------------------
   The session reads like a chat: a sticky header carries the title and the
   status (the vitals sit behind a small details button), the member's
   messages sit in bubbles on the right, the agent's answers are prose on
   the left, and everything the agent did in between — thinking, running
   tools — folds into one quiet worklog card per stretch of work. The
   composer stays docked at the bottom. */

.content:has(> #cloud-session-root) {
    max-width: none;
    padding: 0;
}

#cloud-session-root {
    display: block;
}

.chat {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.chat-top {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: 3.5rem;
    padding: .5rem clamp(1rem, 3vw, 1.6rem);
    border-bottom: 1px solid var(--line-soft);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-back,
.chat-details-trigger {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.chat-back:hover,
.chat-details-trigger:hover,
.chat-details-trigger[aria-expanded="true"] {
    background: var(--surface-3);
    color: var(--text-strong);
}

.chat-back .icon,
.chat-details-trigger .icon {
    width: 18px;
    height: 18px;
}

.chat-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-top-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: .5rem;
}

.chat-stop {
    flex: none;
}

.chat-top .pill {
    font-size: .76rem;
}

/* A running session's dot breathes. */
.chat-top .pill.is-signal::before {
    animation: pulse 1.8s ease-in-out infinite;
}

/* The repository the session works in: name and branch, quiet. The name
   keeps its full length; a long branch name is what gets clipped. */
.chat-repository {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    max-width: 24rem;
    min-width: 0;
    color: var(--muted);
    font-size: .82rem;
    white-space: nowrap;
}

.chat-repository .icon {
    flex: none;
    width: 15px;
    height: 15px;
}

.chat-repository-name {
    flex: none;
    color: var(--text);
}

.chat-repository-branch {
    min-width: 0;
    overflow: hidden;
    color: var(--faint);
    text-overflow: ellipsis;
}

.chat-repository-branch::before {
    content: "·";
    margin-right: .4rem;
}

/* The vitals behind the details button. */
.chat-details {
    position: relative;
    display: inline-flex;
}

.chat-details-popover {
    position: absolute;
    top: calc(100% + .5rem);
    right: 0;
    z-index: 40;
    width: max-content;
    min-width: 18rem;
    max-width: min(28rem, calc(100vw - 2rem));
    padding: .65rem .85rem;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 5%);
    outline: none;
}

.chat-details-popover dl {
    display: grid;
    gap: .4rem;
    margin: 0;
}

.chat-details-row {
    display: flex;
    justify-content: space-between;
    gap: 1.25rem;
    font-size: .82rem;
    line-height: 1.35;
}

.chat-details-row dt {
    flex: none;
    color: var(--muted);
}

.chat-details-row dd {
    min-width: 0;
    margin: 0;
    color: var(--text-strong);
    overflow-wrap: anywhere;
    text-align: right;
}

.chat-details-row code {
    padding: 0;
    background: transparent;
    font-size: .76rem;
}

/* The conversation ------------------------------------------------------ */

.chat-body {
    flex: 1;
    width: min(100%, 53rem);
    margin-inline: auto;
    padding: 1.6rem clamp(1rem, 3vw, 1.6rem) .75rem;
}

.thread {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.msg {
    display: flex;
    gap: .75rem;
}

.msg.is-user {
    justify-content: flex-end;
    margin-top: .5rem;
}

.thread > .msg.is-user:first-child {
    margin-top: 0;
}

.msg-bubble {
    max-width: min(85%, 36rem);
    padding: .7rem 1.05rem;
    border-radius: 1.2rem;
    border-bottom-right-radius: .4rem;
    background: var(--surface-3);
    color: var(--text-strong);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.msg.is-agent {
    align-items: flex-start;
}

.msg-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
    padding-top: .2rem;
}

.msg-prose {
    max-width: 72ch;
    overflow-wrap: anywhere;
}

.msg-prose > :first-child {
    margin-top: 0;
}

.msg-prose > :last-child {
    margin-bottom: 0;
}

/* Agent prose is Markdown: quiet headings, tight lists, soft quotes. */
.msg-prose p {
    margin: 0 0 .7rem;
}

.msg-prose :is(h3, h4, h5) {
    margin: 1.15rem 0 .45rem;
    font-weight: 650;
}

.msg-prose h3 {
    font-size: 1.02rem;
}

.msg-prose h4 {
    font-size: .95rem;
}

.msg-prose h5 {
    font-size: .88rem;
}

.msg-prose :is(ul, ol) {
    margin: 0 0 .7rem;
    padding-left: 1.4rem;
}

.msg-prose :is(ul, ol) :is(ul, ol) {
    margin: .2rem 0 0;
}

.msg-prose li {
    margin: .22rem 0;
}

.msg-prose li::marker {
    color: var(--faint);
}

.msg-prose blockquote {
    margin: 0 0 .7rem;
    padding: .05rem 0 .05rem .9rem;
    border-left: 3px solid var(--line-strong);
    color: var(--muted);
}

.msg-prose blockquote p {
    margin: 0;
}

.msg-prose hr {
    margin: 1.1rem 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.msg-prose .convo-code {
    margin: .2rem 0 .8rem;
}

/* Agent tables are content, not admin data grids: wrap long cells, skip
   hover highlighting, and scroll sideways when a row is wider than the
   prose column. */
:is(.msg-prose, .step-text) .md-table {
    max-width: 100%;
    overflow-x: auto;
}

.msg-prose .md-table {
    margin: 0 0 .7rem;
}

.step-text .md-table {
    margin: 0 0 .4rem;
}

:is(.msg-prose, .step-text) .md-table table {
    width: max-content;
    min-width: 100%;
    font-size: .92em;
    line-height: 1.45;
}

:is(.msg-prose, .step-text) .md-table :is(th, td) {
    padding: .4rem .7rem;
    border: 1px solid var(--line);
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
}

:is(.msg-prose, .step-text) .md-table th {
    background: var(--surface-2);
    color: var(--text-strong);
    font-size: inherit;
    font-weight: 650;
}

:is(.msg-prose, .step-text) .md-table tbody tr:hover td {
    background: transparent;
}

/* When a reply landed and what it cost: there on hover, quiet otherwise. */
.msg-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .6rem;
    margin: 0;
    color: var(--faint);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    transition: opacity .12s ease;
}

.msg:hover .msg-meta,
.msg:focus-within .msg-meta,
.msg.is-error .msg-meta {
    opacity: 1;
}

@media (hover: none) {
    .msg-meta {
        opacity: 1;
    }
}

.msg-time {
    white-space: nowrap;
}

.msg-error {
    max-width: 72ch;
    padding: .7rem .95rem;
    border: 1px solid color-mix(in oklab, var(--danger) 25%, transparent);
    border-radius: var(--radius);
    background: color-mix(in oklab, var(--danger) 5%, transparent);
}

.msg-error-title {
    margin: 0 0 .2rem;
    color: var(--danger-ink);
    font-size: .8rem;
    font-weight: 650;
}

.msg-error-text {
    margin: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.thread-note {
    color: var(--faint);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}

/* Worklog: a stretch of agent work behind one summary line -------------- */

/* The chat draws its own disclosure chrome; undo the console-wide
   details/summary caret, borders, and link colouring. */
.chat details {
    border-top: 0;
}

.chat details > summary::before {
    content: none;
}

.chat details[open] > summary {
    border-bottom: 0;
}

.chat details > summary:hover {
    color: inherit;
}

.worklog > details {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: var(--surface-2);
    transition: background .12s ease, border-color .12s ease;
}

.worklog > details[open] {
    border-color: var(--line);
    background: var(--surface);
}

.worklog-head {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .5rem .8rem;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .82rem;
    font-weight: 500;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.worklog-head::-webkit-details-marker {
    display: none;
}

.chat .worklog-head:hover {
    color: var(--text-strong);
}

.worklog-state {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
}

.worklog-state.is-done {
    color: var(--ok);
}

.worklog-state.is-done .icon {
    width: 14px;
    height: 14px;
}

.worklog-state.is-running {
    width: .8rem;
    height: .8rem;
    margin-inline: .1rem;
    border: 2px solid var(--signal-soft);
    border-top-color: var(--signal);
    border-radius: 50%;
    animation: chat-spin 1s linear infinite;
}

.worklog-state.is-failed {
    color: var(--danger, #b42318);
}

.session-setup-command {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: .8rem;
    overflow-wrap: anywhere;
}

.session-setup-step .step-icon .worklog-state.is-running {
    width: .7rem;
    height: .7rem;
}

.worklog-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.worklog-count {
    flex: none;
    margin-left: auto;
    color: var(--faint);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}

.worklog-caret {
    display: inline-flex;
    flex: none;
    color: var(--faint);
    transition: transform .15s ease;
}

.worklog-caret .icon {
    width: 14px;
    height: 14px;
}

.worklog > details[open] > .worklog-head .worklog-caret {
    transform: rotate(180deg);
}

.worklog-steps {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: .3rem .5rem .45rem;
    border-top: 1px solid var(--line-soft);
    list-style: none;
}

.step.is-thinking {
    display: flex;
    gap: .6rem;
    padding: .4rem .45rem;
    color: var(--muted);
    font-size: .88rem;
}

.step-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    margin-top: .1rem;
    color: var(--faint);
}

.step-icon .icon {
    width: 14px;
    height: 14px;
}

.step-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Thinking summaries are Markdown too, scaled down to step size. */
.step-text > :first-child {
    margin-top: 0;
}

.step-text > :last-child {
    margin-bottom: 0;
}

.step-text p {
    margin: 0 0 .4rem;
}

.step-text :is(h3, h4, h5) {
    margin: .55rem 0 .25rem;
    color: inherit;
    font-size: inherit;
    font-weight: 650;
}

.step-text :is(ul, ol) {
    margin: .2rem 0 .4rem;
    padding-left: 1.2rem;
}

.step-text li {
    margin: .15rem 0;
}

.step-text .convo-code {
    margin: .3rem 0 .5rem;
}

.step.is-tool > details {
    border: 0;
    background: transparent;
}

.step-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem .45rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.step-row::-webkit-details-marker {
    display: none;
}

.step-row:hover {
    background: var(--surface-3);
}

.step-row .step-icon {
    margin-top: 0;
}

.step.is-running .step-icon {
    color: var(--signal);
}

.step-name {
    flex: none;
    padding: 0;
    background: transparent;
    border-radius: 0;
    color: var(--text-strong);
    font-size: .8rem;
    font-weight: 600;
}

.step-preview {
    flex: 1 1 6rem;
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.step-state {
    flex: none;
    margin-left: auto;
    color: var(--faint);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.step-state.is-running {
    color: var(--signal-ink);
}

.step-body {
    padding: .2rem .45rem .65rem 2.2rem;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.tool-section + .tool-section,
.tool-section + .convo-note {
    margin-top: .6rem;
}

.tool-label {
    color: var(--faint);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tool-section .convo-code {
    margin: 0;
}

/* What a running session is doing right now, and what it asks of you ---- */

.chat-activity {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 1.1rem 0 0;
    color: var(--muted);
    font-size: .85rem;
}

.chat-activity-dot {
    flex: none;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--signal);
    animation: pulse 1.8s ease-in-out infinite;
}

.chat-activity-text {
    background: linear-gradient(90deg, var(--muted) 30%, var(--text-strong) 50%, var(--muted) 70%);
    background-clip: text;
    background-size: 200% 100%;
    -webkit-background-clip: text;
    color: transparent;
    animation: chat-shimmer 2.2s linear infinite;
}

.approval {
    margin: 1.1rem 0 0;
    padding: .9rem 1rem;
    border: 1px solid color-mix(in oklab, var(--warn) 35%, transparent);
    border-radius: var(--radius);
    background: color-mix(in oklab, var(--warn) 6%, transparent);
    box-shadow: var(--shadow);
}

.approval-head {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .4rem;
    color: var(--warn-ink);
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.approval-head .icon {
    width: 15px;
    height: 15px;
}

.approval-prompt {
    margin: 0 0 .6rem;
    overflow-wrap: anywhere;
}

.approval-input {
    width: 100%;
    min-height: 3.4rem;
    font-family: var(--font-ui);
    font-size: .9rem;
    resize: vertical;
}

.approval-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .6rem;
}

.plan-request {
    margin: 1.1rem 0 0;
    padding: 1rem 1.05rem 1.05rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.plan-request-head {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: var(--signal-ink);
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.plan-request-head .icon {
    width: 15px;
    height: 15px;
}

.plan-request-title {
    margin: .4rem 0 .7rem;
    color: var(--text-strong);
    font-size: 1.12rem;
    font-weight: 650;
    line-height: 1.3;
}

.plan-request-reason,
.plan-request-question {
    margin: 0 0 .85rem;
}

.plan-request-document {
    max-height: 22rem;
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    overflow: auto;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.plan-request-document.msg-prose,
.plan-request-reason.msg-prose,
.plan-request-question.msg-prose {
    max-width: none;
}

.plan-request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.plan-request-actions.is-stack {
    flex-direction: column;
}

.plan-request-choice {
    width: 100%;
    justify-content: flex-start;
    min-height: 2.6rem;
    padding-block: .7rem;
    white-space: normal;
    text-align: left;
    line-height: 1.35;
}

.plan-request-choice[aria-pressed="true"] {
    border-color: var(--signal);
    background: var(--signal-soft);
}

.plan-request-notes {
    display: grid;
    gap: .5rem;
    margin-top: .9rem;
    padding-top: .9rem;
    border-top: 1px solid var(--line-soft);
}

.plan-request-notes label {
    color: var(--text-strong);
    font-size: .88rem;
    font-weight: 600;
}

.plan-request-notes .btn {
    justify-self: start;
}

.plan-request .msg-error-text {
    margin: .7rem 0 0;
}

/* The docked composer --------------------------------------------------- */

.chat-dock {
    position: sticky;
    bottom: 0;
    z-index: 25;
    margin-top: auto;
    padding: 1.1rem 0 .95rem;
    background: linear-gradient(to top, var(--bg) 72%, transparent);
}

/* Same width and side padding as the conversation, so the reply box lines
   up with the prose above it. */
.chat-dock-inner {
    width: min(100%, 53rem);
    margin-inline: auto;
    padding-inline: clamp(1rem, 3vw, 1.6rem);
}

.chat-dock .composer-reply {
    max-width: none;
    margin: 0;
}

@keyframes chat-spin {
    to { transform: rotate(360deg); }
}

@keyframes chat-shimmer {
    from { background-position: 130% 0; }
    to { background-position: -130% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-activity-text {
        animation: none;
        background: none;
        color: var(--muted);
    }

    .worklog-state.is-running {
        animation-duration: 2.5s;
    }
}

@media (max-width: 640px) {
    .msg-bubble {
        max-width: 92%;
    }

    .chat-repository {
        display: none;
    }

    .step-preview {
        display: none;
    }
}

/* Stat cards ------------------------------------------------------------- */

.rail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.rail-item {
    padding: 1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.rail-label {
    display: block;
    margin-bottom: .3rem;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 500;
}

.rail-value {
    color: var(--text-strong);
    font-size: 1.55rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

.rail-note {
    margin-left: .45rem;
    color: var(--muted);
    font-size: .8rem;
}

.rail-note.is-warn {
    color: var(--warn-ink);
}

.rail-note.is-danger {
    color: var(--danger-ink);
}

/* Panels ----------------------------------------------------------------- */

.panel {
    margin-bottom: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    column-gap: .9rem;
    row-gap: .3rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line-soft);
}

.panel-title {
    margin: 0;
    font-size: .97rem;
    font-weight: 600;
}

.panel-note {
    margin: 0;
    color: var(--muted);
    font-size: .86rem;
}

.panel-count {
    margin-left: auto;
    color: var(--faint);
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.panel-body {
    padding: 1.25rem;
}

.panel-body > :first-child {
    margin-top: 0;
}

.panel-body > :last-child {
    margin-bottom: 0;
}

/* Tables ----------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    line-height: 1.4;
}

th {
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    background: var(--surface-2);
    color: var(--muted);
    font-size: .8rem;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

th:first-child,
td:first-child {
    padding-left: 1.25rem;
}

th:last-child,
td:last-child {
    padding-right: 1.25rem;
}

tbody tr:last-child td {
    border-bottom: 0;
}

/* A form inside a cell lays its control and button out side by side. */
td > form {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
}

td select {
    width: auto;
    min-width: 8rem;
}

tbody tr:hover td {
    background: var(--surface-2);
}

.num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.mono {
    font-family: var(--font-mono);
    font-size: .92em;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: .05rem;
    min-width: 0;
}

.name {
    color: var(--text-strong);
    font-weight: 600;
}

.id {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: .8rem;
}

.muted {
    color: var(--muted);
}

.error-text {
    display: block;
    max-width: 24rem;
    margin-top: .25rem;
    color: var(--danger-ink);
    font-size: .82rem;
    word-break: break-word;
}

.cell-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .4rem;
}

.time {
    display: inline-flex;
    gap: .4rem;
    color: var(--faint);
    font-size: .84rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.time b {
    color: var(--text);
    font-weight: 500;
}

/* Pills and provider marks ----------------------------------------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
}

.pill::before {
    content: "";
    flex: none;
    width: .4rem;
    height: .4rem;
    border-radius: 50%;
    background: currentColor;
}

.pill.is-ok {
    background: color-mix(in oklab, var(--ok) 11%, transparent);
    color: var(--ok-ink);
}

.pill.is-warn {
    background: color-mix(in oklab, var(--warn) 12%, transparent);
    color: var(--warn-ink);
}

.pill.is-danger {
    background: color-mix(in oklab, var(--danger) 10%, transparent);
    color: var(--danger-ink);
}

.pill.is-signal {
    background: var(--signal-soft);
    color: var(--signal-ink);
}

.provider {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    color: var(--text);
    font-size: .9rem;
    white-space: nowrap;
}

.provider::before {
    content: "";
    flex: none;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--faint);
}

.provider.is-openai::before {
    background: var(--ok);
}

.provider.is-xai::before {
    background: var(--violet);
}

.provider.is-anthropic::before {
    background: var(--warn);
}

.provider.is-openrouter::before {
    background: var(--signal);
}

.provider.is-gmail::before {
    background: #4285f4;
}

.provider.is-microsoft::before {
    background: #00a4ef;
}

.provider.is-imap::before {
    background: var(--violet);
}

/* Meters ----------------------------------------------------------------- */

.meter {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 9rem;
}

.meter-track {
    position: relative;
    flex: 1;
    height: .4rem;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

/* Where evenly-paced consumption would sit right now. */
.meter-pace {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: var(--text-strong);
    opacity: .5;
}

.meter-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--signal);
}

.meter-value {
    min-width: 2.6rem;
    color: var(--muted);
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.meter.is-ok .meter-fill {
    background: var(--ok);
}

.meter.is-warn .meter-fill {
    background: var(--warn);
}

.meter.is-danger .meter-fill {
    background: var(--danger);
}

.usage-cell {
    min-width: 13rem;
}

.usage-note {
    display: block;
    margin-top: .15rem;
    color: var(--faint);
    font-size: .78rem;
}

.usage-note.is-danger {
    color: var(--danger-ink);
}

.usage-note.is-ok {
    color: var(--ok-ink);
}

.window-cell {
    min-width: 12rem;
}

/* Routing matrix --------------------------------------------------------- */

.matrix-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .65rem 1.25rem;
    border-bottom: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: .82rem;
}

.matrix-legend span {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.matrix-legend span::before {
    content: "";
    width: .75rem;
    height: .75rem;
    border: 1.5px solid var(--line-strong);
    border-radius: 50%;
}

.matrix-legend span.is-patched::before {
    border-color: var(--signal);
    background: var(--signal);
}

.matrix th.matrix-col {
    padding: .6rem .5rem;
    color: var(--text);
    font-size: .82rem;
    text-align: center;
    vertical-align: bottom;
}

.matrix-col-name {
    display: block;
    max-width: 8rem;
    margin-inline: auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matrix-col .provider {
    justify-content: center;
    color: var(--faint);
    font-size: .74rem;
}

.matrix th.matrix-row {
    width: 1%;
    padding: .6rem 1.25rem;
    border-bottom: 1px solid var(--line-soft);
    background: transparent;
    color: var(--text-strong);
    font-size: .9rem;
    font-weight: 600;
}

.matrix th.matrix-row span {
    display: block;
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: .74rem;
    font-weight: 400;
}

.matrix tbody tr:last-child th.matrix-row {
    border-bottom: 0;
}

.socket-cell {
    position: relative;
    height: 2.6rem;
    padding: 0 .5rem;
    text-align: center;
}

.socket-cell::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: 1px;
    background: var(--line-soft);
}

.socket-cell.is-patched::before {
    background: color-mix(in oklab, var(--signal) 40%, transparent);
}

.socket {
    position: relative;
    width: 1.15rem;
    height: 1.15rem;
    padding: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: none;
    cursor: pointer;
}

.socket:hover {
    border-color: var(--signal);
    background: var(--signal-soft);
}

.socket.is-patched {
    border-color: var(--signal);
    background: var(--signal);
    box-shadow: 0 0 0 3px var(--signal-soft);
}

.socket.is-patched:hover {
    background: var(--signal-hover);
}

/* Event feed ------------------------------------------------------------- */

.feed {
    margin: 0;
    padding: 0;
    list-style: none;
}

.feed li {
    display: grid;
    grid-template-columns: 9.5rem 13rem 1fr;
    gap: .9rem;
    align-items: baseline;
    padding: .65rem 1.25rem;
    border-bottom: 1px solid var(--line-soft);
}

.feed li:last-child {
    border-bottom: 0;
}

.feed li:hover {
    background: var(--surface-2);
}

.feed-subject {
    margin-right: .5rem;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .8rem;
}

.feed-detail {
    color: var(--muted);
    font-size: .86rem;
    word-break: break-word;
}

/* Forms ------------------------------------------------------------------ */

form {
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1rem;
    align-items: end;
}

.form-grid.is-stacked {
    grid-template-columns: 1fr;
}

.connect-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: .75rem;
}

.connect-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
    padding: 1rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.connect-option > span {
    color: var(--muted);
    font-size: .88rem;
}

.connect-option > button {
    margin-top: .25rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    min-width: 0;
}

.field-label {
    color: var(--text);
    font-size: .84rem;
    font-weight: 500;
}

.field-wide {
    grid-column: 1 / -1;
}

input,
select,
textarea {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-strong);
    font: inherit;
    font-size: .92rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--signal);
    box-shadow: 0 0 0 3px var(--signal-soft);
}

input::placeholder,
textarea::placeholder {
    color: var(--faint);
}

input[type="number"] {
    font-variant-numeric: tabular-nums;
}

.permission-grid {
    display: grid;
    gap: .5rem;
    min-width: 28rem;
}

.permission-client {
    display: grid;
    grid-template-columns: minmax(9rem, 1fr) auto auto auto;
    align-items: center;
    gap: .75rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--line-soft);
}

.permission-client:last-child {
    border-bottom: 0;
}

.permission-client-name {
    min-width: 0;
}

.permission-check {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: var(--text);
    font-size: .84rem;
    white-space: nowrap;
}

.permission-check input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--signal);
}

textarea {
    min-height: 9rem;
    font-family: var(--font-mono);
    font-size: .84rem;
    resize: vertical;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-strong);
    font: inherit;
    font-size: .88rem;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}

button:hover,
.btn:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
    color: var(--text-strong);
    text-decoration: none;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: var(--on-primary);
}

.btn-quiet {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.btn-quiet:hover {
    border-color: transparent;
    background: var(--surface-3);
}

.btn-danger:hover {
    border-color: color-mix(in oklab, var(--danger) 45%, transparent);
    color: var(--danger-ink);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding-block: .65rem;
}

.action-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    padding: 1.1rem 1.25rem;
    border-top: 1px solid var(--line-soft);
}

.count-value {
    color: var(--text-strong);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.status-note {
    font-size: .86rem;
}

.auth-card .status-note {
    display: block;
    min-height: 1.2em;
    margin: .75rem 0 0;
}

.auth-card details {
    margin-top: 1.25rem;
    border-top: 1px solid var(--line-soft);
}

.auth-card details > summary {
    padding: .7rem 0;
}

.auth-card .details-body {
    padding: .35rem 0 0;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: .9rem;
}

.inline {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.limit-form input {
    width: 8.5rem;
}

/* Disclosures ------------------------------------------------------------ */

details {
    border-top: 1px solid var(--line-soft);
}

.panel-head + details {
    border-top: 0;
}

details > summary {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .8rem 1.25rem;
    color: var(--signal-ink);
    font-size: .88rem;
    font-weight: 500;
    list-style: none;
    cursor: pointer;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::before {
    content: "";
    flex: none;
    width: .42rem;
    height: .42rem;
    margin-left: .1rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform .12s ease;
}

details[open] > summary::before {
    transform: rotate(45deg);
}

details > summary:hover {
    color: var(--signal-hover);
}

details[open] > summary {
    border-bottom: 1px solid var(--line-soft);
}

.details-body {
    padding: 1.25rem;
}

/* Disclosures that sit next to buttons in a table cell look like one. */
.cell-actions details {
    border-top: 0;
}

.cell-actions details > summary {
    padding: .5rem .85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-strong);
}

.cell-actions details > summary::before {
    display: none;
}

.cell-actions details > summary:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
}

.cell-actions details[open] > summary {
    border-bottom: 1px solid var(--line);
}

.cell-actions .details-body {
    padding: 1rem 0 .25rem;
    text-align: left;
}

/* Conversation ------------------------------------------------------------
   A stored turn read as a transcript. Role labels are colour-coded like
   pills; message prose stays in sans. Tool traffic keeps its JSON in small
   mono blocks. */

.convo {
    padding: .3rem 0 .55rem;
}

.convo-section {
    padding: .45rem 0 .6rem;
}

.convo-section + .convo-section {
    border-top: 1px solid var(--line-soft);
}

.convo-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .9rem;
    padding: .5rem 1.25rem .15rem;
}

.convo-section-title {
    margin: 0;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
}

.convo-tokens {
    color: var(--faint);
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.convo-turn {
    padding: .6rem 1.25rem .4rem;
}

.convo-role {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: 0 0 .3rem;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
}

.convo-role::before {
    content: "";
    flex: none;
    width: .4rem;
    height: .4rem;
    border-radius: 50%;
    background: currentColor;
}

.convo-role.is-user {
    color: var(--signal-ink);
}

.convo-role.is-assistant {
    color: var(--ok-ink);
}

.convo-role.is-system {
    color: var(--warn-ink);
}

.convo-role.is-tool {
    color: var(--violet);
}

.convo-role-detail {
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: .78rem;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.convo-content {
    max-width: 74ch;
}

.convo-text {
    margin: 0 0 .55rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.convo-text:last-child {
    margin-bottom: 0;
}

.convo-refusal {
    color: var(--danger-ink);
}

.convo-attachment {
    display: inline-flex;
    margin: 0 0 .55rem;
    padding: .2rem .55rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: .82rem;
}

.convo-note {
    margin: 0;
    color: var(--muted);
    font-size: .86rem;
}

.convo-empty {
    margin: 0;
    padding: .2rem 1.25rem .4rem;
    color: var(--muted);
    font-size: .86rem;
}

.convo-code {
    max-height: 16rem;
    margin: .15rem 0 .55rem;
    padding: .65rem .8rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* A code element inside a code block is structure, not an inline chip. */
.convo-code code {
    padding: 0;
    border-radius: 0;
    background: transparent;
    font-size: inherit;
}

.convo-code:last-child {
    margin-bottom: 0;
}

/* Payloads --------------------------------------------------------------- */

.payload-wrap {
    position: relative;
}

pre.payload {
    max-height: 30rem;
    margin: 0;
    padding: .9rem 1rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.copy-btn {
    position: absolute;
    top: .5rem;
    right: .5rem;
    opacity: 0;
}

.payload-wrap:hover .copy-btn,
.copy-btn:focus-visible {
    opacity: 1;
}

.kv {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    margin: 0;
}

.kv > div {
    min-width: 0;
    padding: .7rem 1.25rem;
    border-bottom: 1px solid var(--line-soft);
}

.kv > div:last-child {
    border-bottom: 0;
}

.kv dt {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 500;
}

.kv dd {
    margin: .2rem 0 0;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .84rem;
    word-break: break-word;
}

/* Empty states and alerts ------------------------------------------------ */

.empty {
    padding: 2.75rem 1.25rem;
    color: var(--muted);
    text-align: center;
}

.empty strong {
    display: block;
    margin-bottom: .2rem;
    color: var(--text-strong);
    font-weight: 600;
}

.alert {
    margin-bottom: 1rem;
    padding: .65rem .85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: .88rem;
}

.alert-error {
    border-color: color-mix(in oklab, var(--danger) 35%, transparent);
    background: color-mix(in oklab, var(--danger) 8%, transparent);
    color: var(--danger-ink);
}

/* Server-side filters (logs page) ---------------------------------------- */

.filter-bar {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.filter-bar .field {
    flex: 0 1 auto;
}

.filter-bar select {
    width: auto;
    min-width: 12rem;
}

/* Filter (progressive enhancement on the logs table) --------------------- */

.filter {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-left: auto;
}

.filter input {
    width: 15rem;
    padding: .4rem .65rem;
    font-size: .86rem;
}

.filter-count {
    color: var(--faint);
    font-size: .8rem;
    white-space: nowrap;
}

/* Centered pages: sign in, invitation, device login ---------------------- */

.auth {
    display: grid;
    min-height: 100dvh;
    padding: 2rem 1.25rem;
    background: var(--sidebar-bg);
    place-items: center;
}

.auth-card {
    width: min(28rem, 100%);
    padding: 2.25rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.auth-card > .brand {
    margin-bottom: 1.75rem;
}

.auth-card h1 {
    margin: 0 0 .4rem;
    font-size: 1.4rem;
    letter-spacing: -.02em;
}

.auth-card .lede {
    margin-bottom: 1.5rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1rem 0;
    color: var(--muted);
    font-size: .82rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--line-soft);
}

.secret {
    margin: 0 0 1.1rem;
    padding: .9rem 1rem;
    border: 1px dashed color-mix(in oklab, var(--signal) 55%, var(--line));
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-size: .95rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

p.field-label {
    display: block;
    margin: 1.25rem 0 .45rem;
}

.copy-inline {
    margin: -.35rem 0 1.1rem;
}

.secret.is-code {
    font-size: 1.9rem;
    letter-spacing: .22em;
    text-align: center;
    word-break: normal;
}

/* Downloads: numbered install steps and copyable shell commands ---------- */

.install-steps {
    display: grid;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    counter-reset: step;
    list-style: none;
}

.install-steps > li {
    display: grid;
    grid-template-columns: 1.7rem minmax(0, 1fr);
    column-gap: .9rem;
    align-items: start;
}

.install-steps > li::before {
    content: counter(step);
    counter-increment: step;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    margin-top: .05rem;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-strong);
    font-size: .8rem;
    font-weight: 600;
}

.install-steps > li > * {
    grid-column: 2;
}

.install-steps > li > p {
    margin: .25rem 0 .55rem;
}

.install-steps .step-note {
    margin: .7rem 0 0;
    color: var(--muted);
    font-size: .88rem;
}

.step-footer {
    margin: 1.4rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--line-soft);
    font-size: .88rem;
}

.command-wrap {
    position: relative;
}

pre.command {
    margin: 0;
    padding: .8rem 6.5rem .8rem 2.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-size: .86rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

pre.command::before {
    content: "$";
    position: absolute;
    left: .95rem;
    color: var(--faint);
    user-select: none;
}

.command-wrap .copy-btn {
    top: .45rem;
    right: .45rem;
    opacity: 1;
}

/* App banners: one installable app per card, the whole card the link ----- */

.app-banners {
    display: grid;
    gap: .75rem;
}

.app-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.2rem .85rem .95rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}

a.app-banner:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    text-decoration: none;
}

.app-banner-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.9rem;
    height: 2.9rem;
    border-radius: .85rem;
    background: var(--primary);
    color: #ffffff;
}

.app-banner-icon .icon {
    width: 1.45rem;
    height: 1.45rem;
}

.app-banner-text {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
    line-height: 1.35;
}

.app-banner-title {
    color: var(--text-strong);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.app-banner-detail {
    color: var(--muted);
    font-size: .88rem;
}

.app-banner.is-unpublished {
    background: var(--surface-2);
    box-shadow: none;
}

.app-banner.is-unpublished .app-banner-icon {
    background: var(--surface-3);
    color: var(--faint);
}

.app-banner.is-unpublished .app-banner-title {
    color: var(--muted);
}

/* The desktop app floats at the foot of the overview, centered on the
   content column beside the sidebar. */
.app-banner-dock {
    position: fixed;
    right: 0;
    bottom: 1.5rem;
    left: 262px;
    z-index: 5;
    display: flex;
    justify-content: center;
    padding: 0 1.25rem;
    pointer-events: none;
}

.app-banner-dock .app-banner {
    width: min(100%, 38rem);
    padding: 1rem 1.5rem 1rem 1.15rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

.app-banner-dock .app-banner-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 1rem;
}

.app-banner-dock .app-banner-icon .icon {
    width: 1.6rem;
    height: 1.6rem;
}

.app-banner-dock .app-banner-title {
    font-size: 1.1rem;
}

.app-banner-dock .app-banner-detail {
    font-size: .95rem;
}

/* Keep the last rows of the page reachable above the floating banner. */
.content:has(> .app-banner-dock) {
    padding-bottom: 9.5rem;
}

.status-line {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem .85rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: .88rem;
}

.status-line::before {
    content: "";
    flex: none;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--signal);
    animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--signal-soft); }
    50% { opacity: .5; box-shadow: 0 0 0 4px transparent; }
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 900px) {
    .app {
        display: block;
    }

    .sidebar {
        position: static;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: .15rem;
        width: auto;
        height: auto;
        padding: .6rem .75rem;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow: visible;
    }

    .workspace {
        margin-right: .5rem;
        padding: .25rem .5rem;
    }

    .sidenav {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: .15rem;
    }

    .sidenav-link {
        width: auto;
        padding: .4rem .55rem;
    }

    .sidenav-label {
        margin: 0 .35rem;
    }

    .sidebar-foot {
        flex-direction: row;
        align-items: center;
        margin-top: 0;
        margin-left: auto;
        padding-top: 0;
    }

    .sidebar-brand {
        display: none;
    }

    .content {
        padding: 1.5rem 1rem 4rem;
    }

    .sidebar-sessions {
        flex-basis: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: .15rem;
        margin-top: .35rem;
        padding-top: .35rem;
    }

    .sidebar-sessions-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: .15rem;
    }

    .session-link {
        max-width: 14rem;
    }

    .hero {
        margin-top: .5rem;
    }

    .hero-card-foot {
        align-items: flex-start;
        flex-direction: column;
    }

    .composer {
        margin-top: .5rem;
    }

    .composer-head {
        flex-wrap: wrap;
    }

    .composer-bar {
        flex-wrap: wrap;
    }

    .app-banner-dock {
        left: 0;
        bottom: 1rem;
        padding: 0 1rem;
    }

    .app-banner-dock .app-banner {
        padding: .85rem 1.1rem .85rem .9rem;
    }

    .feed li {
        grid-template-columns: 1fr;
        gap: .2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
