﻿:root {
  color-scheme: dark;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: #f3f7ff;
  background: #101722;
  --app: #101722;
  --surface-hover: #d1e8ff24;
  --line: #deebff24;
  --muted: #b3c0d1;
  --accent: #c8e5ff;
  --accent-ink: #172c41;
  --frost: linear-gradient(145deg,#d7eaff22,#accef310 42%,#7292bd08 83%);
  --panel-shadow: inset 0 1px 0 #f2f8ff38,inset 0 -1px 0 #a9dbff14,0 20px 42px #040a1454;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; isolation: isolate; }
main { display: flow-root; }
button, input, textarea, select { font: inherit; }
button {
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: .57rem .86rem;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .2s, box-shadow .2s;
}
button:hover { background: var(--surface-hover); }
button:disabled { opacity: .44; cursor: default; }
button:focus-visible, a:focus-visible {
  outline: none;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: #ecf7ff;
}
a { color: var(--accent); }
h1, h2, h3, h4, p { margin: 0; }
.primary {
  background: linear-gradient(165deg,#f3faff,#c9e4fb 58%,#a9cae9);
  border: 1px solid #f5fbff8c; color: var(--accent-ink); font-weight: 675;
  box-shadow: inset 0 1px 0 #fff9,0 4px 13px #03091c45;
}
.primary:hover { background: linear-gradient(165deg,#fff,#d9efff 63%,#b5d7f6); box-shadow: inset 0 1px 0 #fff,0 5px 16px #8dcbff29; transform: translateY(-1px); }
.primary:active, .secondary:active { transform: translateY(1px); }
.primary:focus-visible { color: var(--accent-ink); }
.secondary { border-color: var(--line); background: linear-gradient(#f4f9ff15,#e8f4ff08); box-shadow: inset 0 1px 0 #f1f8ff17; }
.secondary:hover { background: linear-gradient(#f4f9ff24,#e8f4ff13); }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; font-size: 1.28rem; line-height: 1; flex: none; }
.danger-text { color: #ffaebd; }
.danger { background: #a53e53; color: #fff3f6; font-weight: 650; }
.danger:hover { background: #bd4b62; }
.feedback, .saved-status { color: #ffc0cc; font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.saved-status { color: #b0e5d1; }
.feedback:not(:empty), .saved-status:not(:empty) { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.scene, .veil { position: fixed; inset: 0; pointer-events: none; }
.scene { z-index: -2; background: #0b2333 url("media/moonlit-rikka.jpg") center / cover; }
.scene video { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s; }
.scene video.ready { opacity: 1; }
.veil { z-index: -1; background: radial-gradient(ellipse at 38% 38%,#0c1e3435,#06070fbd 72%),linear-gradient(0deg,#060810ed,#13162a31 73%); }
.brand-mark {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 12px;
  color: #e5f5ff; border: 1px solid #e3f3ff53;
  background: radial-gradient(ellipse at 25% 0%,#e4f7ff54,transparent 74%),linear-gradient(145deg,#c7e8ff23,#385d854e);
  box-shadow: inset 0 1px 0 #f5fbff65,0 5px 16px #030a2069;
}
#gate, #intro { min-height: 100svh; display: grid; place-items: center; }
.gate-content { display: grid; justify-items: center; gap: 24px; padding: 28px; animation: rise .8s ease both; }
.gate-content .brand-mark { width: 74px; height: 74px; border-radius: 24px; font-size: 2.45rem; backdrop-filter: blur(20px); box-shadow: inset 0 1px 0 #f3f7ffc1,0 12px 70px #a0d9ff38; }
.gate-content h1, .intro-title { font-size: clamp(3.4rem,11vw,8.5rem); line-height: 1; letter-spacing: -.06em; text-shadow: 0 6px 45px #0b0918; }
.gate-content h1 span, .intro-title span, .auth-title h1 span, .empty-state h2 span { color: var(--accent); }
@supports (background-clip: text) {
  .gate-content h1, .intro-title {
    background: linear-gradient(172deg,#f9fcfff4 13%,#d9f1ffe8 41%,#a6c6e3a1 82%);
    background-clip: text; color: transparent; text-shadow: none; padding-inline: .045em;
  }
  .gate-content h1 span, .intro-title span { color: inherit; }
}
#enter { padding: .8rem 1.35rem; border-radius: 999px; }
#intro { position: fixed; inset: 0; z-index: 10; background: #0d0b195c; animation: intro-out 2.65s both; }
.intro-title { animation: rise 1.9s both; }
.letterbox { position: absolute; inset-inline: 0; height: 11%; background: #08080d; }
.letterbox:first-child { top: 0; }
.letterbox:last-child { bottom: 0; }
@keyframes intro-out { 0%,76%{opacity:1}100%{opacity:0} }
@keyframes rise { from{opacity:0;transform:translateY(15px);filter:blur(8px)}to{opacity:1;transform:none;filter:none} }

.auth {
  width: min(92vw, 870px); display: grid; grid-template-columns: 1fr minmax(330px, 420px);
  min-height: 430px; margin: max(24px, calc((100svh - 430px) / 2)) auto 24px;
  border: 1px solid #ffffff32; border-radius: 24px; overflow: hidden;
  background: #16212edc; backdrop-filter: blur(25px) saturate(122%);
  box-shadow: inset 0 1px 0 #edf8ff6e,0 28px 90px #080815ae; animation: rise .65s both;
}
.auth-visual {
  display: flex; align-items: flex-end; gap: 11px; padding: 28px; font-size: 1.2rem; font-weight: 680;
  background: linear-gradient(0deg,#100e1bed,transparent 57%),url("media/moonlit-rikka.jpg") 66% center / cover;
}
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(23px,4vw,43px); }
.auth-title { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-title h1 { font-size: 2rem; letter-spacing: -.06em; }
.tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; background: #0b14209a; border: 1px solid var(--line); padding: 4px; border-radius: 13px; margin-bottom: 18px; }
.tabs button { padding: .5rem .35rem; color: var(--muted); font-size: .89rem; }
.tabs .selected { background: linear-gradient(#e4f2ff28,#b6d6f218); box-shadow: inset 0 1px 0 #e8f6ff3a; color: #f8fcff; }
form, label, .form-fields { display: grid; gap: 12px; }
label { gap: 7px; font-size: .9rem; font-weight: 560; }
input:not([type=checkbox]), textarea, select {
  min-width: 0; width: 100%; color: inherit; font-weight: 400; background: #0a1421a1;
  border: 1px solid #e0efff2c; border-radius: 12px; padding: .7rem .8rem; outline: none;
  box-shadow: inset 0 1px 2px #080e1b70;
}
input:not([type=checkbox]):focus, textarea:focus, select:focus { border-color: #b4dfffaa; }
input::placeholder, textarea::placeholder { color: #a2b2c8; }
textarea { resize: vertical; line-height: 1.52; }

#workspace {
  position: relative; isolation: isolate; height: 100svh; min-height: 420px; display: grid;
  grid-template-columns: clamp(224px,19vw,278px) minmax(0,1fr); gap: 13px; padding: 13px;
  background: var(--app); overflow: hidden;
}
#workspace::before {
  content: ""; position: absolute; z-index: -1; inset: -28px; pointer-events: none;
  background: linear-gradient(135deg,#11304766,#111b2ac9 48%,#1e315972),
    radial-gradient(ellipse at 16% 8%,#7ca6da59,transparent 52%),
    url("media/moonlit-rikka.jpg") center 41% / cover;
  filter: blur(28px) saturate(.78);
}
.sidebar {
  min-height: 0; min-width: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; gap: 15px;
  padding: 15px 11px 11px; border-radius: 23px;
  background: var(--frost),#121d2bbf; border: 1px solid #dfecff2b;
  backdrop-filter: blur(26px) saturate(132%); box-shadow: var(--panel-shadow);
}
.sidebar-top { display: flex; justify-content: space-between; align-items: center; padding-inline: 5px; }
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.025em; }
#sidebar-open, #sidebar-close { display: none; }
.new-chat {
  display: flex; align-items: center; gap: 9px; text-align: start; width: 100%;
  background: linear-gradient(#e0f0ff24,#c5e3ff12); border-color: #d5edff34; padding-inline: 13px; font-weight: 620;
  box-shadow: inset 0 1px 0 #e6f3ff3d;
}
.new-chat:hover { background: #d1eaff2b; }
.new-chat span { color: var(--accent); font-size: 1.14rem; line-height: 1; }
.chat-nav { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #637e9b72 transparent; }
.chat-nav h2 { color: var(--muted); font-size: .78rem; font-weight: 660; padding: 6px 11px 8px; }
#chat-list { display: grid; gap: 3px; }
.chat-entry { display: grid; grid-template-columns: 31px minmax(0,1fr) 32px; gap: 1px; align-items: center; border: 1px solid transparent; border-radius: 12px; }
.chat-entry:has([aria-current=page]) { background: linear-gradient(145deg,#d4edff22,#c8e6ff10); border-color: #cce6ff2b; box-shadow: inset 0 1px 0 #e5f3ff23; }
.chat-row {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%;
  text-align: start; font-size: .9rem; padding: .55rem .62rem; color: #dce6f3;
}
.chat-row span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-row[aria-current=page] { color: #f2f8ff; }
.chat-entry button:hover { background: #e7f3ff15; }
.chat-star { display:grid; place-items:center; width:30px; height:32px; padding:0; border-radius:9px; font-family:"Segoe UI Symbol", system-ui, sans-serif; font-size:1.18rem; line-height:1; color:#b5c6db; }
.chat-star[aria-pressed=true], .chat-star:hover { color:#ffdb94; }
.chat-star[aria-pressed=true] { text-shadow:0 0 9px #ffcd7670; }
.chat-delete { display: grid; place-items: center; width: 30px; height: 32px; padding: 0; color: #9fb1c6; border-radius: 9px; }
.chat-delete:hover, .chat-delete:focus-visible { color: #ffc7d2; background: #ef799d22 !important; }
.trash-icon { position: relative; display: block; width: 14px; height: 16px; }
.trash-icon::before { content: ""; position: absolute; inset: 4px 2px 1px; border: 1px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; }
.trash-icon::after { content: ""; position: absolute; top: 2px; left: 0; width: 14px; height: 1px; background: currentColor; border-radius: 2px; }
.sidebar-footer { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.sidebar-action { display: flex; align-items: center; gap: 9px; text-align: start; color: #d7e4f5; font-size: .9rem; }
.panel-icon { width: 18px; text-align: center; color: var(--accent); }
.profile-button { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center; text-align: start; width: 100%; background: linear-gradient(#dceeff19,#bfdeff0b); border-color: #e4f4ff21; box-shadow: inset 0 1px 0 #e4f4ff16; }
.profile-button img, .account-identity img { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; border: 1px solid #ffffff32; }
.profile-button strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.profile-button small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.profile-gear { color: var(--muted); font-size: 1rem; }

.workspace-content { min-width: 0; min-height: 0; display: grid; grid-template-rows: 56px minmax(0,1fr); gap: 13px; }
.workspace-header {
  display: flex; align-items: center; gap: 10px; padding: 0 clamp(12px,1.8vw,24px); min-width: 0;
  border: 1px solid #dcecff2b; border-radius: 19px;
  background: var(--frost),#152132bd; backdrop-filter: blur(24px) saturate(135%); box-shadow: var(--panel-shadow);
}
.workspace-header h1 { flex: 1; min-width: 0; font-size: 1rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.header-actions { display: flex; align-items: center; gap: 7px; }
.header-actions .secondary { font-size: .85rem; white-space: nowrap; border-radius: 999px; }
.studio { display: grid; grid-template-columns: minmax(0,1fr) clamp(338px,37vw,570px); gap: 12px; min-height: 0; min-width: 0; }
.studio.stage-hidden { grid-template-columns: minmax(0,1fr); }
.chat {
  display: grid; grid-template-rows: minmax(0,1fr) auto; min-width: 0; min-height: 0;
  position: relative; z-index: 1;
  border: 1px solid #d6e9ff2a; border-radius: 24px; isolation: isolate;
  background: linear-gradient(165deg,#303f539e,#192435d4 44%,#162131ed);
  backdrop-filter: blur(24px) saturate(138%); box-shadow: var(--panel-shadow);
}
#thread { min-width: 0; overflow: auto; display: flex; flex-direction: column; gap: 21px; padding: 24px clamp(15px,3.4vw,49px); scrollbar-width: thin; scrollbar-color: #7591af60 transparent; }
#thread { border-radius: 24px 24px 0 0; }
.empty-state { display: grid; justify-items: center; gap: 14px; margin: auto; padding: 22px 8px; text-align: center; }
.empty-state .brand-mark { width: 65px; height: 65px; border-radius: 22px; font-size: 1.85rem; box-shadow: inset 0 1px 0 #f1f9ff94,0 8px 28px #96c9ff35; }
.empty-state h2 { font-size: clamp(2.2rem,4vw,3rem); line-height: 1.02; letter-spacing: -.065em; font-weight: 690; }
.empty-state button { margin-top: 5px; }
.bubble {
  position: relative; width: fit-content; max-width: min(89%, 720px); color: #eef4fd; padding: .72rem .95rem;
  font-size: 1rem; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble.assistant { align-self: flex-start; margin-left: 40px; max-width: calc(100% - 40px); padding: 3px 0; }
.bubble.assistant::before {
  content: "✦"; position: absolute; top: 2px; left: -40px; width: 29px; height: 29px; display: grid; place-items: center;
  border-radius: 10px; color: #e4f5ff; background: linear-gradient(145deg,#d4ecff39,#9ac0ef1b);
  border: 1px solid #c4e5ff3e; box-shadow: inset 0 1px 0 #e8f6ff46; font-size: .8rem;
}
.bubble.user {
  align-self: flex-end; border: 1px solid #cbe7ff3c; border-radius: 20px 20px 7px 20px;
  background: linear-gradient(145deg,#86b6eb35,#7896c225 88%);
  box-shadow: inset 0 1px 0 #e2f2ff2c,0 8px 18px #050f1e32;
}
.message-enter { animation: message-in .3s cubic-bezier(.18,.77,.22,1) both; }
@keyframes message-in { from {opacity:0;transform:translateY(7px) scale(.985)} to {opacity:1;transform:none} }
.message-content.formatted { white-space: normal; }
.message-content.formatted > * + * { margin-top: .72em; }
.message-content.formatted h1,.message-content.formatted h2,.message-content.formatted h3 { font-size: 1.12rem; letter-spacing: -.015em; }
.message-content.formatted ol,.message-content.formatted ul { padding-inline-start: 1.35rem; margin-block: .6em; }
.message-content.formatted li + li { margin-top: .22em; }
.message-content.formatted code { font: .88em ui-monospace, monospace; color:#e0f1ff; background:#08142299; border-radius:5px; padding:.08em .26em; }
.message-content.formatted pre { background:#081322ab; border:1px solid #c4e6ff24; border-radius:13px; padding:11px; overflow:auto; white-space:pre; scrollbar-width:thin; scrollbar-color:#718ba471 transparent; }
.message-content.formatted pre code { background:none; padding:0; }
.message-content.formatted blockquote { margin-inline:0; padding-left:10px; border-left:2px solid #b5d9ff70; color:#bfd1e4; }
.message-content.formatted table { border-collapse:collapse; display:block; overflow:auto; }
.message-content.formatted td,.message-content.formatted th { border:1px solid #bddaff35; padding:5px 9px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: .82rem; white-space: normal; }
.sources a { border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; text-decoration: none; }
.sources a:hover { background: #c0e1ff20; text-decoration: underline; }
.response-progress, .response-activity { font-size: .83rem; line-height: 1.45; color: var(--muted); white-space: normal; }
.response-progress { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.response-progress::before { content:""; width:6px; height:6px; flex:none; border-radius:50%; background:var(--accent); animation:working 1.2s ease-in-out infinite alternate; }
@keyframes working { to { opacity: .3; } }
.response-activity { margin-bottom: 4px; }
.response-activity summary { cursor: pointer; width: fit-content; padding: 2px 7px; border: 1px solid #cfebff27; border-radius: 8px; background: #cdedff0b; }
.response-activity ol { margin: 4px 0 8px; padding-inline-start: 1.35em; }
.response-approach {
  max-width: 610px; padding: 8px 12px 9px; margin: 6px 0 10px;
  border-left: 2px solid #a8d8ff; border-radius: 0 12px 12px 0;
  background: linear-gradient(110deg,#b2d8fc22,#bbdffb08); white-space: normal; color: #dce9f6;
}
.response-approach strong { display: block; font-size: .8rem; font-weight: 650; color: #e0f1ff; }
.response-approach p { font-size: .89rem; line-height: 1.45; }
.composer-wrap { width: min(100%, 900px); margin-inline: auto; padding: 0 clamp(14px,3.4vw,49px) 17px; }
#composer {
  gap: 4px; border: 1px solid #d3eaff48; border-radius: 21px; padding: 8px;
  background: radial-gradient(ellipse at 10% 0%,#c0e3ff24,transparent 74%),linear-gradient(155deg,#40556d9e,#233347d9);
  box-shadow: inset 0 1px 0 #f0f8ff63,inset 0 -1px 0 #ccedff12,0 14px 27px #050e1c62;
  transition: border-color .22s,box-shadow .22s;
}
#composer:focus-within { border-color: #b7deff80; box-shadow: inset 0 1px 0 #f1faff6b,0 10px 27px #050e1c62,0 0 16px #a9ddff1f; }
#message { resize: none; min-height: 45px; max-height: 140px; border: none; background: transparent; padding: 8px 10px 0; box-shadow:none; }
.composer-actions { display: flex; align-items: center; gap: 6px; padding: 1px 1px 0; }
.composer-actions button { padding: .46rem .83rem; font-size: .875rem; }
.composer-actions #send { margin-left: auto; }
.composer-actions #stop { color: #ffdddd; }
.composer-actions #mic, .composer-actions #send, .composer-actions #stop { border-radius: 999px; }
.composer-actions #attach { display:grid; place-items:center; flex:none; width:36px; height:36px; border-radius:50%; padding:0; font-size:1.12rem; line-height:1; }
.composer-actions { flex-wrap:wrap; }
.tool-toggle { white-space:nowrap; border-radius:999px; }
.tool-toggle[aria-pressed=true] { color:#e7f5ff; border-color:#b3d7ff8a; background:linear-gradient(#a9d7fa3e,#7db3ee24); box-shadow:inset 0 1px 0 #e7f4ff38,0 0 12px #85b5f02f; }
.workspace-tools { margin-top:18px; border-top:1px solid var(--line); padding-top:13px; }
#chat-files-list { max-height:38svh; overflow:auto; scrollbar-width:thin; }
.dialog-body .workspace-tools h3 { font-size:1rem; margin-bottom:8px; }
.code-result pre { color:#d7e9fd; overflow:auto; max-height:230px; padding:8px; white-space:pre-wrap; overflow-wrap:anywhere; background:#14253f; border-radius:8px; }
.draft-files, .message-files { display:flex; flex-wrap:wrap; gap:7px; }
.draft-files { padding:3px 4px 8px; max-height:106px; overflow:auto; }
.draft-file { display:flex; align-items:center; gap:6px; max-width:100%; min-width:0; border:1px solid #cce9ff3b; border-radius:10px; background:linear-gradient(#cde8ff22,#bddcff11); padding-left:9px; font-size:.8rem; }
.draft-file span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.draft-file-remove { width:28px; height:28px; padding:0; flex:none; border-radius:8px; color:#dcecff; }
.message-files { margin-top:6px; }
.message-content:empty + .message-files { margin-top:0; }
.file-card { display:grid; gap:4px; min-width:0; max-width:100%; padding:7px 10px; border:1px solid #d8ebff33; border-radius:10px; background:#101e3370; text-align:left; text-decoration:none; }
.file-card strong { color:#e8f4ff; font-size:.84rem; overflow-wrap:anywhere; }
.file-card small { color:var(--muted); font-size:.72rem; }
a.file-card:hover { background:#2d4868c9; }
.file-card img { display:block; max-width:min(100%,180px); max-height:132px; object-fit:contain; border-radius:7px; margin-bottom:3px; }
.reasoning-control { position: relative; }
#reasoning {
  display: flex; align-items: center; gap: 7px; white-space: nowrap; border-radius: 999px; padding: .42rem .7rem;
  background: linear-gradient(#e0f3ff23,#c2e5ff12); border-color: #d3ebff37; box-shadow: inset 0 1px 0 #edf8ff2e;
}
#reasoning:hover,#reasoning[aria-expanded=true] { background: #cae9ff28; }
.reasoning-icon { color: var(--accent); font-size: .92rem; }
.chevron { display:inline-block; width:6px; height:6px; border-right:1px solid currentColor; border-bottom:1px solid currentColor; transform: rotate(45deg) translateY(-1px); transition: transform .2s; color: #c6d6e7; }
#reasoning[aria-expanded=true] .chevron { transform: rotate(225deg) translateY(-1px); }
#reasoning-menu {
  position: absolute; bottom: calc(100% + 9px); left: 0; z-index: 4; width: min(255px,75vw); padding: 6px;
  border: 1px solid #d8ecff5a; border-radius: 16px; background: var(--frost),#182a3ded;
  box-shadow: var(--panel-shadow); backdrop-filter: blur(30px) saturate(145%);
  animation: menu-in .22s cubic-bezier(.24,.78,.23,1) both; transform-origin: bottom left;
}
@keyframes menu-in {from {opacity:0;transform:translateY(6px) scale(.975)} to {opacity:1;transform:none}}
#reasoning-menu button { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: start; width: 100%; padding: 8px 10px; }
.menu-label { padding: 4px 10px 6px; font-size: .77rem; color: var(--muted); font-weight: 630; }
#reasoning-menu button strong,#reasoning-menu button small { display: block; }
#reasoning-menu button strong { font-size: .9rem; font-weight: 650; }
#reasoning-menu button small { font-size: .78rem; margin-top: 1px; color: #adc3d9; }
#reasoning-menu button[aria-selected=true] { background: linear-gradient(#d2ecff22,#d2ecff13); border-color: #cfeaff26; }
#reasoning-menu button[aria-selected=true]::after { content: "✓"; color: #c6e6ff; font-size: .94rem; }
#reasoning-menu button:focus-visible { background: #b6ddff2e; outline: none; text-decoration:none; }
#chat-error:not(:empty) { margin-top: 7px; }

@property --stage-light { syntax:"<color>"; inherits:true; initial-value:#91c5ef; }
.stage {
  --stage-light: #91c5ef; min-width: 0; min-height: 0; margin: 0;
  position: relative; overflow: hidden; isolation: isolate; border-radius: 24px;
  border: 1px solid #d9eeff44; background: #182538; transition: --stage-light .48s ease;
  box-shadow: var(--panel-shadow);
}
.stage .scene, .stage .veil { position: absolute; }
.stage .scene { z-index: -3; filter: blur(9px) saturate(.79) hue-rotate(8deg); transform: scale(1.075); }
.stage .scene video.ready { opacity: .6; }
.stage .veil {
  z-index: -2;
  background: linear-gradient(170deg,#213147a8,#1b355954 44%,#0c1624dc),
    radial-gradient(ellipse at 72% 72%,#90cfff59,transparent 73%);
}
.stage:before {
  content: ""; position:absolute; inset:0; z-index:-1; pointer-events:none;
  background:
    radial-gradient(ellipse 84% 70% at 49% 38%,color-mix(in srgb,var(--stage-light) 54%,transparent),transparent 76%),
    radial-gradient(ellipse 80% 26% at 50% 100%,#91c4f26b,transparent 90%),
    linear-gradient(0deg,#131e2e96,transparent 28%);
  animation: ambient-shift 9s ease-in-out infinite alternate;
}
@keyframes ambient-shift { from {opacity:.74} to {opacity:1} }
.stage::after { content:""; position:absolute; inset:0; border-radius:inherit; pointer-events:none; box-shadow:inset 0 1px 1px #eaf5ff86,inset 0 -1px 0 #d1eaff40; }
.stage[data-mood=happy],.stage[data-mood=grin],.stage[data-mood=excited],.stage[data-mood=playful],.stage[data-mood=adoring]{--stage-light:#e5a6ee}
.stage[data-mood=shy],.stage[data-mood=blushing],.stage[data-mood=tender]{--stage-light:#e5aec7}
.stage[data-mood=sad],.stage[data-mood=gloomy],.stage[data-mood=deadpan],.stage[data-mood=blank-stare]{--stage-light:#8299da}
.stage[data-mood=annoyed],.stage[data-mood=startled],.stage[data-mood=angry]{--stage-light:#ee9b9b}
.stage[data-mood=surprised],.stage[data-mood=wide-eyed],.stage[data-mood=laugh]{--stage-light:#ecc3a3}
.stage[data-mood=worried],.stage[data-mood=confused],.stage[data-mood=skeptical]{--stage-light:#ab9aea}
.stage[data-mood=smirk],.stage[data-mood=side-mouth],.stage[data-mood=tongue],.stage[data-mood=wink]{--stage-light:#c9a1ed}
.stage[data-mood=shadow-smirk],.stage[data-mood=bloodstain-1],.stage[data-mood=bloodstain-2]{--stage-light:#bb82a5}
.stage[data-mood=dizzy]{--stage-light:#a2c9b8}
.stage[data-mood=scared],.stage[data-mood=disgusted]{--stage-light:#d0a4d7}
.stage[data-mood=relieved]{--stage-light:#b1dfd7}
.stage[data-mood=awkward],.stage[data-mood=squint]{--stage-light:#ddb3ce}
.stage[data-mood=tearful],.stage[data-mood=crying]{--stage-light:#94b1e5}
.stage-top { position:absolute; inset: 13px 15px auto; display:flex; justify-content:space-between; align-items:start; gap:10px; color:#eff8ff; font-size:.875rem; font-weight:640; z-index:2; pointer-events:none; }
.stage-top > span,.stage-top p { padding:4px 10px; border-radius:999px; border:1px solid #d6ecff31; background:linear-gradient(#405b756b,#253b547a); box-shadow:inset 0 1px 0 #d9efff28; backdrop-filter:blur(12px); }
.stage-top p { color:#ecf7ff; font-weight:450; transition:border-color .3s ease, box-shadow .3s ease; }
.stage[data-speaking=true] .stage-top p { border-color:#d9ecff63; box-shadow:inset 0 1px 0 #d9efff38,0 0 16px color-mix(in srgb,var(--stage-light) 24%,transparent); }
.stage-top p:empty { display:none; }
.stage-view { position:absolute; inset: 24px 0 44px; overflow:hidden; }
.stage canvas { position:absolute; inset:0; width:100%; height:100%; filter:drop-shadow(0 18px 24px #0b1026a0) drop-shadow(0 0 16px #d3ecff4f); }
.model-state { position:absolute; inset:47% 12px auto; color:#efe9ff; text-align:center; font-size:.875rem; }
.camera {
  position:absolute; bottom:12px; left:50%; transform:translateX(-50%); display:grid; grid-template-columns:1fr 1fr;
  padding:4px; border:1px solid #d2eaff55; border-radius:999px;
  background:linear-gradient(#91b6df37,#20384dd1); backdrop-filter:blur(20px) saturate(145%);
  box-shadow:inset 0 1px 0 #eef7ff54,0 6px 18px #06102254; white-space:nowrap; isolation:isolate;
}
.camera::before {
  content:""; position:absolute; inset:4px auto 4px 4px; width:calc(50% - 4px); z-index:-1; border-radius:999px;
  background:linear-gradient(#f0f8ff61,#bcddff35); box-shadow:inset 0 1px 0 #f5fcff89;
  transition:transform .38s cubic-bezier(.23,.72,.22,1);
}
.stage[data-framing=portrait] .camera::before { transform:translateX(100%); }
.camera button { padding:.4rem .8rem; font-size:.83rem; border-radius:999px; }
.camera button[aria-pressed=true] { color:#fff; }
.camera button:hover { background:#deeeff17; }

dialog {
  max-width: calc(100vw - 24px); max-height: 89svh; padding: 0; color: inherit;
  background: radial-gradient(ellipse at 10% 0%,#99c4ed29,transparent 57%),linear-gradient(155deg,#223246f0,#162132f7);
  backdrop-filter: blur(32px) saturate(148%); border: 1px solid #e5f3ff49; border-radius: 23px;
  box-shadow: inset 0 1px 0 #f3f9ff60,0 24px 100px #000a; overflow: auto;
}
dialog[open] { animation: panel-in .27s cubic-bezier(.21,.75,.23,1) both; }
dialog::backdrop { background: #080e1b94; backdrop-filter: blur(10px); animation: veil-in .25s ease both; }
@keyframes panel-in { from {opacity:0;transform:translateY(10px) scale(.985)} to {opacity:1;transform:none} }
@keyframes veil-in { from {opacity:0} to {opacity:1} }
.console-dialog { width: 740px; }
.admin-dialog { width: 850px; }
.small-dialog { width: 440px; }
.dialog-header { display:flex; justify-content:space-between; align-items:center; min-height:62px; padding:8px 16px 8px 21px; border-bottom:1px solid var(--line); }
.dialog-header h2 { font-size:1.14rem; font-weight:700; letter-spacing:-.02em; }
.dialog-header .icon-button { color: var(--muted); }
.dialog-body { padding:19px 21px 23px; }
.console-layout { display:grid; grid-template-columns:165px minmax(0,1fr); min-height:330px; }
.console-nav { display:flex; flex-direction:column; gap:5px; padding:13px 9px; border-right:1px solid var(--line); background:#0e1a2b45; }
.console-nav button { text-align:start; color:#c4d5e7; font-size:.9rem; }
.console-nav button[aria-current=page] { color:#f2f9ff; background:linear-gradient(#d4ecff25,#bbdcff16); border-color:#cce7ff2b; box-shadow:inset 0 1px 0 #ecf7ff28; }
.console-content { min-width:0; padding: clamp(16px,3.4vw,28px); max-height: min(70svh,720px); overflow:auto; scrollbar-width:thin; scrollbar-color:#779cbc85 transparent; }
.console-content [data-console-panel]:not([hidden]) { animation: menu-in .22s ease both; }
.console-content h3, .dialog-body h3 { font-size:1.35rem; font-weight:690; letter-spacing:-.03em; margin-bottom:14px; }
.panel-description { color:var(--muted); font-size:.89rem; line-height:1.5; margin-bottom:13px; }
.settings-rows { border-top:1px solid var(--line); }
.setting-row { display:flex; align-items:center; justify-content:space-between; gap:14px; min-height:70px; border-bottom:1px solid var(--line); padding:10px 0; }
.setting-row h4 { font-size:.95rem; font-weight:640; }
.setting-row p { color:var(--muted); font-size:.84rem; line-height:1.45; margin-top:4px; }
.toggle { width:46px; height:26px; border:1px solid #ffffff2d; border-radius:999px; flex:none; padding:3px; background:#66819c42; box-shadow:inset 0 1px 2px #02081368; }
.toggle::before { content:""; display:block; width:18px; height:18px; border-radius:50%; background:linear-gradient(#f0f9ff,#a7bfd5); box-shadow:0 2px 6px #07132470; transition:transform .28s cubic-bezier(.23,.8,.24,1); }
.toggle[aria-checked=true] { background:linear-gradient(#b3dcfa,#79b0e3); border-color:#c6e8ff; }
.toggle[aria-checked=true]::before { transform:translateX(19px); background:linear-gradient(#fff,#dcefff); }
.toggle:focus-visible { box-shadow:0 0 0 3px #b4dcff55; }
.account-identity { display:flex; align-items:center; gap:11px; min-width:0; }
.account-identity h4 { overflow-wrap:anywhere; }
.dialog-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:7px; margin-top:5px; }
#rename-chat .danger-text { margin-right:auto; }
.appearance-heading { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:12px; }
.appearance-heading input { max-width: 330px; }
#appearance-count { color:var(--muted); font-size:.83rem; white-space:nowrap; }
.preset-group { margin-block:13px; }
.preset-group h4 { color:var(--muted); font-size:.82rem; font-weight:650; margin-bottom:7px; }
.preset-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
.preset-option {
  display:flex; align-items:center; gap:8px; min-width:0; border:1px solid var(--line); border-radius:9px;
  padding:8px; font-size:.83rem; color:#dbd7e7; cursor:pointer;
}
.preset-option:hover { background:#ffffff09; }
.preset-option:has(input:checked) { background:linear-gradient(#d2eaff27,#c2e3ff12); border-color:#b5d9fb70; box-shadow:inset 0 1px 0 #ebf6ff2e; }
.preset-option input {
  appearance:none; width:15px; height:15px; flex:none; margin:0; display:grid; place-items:center;
  border:1px solid #b8d7f16e; border-radius:5px; background:#0c1e3299; color:#203953;
}
.preset-option input:checked { background:linear-gradient(#f2faff,#aad4f4); border-color:#e4f4ff; }
.preset-option input:checked::after { content:"✓"; font-size:.74rem; line-height:1; font-weight:800; }
.invite-form, .invite-output { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:end; margin-bottom:14px; }
.invite-output { background:linear-gradient(#a1d0ff23,#689bc41b); border:1px solid #bfdeff35; padding:11px; border-radius:12px; }
#invite-code { font-family:ui-monospace,monospace; font-size:.83rem; }
#invite-table { width:100%; border-collapse:collapse; text-align:start; font-size:.86rem; }
#invite-table th, #invite-table td { border-bottom:1px solid var(--line); text-align:start; padding:9px 6px; overflow-wrap:anywhere; }
#invite-table th { color:var(--muted); font-weight:570; }
.invite-state { display:inline-block; border-radius:999px; padding:3px 7px; color:#c3bed4; background:#ffffff0a; white-space:nowrap; font-size:.76rem; }
.invite-state.available { color:#a8e7cf; background:#68c8a222; }
.invite-state.revoked { color:#ffc1cd; background:#ef86941e; }
#invite-table td:last-child { width:1%; }
#invite-table .danger-text { padding:.32rem .45rem; }
.panel-heading, .panel-toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.panel-heading { margin-bottom:12px; }
.console-content .panel-heading h3 { margin-bottom:0; }
.panel-toolbar input { min-width:0; }
.panel-editor, .memory-card, .account-entry, .admin-history article {
  background:linear-gradient(150deg,#d3ecff17,#a3c7e006 75%);
  border:1px solid #d4e9ff29; border-radius:15px; box-shadow:inset 0 1px 0 #e5f4ff14;
}
.panel-editor { display:grid; gap:12px; padding:15px; margin-block:14px 8px; }
.panel-editor input[type=file] { padding:.54rem; font-size:.86rem; }
input[type=file]::file-selector-button {
  border:1px solid #d3e8ff24; background:#b5dbff17; color:var(--accent); border-radius:7px;
  padding:.4rem .55rem; margin-right:.6rem; font:inherit; cursor:pointer;
}
.panel-editor .panel-description { margin:0; }
.agent-connection { display:grid; gap:10px; padding:13px 15px; border:1px solid var(--line); border-radius:13px; background:#111e304d; }
.agent-connection > div { display:grid; grid-template-columns:5rem minmax(0,1fr); gap:6px 12px; }
.agent-connection dt,.agent-key-row small { color:var(--muted); font-size:.84rem; }
.agent-connection dd { min-width:0; color:#d7edff; overflow-wrap:anywhere; }
.agent-key-list { display:grid; gap:7px; margin-top:12px; padding:0; list-style:none; }
.agent-key-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; border:1px solid var(--line); border-radius:11px; background:#d2e8ff0a; }
.agent-key-row strong,.agent-key-row small { display:block; overflow-wrap:anywhere; }
.agent-key-row button { flex:none; }
.account-api-setting { border-top:1px solid var(--line); }
.account-api-usage { display:grid; gap:9px; }
.api-usage-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.api-usage-heading h4 { font-size:.95rem; font-weight:640; }
.api-usage-values { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
.api-usage-values > div { min-width:0; padding:9px; border:1px solid var(--line); border-radius:9px; background:#d2e8ff0a; }
.api-usage-values dt { color:var(--muted); font-size:.78rem; }
.api-usage-values dd { margin-top:4px; color:#e0effc; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.check-label { display:flex; align-items:center; justify-content:flex-start; }
.check-label input { accent-color:#b4dfff; }
.filter-tags { display:flex; flex-wrap:wrap; gap:6px; }
#memory-tags:not(:empty) { padding-top:10px; }
.filter-tag, .memory-tag {
  display:inline-flex; align-items:center; border:1px solid #cde5ff25; border-radius:999px;
  padding:.31rem .6rem; background:#aed6ff0d; color:#c4d8ed; font-size:.78rem; overflow-wrap:anywhere;
}
.filter-tag[aria-pressed=true] { border-color:#bde3ff68; background:#a1d5ff28; color:#eff8ff; }
.memory-list, .accounts-list, .admin-history { display:grid; gap:8px; margin-top:13px; }
.memory-setting { margin-bottom:14px; padding-inline:11px; border:1px solid var(--line); border-radius:12px; background:#d2e8ff0a; }
.memory-card, .admin-history article { min-width:0; padding:13px; }
.memory-card .panel-heading { align-items:flex-start; margin-bottom:8px; }
.memory-card h4, .admin-history strong { overflow-wrap:anywhere; font-weight:650; }
.memory-card p, .admin-history article p { white-space:pre-wrap; overflow-wrap:anywhere; color:#e0edfa; font-size:.88rem; line-height:1.55; }
.memory-card .filter-tags:not(:empty) { margin-top:10px; }
.row-actions { display:flex; gap:2px; }
.row-actions button { padding:.25rem .46rem; font-size:.8rem; }
.panel-empty { padding:16px; background:#bfdcff08; border:1px dashed #c7e4ff35; border-radius:12px; margin:0; }
.memory-notice { color:#abe8d1; font-size:.78rem; margin-top:9px; }
.account-entry { width:100%; display:grid; grid-template-columns:38px minmax(0,1fr) auto; align-items:center; gap:11px; text-align:left; }
.account-entry img { width:38px; height:38px; border-radius:50%; object-fit:cover; border:1px solid #dfeeff44; }
.account-entry strong,.account-entry small { display:block; overflow-wrap:anywhere; }
.account-entry small { margin-top:4px; color:var(--muted); }
.account-entry > :last-child { font-size:1.35rem; color:var(--accent); }
.account-detail-identity img { width:52px; height:52px; }
.account-detail-identity p { margin:4px 0 0; }
.account-sections {
  display:flex; gap:5px; width:fit-content; padding:4px; margin-top:15px; border:1px solid var(--line);
  border-radius:12px; background:#111e3087;
}
.account-sections button { padding:.39rem .68rem; color:var(--muted); font-size:.85rem; }
.account-sections button[aria-pressed=true] { color:#f1f8ff; border-color:#d3e8ff3e; background:#c8e3ff1c; box-shadow:inset 0 1px 0 #eaf6ff1f; }
.account-history { margin-top:15px; }
.account-history .panel-description:not(:empty), #older-history { margin-top:10px; }
.account-history .panel-description:empty { display:none; }
.admin-history strong { display:block; font-size:.82rem; margin-bottom:5px; color:#b9daf6; }
.admin-history article[data-role=user] { background:#b3d9ff1d; }

@media (max-width: 1100px) and (min-width: 851px) {
  #workspace { grid-template-columns: 200px minmax(0,1fr); }
  .studio { grid-template-columns: minmax(0,1fr) minmax(258px,40%); gap: 10px; }
  #thread, .composer-wrap { padding-inline: 20px; }
}
@media (max-width: 850px) {
  #workspace { grid-template-columns:minmax(0,1fr); min-height:480px; padding:8px; gap:0; }
  .workspace-content { grid-template-rows:50px minmax(0,1fr); gap:8px; }
  .workspace-header { border-radius:16px; }
  .sidebar { position:fixed; inset:8px auto 8px 8px; width:min(86vw,280px); z-index:7; transform:translateX(-110%); visibility:hidden; transition:transform .29s cubic-bezier(.23,.74,.23,1),visibility .29s; }
  #workspace[data-sidebar-open=true] .sidebar { visibility:visible; transform:none; }
  #sidebar-open, #sidebar-close { display:grid; }
  #sidebar-scrim { position:fixed; inset:0; z-index:6; border:0; border-radius:0; background:#030c19ad; backdrop-filter:blur(4px); animation:veil-in .23s both; }
  .menu-icon { width:16px; height:12px; border-block:1px solid #ded6ed; position:relative; }
  .menu-icon::after { content:""; position:absolute; inset:5px 0 auto; height:1px; background:#ded6ed; }
  .studio { grid-template-columns:minmax(0,1fr); grid-template-rows: minmax(180px,42svh) minmax(0,1fr); gap:8px; }
  .studio.stage-hidden { grid-template-rows:minmax(0,1fr); }
  .studio > .stage { grid-row:1; border-radius:19px; }
  .chat { border-radius:19px; }
  #thread { padding-block:14px; gap:14px; }
  .composer-wrap { padding-bottom:11px; }
  .stage-top { inset:9px 11px auto; }
  .stage-view { top:10px; }
}
@media (max-width: 360px) {
  #reasoning-menu { left:-35px; }
  .composer-actions { flex-wrap:wrap; }
}
@media (max-width: 610px) {
  .auth { grid-template-columns:minmax(0,1fr); width:min(92vw,420px); min-height:0; }
  .auth-visual { display:none; }
  .console-layout { grid-template-columns:minmax(0,1fr); }
  .console-nav { flex-direction:row; flex-wrap:wrap; border-right:0; border-bottom:1px solid var(--line); padding:7px; }
  .console-nav button { padding:.45rem .58rem; }
  .console-content { max-height:65svh; }
  .panel-heading .primary, .panel-heading .secondary { padding:.45rem .62rem; }
  .invite-form,.invite-output { grid-template-columns:minmax(0,1fr); }
  .invite-form button,.invite-output button { justify-self:start; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation:none!important; transition:none!important; } }

