/* hello chat: workspace layout, thread, composer, artifact panel and settings.
   Built on intel's tokens (style.css); every color is a theme token. */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chat-main { min-height: 0; }

/* Chat pages are one viewport tall: the masthead takes what it needs (two rows on a phone) and the
   workspace fills the rest, so the composer never falls below the fold. */
body:has(.chat-app) { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body:has(.chat-app) .chat-main { flex: 1 1 auto; display: flex; flex-direction: column; }

.icon-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
    border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; color: var(--text-dim);
    cursor: pointer; transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.icon-btn:focus-visible, .chat-list button:focus-visible { outline: none; box-shadow: var(--focus); }

/* --- layout ------------------------------------------------------------- */

/* The chat is an app, not a page: the site masthead steps aside and the brand moves into the sidebar. */
body:has(.chat-app) .masthead { display: none; }

.chat-app {
    --sidebar-w: 268px;
    display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    flex: 1 1 auto; min-height: 0;
    transition: grid-template-columns var(--ease-out);
}
.chat-app.has-panel { grid-template-columns: var(--sidebar-w) minmax(360px, 1fr) minmax(380px, 1.15fr); }
.chat-app.is-collapsed { --sidebar-w: 0px; }
.chat-app.is-collapsed .chat-sidebar { visibility: hidden; }

.chat-sidebar {
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
    border-right: 1px solid var(--rule); background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.chat-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 6px 16px; min-height: 56px; }
.chat-brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.chat-brand:hover { text-decoration: none; }
.chat-brand .chat-brand-glyph { width: 24px; height: 24px; overflow: visible; }
.chat-brand .brand-wordmark-svg { height: 17px; }
.chat-brand:hover .brand-wordmark-svg { color: var(--accent); }

.chat-new {
    display: flex; align-items: center; gap: 10px; margin: 6px 10px 10px; padding: 7px 10px;
    border: 0; border-radius: var(--radius-s); background: none; cursor: pointer;
    font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink); text-align: left;
    transition: background var(--ease);
}
.chat-new:hover:not(:disabled) { background: var(--surface-2); }
.chat-new:disabled { opacity: .5; cursor: default; }
.chat-new:focus-visible { outline: none; box-shadow: var(--focus); }
.chat-new-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ip-mark); color: #fff; }

.chat-list-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 8px 12px; scrollbar-width: thin; }
.chat-group + .chat-group { margin-top: 14px; }
.chat-group-label { margin: 0; padding: 6px 10px 4px; font-family: var(--meta); font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--text-mute); }
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-list li { position: relative; display: flex; align-items: center; border-radius: var(--radius-s); transition: background var(--ease); }
.chat-list li:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.chat-list li.is-active { background: var(--surface-2); }
.chat-list-open {
    flex: 1 1 auto; min-width: 0; padding: 7px 10px; border: 0; background: none; text-align: left; cursor: pointer;
    font: inherit; font-size: var(--fs-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-list li:hover .chat-list-open, .chat-list li:focus-within .chat-list-open { -webkit-mask-image: linear-gradient(90deg, #000 70%, transparent); mask-image: linear-gradient(90deg, #000 70%, transparent); }
.chat-list li.is-active .chat-list-open { color: var(--ink); font-weight: var(--fw-medium); }
.chat-list-tools { position: absolute; right: 4px; display: none; gap: 0; }
.chat-list li:hover .chat-list-tools, .chat-list li:focus-within .chat-list-tools { display: inline-flex; }
.chat-list-tools button { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-mute); cursor: pointer; }
.chat-list-tools button:hover { color: var(--ink); background: var(--surface); }
.chat-list form { flex: 1; padding: 3px; }
.chat-list input { width: 100%; font: inherit; font-size: var(--fs-sm); padding: 5px 8px; border: 1px solid var(--rule-2); border-radius: var(--radius-xs); background: var(--surface); color: var(--ink); outline: none; }
.chat-list-empty { margin: 0; padding: 10px; color: var(--text-mute); font-size: var(--fs-sm); line-height: 1.5; }

.chat-sidebar-foot { display: flex; gap: 4px; padding: 8px; border-top: 1px solid var(--rule); }
.chat-foot-link {
    flex: 1 1 0; display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-s);
    font-size: var(--fs-sm); color: var(--text-dim); text-decoration: none; transition: background var(--ease), color var(--ease);
}
.chat-foot-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }

.chat-center { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-bar { display: flex; align-items: center; gap: 6px; padding: 8px 16px 8px 12px; min-height: 56px; position: relative; z-index: 2; }
.chat-sidebar-toggle, .chat-bar-new { display: none; }
.chat-app.is-collapsed .chat-sidebar-toggle, .chat-app.is-collapsed .chat-bar-new { display: inline-grid; }
.chat-title { flex: 1 1 auto; min-width: 0; margin: 0 0 0 6px; font-family: var(--sans); font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-scroll { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 12px 24px 28px; scroll-padding-bottom: 24px; }
/* The thread fades out above the composer instead of stopping at a hard edge. */
.chat-center:not(.is-empty) .chat-scroll { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }

/* A new chat: greeting and composer sit together in the middle, with starters underneath. */
.chat-center.is-empty .chat-scroll { flex: 0 0 auto; overflow: visible; padding-top: 0; padding-bottom: 20px; margin-top: auto; }
.chat-center.is-empty .chat-suggest { margin-bottom: auto; }
.chat-center.is-empty { padding-bottom: 8vh; }
.chat-empty { display: grid; justify-items: center; gap: 10px; margin: 0 auto; max-width: 52ch; text-align: center; color: var(--text-dim); }
.chat-empty innerpulse-mark { display: block; width: 64px; }
.chat-greeting { margin: 0; font-family: var(--serif); font-size: clamp(1.9rem, 3.2vw, 2.5rem); font-weight: 700; letter-spacing: var(--track-tighter); color: var(--ink); line-height: var(--leading-title); }
.chat-empty p { margin: 0; line-height: var(--leading-ui); }
.chat-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: calc(100% - 48px); max-width: 760px; margin: 14px auto 0; }
.chat-suggest button {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px 7px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface);
    font: inherit; font-size: var(--fs-sm); color: var(--text-dim); cursor: pointer;
    transition: border-color var(--ease), color var(--ease), background var(--ease);
}
.chat-suggest button:hover { border-color: var(--rule-2); color: var(--ink); background: var(--surface-2); }
.chat-suggest button:focus-visible { outline: none; box-shadow: var(--focus); }

.chat-jump {
    position: absolute; left: 50%; bottom: calc(100% + 14px); z-index: 3; margin-left: -17px;
    display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--rule-2); border-radius: 50%;
    background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: pointer;
    animation: msg-in 160ms ease-out;
}
.chat-jump:hover { color: var(--ink); border-color: var(--text-mute); }

/* --- thread ------------------------------------------------------------- */

.thread { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.msg { animation: msg-in 220ms ease-out both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg-user { position: relative; display: flex; flex-direction: column; align-items: flex-end; }
.msg-user-body {
    max-width: min(85%, 620px); padding: 10px 16px; border-radius: 20px 20px 6px 20px;
    background: var(--surface-2); color: var(--ink);
    white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--leading-ui);
}
.msg-user-tag { margin: 0 6px 4px 0; font-size: var(--fs-xs); color: var(--text-mute); }
.msg-user.is-queued .msg-user-body { background: transparent; border: 1px dashed var(--rule); color: var(--text); }
.msg-assistant { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* Chat replies read like intel, a size down from its article body. */
.msg-md { font-family: var(--serif); font-size: var(--fs-lg); line-height: 1.7; color: var(--text); overflow-wrap: anywhere; }
.msg-md > :first-child { margin-top: 0; }
.msg-md > :last-child { margin-bottom: 0; }
.msg-md p, .msg-md ul, .msg-md ol { margin: 0 0 .85em; }
.msg-md ul, .msg-md ol { padding-left: 1.4em; }
.msg-md li { margin-bottom: .3em; }
.msg-md li::marker { color: var(--text-mute); }
.msg-md h1, .msg-md h2, .msg-md h3, .msg-md h4 { font-family: var(--serif); color: var(--ink); line-height: var(--leading-heading); margin: 1.3em 0 .5em; letter-spacing: var(--track-tight); }
.msg-md h1 { font-size: var(--fs-4xl); } .msg-md h2 { font-size: var(--fs-3xl); } .msg-md h3 { font-size: var(--fs-2xl); } .msg-md h4 { font-size: var(--fs-lg); }
.msg-md strong { color: var(--ink); }
.msg-md a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.msg-md blockquote { margin: 0 0 .85em; padding-left: 14px; border-left: 2px solid var(--rule-2); color: var(--text-dim); }
.msg-md code { font-family: var(--mono); font-size: .84em; background: var(--surface-2); border-radius: var(--radius-xs); padding: 1px 5px; color: var(--ink); }

/* Fenced code: a header bar with the language and a copy button, then the code. */
.code-block { margin: 0 0 1em; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }
.code-block-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 14px;
    border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--surface-2) 60%, var(--surface));
    font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute);
}
.code-copy { display: inline-grid; place-items: center; width: 28px; height: 26px; border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-mute); cursor: pointer; }
.code-copy:hover { background: var(--surface); color: var(--ink); }
.code-copy.is-done { color: var(--ok); }
.code-block pre, .msg-md pre {
    margin: 0; padding: 14px 16px; overflow-x: auto; background: none; border: 0;
    font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6;
}
.code-block pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.article-body.code-only .code-block { margin: 0; border: 0; border-radius: 0; background: none; }
.article-body.code-only .code-block-head { position: sticky; top: 0; z-index: 1; }
.article-body.code-only pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-md hr { border: 0; border-top: 1px solid var(--rule); margin: 1.3em 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--rule); border-radius: var(--radius); }
.msg-md table { overflow-wrap: normal; border-collapse: collapse; font-family: var(--sans); font-size: var(--fs-sm); min-width: 100%; }
.msg-md th, .msg-md td { padding: 8px 14px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.msg-md tr:last-child td { border-bottom: 0; }
.msg-md th { font-weight: var(--fw-semibold); color: var(--ink); background: var(--surface-2); }

.msg-note { margin: 0; font-family: var(--meta); font-size: var(--fs-sm); color: var(--text-mute); }
.msg-resume { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 760px; width: 100%; margin: 0 auto; }
.msg-notice { max-width: 760px; width: 100%; margin: 0 auto; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--rule)); border-radius: var(--radius-s); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); color: var(--text); }

/* Message actions: quiet until the message is hovered (always shown on the latest reply and on touch). */
.msg-foot { display: flex; align-items: center; gap: 2px; min-height: 28px; margin-left: -6px; opacity: 0; transition: opacity var(--ease); }
.msg-foot-user { position: absolute; top: 100%; right: 0; margin: 2px -6px 0 0; }
.msg:hover .msg-foot, .msg-foot:focus-within, .msg-foot.is-last { opacity: 1; }
@media (hover: none) { .msg-foot { opacity: 1; } }
.msg-model { margin-left: 8px; font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); }
.msg-action { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; background: none; border-radius: var(--radius-s); color: var(--text-mute); cursor: pointer; transition: background var(--ease), color var(--ease); }
.msg-action:hover { background: var(--surface-2); color: var(--ink); }
.msg-action.is-done { color: var(--ok); }
.msg-action:focus-visible { outline: none; box-shadow: var(--focus); }

/* The working line: the brand's <innerpulse-working>, the six-bar mark drifting at text height. */
.msg-status { margin: 0; font-family: var(--meta); font-size: var(--fs-sm); color: var(--text-mute); }
.msg-status innerpulse-working { --innerpulse-working-dim: var(--text-mute); }

/* Steps: thinking and tool calls in intel's run-transcript format, on its dark terminal panel:
   "● Search(query)" with the result under "⎿", "✻ Thinking" folding to its first line. */
.term {
    color-scheme: dark;
    --t-bg: #111317; --t-line: #1f2329; --t-fg: #e3e6e9; --t-fg2: #b9bdc3; --t-fg3: #8f949b;
    --t-ember: #f43a2a; --t-ok: #7dffb0; --t-warn: #ffb347; --t-err: #ff6b5e; --t-violet: #b38cff;
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px 16px; border: 1px solid #2b3037; border-radius: var(--radius);
    background: var(--t-bg); color: var(--t-fg); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, var(--shadow-sm);
    font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
    --innerpulse-working-fg: #ff8a6b; --innerpulse-working-shine: #ffd2c2; --innerpulse-working-dim: var(--t-fg3);
    --innerpulse-mark: #f43a2a;
}
.term .blk { min-width: 0; animation: msg-in .25s ease both; }
.term .ln {
    display: flex; align-items: baseline; width: 100%; min-width: 0; padding: 0; border: 0; background: none;
    font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.term .ln:disabled { cursor: default; }
.term .ln:focus-visible { outline: 1px solid var(--t-fg3); outline-offset: 2px; border-radius: 3px; }
.term .bul { display: inline-block; width: 18px; flex: none; }
.term .call .bul { color: var(--t-ember); }
.term .call.is-running .bul { animation: think-blink 1s ease-in-out infinite; }
@keyframes think-blink { 50% { opacity: .25; } }
.term .call.is-ok .bul { color: var(--t-ok); }
.term .call.is-err .bul { color: var(--t-err); }
.term .tname { flex: none; font-weight: 600; color: var(--t-fg); }
.term .targ { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t-fg2); }
.term .tmore { flex: none; margin-left: auto; padding-left: 14px; font-size: 11px; color: #5c6b85; }
.term .ln:not(:disabled):hover .tmore { color: var(--t-fg2); }
.term .res { display: flex; align-items: baseline; padding-left: 18px; color: var(--t-fg2); }
.term .gut { width: 26px; flex: none; padding-left: 2px; color: #4f5d75; }
.term .rtext { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.term .res.is-pending .rtext { color: var(--t-fg3); font-style: italic; }
.term .res.is-err .rtext { color: var(--t-err); }
.term .srcs { list-style: none; margin: 4px 0 2px 44px; padding: 0 0 0 12px; border-left: 1px solid #253044; }
.term .srcs li { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.term .srcs a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t-fg); text-decoration: none; }
.term .srcs a:hover { color: #52e3ff; text-decoration: underline; }
.term .srcs-host { flex: none; font-size: 11px; color: #5c6b85; }
.term .think { color: var(--t-fg3); }
.term .think .bul, .term .think .tlabel { color: var(--t-violet); }
.term .think .tlabel { flex: none; margin-right: 10px; font-style: italic; }
.term .think .tfirst { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.term .think innerpulse-working { font-size: inherit; }
.term .tbody {
    margin: 4px 0 0 6px; padding: 4px 0 2px 18px; border-left: 1px solid #253044;
    white-space: pre-wrap; overflow-wrap: anywhere; font-style: italic; color: var(--t-fg2);
    max-height: 24em; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #253044 transparent;
}

.tool-artifact {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 14px; width: min(100%, 420px);
    padding: 12px 16px 12px 12px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
    box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; font: inherit; color: var(--ink);
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.tool-artifact::before {
    content: ""; flex: none; width: 40px; height: 40px; border-radius: var(--radius-s);
    background: color-mix(in srgb, var(--ip-mark) 10%, var(--surface-2)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 3.5h5.5L15 7v9.5H6z M11.5 3.5V7H15' fill='none' stroke='%23cc2a1c' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") center / 20px no-repeat;
}
.tool-artifact:hover { border-color: var(--rule-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.tool-artifact:focus-visible { outline: none; box-shadow: var(--focus); }
.tool-artifact-kind { order: 3; margin-left: auto; font-family: var(--meta); font-size: var(--fs-micro); letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--text-mute); }
.tool-artifact-title { font-family: var(--serif); font-weight: 700; font-size: var(--fs-md); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-artifact-v { font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); font-variant-numeric: tabular-nums; }

/* Files: attachments on a typed message, files code made, design-check screenshots. */
.msg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: 8px; max-width: min(85%, 620px); margin-bottom: 8px; }
.file-image { display: block; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); line-height: 0; }
.file-image img { display: block; max-width: 240px; max-height: 200px; width: auto; height: auto; object-fit: cover; }
.file-image:hover { border-color: var(--rule-2); }
.file-chip {
    display: inline-flex; align-items: center; gap: 10px; max-width: 300px; padding: 8px 12px 8px 8px;
    border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none;
    font-family: var(--meta); font-size: var(--fs-sm);
}
.file-chip:hover { border-color: var(--rule-2); text-decoration: none; }
.file-chip-ext {
    display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--radius-s);
    background: color-mix(in srgb, var(--ip-mark) 10%, var(--surface-2)); color: var(--ip-mark);
    font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--track-micro);
}
.file-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-size { flex: none; color: var(--text-mute); font-size: var(--fs-label); font-variant-numeric: tabular-nums; }
.tool-shot { display: block; width: fit-content; max-width: min(100%, 420px); margin: 4px 0 8px 34px; border: 1px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; line-height: 0; box-shadow: var(--shadow-sm); }
.tool-shot img { display: block; width: 100%; height: auto; max-height: 280px; object-fit: cover; object-position: top; }

/* Code steps in the transcript: the command or file, its output, and any files it made. */
.term .code-io { margin: 4px 0 4px 44px; padding: 0 0 0 12px; border-left: 1px solid #253044; }
.term .code-io pre {
    margin: 0; padding: 4px 0; max-height: 22em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
    font: inherit; color: var(--t-fg); background: none; border: 0;
    scrollbar-width: thin; scrollbar-color: #253044 transparent;
}
.term .code-io .code-io-out { color: var(--t-fg2); }
.term .code-io-in + .code-io-out { border-top: 1px dashed #253044; }
.term .code-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px 44px; font-family: var(--meta); }
.term .code-files .file-image { max-width: min(100%, 520px); background: #fff; border-color: #253044; }
.term .code-files .file-image img { max-width: 100%; max-height: 360px; }
.term .tool-shot { margin: 6px 0 4px 44px; border-color: #253044; }

/* --- composer ----------------------------------------------------------- */

.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

.composer {
    position: relative; z-index: 2;
    display: flex; flex-direction: column; gap: 6px; width: calc(100% - 48px); max-width: 760px; margin: 0 auto;
    padding: 14px 12px 10px 18px; border: 1px solid var(--rule); border-radius: 24px; background: var(--surface);
    box-shadow: var(--shadow); transition: border-color var(--ease), box-shadow var(--ease);
}
/* Focus is a quiet border change, not a ring. */
.composer:focus-within { border-color: var(--rule-2); box-shadow: var(--shadow-lg); }
.composer textarea {
    display: block; width: 100%; resize: none; border: 0; outline: none; background: transparent; box-shadow: none;
    font: inherit; font-size: var(--fs-md); line-height: 1.55; color: var(--ink); padding: 2px 0 4px; max-height: 40vh; overflow-y: auto;
}
.chat-center.is-empty .composer textarea { min-height: 52px; }
.composer textarea:focus, .composer textarea:focus-visible { outline: none; box-shadow: none; }
.composer textarea::placeholder { color: var(--text-mute); }
.composer-foot { display: flex; align-items: center; gap: 2px; margin-left: -8px; }
.composer-spacer { flex: 1 1 auto; }
.composer-pick select {
    appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: var(--fs-sm); color: var(--text-dim); padding: 5px 22px 5px 9px; border-radius: var(--radius-s);
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; background-size: 4px 4px; background-repeat: no-repeat;
}
.composer-pick select:hover, .composer-pick select:focus-visible { background-color: var(--surface-2); color: var(--ink); outline: none; }
.composer-pick select:disabled { opacity: .55; cursor: default; }
.composer-flag {
    display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; padding: 3px 9px; border-radius: 999px;
    background: var(--surface-2); font-family: var(--meta); font-size: var(--fs-label); color: var(--text-dim); text-decoration: none;
}
.composer-flag:hover { color: var(--ink); text-decoration: none; }
.composer-send {
    display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%;
    background: var(--ip-mark); color: #fff; cursor: pointer; transition: background var(--ease), opacity var(--ease), transform var(--ease);
}
.composer-send:hover:not(:disabled) { background: color-mix(in srgb, var(--ip-mark) 88%, #000); }
.composer-send:active:not(:disabled) { transform: scale(.94); }
.composer-send:disabled { background: var(--surface-2); color: var(--text-mute); cursor: not-allowed; }
.composer-send.is-stop { background: var(--ink); color: var(--paper); }
.composer-send:focus-visible { outline: none; box-shadow: var(--focus); }
.composer-hint { margin: 6px auto 10px; text-align: center; font-family: var(--meta); font-size: var(--fs-micro); color: var(--text-mute); }
.composer-hint kbd { font-family: inherit; font-size: inherit; padding: 0 4px; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }

.composer.is-dragging { border-color: var(--ip-mark); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ip-mark) 18%, transparent); }
.composer-attach { width: 30px; height: 30px; border-radius: 50%; }
.composer-attach:disabled { opacity: .45; cursor: default; }
.composer-files { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 2px; padding: 0; }
.composer-file {
    display: inline-flex; align-items: center; gap: 8px; max-width: 240px; margin: 0; padding: 4px 4px 4px 4px;
    border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface-2);
    font-family: var(--meta); font-size: var(--fs-label); color: var(--text);
}
.composer-file img, .composer-file-ext { flex: none; width: 30px; height: 30px; border-radius: 6px; object-fit: cover; }
.composer-file-ext { display: grid; place-items: center; background: var(--surface); color: var(--ip-mark); font-size: var(--fs-micro); text-transform: uppercase; }
.composer-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-file.is-uploading { opacity: .7; }
.composer-file.is-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--rule)); color: var(--danger); }
.composer-file button { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--text-mute); cursor: pointer; }
.composer-file button:hover { background: var(--surface); color: var(--ink); }
.composer-file-spin { flex: none; width: 12px; height: 12px; border: 1.5px solid var(--rule-2); border-top-color: var(--ip-mark); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- artifact panel ----------------------------------------------------- */

.artifact-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--rule); background: var(--surface); }
.artifact-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--rule); min-height: 52px; flex-wrap: wrap; }
.artifact-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 200px; }
.artifact-title h2 { margin: 0; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-pick select { max-width: 100%; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 700; color: var(--ink); border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; padding: 2px 4px; cursor: pointer; }
.artifact-pick select:hover { border-color: var(--rule); }
.artifact-pick { min-width: 0; }
.artifact-kind { flex: none; font-family: var(--meta); font-size: var(--fs-micro); letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--ip-mark); }
.artifact-tools { display: flex; align-items: center; gap: 4px; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface-2); margin-right: 6px; }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: 6px; font: inherit; font-size: var(--fs-sm); color: var(--text-dim); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.artifact-version select { font: inherit; font-size: var(--fs-sm); padding: 4px 6px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface); color: var(--text); margin-right: 4px; }
.artifact-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--paper); }
.artifact-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.artifact-doc { max-width: var(--column); margin: 0 auto; padding: 36px 28px 72px; }
.artifact-doc .article-body { font-size: var(--fs-xl); }
.artifact-code { padding: 16px; }
.article-body.code-only pre { margin: 0; font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.article-body.code-only pre[data-lang] { padding-top: 34px; }
.artifact-live {
    margin: 0; padding: 16px 18px 40px; min-height: 100%; white-space: pre-wrap; overflow-wrap: anywhere;
    font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; color: var(--text); background: var(--surface-2);
}
.artifact-count { font-family: var(--meta); font-size: var(--fs-sm); color: var(--text-mute); margin-right: 6px; white-space: nowrap; }
.artifact-loading { margin: 24px; color: var(--text-mute); font-family: var(--meta); font-size: var(--fs-sm); }

/* --- gallery management (settings) ------------------------------------- */

.gm-list { list-style: none; margin: 0; padding: 0; display: grid; }
.gm-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 14px 0; border-top: 1px solid var(--rule); }
.gm-item:first-child { border-top: 0; padding-top: 2px; }
.gm-main { min-width: 0; display: grid; gap: 4px; }
.gm-title { margin: 0; font-family: var(--serif); font-size: var(--fs-xl); color: var(--ink); overflow-wrap: anywhere; }
.gm-dek { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); }
.gm-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); }
.gm-meta a { color: var(--accent); }
.gm-kind { letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--ip-mark); }
.gm-actions { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: 6px; }
.gm-order { display: inline-flex; gap: 2px; }
.gm-order .btn { padding-inline: 9px; }
.gm-edit { grid-column: 1 / -1; border: 1px solid var(--rule); border-radius: var(--radius-s); }
.gm-edit select { font: inherit; font-size: var(--fs-sm); padding: 7px 10px; border: 1px solid var(--rule-2); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); }
@media (max-width: 620px) {
  .gm-item { grid-template-columns: 1fr; }
  .gm-actions { justify-content: flex-start; }
}

/* --- publishing --------------------------------------------------------- */

.publish-toggle { margin: 0 4px 0 2px; }
.publish-toggle.is-live { border-color: var(--ok); color: var(--ink); }
.publish { display: grid; gap: 12px; padding: 14px 18px 16px; border-bottom: 1px solid var(--rule); background: var(--surface-2); }
.publish label > span:first-child { display: block; margin-bottom: 4px; font-size: var(--fs-label); font-weight: var(--fw-semibold); color: var(--text-dim); }
.publish input[type="text"], .publish input:not([type]) { font: inherit; font-size: var(--fs-sm); padding: 7px 10px; border: 1px solid var(--rule-2); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); width: 100%; }
.publish select { font: inherit; font-size: var(--fs-sm); padding: 7px 10px; border: 1px solid var(--rule-2); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); width: 100%; }
.publish input:focus, .publish select:focus { outline: none; border-color: var(--ip-mark); }
.publish-msg a { color: var(--accent); }
.publish-url { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-mute); }
.publish-url input { font-family: var(--mono) !important; }
.publish-check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.publish-check input { margin-top: 3px; accent-color: var(--ip-mark); }
.publish-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.publish-msg { font-size: var(--fs-sm); color: var(--ok); }
.publish-msg.is-error { color: var(--danger); }
.publish-status { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); }
.publish-status a { color: var(--accent); }

/* --- syntax colors (highlight.js classes) on theme tokens --------------- */

.hljs-comment, .hljs-quote { color: var(--text-mute); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-section { color: var(--c3); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { color: var(--c4); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--c2); }
.hljs-title, .hljs-title.function_, .hljs-name { color: var(--c1); }
.hljs-type, .hljs-built_in, .hljs-class .hljs-title, .hljs-title.class_ { color: var(--c6); }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-property, .hljs-params { color: var(--c5); }
.hljs-meta, .hljs-tag { color: var(--text-dim); }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* --- settings ----------------------------------------------------------- */

.settings { max-width: 760px; padding-top: clamp(28px, 4vw, 48px); padding-bottom: 96px; }
.settings h1 { margin: 0 0 18px; font-family: var(--serif); font-size: clamp(2rem, 3.4vw, 2.6rem); color: var(--ink); letter-spacing: var(--track-tighter); }
.settings .eyebrow a { color: inherit; text-decoration: none; }
.settings-flash { margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--rule); border-left: 2px solid var(--ok); border-radius: var(--radius-xs); background: var(--surface); color: var(--text); }
.settings-flash.is-error { border-left-color: var(--danger); }
.settings-card { margin: 0 0 22px; padding: 22px 24px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); display: grid; gap: 16px; }
.settings-card h2 { margin: 0; font-family: var(--serif); font-size: var(--fs-3xl); color: var(--ink); }
.settings-help { display: block; margin-top: 3px; font-size: var(--fs-sm); color: var(--text-mute); line-height: 1.5; font-weight: 400; }
.settings-card > .settings-help { margin: -8px 0 0; }
.settings-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.settings-row input[type="password"] { flex: 1 1 260px; }
.settings input[type="password"], .settings input[type="number"], .settings select, .settings textarea {
    font: inherit; font-size: var(--fs-base); padding: 9px 12px; border: 1px solid var(--rule-2); border-radius: var(--radius-s); background: var(--paper); color: var(--ink);
}
.settings input:focus, .settings select:focus, .settings textarea:focus { outline: none; border-color: var(--ip-mark); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ip-mark) 14%, transparent); }
.settings textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.55; }
.settings-models { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.settings-models legend { margin-bottom: 8px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-dim); }
.settings-model { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius-s); cursor: pointer; }
.settings-model:has(input:checked) { border-color: var(--ip-mark); box-shadow: 0 0 0 1px var(--ip-mark) inset; }
.settings-model input { margin-top: 4px; accent-color: var(--ip-mark); }
.settings-model strong { display: block; color: var(--ink); }
.settings-model code { font-family: var(--mono); font-size: var(--fs-micro); color: var(--text-mute); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-grid label, .settings-block { display: grid; gap: 6px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-dim); }
.settings-check { display: flex; gap: 10px; align-items: flex-start; font-weight: var(--fw-medium); color: var(--ink); cursor: pointer; }
.settings-check input { margin-top: 4px; accent-color: var(--ip-mark); }
.memory-file { border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 8px 12px; }
.memory-file summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; }
.memory-file pre { margin: 8px 0; padding: 10px 12px; max-height: 20em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: var(--fs-sm); background: var(--surface-2); border-radius: var(--radius-xs); }

/* --- narrow screens ----------------------------------------------------- */

@media (max-width: 1100px) {
    .chat-app.has-panel { grid-template-columns: 0 minmax(0, 1fr) minmax(0, 1.1fr); }
    .chat-app.has-panel .chat-sidebar { visibility: hidden; }
    .chat-app.has-panel .chat-sidebar-toggle, .chat-app.has-panel .chat-bar-new { display: inline-grid; }
}
@media (max-width: 820px) {
    .chat-app, .chat-app.has-panel, .chat-app.is-collapsed { grid-template-columns: minmax(0, 1fr); position: relative; }
    .chat-sidebar {
        position: absolute; z-index: 20; inset: 0 auto 0 0; width: min(300px, 86vw);
        background: var(--paper); box-shadow: var(--shadow-lg); transform: translateX(-102%); transition: transform var(--ease-out); visibility: visible !important;
    }
    .chat-app.sidebar-open .chat-sidebar { transform: none; }
    .chat-scrim { position: absolute; inset: 0; z-index: 15; background: rgba(0, 0, 0, .28); animation: msg-in 160ms ease-out; }
    .chat-sidebar-toggle, .chat-bar-new { display: inline-grid; }
    .artifact-panel { position: absolute; z-index: 30; inset: 0; border-left: 0; }
    .chat-bar { padding: 6px 8px; min-height: 50px; }
    .chat-title { text-align: center; margin: 0; }
    .chat-bar-new { order: 3; }
    .chat-scroll { padding: 8px 16px 24px; }
    .composer { width: calc(100% - 20px); padding-left: 14px; }
    .composer textarea { font-size: 16px; } /* 16px keeps iOS from zooming on focus */
    .composer-hint { display: none; }
    .composer { margin-bottom: 10px; }
    .chat-suggest { width: calc(100% - 20px); }
    .chat-bar .btn { padding: 5px 10px; font-size: var(--fs-sm); white-space: nowrap; }
    .msg-user-body { max-width: 88%; }
    .settings-models, .settings-grid { grid-template-columns: minmax(0, 1fr); }
    .settings-card { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .msg, .chat-jump, .chat-scrim, .term .blk, .term .call.is-running .bul { animation: none; }
    .chat-sidebar, .chat-app { transition: none; }
}

/* --- new-chat halo ------------------------------------------------------- */

/* The plate on its own: no rings, sparks or glow around it (innerpulse-brand, 2026-11-11). */
.chat-halo { position: relative; display: grid; place-items: center; width: 168px; height: 112px; margin: -8px 0 0; }
.chat-halo innerpulse-mark { position: relative; }
@media (prefers-reduced-motion: no-preference) {
    .chat-empty > * { animation: hero-rise .8s cubic-bezier(.16, 1, .3, 1) both; }
    .chat-empty > :nth-child(2) { animation-delay: .06s; }
    .chat-empty > :nth-child(3) { animation-delay: .12s; }
    .chat-center.is-empty .composer { animation: hero-rise .8s cubic-bezier(.16, 1, .3, 1) .18s both; }
    .chat-center.is-empty .chat-suggest button { animation: hero-rise .7s cubic-bezier(.16, 1, .3, 1) both; }
    .chat-suggest button:nth-child(1) { animation-delay: .26s; }
    .chat-suggest button:nth-child(2) { animation-delay: .31s; }
    .chat-suggest button:nth-child(3) { animation-delay: .36s; }
    .chat-suggest button:nth-child(4) { animation-delay: .41s; }
}
.chat-suggest button svg { color: var(--text-mute); transition: color var(--ease); }
.chat-suggest button:hover svg { color: var(--ip-mark); }

/* While Claude works, an ember light runs along the composer's top edge. */
.composer::before {
    content: ""; position: absolute; left: 22px; right: 22px; top: -1px; height: 1px; pointer-events: none; opacity: 0;
    background: linear-gradient(90deg, transparent, var(--ip-mark) 40%, #ff5a2e 60%, transparent) no-repeat;
    background-size: 40% 100%; transition: opacity .3s ease;
}
.composer.is-busy::before { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
    .composer.is-busy::before { animation: busy-run 1.8s cubic-bezier(.45, 0, .55, 1) infinite; }
}
@keyframes busy-run { from { background-position: -60% 0; } to { background-position: 160% 0; } }

/* --- studio navigation (chat sidebar foot, settings rail) ---------------- */

.studio-search {
    display: flex; align-items: center; gap: 10px; margin: -4px 10px 10px; padding: 7px 10px 7px 14px;
    border: 0; border-radius: var(--radius-s); background: none; cursor: pointer; text-align: left;
    font: inherit; font-size: var(--fs-sm); color: var(--text-dim); transition: background var(--ease), color var(--ease);
}
.studio-search:hover { background: var(--surface-2); color: var(--ink); }
.studio-search:focus-visible { outline: none; box-shadow: var(--focus); }
.studio-search span { flex: 1 1 auto; }
.studio-search kbd, .palette-foot kbd {
    font-family: var(--meta); font-size: var(--fs-micro); color: var(--text-mute); padding: 1px 5px;
    border: 1px solid var(--rule); border-radius: 4px; background: var(--surface);
}

.chat-sidebar-foot.studio-foot { display: block; padding: 6px 8px 8px; }
.studio-links { display: grid; gap: 1px; }
.studio-link {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
    font-size: var(--fs-sm); color: var(--text-dim); text-decoration: none; transition: background var(--ease), color var(--ease);
}
.studio-link svg { flex: none; color: var(--text-mute); transition: color var(--ease); }
.studio-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.studio-link:hover svg { color: var(--ink); }
.studio-link[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: var(--fw-medium); }
.studio-link[aria-current="page"] svg { color: var(--ip-mark); }
.studio-link-out { margin-left: auto; display: inline-flex; opacity: .55; }
.studio-account { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; padding: 8px 4px 0 10px; border-top: 1px solid var(--rule); }
.studio-account-who { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-label); color: var(--text-mute); }
.studio-signout { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-s); background: none; color: var(--text-mute); cursor: pointer; }
.studio-signout:hover { background: var(--surface-2); color: var(--ink); }
.studio-signout:focus-visible { outline: none; box-shadow: var(--focus); }

/* The studio's own pages: the rail on the left, the page on the right; the public masthead steps aside. */
body:has(.studio) .masthead { display: none; }
.studio { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100dvh; }
.studio-rail {
    position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
    border-right: 1px solid var(--rule); background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.studio-rail .chat-new { text-decoration: none; }
.studio-badge {
    font-family: var(--meta); font-size: var(--fs-micro); letter-spacing: var(--track-micro); text-transform: uppercase;
    color: var(--ip-mark); padding: 2px 8px; border: 1px solid color-mix(in srgb, var(--ip-mark) 35%, transparent); border-radius: 999px; margin-right: 6px;
}
.studio-recent { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.studio-recent svg { flex: none; color: var(--text-mute); }
.studio-recent span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.studio-recent:hover { text-decoration: none; }
.studio-main { min-width: 0; }
.studio-main .settings { margin: 0 auto; }
.settings-lede { margin: -6px 0 24px; color: var(--text-dim); line-height: var(--leading-ui); max-width: 60ch; }

.settings-toc {
    position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; flex-wrap: wrap; margin: 0 -8px 22px; padding: 10px 8px;
    background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.settings-toc a { padding: 5px 12px; border: 1px solid var(--rule); border-radius: 999px; font-size: var(--fs-sm); color: var(--text-dim); text-decoration: none; transition: color var(--ease), border-color var(--ease), background var(--ease); }
.settings-toc a:hover { color: var(--ink); border-color: var(--rule-2); background: var(--surface); }
.settings-sub { margin: 10px 0 -4px; padding-top: 16px; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: var(--fs-label); font-weight: var(--fw-semibold); letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--text-mute); }
.settings-card, .settings-sub { scroll-margin-top: 64px; }
@media (prefers-reduced-motion: no-preference) {
    .studio-main .settings > * { animation: hero-rise .6s cubic-bezier(.16, 1, .3, 1) both; }
    .studio-main .settings > :nth-child(n+4) { animation-delay: .08s; }
}

@media (max-width: 900px) {
    .studio { grid-template-columns: minmax(0, 1fr); }
    .studio-rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
    .studio-rail .chat-list-scroll { display: none; }
    .studio-rail .studio-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .studio-rail .studio-account { grid-column: 1 / -1; }
}

/* --- quick switcher ------------------------------------------------------ */

.palette-scrim {
    position: fixed; inset: 0; z-index: 100; display: grid; justify-items: center; align-items: start; padding: 12vh 16px 16px;
    background: color-mix(in srgb, #000 38%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    animation: pal-fade .14s ease-out;
}
.palette {
    width: min(620px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid var(--rule-2); border-radius: 16px; background: var(--surface); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5), var(--shadow-lg);
    animation: pal-in .2s cubic-bezier(.16, 1, .3, 1);
}
@keyframes pal-fade { from { opacity: 0; } }
@keyframes pal-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.palette-input {
    width: 100%; padding: 16px 20px; border: 0 !important; border-bottom: 1px solid var(--rule) !important; border-radius: 0 !important;
    background: transparent !important; box-shadow: none !important; outline: none; font: inherit; font-size: var(--fs-lg); color: var(--ink);
}
.palette-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.palette-group { margin: 8px 10px 4px; font-family: var(--meta); font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--text-mute); }
.palette-list button {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: var(--radius-s);
    background: none; text-align: left; font: inherit; font-size: var(--fs-sm); color: var(--text); cursor: pointer;
}
.palette-list button.is-at { background: var(--surface-2); color: var(--ink); }
.palette-icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: var(--radius-s); border: 1px solid var(--rule); color: var(--text-mute); background: var(--surface); }
.palette-list button.is-at .palette-icon { color: var(--ip-mark); border-color: color-mix(in srgb, var(--ip-mark) 40%, var(--rule)); }
.palette-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { flex: none; font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); }
.palette-empty { padding: 18px 12px; color: var(--text-mute); font-size: var(--fs-sm); }
.palette-foot { margin: 0; padding: 9px 16px; border-top: 1px solid var(--rule); font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); display: flex; gap: 4px; align-items: center; }
@media (prefers-reduced-motion: reduce) { .palette, .palette-scrim { animation: none; } }

/* --- usage: per reply, per chat, and the studio's Usage page ------------- */

.msg-usage { margin-left: 10px; font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; cursor: help; }
.msg-usage::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; vertical-align: middle; margin: 0 10px 2px 0; }
.chat-cost {
    flex: none; display: inline-flex; align-items: baseline; gap: 8px; padding: 4px 11px; border: 1px solid var(--rule); border-radius: 999px;
    font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chat-cost b { color: var(--ink); font-weight: var(--fw-semibold); }
.chat-cost:hover { background: var(--surface-2); color: var(--text-dim); text-decoration: none; }
@media (max-width: 640px) { .chat-cost-tokens { display: none; } .msg-usage { white-space: normal; } }

.usage { max-width: 920px; }
.usage-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 22px; }
.usage-stat {
    display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
}
.usage-stat strong { font-family: var(--serif); font-size: var(--fs-5xl); line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: var(--track-tight); }
.usage-stat.is-total { border-color: color-mix(in srgb, var(--ip-mark) 40%, var(--rule)); }
.usage-stat.is-total strong { color: var(--ip-mark); }
.usage-stat-label { font-family: var(--meta); font-size: var(--fs-micro); letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--text-mute); }
.usage-split { font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); font-variant-numeric: tabular-nums; }
.usage-days { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); align-items: end; gap: 3px; height: 120px; padding-bottom: 1px; border-bottom: 1px solid var(--rule); }
.usage-day { height: var(--h); min-height: 0; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--ip-mark) 70%, var(--surface)); transition: background var(--ease); }
.usage-day:last-child { background: var(--ip-mark); }
.usage-day:hover { background: var(--accent); }
.usage-days-axis { display: flex; justify-content: space-between; margin-top: -8px; font-family: var(--meta); font-size: var(--fs-label); color: var(--text-mute); }
.usage-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.usage-table th { text-align: left; font-family: var(--meta); font-size: var(--fs-micro); letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--text-mute); font-weight: var(--fw-medium); padding: 0 8px 8px; border-bottom: 1px solid var(--rule); }
.usage-table td { padding: 9px 8px; border-bottom: 1px solid var(--rule); color: var(--text); }
.usage-table tr:last-child td { border-bottom: 0; }
.usage-table .num { text-align: right; white-space: nowrap; }
.usage-table td:last-child { color: var(--ink); font-weight: var(--fw-medium); }
.usage-chats { list-style: none; margin: 0; padding: 0; display: grid; }
.usage-chats li { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.usage-chats li:last-child { border-bottom: 0; }
.usage-chats a { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.usage-chats b { flex: none; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: var(--fw-semibold); min-width: 5.5em; text-align: right; }
@media (max-width: 760px) {
    .usage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .usage .settings-card { overflow-x: auto; }
    .usage-chats .usage-split { display: none; }
}

/* --- theme picker: in the masthead, and as a row in the studio's links ---- */

.theme-option-text { display: grid; gap: 1px; line-height: 1.3; }
.theme-option-text small { font-size: var(--fs-label); color: var(--text-mute); font-weight: 400; }
.theme-option.is-active .theme-option-text small { color: inherit; opacity: .75; }
.theme-option.has-rule { margin-top: 4px; position: relative; }
.theme-option.has-rule::before { content: ""; position: absolute; left: 10px; right: 10px; top: -3px; border-top: 1px solid var(--rule); }
.theme-menu { min-width: 230px; }
.theme-picker-row { display: block; }
.theme-row { width: 100%; border: 0; background: transparent; font-family: inherit; font-size: var(--fs-sm); line-height: inherit; cursor: pointer; text-align: left; }
.theme-row-current { margin-left: auto; font-size: var(--fs-label); color: var(--text-mute); }
.theme-picker-row .theme-menu { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
.theme-picker-row.is-open .theme-row { background: var(--surface-2); color: var(--ink); }

/* The artifact pinned to the landing page's large plate. */
.gm-pin { display: inline-flex; align-items: center; gap: 6px; }
.gm-pin.is-on { color: var(--ip-mark); border-color: color-mix(in srgb, var(--ip-mark) 45%, var(--rule)); background: color-mix(in srgb, var(--ip-mark) 8%, transparent); }
.gm-pinned {
    display: inline-block; margin-left: 10px; padding: 2px 8px; vertical-align: 3px; border-radius: 999px;
    font-family: var(--meta); font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--track-micro); text-transform: uppercase;
    color: var(--ip-mark); border: 1px solid color-mix(in srgb, var(--ip-mark) 40%, transparent);
}

/* --- design review fixes (2026-10-08 critique) ---------------------------- */

/* Studio sidebar foot: Artifacts, Settings and Usage as rows; theme, public site and sign-out as
   icons on the account row, which gives the chat list two more rows. */
.studio-account { gap: 2px; padding-right: 0; }
.studio-account .theme-picker { flex: none; }
.studio-account-btn {
    display: grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--radius-s);
    background: none; color: var(--text-mute); cursor: pointer; transition: background var(--ease), color var(--ease);
}
.studio-account-btn:hover, .theme-picker.is-open .studio-account-btn { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.studio-account-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.theme-picker-account .theme-menu { top: auto; bottom: calc(100% + 6px); right: -76px; left: auto; }
.studio-badge { color: var(--ip-mark-text, var(--ip-mark)); }
.studio-link[aria-current="page"] svg { color: var(--ip-mark-text, var(--ip-mark)); }

/* The rail's recent chats read like the chat sidebar's list. */
.studio-recent { display: block; }

/* No shortcut hint where there's no keyboard. */
@media (hover: none) and (pointer: coarse) { .studio-search kbd { display: none; } }

/* On a phone the rail folds to one bar; the menu button opens the rest (components/studio/rail-toggle.tsx). */
.studio-rail-toggle { display: none; }
@media (max-width: 900px) {
    .studio-rail { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
    .studio-rail .chat-sidebar-head { min-height: 52px; padding: 8px 8px 8px 16px; }
    .studio-rail .studio-badge { margin-left: auto; margin-right: 2px; }
    .studio-rail-toggle { display: inline-grid; }
    .studio-rail:not([data-open]) > :not(.chat-sidebar-head) { display: none; }
    .studio-rail[data-open] { padding-bottom: 6px; box-shadow: var(--shadow-lg); }
    .studio-rail .studio-links { grid-template-columns: minmax(0, 1fr); }
    .studio-rail .chat-new, .studio-rail .studio-search, .studio-rail .studio-link { min-height: 44px; }
}

/* Thinking: one quiet line, no tint or italics, so it doesn't outrank the answer. */
.term .think .bul, .term .think .tlabel { color: var(--t-fg2); }
.term .think .tlabel, .term .think .tfirst, .term .tbody { font-style: normal; }
/* Small labels on the run panel clear 4.5:1. */
.term .tmore, .term .srcs-host { font-size: 11.5px; color: var(--t-fg3); }

/* Model and effort pickers size to their label, so the caret sits next to it. */
.composer-pick select { field-sizing: content; }

/* Touch: message and code actions get room for a thumb. */
@media (pointer: coarse) {
    .msg-action, .code-copy, .studio-account-btn { width: 40px; height: 40px; }
    .msg-foot { min-height: 40px; }
}

/* The chat panel's drawing and diagram previews keep the panel's ground. */
.artifact-frame.is-clear { background: transparent; color-scheme: normal; }

/* Studio pages share one content width, and the section links line up with the cards. */
.settings, .usage { max-width: 820px; }
.settings-toc { margin: 0 0 22px; padding: 10px 0; }

/* UX sweep, 2026-10-09. */
/* On a phone a reply's figures take their own line under the actions, and the model name never breaks. */
.msg-foot { flex-wrap: wrap; }
.msg-model { white-space: nowrap; }
@media (max-width: 640px) {
    .msg-usage { flex-basis: 100%; margin-left: 6px; white-space: nowrap; }
    .msg-usage::before { display: none; }
}
/* The transcript fades out under the top bar instead of cutting a line in half. */
.chat-scroll { padding-top: 20px; mask-image: linear-gradient(to bottom, transparent 0, #000 18px); }
/* The code language label clears 4.5:1 on the light grounds. */
.code-block-head { color: var(--text-dim); }
/* Settings: the Save bar stays in reach while the form is on screen, and both controls look alike. */
.settings-save {
    position: sticky; bottom: 0; z-index: 2; margin: 2px -24px -22px; padding: 12px 24px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
    border-top: 1px solid var(--rule); border-radius: 0 0 var(--radius) var(--radius);
}
@media (max-width: 820px) { .settings-save { margin: 2px -16px -18px; padding: 12px 16px; } }
.settings input[type="number"], .settings select { font-weight: 400; }
.settings select {
    appearance: none; padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
/* Artifacts manager on a phone: the star button drops its word so a row's actions fit on one line. */
@media (max-width: 620px) {
    .gm-actions { flex-wrap: nowrap; gap: 4px; }
    .gm-actions .btn-sm { padding-inline: 10px; }
    .gm-pin-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
/* The panel's publish pill stays on one line; on a phone it drops the version. */
.publish-toggle { white-space: nowrap; }
@media (max-width: 520px) { .publish-toggle-v { display: none; } }

/* Artifacts manager thumbnails: a frame laid out at 800x500 and scaled to the tile. */
.gm-item { grid-template-columns: 128px minmax(0, 1fr); }
/* The actions sit under the text, so the title and meta keep the full column beside the thumbnail. */
.gm-item .gm-actions { grid-column: 2; justify-content: flex-start; }
.gm-thumb {
    --gm-w: 128px; position: relative; display: block; width: var(--gm-w); aspect-ratio: 8 / 5; align-self: start; overflow: hidden;
    border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface-2); text-decoration: none;
}
.gm-thumb:hover { border-color: var(--rule-2); }
.gm-thumb iframe {
    position: absolute; inset: 0 auto auto 0; width: 800px; height: 500px; border: 0; background: #fff;
    transform: scale(.16); transform-origin: 0 0; pointer-events: none;
}
.gm-thumb.is-svg iframe, .gm-thumb.is-mermaid iframe { background: var(--surface-2); color-scheme: normal; }
.gm-thumb-kind {
    position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--meta); font-size: var(--fs-micro);
    letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--text-mute);
}
.gm-thumb-text {
    position: absolute; inset: 0; margin: 0; padding: 8px 9px; overflow: hidden; background: var(--surface-2);
    font-family: var(--mono); font-size: 7.5px; line-height: 1.45; color: var(--text-dim); white-space: pre-wrap; overflow-wrap: anywhere;
    mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
.gm-thumb.is-markdown .gm-thumb-text { font-family: var(--serif); font-size: 8.5px; }
.gm-item .gm-edit { grid-column: 1 / -1; }
@media (max-width: 620px) {
    .gm-item { grid-template-columns: 88px minmax(0, 1fr); }
    .gm-thumb { --gm-w: 88px; }
    .gm-thumb iframe { transform: scale(.11); }
    .gm-item .gm-actions { grid-column: 1 / -1; }
}

/* UX sweep 3, 2026-10-09. */
/* One mask per state: a thread fades at both edges (under the top bar, above the composer); a new
   chat has none, so the halo's glow isn't clipped to the scroll box. */
.chat-center:not(.is-empty) .chat-scroll {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 32px), transparent);
}
.chat-center.is-empty .chat-scroll { -webkit-mask-image: none; mask-image: none; }
/* Phones: the four starters sit as an even two by two. */
@media (max-width: 520px) {
    .chat-suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chat-suggest button { justify-content: center; }
}

/* The artifact panel on a phone: close sits on the title row, where it always fits, and the tools
   tighten to one row (scrolling sideways rather than off the edge if a title row ever runs long). */
@media (max-width: 560px) {
    .artifact-head { position: relative; padding: 8px 10px 8px 14px; gap: 8px; }
    .artifact-title { flex-basis: 100%; padding-right: 40px; }
    .artifact-close { position: absolute; top: 8px; right: 8px; }
    .artifact-tools { width: 100%; gap: 2px; overflow-x: auto; scrollbar-width: none; }
    .artifact-tools::-webkit-scrollbar { display: none; }
    .artifact-tools > * { flex: none; }
    .artifact-tools .seg { margin-right: 4px; }
    .artifact-tools .seg button { padding: 4px 9px; }
    .artifact-tools .publish-toggle { margin-left: auto; padding-inline: 10px; }
    .artifact-tools .artifact-version select { margin-right: 0; }
}
/* The narrowest phones leave copying to the Code view's own copy button. */
@media (max-width: 420px) { .artifact-copy { display: none; } }

/* Copy a published link, beside the link. */
.gm-link { display: inline-flex; align-items: center; gap: 2px; }
.link-copy {
    display: inline-grid; place-items: center; width: 26px; height: 26px; margin: -6px -4px -6px 0; padding: 0; border: 0; border-radius: var(--radius-xs);
    background: none; color: var(--text-mute); cursor: pointer; vertical-align: middle;
}
.link-copy:hover { background: var(--surface-2); color: var(--ink); }
.link-copy.is-done { color: var(--ok); }
.link-copy svg { width: 13px; height: 13px; }

/* Usage on a phone: model, input, output and cost; calls and cache figures are on wider screens. A
   long chat title shortens with an ellipsis instead of pushing its cost out of the card. */
.usage-model { white-space: nowrap; }
.usage-chats { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 560px) {
    .usage-x, .usage-brand { display: none; }
    .usage-table th.num { white-space: normal; }
    .usage-table th, .usage-table td { padding-inline: 6px; }
}

/* Settings sections on a phone: one row of chips that scrolls sideways, not two ragged rows. */
@media (max-width: 640px) {
    .settings-toc { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
    .settings-toc::-webkit-scrollbar { display: none; }
    .settings-toc a { flex: none; white-space: nowrap; }
}

/* Files: what code execution made, across chats. */
.files-list .gm-title { font-family: var(--sans, inherit); font-size: var(--fs-lg, 1.05rem); }
.files-empty { color: var(--text-mute); }

/* Design sweep, 2026-10-25. */
/* Files: the Artifacts grid with a type tile (or the picture itself) in the thumbnail column, and long
   names break anywhere rather than one syllable a line. */
.files-thumb { display: grid; place-items: center; }
.files-thumb.is-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.files-thumb-ext {
    font-family: var(--meta); font-size: var(--fs-label); font-weight: var(--fw-semibold); letter-spacing: var(--track-micro);
    color: var(--text-dim); padding: 3px 8px; border: 1px solid var(--rule-2); border-radius: var(--radius-xs);
}
.files-list .gm-title { overflow-wrap: anywhere; margin: 0 0 4px; }

/* Settings: the key's last four stay together; the save bar says when there are unsaved changes; a
   tool that isn't connected reads as unavailable rather than on. */
.settings-key-hint { white-space: nowrap; font-size: .95em; }
.settings-save { display: flex; align-items: center; gap: 14px; }
.settings-unsaved { font-size: var(--fs-sm); color: var(--text-mute); }
.settings-unsaved.is-on::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.settings-check.is-off { cursor: default; color: var(--text-dim); }

/* Artifacts: a published piece with a newer version says so, with a one-click update. */
.gm-newer { color: var(--accent); }
.gm-update { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule-2)); }

/* The chat's title renames in place from the top bar. */
.chat-title-btn {
    max-width: 100%; padding: 4px 8px; margin: 0 0 0 -8px; border: 0; border-radius: var(--radius-xs); background: none; cursor: text;
    font: inherit; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-title-btn:hover { background: var(--surface-2); }
.chat-title-edit { flex: 1 1 auto; min-width: 0; margin-left: 6px; }
.chat-title-edit input {
    width: 100%; max-width: 520px; padding: 4px 8px; margin-left: -8px; font: inherit; font-size: var(--fs-base); font-weight: var(--fw-medium);
    color: var(--ink); background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--radius-xs); outline: none;
}
.chat-title-edit input:focus { border-color: var(--accent); }
@media (max-width: 900px) {
    .chat-title-btn { margin: 0; }
    .chat-title-edit input { margin-left: 0; text-align: center; }
}

/* Touch screens have no hover, so the open chat keeps its rename and delete buttons showing. */
@media (hover: none) {
    .chat-list li.is-active .chat-list-tools { display: inline-flex; }
    .chat-list li.is-active .chat-list-open { padding-right: 64px; }
    .chat-list-tools button { width: 30px; height: 30px; }
}

/* Usage: a chat's token split stays on one line beside a long title. */
.usage-chats .usage-split { flex: none; white-space: nowrap; }
