:root {
  color-scheme: dark;
  --ink: #FFE135;
  --muted: #b6b5aa;
  --accent: #FFE135;
  --accent-hover: #ffeb79;
  --paper: #262626;
  --surface: #303030;
  --soft: #38382c;
  --border: #414139;
  --danger: #ffaaa0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #262626;
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button, textarea, input { outline: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #ffe13515; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
::selection { color: #262626; background: var(--accent); }

/* Brand and shared controls */
.brand { display: inline-flex; align-items: center; font-size: 30px; font-weight: 750; letter-spacing: -1.6px; gap: 10px; line-height: 1; }
.brand-dot { color: var(--accent); margin-left: -8px; }
.brand-mark { height: 36px; width: 36px; background: var(--accent); border-radius: 12px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 9px; }
.brand-mark i { display: block; height: 2px; border-radius: 2px; background: #262626; }
.brand-mark i:nth-child(2) { width: 75%; }
.brand-mark i:nth-child(3) { width: 45%; }
.eyebrow { display: block; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: 2px; text-transform: uppercase; line-height: 1.6; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.7; }
label { display: grid; gap: 9px; font-size: 12px; font-weight: 550; color: var(--ink); }
input, textarea { width: 100%; color: var(--ink); background: #292929; border: 1px solid #4b4b42; border-radius: 12px; padding: 14px 15px; font-size: 14px; transition: border-color .18s, box-shadow .18s; }
input::placeholder, textarea::placeholder { color: #a6a69a; }
textarea { resize: vertical; line-height: 1.5; }
.field-note { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.7; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: 12px; border: 1px solid transparent; padding: 14px 20px; font-weight: 650; font-size: 13px; transition: background .18s, transform .18s; }
.button.primary { background: var(--accent); color: #262626; }
.button.primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.button.secondary { background: #3a3a32; border-color: var(--border); color: var(--ink); }
.button.secondary:hover { background: #454538; }
.button.wide { width: 100%; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; background: transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; transition: background .18s, color .18s; }
.icon-button:hover { background: #3c3c32; color: var(--accent); }
.icon-button.filled { background: var(--accent); color: #262626; }
.icon-button.filled:hover { background: var(--accent-hover); }
.text-button { background: none; border: 0; color: var(--accent); font-size: 11px; padding: 10px 14px; border-radius: 9px; }
.text-button:hover { background: #ffe1350e; }
.form-notice { color: var(--danger); font-size: 12px; line-height: 1.6; background: #452f2d; border: 1px solid #70453e; border-radius: 10px; padding: 11px 13px; }
.form-notice.success { color: var(--ink); background: var(--soft); border-color: #686032; }

/* Entry screen */
.auth-layout { min-height: 100svh; display: grid; grid-template-columns: 1.1fr 1fr; max-width: 1440px; margin: auto; }
.intro { position: relative; min-height: 760px; padding: 50px 64px 40px; overflow: hidden; background: radial-gradient(ellipse at 5% 95%, #ffe13508, transparent 65%), var(--paper); }
.intro::before { content: ""; position: absolute; inset: auto auto -270px -250px; width: 760px; height: 760px; border: 1px solid #ffe13520; border-radius: 50%; pointer-events: none; }
.intro::after { content: ""; position: absolute; right: -190px; top: 90px; width: 440px; height: 440px; border: 1px solid #ffe13512; border-radius: 50%; pointer-events: none; }
.intro-copy { margin-top: 82px; position: relative; z-index: 1; }
.intro-copy .eyebrow { color: var(--accent); padding-left: 22px; position: relative; }
.intro-copy .eyebrow::before { content: ""; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; position: absolute; left: 0; top: 5px; }
.intro h1 { font-size: clamp(48px, 5vw, 72px); line-height: 1.04; font-weight: 700; letter-spacing: -3.5px; margin: 22px 0 26px; }
.intro em, .welcome em { font-family: Georgia, "Times New Roman", serif; font-weight: 400; color: var(--accent); }
.intro-copy p { color: var(--muted); line-height: 1.8; font-size: 15px; }
.conversation-art { position: relative; width: 330px; height: 165px; margin: 38px 0 25px 34px; z-index: 1; }
.art-bubble { position: absolute; padding: 17px 22px 13px; border-radius: 18px; font-size: 14px; box-shadow: 0 12px 30px #00000020; }
.art-bubble span { display: block; font-size: 10px; text-align: right; margin-top: 8px; opacity: .65; }
.art-bubble b { font-weight: 500; }
.art-one { background: #353530; border: 1px solid #4a4a3c; left: 0; top: 0; transform: rotate(-4deg); border-bottom-left-radius: 5px; min-width: 195px; }
.art-two { background: var(--accent); color: #262626; right: 0; top: 67px; transform: rotate(3deg); border-bottom-right-radius: 5px; min-width: 218px; }
.art-typing { position: absolute; bottom: 0; left: 15px; display: flex; gap: 5px; border-radius: 12px; background: #353530; border: 1px solid var(--border); padding: 13px 19px; }
.art-typing i { background: var(--accent); width: 5px; height: 5px; border-radius: 50%; }
.art-orbit { position: absolute; right: -45px; top: 5px; width: 11px; height: 11px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 9px #ffe13508; }
.intro-footer { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 9px; margin-top: 38px; position: relative; }
.status-dot { height: 6px; width: 6px; background: var(--accent); border-radius: 50%; }
.auth-side { background: #2c2c2a; border-left: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 50px 64px 25px; min-height: 760px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-switch { display: flex; padding: 5px; background: #222222; border: 1px solid #404037; border-radius: 14px; margin-bottom: 42px; }
.auth-switch button { width: 50%; background: transparent; border: 0; border-radius: 9px; color: var(--muted); padding: 11px; font-size: 12px; font-weight: 600; }
.auth-switch .active { background: var(--accent); color: #262626; box-shadow: 0 3px 12px #00000018; }
.auth-card h2 { font-weight: 650; font-size: 40px; letter-spacing: -1.7px; line-height: 1.15; margin: 12px 0; }
.auth-card .muted { margin: 13px 0 30px; }
.auth-card form { display: grid; gap: 20px; }
.auth-card .wide { margin-top: 5px; justify-content: space-between; }
.auth-card .wide > span { font-size: 21px; line-height: 1; }
.auth-footnote { font-size: 11px; color: var(--muted); margin: 24px 0; text-align: center; }
.auth-bottom { color: var(--muted); font-size: 10px; letter-spacing: .6px; margin-top: 40px; }

/* Conversations */
.app-shell { display: grid; grid-template-columns: 310px minmax(0,1fr); height: calc(100svh - 44px); max-width: 1440px; margin: 22px auto; border: 1px solid #46463c; border-radius: 24px; overflow: hidden; box-shadow: 0 20px 70px #00000025; background: var(--paper); }
.sidebar { min-height: 0; background: #222222; border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 29px 19px 0; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 9px; }
.sidebar .brand { font-size: 28px; }
.sidebar .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; padding: 35px 9px 22px; }
.sidebar-heading .eyebrow { font-size: 9px; letter-spacing: 1.7px; }
.sidebar-heading h2 { margin: 6px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -.7px; }
.count { font-size: 11px; font-weight: 600; background: #ffe13516; border: 1px solid #ffe13525; border-radius: 7px; margin-left: 9px; padding: 3px 7px; vertical-align: middle; color: var(--accent); }
.count:empty { display: none; }
.search-field { display: flex; align-items: center; background: #2d2d2b; border: 1px solid #414139; border-radius: 12px; margin: 0 9px 22px; padding: 0 11px; gap: 8px; }
.search-field > span:not(.visually-hidden) { font-size: 25px; line-height: 1; color: var(--muted); }
.search-field input { border: 0; background: transparent; padding: 12px 0; font-size: 12px; box-shadow: none; }
.search-field:focus-within { border-color: var(--accent); }
.chat-list { flex: 1; overflow: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #646451 transparent; }
.chat-row { display: flex; align-items: center; gap: 13px; position: relative; border: 1px solid transparent; background: transparent; text-align: left; padding: 15px 11px; width: 100%; border-radius: 14px; color: var(--ink); margin-bottom: 6px; transition: background .18s, border-color .18s; }
.chat-row:hover { background: #2e2e29; }
.chat-row.active { background: #ffe1350f; border-color: #ffe13540; }
.chat-row.active::after { content: ""; position: absolute; right: 11px; height: 6px; width: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #ffe1350b; }
.avatar { display: flex; align-items: center; justify-content: center; width: 43px; height: 43px; border-radius: 14px; background: #45432a; color: var(--accent); font-size: 14px; font-weight: 650; flex-shrink: 0; letter-spacing: -.5px; border: 1px solid #ffe1351a; }
.avatar.tone-1 { background: #4b3e2a; color: #ffd68a; border-color: #ffd68a20; }
.avatar.tone-2 { background: #3b4032; color: #d9df9d; border-color: #d9df9d20; }
.avatar.tone-3 { background: #493b36; color: #edc5a5; border-color: #edc5a520; }
.chat-row.active .avatar { background: var(--accent); color: #262626; border-color: transparent; }
.chat-row-text { display: grid; gap: 6px; min-width: 0; flex: 1; }
.chat-row strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.chat-row small { font-size: 11px; color: var(--muted); }
.list-empty { font-size: 12px; text-align: center; line-height: 1.7; color: var(--muted); padding: 20px 15px; }
.profile { border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px; margin-top: 12px; padding: 20px 7px; }
.profile-main { display: flex; align-items: center; gap: 11px; text-align: left; background: none; border: 0; padding: 0; min-width: 0; flex: 1; color: var(--ink); }
.profile .avatar { border-radius: 50%; background: #39392c; color: var(--accent); width: 37px; height: 37px; font-size: 12px; }
.profile-text { display: grid; gap: 5px; min-width: 0; }
.profile-text strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.profile-text > span { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace { min-width: 0; min-height: 0; position: relative; background: var(--paper); }
.welcome { height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; position: relative; padding: 35px; background: radial-gradient(ellipse at center, #ffe13505, transparent 70%); }
.welcome-symbol { width: 110px; height: 110px; background: #ffe1350b; border: 1px solid #ffe13529; border-radius: 34px; position: relative; display: flex; align-items: center; justify-content: center; margin-bottom: 34px; transform: rotate(-6deg); }
.welcome-symbol svg { width: 44px; height: 44px; color: var(--accent); stroke-width: 1.4; transform: rotate(6deg); }
.tiny-dot { position: absolute; width: 17px; height: 17px; right: -4px; top: 4px; border-radius: 50%; background: var(--accent); border: 4px solid var(--paper); }
.welcome .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
.welcome h1 { font-weight: 650; font-size: 43px; letter-spacing: -1.7px; line-height: 1.2; margin: 18px 0; }
.welcome p { font-size: 13px; line-height: 1.8; color: var(--muted); margin: 0 0 27px; }
.welcome .button svg { width: 17px; height: 17px; }
.welcome-bottom { position: absolute; bottom: 30px; font-size: 10px; color: var(--muted); letter-spacing: .4px; }
.conversation { height: 100%; display: flex; flex-direction: column; }
.chat-header { display: flex; align-items: center; gap: 14px; padding: 21px 30px; border-bottom: 1px solid var(--border); min-height: 90px; background: #292929; }
.chat-header .chat-avatar { height: 43px; width: 43px; }
.chat-heading { flex: 1; min-width: 0; }
.chat-heading h2 { font-size: 17px; font-weight: 650; margin: 0 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.3px; }
.chat-heading span { font-size: 11px; color: var(--muted); }
.message-region { position: relative; flex: 1; min-height: 0; display: flex; }
.message-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px 32px 24px; scrollbar-width: thin; scrollbar-color: #646451 transparent; scroll-behavior: auto; background: radial-gradient(ellipse at 100% 100%, #ffe13504, transparent 70%); }
.history-control { text-align: center; min-height: 18px; }
.message-list { display: flex; flex-direction: column; gap: 14px; }
.date-separator { align-self: center; background: #30302c; border: 1px solid #414139; border-radius: 20px; padding: 6px 12px; text-align: center; color: var(--muted); font-size: 10px; letter-spacing: .3px; margin: 20px 0 12px; }
.message { max-width: 76%; align-self: flex-start; display: grid; gap: 6px; }
.message.mine { align-self: flex-end; }
.message-author { font-size: 10px; color: var(--muted); padding-left: 8px; }
.message-bubble { background: #343430; border: 1px solid #46463b; border-radius: 17px 17px 17px 5px; padding: 13px 16px 10px; min-width: 90px; box-shadow: 0 4px 14px #00000008; }
.mine .message-bubble { background: var(--accent); color: #262626; border: 1px solid var(--accent); border-radius: 17px 17px 5px 17px; }
.message-text { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; margin: 0; }
.message-time { font-size: 10px; display: block; text-align: right; color: var(--muted); margin-top: 7px; }
.mine .message-time { color: #5c5324; }
.empty-conversation { text-align: center; position: relative; top: 28%; font-size: 13px; color: var(--muted); line-height: 1.9; }
.composer { display: grid; grid-template-columns: minmax(0,1fr) 46px; gap: 10px; align-items: end; border-top: 1px solid var(--border); padding: 20px 29px 16px; background: #292929; }
.composer textarea { border: 1px solid #4b4b42; background: #30302d; border-radius: 13px; padding: 13px 15px; font-size: 14px; resize: none; max-height: 140px; min-height: 47px; scrollbar-width: thin; }
.send-button { display: flex; align-items: center; justify-content: center; background: var(--accent); border: 0; color: #262626; width: 46px; height: 47px; border-radius: 13px; margin-bottom: 1px; transition: background .18s; }
.send-button:hover { background: var(--accent-hover); }
.send-button:disabled { background: #444439; opacity: 1; color: #abab95; }
.send-button svg { height: 21px; width: 21px; }
.composer-note { grid-column: 1/-1; display: flex; justify-content: space-between; font-size: 9px; color: var(--muted); padding: 2px 3px; gap: 15px; }
.composer-note .over-limit { color: var(--danger); }
.mobile-only { display: none; }
.toast { position: fixed; bottom: 27px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #262626; border: 1px solid #ffec7d; box-shadow: 0 8px 35px #00000030; border-radius: 13px; padding: 13px 20px; font-size: 12px; line-height: 1.5; max-width: min(90%,520px); z-index: 20; }
.toast.error { background: #452f2d; color: var(--danger); border-color: #70453e; }

/* Dialogs */
dialog { border: 1px solid #575744; border-radius: 22px; padding: 28px; max-width: 440px; width: calc(100% - 36px); color: var(--ink); background: #2c2c2a; box-shadow: 0 24px 100px #00000060; }
dialog::backdrop { background: #151515aa; backdrop-filter: blur(6px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.dialog-heading h2 { font-size: 25px; font-weight: 650; letter-spacing: -.8px; margin: 0; }
.dialog-heading .icon-button { width: 30px; height: 30px; }
dialog .muted { font-size: 12px; margin: 14px 0 25px; }
dialog form { display: grid; gap: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 3px; }
#my-id { font-size: 12px; font-family: ui-monospace, monospace; background: #242424; }
#profile-dialog .wide { margin-top: 17px; }
.members-list { display: grid; gap: 16px; padding-top: 25px; }
.member-item { display: grid; gap: 8px; }
.member-item strong { font-size: 13px; font-weight: 550; }
.member-item code { font-size: 11px; overflow-wrap: anywhere; color: var(--muted); background: #242424; border: 1px solid var(--border); padding: 12px; border-radius: 10px; }

/* Optional API explanation panel */
.diagnostics-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; background: transparent; border: 1px solid #515143; border-radius: 11px; padding: 11px 12px; color: var(--muted); font-size: 11px; font-weight: 550; }
.diagnostics-toggle svg { width: 15px; height: 15px; }
.diagnostics-toggle:hover, .diagnostics-toggle[aria-expanded=true] { background: #ffe1350d; border-color: #ffe13565; color: var(--accent); }
.auth-bottom .diagnostics-toggle { margin: 15px auto 0; }
.sidebar-diagnostics { margin: 10px 9px 0; flex-shrink: 0; }
.diagnostics-panel { position: fixed; z-index: 15; right: 30px; top: 108px; width: 330px; max-height: min(56svh,490px); overflow: auto; background: #2c2c2a; border: 1px solid #66603a; border-radius: 20px; box-shadow: 0 18px 55px #00000030; padding: 20px; scrollbar-width: thin; scrollbar-color: #646451 transparent; }
.diagnostics-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; }
.diagnostics-heading .eyebrow { font-size: 9px; letter-spacing: 1.4px; }
.diagnostics-heading h2 { font-size: 19px; font-weight: 650; letter-spacing: -.5px; margin: 5px 0 0; }
.diagnostics-heading .icon-button { width: 30px; height: 30px; }
.diagnostics-label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.diagnostics-summary { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; background: #ffe1350c; border: 1px solid #ffe13520; border-radius: 12px; padding: 12px; }
.diagnostics-summary strong { display: block; font-size: 11px; overflow-wrap: anywhere; }
.diagnostics-history { padding: 16px 0; border-bottom: 1px solid var(--border); }
.diagnostics-history > strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.diagnostics-history > p { font-size: 11px; color: var(--muted); margin: 8px 0 0; }
.diagnostics-request { padding-top: 16px; }
.diagnostics-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.diagnostics-section-heading h3 { font-size: 12px; margin: 0; font-weight: 600; }
.diagnostics-section-heading time { font-size: 10px; color: var(--muted); }
.diagnostics-request-line { display: flex; align-items: center; gap: 8px; }
.diagnostics-method, .diagnostics-status { font: 600 11px ui-monospace, monospace; padding: 6px 8px; border-radius: 6px; background: #404036; color: var(--accent); }
.diagnostics-status { background: var(--accent); color: #262626; }
.diagnostics-status.failed { background: #56332e; color: var(--danger); }
.diagnostics-path { display: block; font: 11px/1.6 ui-monospace, monospace; overflow-wrap: anywhere; color: var(--muted); margin-top: 10px; }
.diagnostics-result { font-size: 12px; line-height: 1.6; color: var(--accent); margin: 10px 0 14px; }
.diagnostics-result.failed { color: var(--danger); }
.diagnostics-metrics { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 14px; gap: 12px; }
.diagnostics-metrics dt { font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.diagnostics-metrics dd { font: 550 12px ui-monospace, monospace; margin: 0; color: var(--ink); }
.diagnostics-request-id { display: block; font: 10px/1.7 ui-monospace, monospace; overflow-wrap: anywhere; color: var(--muted); }
.diagnostics-previous { list-style: none; margin: 15px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.diagnostics-previous li { display: flex; gap: 8px; align-items: center; min-width: 0; }
.diagnostics-mini-status { font: 550 10px ui-monospace, monospace; color: var(--accent); min-width: 23px; }
.diagnostics-mini-status.failed { color: var(--danger); }
.diagnostics-previous code { font: 10px ui-monospace, monospace; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diagnostics-background { font-size: 10px; color: var(--muted); margin: 12px 0 0; line-height: 1.7; }
.diagnostics-note { font-size: 11px; color: var(--muted); line-height: 1.7; margin: 0; }
.diagnostics-footnote { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 14px; font-size: 10px; }

@media (min-width: 1490px) {
  .app-shell { height: calc(100svh - 64px); margin: 32px auto; }
}
@media (max-width: 1100px) {
  .intro { padding: 40px 38px; }
  .auth-side { padding: 40px 35px; }
  .app-shell { margin: 14px; height: calc(100svh - 28px); grid-template-columns: 280px minmax(0,1fr); }
  .conversation-art { margin-left: 0; width: 290px; }
  .intro h1 { font-size: 56px; }
  .sidebar { padding-left: 14px; padding-right: 14px; }
  .message-scroll { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 720px) {
  .auth-layout { display: block; }
  .intro { min-height: 0; padding: 28px; }
  .intro-copy { margin-top: 30px; }
  .intro h1 { font-size: 42px; letter-spacing: -2px; line-height: 1.08; margin: 14px 0 0; }
  .intro h1 br { display: none; }
  .intro-copy .eyebrow { font-size: 9px; }
  .intro-copy p, .conversation-art, .intro-footer { display: none; }
  .auth-side { min-height: 0; padding: 30px 28px; align-items: center; border-left: 0; border-top: 1px solid var(--border); }
  .auth-card { max-width: 440px; }
  .auth-switch { margin-bottom: 28px; }
  .auth-card h2 { font-size: 32px; }
  .auth-card h2 br { display: none; }
  .auth-card .muted { margin-bottom: 22px; }
  .auth-card form { gap: 17px; }
  .auth-bottom { margin-top: 20px; }
  .app-shell { margin: 0; border: 0; border-radius: 0; height: 100svh; display: block; }
  .sidebar { height: 100%; width: 100%; padding: 25px 18px 0; border: 0; }
  .sidebar-heading { padding-top: 30px; }
  .workspace { display: none; height: 100%; }
  .app-shell.chat-open .sidebar { display: none; }
  .app-shell.chat-open .workspace { display: block; }
  .welcome { display: none; }
  .mobile-only { display: flex; }
  .chat-header { padding: 15px; gap: 7px; min-height: 75px; }
  .chat-header .avatar { width: 35px; height: 35px; border-radius: 11px; }
  .chat-heading h2 { font-size: 14px; }
  .chat-header .icon-button { width: 31px; height: 31px; }
  .chat-header .icon-button svg { width: 19px; height: 19px; }
  .message-scroll { padding: 10px 16px 20px; }
  .message { max-width: 88%; }
  .composer { padding: 14px 16px max(13px, env(safe-area-inset-bottom)); }
  .composer-note { font-size: 9px; }
  .composer-note > span:first-child { max-width: 70%; }
  .profile { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .toast { bottom: 20px; }
  .diagnostics-panel { top: 83px; right: 12px; width: calc(100% - 24px); max-height: 52svh; padding: 16px; }
  .sidebar-diagnostics { margin-top: 9px; }
}
@media (min-width: 721px) {
  body:not(.has-session) .diagnostics-panel { right: 24px; left: auto; }
}
@media (min-width: 1100px) {
  .diagnostics-open.has-session .app-shell { margin-left: 22px; margin-right: 380px; }
  .diagnostics-open.has-session .diagnostics-panel { top: 22px; max-height: calc(100svh - 44px); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* Password controls and the animated SVG character. */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 47px; }
.password-toggle { position: absolute; right: 7px; top: 7px; width: 33px; height: 33px; border: 0; background: transparent; border-radius: 9px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.password-toggle:hover, .password-toggle[aria-pressed=true] { color: var(--accent); background: #ffe1350c; }
.password-toggle svg { width: 18px; height: 18px; }
/* One SVG mascot; CSS handles poses and the browser handles animation frames. */
.mascot-stage { position: relative; width: 350px; max-width: 100%; height: 280px; margin: 20px 0 0 5px; pointer-events: none; isolation: isolate; --scene-surface: #262626; --gaze-x: 0px; --gaze-y: 0px; }
.spirit-svg { stroke: none; position: absolute; left: 0; bottom: 0; width: 285px; height: 285px; overflow: visible; z-index: 2; }
.spirit-motion { animation: spirit-breathe 4.5s ease-in-out infinite; }
.spirit-lean { transform-origin: 150px 268px; transition: transform .65s cubic-bezier(.22,1,.36,1); }
.spirit-eye { transform-box: fill-box; transform-origin: center; animation: spirit-blink 7s infinite; }
.spirit-eye-right { animation-delay: .1s; }
.spirit-pupil { transform: translate(var(--gaze-x), var(--gaze-y)); transition: transform .16s ease-out; }
.spirit-hand { transform-box: view-box; transition: transform .55s cubic-bezier(.22,1,.36,1); }
.spirit-gasp { opacity: 0; }
.mascot-stage[data-mood=looking] .spirit-lean { transform: translate(8px,-3px) rotate(3deg); }
.mascot-stage.is-curious .spirit-motion { animation: spirit-step .42s ease-in-out 3; }
.mascot-stage:is([data-mood=private],[data-mood=short],[data-mood=revealed]) .spirit-lean { transform: rotate(-4deg); }
.mascot-stage:is([data-mood=private],[data-mood=short],[data-mood=revealed]) .spirit-hand-left { transform: translate(28px,-37px) rotate(3deg); }
.mascot-stage:is([data-mood=private],[data-mood=short]) .spirit-hand-right { transform: translate(-28px,-25px) rotate(-3deg); }
.mascot-stage:is([data-mood=private],[data-mood=short]) .spirit-eye { animation: none; scale: 1 .08; }
.mascot-stage[data-mood=revealed] .spirit-hand-right { transform: translate(-28px,-39px) rotate(-3deg); }
.mascot-stage[data-mood=revealed] .spirit-eye { animation: none; scale: 1 .08; }
.mascot-stage[data-mood=pending] .spirit-motion { animation: spirit-breathe 1.1s ease-in-out infinite; }
.mascot-stage[data-mood=error] .spirit-motion { animation: spirit-shake .4s ease-in-out 2; }
.mascot-stage[data-mood=success] .spirit-motion { animation: spirit-hop .65s ease-in-out; }
.mascot-stage.is-sleepy .spirit-eye { animation: none; scale: 1 .2; }
.mascot-stage.is-sleepy .spirit-lean { transform: rotate(-5deg); }
.mascot-stage.is-scared .spirit-motion { animation: spirit-shake .25s ease-in-out infinite; }
.mascot-stage.is-scared :is(.spirit-smile,.kolo-tooth) { opacity: 0; }
.mascot-stage.is-scared .spirit-gasp { opacity: 1; }
.mascot-stage:not(.is-visible) * { animation-play-state: paused; }
.mascot-conversation { position: absolute; inset: 0; z-index: 0; }
.mascot-bubble { position: absolute; border-radius: 17px; animation: spirit-float 5s ease-in-out infinite; }
.mascot-bubble-filled { left: 247px; top: 20px; width: 88px; height: 50px; background: var(--accent); display: flex; align-items: center; justify-content: center; gap: 6px; rotate: -6deg; }
.mascot-bubble-filled::after { content: ""; position: absolute; bottom: -7px; left: 18px; width: 17px; height: 17px; background: var(--accent); clip-path: polygon(0 0,100% 0,0 100%); }
.mascot-bubble-filled span { width: 5px; height: 5px; border-radius: 50%; background: #262626; animation: spirit-typing 1.8s ease-in-out infinite; }
.mascot-bubble-filled span:nth-child(2) { animation-delay: .16s; }
.mascot-bubble-filled span:nth-child(3) { animation-delay: .32s; }
.mascot-bubble-outline { left: 265px; top: 107px; width: 77px; height: 55px; border: 1.5px solid #ffe13555; background: var(--scene-surface); rotate: 7deg; animation-delay: -2.5s; padding: 18px 15px; }
.mascot-bubble-outline::after { content: ""; position: absolute; bottom: -6px; right: 16px; width: 11px; height: 11px; border-right: 1.5px solid #ffe13555; border-bottom: 1.5px solid #ffe13555; background: var(--scene-surface); rotate: 45deg; }
.mascot-bubble-outline i { display: block; height: 2px; width: 100%; margin-bottom: 8px; border-radius: 2px; background: #ffe13555; }
.mascot-bubble-outline i:last-child { width: 65%; }
@keyframes spirit-breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes spirit-step { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes spirit-blink { 0%,42%,46%,100% { scale: 1 1; } 44% { scale: 1 .08; } }
@keyframes spirit-peek { 0%,20%,76%,100% { scale: 1 .12; } 30%,66% { scale: 1 1; } }
@keyframes spirit-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes spirit-hop { 0%,100% { transform: translateY(0); } 25% { transform: translateY(3px); } 60% { transform: translateY(-15px); } }
@keyframes spirit-float { 0%,100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes spirit-typing { 0%,55%,100% { translate: 0 0; opacity: .4; } 28% { translate: 0 -3px; opacity: 1; } }

.scenario-section { padding: 17px 0 15px; border-bottom: 1px solid var(--border); }
.scenario-section h3 { font-size: 13px; margin: 0 0 9px; }
.scenario-description { font-size: 10px; line-height: 1.7; color: var(--muted); margin: 0 0 12px; }
.scenario-actions { display: grid; gap: 8px; }
.scenario-actions .button { padding: 11px 10px; font-size: 11px; }
.scenario-status { font-size: 11px; line-height: 1.6; margin: 12px 0 0; color: var(--ink); }
.scenario-status.failed { color: var(--danger); }
.scenario-scope { margin: 12px 0 0; }
.scenario-steps { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; max-height: 245px; overflow: auto; scrollbar-width: thin; scrollbar-color: #646451 transparent; }
.scenario-step { border: 1px solid var(--border); border-radius: 10px; background: #262626; padding: 10px; }
.scenario-step[data-state=failed] { border-color: #9a5b51; }
.scenario-step summary { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 11px; line-height: 1.5; list-style: none; }
.scenario-step summary::before { content: "▸"; color: var(--muted); }
.scenario-step[open] summary::before { content: "▾"; }
.scenario-step summary::-webkit-details-marker { display: none; }
.scenario-step-badge { flex-shrink: 0; color: var(--accent); font: 650 10px/1.65 ui-monospace, monospace; }
.scenario-step[data-state=failed] .scenario-step-badge { color: var(--danger); }
.scenario-step[data-state=pending] .scenario-step-badge { color: var(--muted); }
.scenario-step p { color: var(--muted); font-size: 10px; line-height: 1.7; margin: 9px 0 0; }
.scenario-step code { display: block; color: var(--muted); font: 10px/1.7 ui-monospace, monospace; overflow-wrap: anywhere; margin-top: 7px; }
@media (max-width: 720px) {
  .auth-card .mascot-stage { width: 100%; height: 166px; margin: -14px auto 14px; --scene-surface: #2c2c2a; }
  .spirit-svg { width: 178px; height: 178px; left: calc(50% - 105px); }
  .mascot-bubble { border-radius: 13px; }
  .mascot-bubble-filled { left: calc(50% + 45px); top: 9px; width: 58px; height: 34px; gap: 4px; }
  .mascot-bubble-filled span { width: 4px; height: 4px; }
  .mascot-bubble-filled::after { width: 12px; height: 12px; bottom: -5px; left: 13px; }
  .mascot-bubble-outline { left: calc(50% + 52px); top: 66px; width: 54px; height: 40px; padding: 13px 10px; }
  .mascot-bubble-outline i { margin-bottom: 6px; }
  .mascot-bubble-outline::after { width: 8px; height: 8px; bottom: -5px; right: 12px; }
  .intro h1 { font-size: 36px; }
  .intro { padding-bottom: 18px; }
  .scenario-steps { max-height: 175px; }
}
.diagnostics-origin { margin-top: 10px; }

.auth-card form { margin-top: 24px; }
.auth-card .muted + form { margin-top: 0; }
.diagnostics-help { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.diagnostics-help summary { color: var(--muted); font-size: 10px; cursor: pointer; }
.diagnostics-help .diagnostics-note { margin-top: 10px; font-size: 10px; }
@media (prefers-reduced-motion: reduce) {
  .mascot-stage *, .mascot-stage *::before { animation: none !important; transition: none !important; }
}

/* Keep the reader's position while messages arrive below. */
.jump-latest { position: absolute; right: 24px; bottom: 16px; border: 1px solid #ffe13555; background: #36362d; color: var(--accent); padding: 10px 15px; border-radius: 20px; font-size: 12px; box-shadow: 0 5px 20px #0004; z-index: 2; }
.jump-latest:hover { background: #424234; }
.message.grouped { margin-top: -9px; }
.message.grouped .message-bubble { border-top-left-radius: 8px; }
.message.mine.grouped .message-bubble { border-top-left-radius: 17px; border-top-right-radius: 8px; }
@media (max-width: 720px) { .jump-latest { right: 14px; bottom: 12px; } }

.welcome-illustration { width: 260px; max-width: 75%; height: auto; margin-bottom: 12px; }
.welcome h1 { font-size: 38px; margin: 14px 0; }
.empty-conversation { top: auto; padding: 35px 16px; color: #d6d6c9; }
.empty-conversation img { width: 165px; max-width: 70%; height: auto; }
.empty-conversation p { color: var(--ink); font-size: 16px; margin: 15px 0 8px; }
.empty-conversation span { color: var(--muted); font-size: 12px; }
.message-bubble { color: #e5e5dc; }
.mine .message-bubble { color: #262626; }
.composer-note { font-size: 10px; line-height: 1.5; }
@media (max-width: 720px) { .welcome-illustration { width: 200px; } .welcome h1 { font-size: 32px; } }
.message-scroll { background-image: url('/assets/chat-pattern.svg'); background-size: 180px 160px; }

/* Head, ears and mushrooms remain independent of the body. */
.kolo-head { transform-origin: 151px 202px; transition: transform .65s cubic-bezier(.22,1,.36,1); }
.kolo-ear { transform-origin: 150px 135px; transition: transform .7s ease; }
.kolo-mushrooms { transform-origin: 153px 83px; animation: kolo-sway 6s ease-in-out infinite; }
.mascot-stage[data-mood=looking] .kolo-head { transform: rotate(4deg) translate(3px,-2px); }
.mascot-stage[data-mood=looking] .kolo-ear-right { transform: rotate(-3deg); }
.mascot-stage:is([data-mood=private],[data-mood=short],[data-mood=revealed]) .kolo-head { transform: translate(-5px,2px) rotate(-9deg); }
.mascot-stage:is([data-mood=private],[data-mood=short],[data-mood=revealed]) .spirit-face { opacity: .65; }
.mascot-stage[data-mood=success] .kolo-ear { transform: rotate(-3deg); }
.mascot-stage.is-sleepy .kolo-head { transform: rotate(-6deg) translateY(3px); }
.auth-error-art { float: right; width: 66px; height: 66px; object-fit: contain; margin: 10px 0 0 10px; }
.state-error { text-align: center; padding: 28px 18px; color: var(--muted); }
.state-error img { width: 160px; max-width: 65%; height: auto; }
.state-error h2, .state-error h3 { color: var(--ink); font-size: 19px; font-weight: 600; margin: 14px 0 10px; }
.state-error p { font-size: 12px; line-height: 1.7; margin: 0 0 18px; }
.state-error .button { font-size: 12px; padding: 11px 18px; }
.welcome.state-error { height: 100%; }
@keyframes kolo-sway { 0%,100% { transform: rotate(-1deg); } 50% { transform: rotate(2deg); } }
@media (max-width: 720px) {
  .state-error img { width: 130px; }
  .welcome-illustration { width: 200px; max-height: 24svh; object-fit: contain; }
}
@media (prefers-reduced-motion: reduce) {
  .kolo-mushrooms { animation: none; }
}

.message-scroll:has(> :is(.empty-conversation,.state-error):not([hidden])) { display: flex; flex-direction: column; }
.message-scroll > :is(.empty-conversation,.state-error) { margin: auto 0; }
