/* Chat, account, and products. One surface language on tokens.css. */

body { background: var(--ink); }
.nav {
  position: sticky; top: 0; z-index: 20; background: rgba(7,8,13,.92);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 10px; min-height: 64px; }
.nav .brand { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; text-decoration: none; font: 600 17px/1 var(--display); letter-spacing: -.03em; }
.nav-links { display: none; }
.nav-links.open {
  display: flex; flex-direction: column; position: absolute; left: 0; right: 0; top: 64px;
  background: var(--ink); border-bottom: 1px solid var(--line); padding: 8px var(--gutter) 16px; z-index: 30;
}
.nav-links a, .nav-links button {
  min-height: 44px; text-align: left; background: none; border: 0; color: var(--muted);
  padding: 0 4px; font: 600 16px/1 var(--sans); cursor: pointer; text-decoration: none;
}
.nav-links [aria-current="page"] { color: var(--text); }
.menu-btn, .nav .btn { min-height: 44px; }
.nav .wrap > .btn-primary { margin-left: auto; }
.menu-btn { margin-left: 0; }
@media (min-width: 900px) {
  .nav-links { display: flex; gap: 4px; flex: 1; justify-content: center; position: static; background: none; border: 0; padding: 0; }
  .nav-links.open { display: flex; }
  .menu-btn { display: none; }
  .nav-links a, .nav-links button { padding: 0 12px; border-radius: var(--pill); font-size: 14px; }
  .nav-links [aria-current="page"] { background: var(--surface); }
}

.shell-foot { padding: 28px 0 48px; color: var(--muted); font-size: 14px; }
.shell-foot a { color: var(--text); min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px; }

.page-head { padding: 36px 0 8px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.page-head h1 { font-size: 44px; line-height: 46px; }
.page-head p { color: var(--muted); max-width: 42rem; }
.chapters { display: grid; gap: 72px; padding-bottom: 72px; }
.chapter { display: grid; gap: 16px; }
.chapter h2 { font-size: 32px; }
.chapter p { color: var(--muted); }
.product-status { color: var(--win-muted); font-size: 14px; }
.chapter .btn { justify-self: start; }
@media (min-width: 900px) {
  .chapters { gap: 120px; }
  .chapter { grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); align-items: center; gap: 36px; }
  .chapter .win { width: min(100%, 960px); }
}

/* Account */
.orb-account { width: 112px; height: 112px; margin: 4px auto 0; }
.auth-card {
  width: min(100%, 440px); margin: 12px auto 48px; padding: 22px;
  display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 0 40px rgba(124,156,255,.12);
}
.auth-card h2 { font-size: 28px; margin-bottom: 4px; }
.auth-card label { font-size: 14px; color: var(--muted); }
.auth-card input, .workspace-dialog input, .workspace-dialog select, .session-search {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--win); color: var(--text); padding: 12px 14px; font-size: 16px;
}
.auth-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(124,156,255,.28); outline: none; }
.auth-card button { min-height: 48px; border-radius: var(--pill); border: 1px solid var(--line); background: transparent; cursor: pointer; }
.auth-card .message-error:empty { display: none; }
.privacy-note { text-align: center; color: var(--muted); font-size: 14px; max-width: 36rem; margin: 0 auto 28px; }

/* Chat shell */
body.is-chat-experience { height: calc(100dvh - var(--kb)); overflow: hidden; }
body.is-chat-experience > .nav, body.is-chat-experience > .shell-foot { display: none; }
body.is-chat-experience main { height: 100%; padding: 0; }
body.is-chat-experience #view-chat { height: 100%; padding: 0; }
body.is-chat-experience #view-chat > .wrap { width: 100%; max-width: none; height: 100%; margin: 0; padding: 0; }
body.is-chat-experience .chat {
  display: grid; grid-template-columns: 268px minmax(0,1fr);
  height: 100%; min-height: 0; margin: 0; border: 0; background: transparent; overflow: hidden;
}
body.is-chat-experience .chat > aside {
  display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); overflow: auto;
}
.experience-rail-head { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.experience-rail-head .brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font: 600 18px/1 var(--display); }
.experience-sidebar-close, .experience-menu {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--ink); color: var(--text); cursor: pointer; font-size: 20px;
}
.experience-sidebar-close { margin-left: auto; display: none; }
.experience-menu { display: none; flex: none; }
body.is-chat-experience aside .new {
  width: 100%; min-height: 48px; justify-content: flex-start; border-radius: 12px;
  background: var(--pop); color: var(--ink); border: 0; font-weight: 700;
}
body.is-chat-experience aside .c {
  width: 100%; min-height: 44px; text-align: left; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); padding: 10px 12px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.is-chat-experience aside .c[aria-current="true"], body.is-chat-experience aside .c:hover {
  background: #1a1e2c; color: var(--text);
}
.experience-history-label { margin: 8px 8px 0; color: var(--teal); font: 600 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.session-list { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.session-note, .experience-rail-footer { color: var(--muted); font-size: 13px; padding: 0 8px; }
.session-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.session-actions button, .session-archive-toggle {
  min-height: 44px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 8px;
}
.experience-rail-links { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
.experience-rail-links a, .experience-rail-links button {
  min-height: 44px; display: flex; align-items: center; padding: 0 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); text-decoration: none; text-align: left; cursor: pointer;
}
.experience-rail-links a:hover, .experience-rail-links button:hover { background: #1a1e2c; color: var(--text); }
.experience-veil { display: none; }

body.is-chat-experience .convo {
  min-width: 0; min-height: 0; height: 100%; display: grid;
  grid-template-rows: auto minmax(0,1fr) auto; position: relative; overflow: hidden;
  background: rgba(7,8,13,.86);
}
.workspace-header {
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
  background: rgba(17,19,27,.96); border-bottom: 1px solid var(--line); z-index: 3;
}
.workspace-top {
  display: grid; grid-template-columns: 44px minmax(0,1fr) auto; grid-template-areas: "menu name account" "orb status status";
  gap: 6px 8px; align-items: center; min-height: 44px;
}
.experience-menu { grid-area: menu; }
.workspace-name { grid-area: name; font: 600 16px/1.2 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-account { grid-area: account; min-height: 44px; border-radius: var(--pill); border: 0; background: var(--pop); color: var(--ink); font-weight: 700; padding: 0 14px; cursor: pointer; }
.model-status { grid-area: status; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-height: 28px; }
.model-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.model-status[data-state="available"]::before { background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.model-status[data-state="unavailable"]::before { background: var(--magenta); }
.orb-mini { grid-area: orb; width: 36px; height: 36px; }
body.experience-empty .orb-mini { display: none; }
.workspace-tabs { display: flex; gap: 6px; margin-top: 6px; }
.workspace-tabs button {
  min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--muted);
  font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
}
.workspace-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--lime); }
.workspace-models, .workspace-branches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; padding: 6px 0; }
.workspace-models select, .workspace-branches select, .workspace-voice select {
  min-height: 44px; background: var(--win); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 16px;
}
.session-mobile { display: none; }
.convo:not(:has(> .workspace-header)) > .msgs { margin-top: 108px; }

body.is-chat-experience .msgs, body.is-chat-experience .workspace-panel {
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px var(--gutter) 12px; display: flex; flex-direction: column; gap: 18px;
}
body.experience-empty .msgs { justify-content: flex-start; }
.workspace-welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; width: min(100%, 640px); margin: 0 auto; padding-bottom: 8px; background: transparent; }
.orb-slot, .orb-mini, .orb-account { background: transparent; border: 0; box-shadow: none; overflow: visible; }
.orb-slot { width: min(220px, 52vw); height: min(220px, 52vw); }
.orb-slot .orb, .orb-account, canvas[data-orb] { width: 100%; height: 100%; display: block; background: transparent; border: 0; box-shadow: none; }
.workspace-welcome h2 { font-size: 36px; line-height: 1.08; }
.workspace-welcome p { color: var(--muted); max-width: 40ch; }
.workspace-prompts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.workspace-prompts button {
  min-height: 48px; text-align: left; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-size: 15px;
}
.workspace-prompts button:hover { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), 0 0 18px rgba(124,156,255,.25); }
.workspace-welcome > .btn-primary { min-height: 48px; }
@media (max-width: 480px) {
  .orb-slot { width: 128px; height: 128px; }
  .workspace-welcome { gap: 8px; }
  .workspace-welcome h2 { font-size: 28px; }
  .workspace-welcome > p { font-size: 14px; line-height: 1.45; }
  .workspace-prompts button { min-height: 44px; font-size: 13px; padding: 8px 10px; }
  body.is-chat-experience .msgs { padding-top: 8px; padding-bottom: 4px; }
}
@media (max-height: 740px) {
  .orb-slot { width: 108px; height: 108px; }
  .workspace-welcome h2 { font-size: 26px; }
  body.experience-empty .msgs { justify-content: flex-start; }
}

.msg { display: grid; gap: 6px; min-width: 0; max-width: min(100%, 42rem); }
.msg.user {
  justify-self: end; width: auto; max-width: min(86%, 34rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px 18px 6px 18px; padding: 12px 14px;
}
.msg.sys { justify-self: start; }
.msg .who { font: 600 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.msg.user .who { display: none; }
.msg .body { font-size: 16px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; display: grid; gap: 8px; }
.msg .body p { white-space: pre-wrap; }
.msg .body a { color: var(--blue); }
.msg .body ul, .msg .body ol { margin: 0; padding-left: 1.2em; }
.msg .body h2 { font-size: 22px; } .msg .body h3 { font-size: 18px; }
.msg .body p code { font: 13px var(--mono); background: var(--win); padding: 1px 6px; border-radius: 6px; }
.message-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.message-actions button {
  min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 13px;
}
.message-actions button:hover { background: var(--surface); color: var(--text); }
.message-state { color: var(--teal); font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.message-error { color: var(--text); border-left: 3px solid var(--magenta); padding-left: 10px; }
.typing-dots { display: inline-flex; gap: 5px; height: 22px; align-items: center; margin: 0; }
.typing-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); animation: bounce 1.1s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; background: var(--lime); }
.typing-dots i:nth-child(3) { animation-delay: .3s; background: var(--magenta); }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .35; } 30% { transform: translateY(-3px); opacity: 1; } }
.msg.is-streaming .body > :last-child::after {
  content: ""; display: inline-block; width: 8px; height: .9em; margin-left: 4px;
  background: var(--lime); vertical-align: text-bottom; animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.codeblock { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--win); min-width: 0; }
.code-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 12px; border-bottom: 1px solid var(--line); color: var(--win-muted); font: 12px var(--mono); }
.code-bar button { min-height: 44px; min-width: 44px; border: 0; background: transparent; color: var(--lime); font-weight: 700; cursor: pointer; }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 13.5px/1.55 var(--mono); color: var(--win-text); }
.tool-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.tool-log > li { padding-left: 16px; position: relative; }
.tool-log > li::before { content: ""; position: absolute; left: 0; top: .5em; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tool-log > li.ok::before { background: var(--teal); }
.tool-log > li.failed::before { background: var(--magenta); }
.tool-log > li.pending::before { background: var(--lime); animation: bounce 1.1s infinite; }
.tool-log a { color: var(--blue); }
.activity-group { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.workspace-empty { color: var(--muted); }

.composer {
  position: relative; z-index: 4; padding: 8px var(--gutter) max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(7,8,13,0), rgba(7,8,13,.96) 28%);
}
.offline-banner, .workspace-notice {
  width: min(760px, 100%); margin: 0 auto 8px; border-radius: 12px; padding: 10px 12px;
  background: #1a1020; border: 1px solid var(--magenta); color: var(--text); font-size: 14px;
}
.offline-banner { display: none; }
body.is-offline .offline-banner { display: block; }
.workspace-notice:empty { display: none; }
.composer form {
  width: min(760px, 100%); margin: 0 auto; position: relative;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px; border-radius: 28px; background: var(--surface); border: 1px solid transparent;
}
.composer form::before {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--spin), var(--blue), var(--teal), var(--magenta), var(--lime), var(--blue));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .7; animation: spin 7s linear infinite;
}
@keyframes spin { to { --spin: 360deg; } }
.composer form:focus-within { box-shadow: 0 0 28px rgba(124,156,255,.35); }
.composer form:focus-within::before { opacity: 1; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
  color: var(--text); font: 16px/1.45 var(--sans); padding: 12px 8px; max-height: 160px; min-height: 44px;
}
.composer textarea::placeholder { color: var(--muted); }
.mic, .send {
  width: 48px; height: 48px; flex: none; border-radius: 16px; border: 0; cursor: pointer;
  display: grid; place-items: center;
}
.mic { background: transparent; color: var(--text); border: 1px solid var(--line); }
body.is-listening .mic { color: var(--ink); background: var(--lime); box-shadow: 0 0 18px var(--lime); }
.send { background: var(--pop); color: var(--ink); box-shadow: 0 0 22px rgba(25,211,197,.45); }
.send svg { width: 18px; height: 18px; }
.composer form[aria-busy="true"] textarea { opacity: .6; }
.composer form[aria-busy="true"] .send { box-shadow: 0 0 22px var(--magenta); }
.composer form:not([aria-busy="true"]):has(textarea:placeholder-shown) .send { opacity: .38; box-shadow: none; }
.composer .hint { width: min(760px, 100%); margin: 8px auto 0; text-align: center; color: var(--muted); font-size: 13px; }
.experience-read-aloud { width: min(760px, 100%); margin: 8px auto 0; color: var(--muted); font-size: 14px; }
.experience-read-aloud summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text); font-weight: 600; }
.workspace-voice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0 4px; }
.workspace-voice select { flex: 1 1 180px; min-width: 0; }
.workspace-voice button { min-height: 44px; padding: 0 14px; border-radius: var(--pill); border: 1px solid var(--line); background: var(--ink); color: var(--text); cursor: pointer; }
.voice-provider { flex: 1 0 100%; margin: 0; color: var(--teal); font: 600 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.voice-auto { min-height: 44px; }
.bub { max-width: 92%; margin: 0 0 10px; padding: 12px 14px; border-radius: 16px; font-size: 14.5px; }
.bub.u { margin-left: auto; background: #191c28; border: 1px solid var(--line); }
.chapter ul { margin: 0; padding-left: 1.1em; color: var(--muted); display: grid; gap: 6px; }
.voice-auto { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.jump {
  position: absolute; left: 50%; top: 8px; transform: translate(-50%, -100%); z-index: 6;
  min-height: 44px; padding: 0 16px; border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: 0 0 18px rgba(124,156,255,.35); cursor: pointer; font-weight: 700;
}
body.experience-empty .jump { display: none; }

.workspace-dialog {
  width: min(440px, calc(100% - 24px)); padding: 22px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text);
}
.workspace-dialog::backdrop { background: rgba(0,0,0,.62); }
.workspace-dialog button { min-height: 44px; margin-top: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink); color: var(--text); cursor: pointer; }
.workspace-dialog p { color: var(--muted); font-size: 14px; }

@media (min-width: 900px) {
  .experience-menu { display: none; }
  .workspace-top { grid-template-columns: auto minmax(0,1fr) auto auto; grid-template-areas: "orb name status account"; }
  .workspace-header { padding: 14px 22px 0; }
  .convo:not(:has(> .workspace-header)) > .msgs { margin-top: 96px; }
}
@media (max-width: 899px) {
  body.is-chat-experience .chat { grid-template-columns: minmax(0,1fr); }
  body.is-chat-experience .chat > aside {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
    transform: translateX(-105%); transition: transform .2s ease;
    padding-top: max(16px, env(safe-area-inset-top));
  }
  body.experience-sidebar-open .chat > aside { transform: none; }
  body.experience-sidebar-open .experience-veil { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); border: 0; }
  .experience-sidebar-close, .experience-menu { display: grid; place-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  .composer form::before, .typing-dots i, .msg.is-streaming .body > :last-child::after { animation: none; }
  body.is-chat-experience .chat > aside { transition: none; }
}
