:root {
  color-scheme: light;
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
  --ink: #241c41;
  --muted: #625976;
  --accent: #5941c8;
  --accent-text: #5139bd;
  --ground: #f0ecff;
  --glass: rgba(255, 255, 255, .48);
  --strong-glass: rgba(251, 249, 255, .86);
  --edge: rgba(255, 255, 255, .82);
  --line: rgba(91, 70, 152, .14);
  --wash: rgba(106, 77, 219, .09);
  --shadow: 0 12px 38px rgba(66, 43, 130, .1), inset 0 1px 0 rgba(255, 255, 255, .6);
  --danger: #aa235c;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4efff;
  --muted: #c0b5d5;
  --accent: #a291ff;
  --accent-text: #c1b5ff;
  --ground: #181127;
  --glass: rgba(39, 29, 60, .65);
  --strong-glass: rgba(37, 27, 56, .96);
  --edge: rgba(220, 202, 255, .18);
  --line: rgba(220, 202, 255, .16);
  --wash: rgba(194, 171, 255, .12);
  --shadow: 0 12px 38px rgba(7, 3, 15, .2), inset 0 1px 0 rgba(255, 255, 255, .06);
  --danger: #ff9cc4;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--ground); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button { border: 0; background: transparent; }
svg { display: block; width: 19px; height: 19px; flex: none; }
a { color: var(--accent-text); }
small { display: block; color: var(--muted); }
.ambient { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.ambient i { position: absolute; display: block; border-radius: 50%; filter: blur(75px); opacity: .7; }
.ambient i:nth-child(1) { width: 66vw; height: 62vh; left: -16vw; top: -20vh; background: #bba6ff; }
.ambient i:nth-child(2) { width: 55vw; height: 63vh; right: -16vw; bottom: -20vh; background: #f4c6e4; }
.ambient i:nth-child(3) { width: 50vw; height: 45vh; right: -9vw; top: -16vh; background: #b7d5ff; }
[data-theme="dark"] .ambient i { opacity: .28; }
[data-theme="dark"] .ambient i:nth-child(1) { background: #7449da; }
[data-theme="dark"] .ambient i:nth-child(2) { background: #8f487e; }
[data-theme="dark"] .ambient i:nth-child(3) { background: #4e5ca9; }
.glass { background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow); backdrop-filter: blur(24px) saturate(145%); }
.workspace {
  --top-inset: max(14px, env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --bottom-inset: max(14px, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 14px;
  height: var(--tg-viewport-height, 100dvh);
  padding: var(--top-inset) max(14px, env(safe-area-inset-right)) var(--bottom-inset) max(14px, env(safe-area-inset-left));
}
.sidebar { border-radius: 25px; display: flex; flex-direction: column; padding: 19px 14px 11px; min-height: 0; }
.brand-row, .profile { display: flex; align-items: center; gap: 10px; }
.brand-row { margin: 2px 6px 22px; }
.brand-row strong { font-size: 23px; line-height: 1; letter-spacing: -.07em; }
.brand-row small, .profile small { font-size: 11px; margin-top: 2px; }
.brand-icon { filter: drop-shadow(0 4px 8px #7359d14d); }
.new-button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px;
  background: linear-gradient(145deg, #7b60f0, #5840c6); color: white; border-radius: 14px; font-weight: 650;
  box-shadow: 0 5px 14px #6042d049, inset 0 1px 0 #ffffff4d;
}
.new-button:hover, .send:not(:disabled):hover { filter: brightness(1.1); }
.new-arrow { margin-left: auto; opacity: .7; }
.new-arrow svg { width: 15px; }
.history-search {
  margin: 13px 0 12px; display: flex; align-items: center; gap: 7px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 11px; color: var(--muted);
}
.history-search svg { width: 15px; height: 15px; }
.history-search input { width: 100%; padding: 0; border: 0; background: none; outline: none; font-size: 13px; }
.history-search:focus-within { border-color: var(--accent); }
.history-search input::placeholder, textarea::placeholder { color: var(--muted); }
.side-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; }
.side-label { padding: 5px 10px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .105em; }
.folder-label { margin-top: 9px; display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.history-label { margin-top: 12px; }
.nav-row { width: 100%; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; text-align: left; font-size: 13px; }
.nav-row svg { width: 16px; height: 16px; color: var(--muted); }
.nav-row:hover, .icon-btn:hover, .tool-btn:hover, .list-option:hover { background: var(--wash); }
.nav-row.active { background: var(--wash); color: var(--accent-text); font-weight: 660; }
.nav-row.active svg { color: var(--accent); }
.side-item { display: flex; align-items: center; gap: 2px; }
.side-item .nav-row { flex: 1; }
.truncate, .top-title, .profile-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.side-item .small { opacity: .55; }
.side-item:hover .small, .side-item:focus-within .small { opacity: 1; }
.side-empty { color: var(--muted); font-size: 12px; padding: 6px 10px; }
.profile { border-top: 1px solid var(--line); padding: 12px 2px 2px; margin-top: 9px; }
.profile-entry { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; border-radius: 11px; padding: 4px; text-align: left; }
.profile-entry:hover, .profile-entry[aria-current="page"] { background: var(--wash); }
.profile-text { flex: 1; }
.profile strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.avatar {
  --avatar-from: #ba9bff; --avatar-to: #664fd7; --avatar-ink: #fff;
  width: 35px; height: 35px; flex: none; display: grid; place-items: center; border-radius: 13px; padding: 0; overflow: hidden;
  background: linear-gradient(145deg, var(--avatar-from), var(--avatar-to)); color: var(--avatar-ink);
  font-weight: 750; box-shadow: inset 0 1px 0 #ffffff75, 0 3px 8px #6550ad2a;
}
.avatar[data-preset="1"] { --avatar-from: #8987c8; --avatar-to: #30315b; }
.avatar[data-preset="2"] { --avatar-from: #a2edff; --avatar-to: #5684e8; }
.avatar[data-preset="3"] { --avatar-from: #ffdbeb; --avatar-to: #c979b5; }
.avatar[data-preset="4"] { --avatar-from: #d2f2ac; --avatar-to: #5aa986; }
.avatar[data-preset="5"] { --avatar-from: #ffe7a2; --avatar-to: #d77b42; }
.avatar[data-preset="6"] { --avatar-from: #e2b5ff; --avatar-to: #6554aa; }
.avatar[data-preset="7"] { --avatar-from: #f5acd6; --avatar-to: #7561d8; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-preview { width: 62px; height: 62px; border-radius: 19px; font-size: 29px; }
.icon-btn { width: 36px; height: 36px; border-radius: 11px; display: inline-grid; place-items: center; flex: none; padding: 0; color: var(--muted); }
.icon-btn.small { width: 29px; height: 29px; }
.icon-btn.small svg { width: 15px; height: 15px; }
.mobile-only, .veil { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 12px; min-height: 55px; padding: 7px 12px; border-radius: 19px; }
.model-pill {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--wash); min-height: 35px; padding: 5px 9px; font-size: 13px; font-weight: 650;
}
.model-pill svg { width: 14px; height: 14px; color: var(--muted); }
#model-name { max-width: min(27vw, 230px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-dot, .eyebrow i { display: block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #8a70ff; box-shadow: 0 0 0 3px #8a70ff26; }
.top-title { flex: 1; color: var(--muted); font-size: 13px; }
.top-end, .private-tag { display: flex; align-items: center; gap: 7px; flex: none; }
.private-tag { color: var(--muted); font-size: 11px; padding: 0 4px; }
.private-tag svg { width: 14px; height: 14px; }
.content { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; scrollbar-width: thin; overscroll-behavior: contain; }
.hero { margin: auto; text-align: center; width: min(100%, 780px); padding: 25px 12px 16px; }
.orb {
  width: clamp(67px, 12vh, 101px); aspect-ratio: 1; margin: 0 auto 20px; border-radius: 34%;
  display: grid; place-items: center; transform: rotate(-9deg);
  color: #fff; border: 1px solid #ffffffc9;
  background: radial-gradient(ellipse at 28% 13%, #ffffffb8, transparent 42%), linear-gradient(152deg, #c5aaff, #7b62ef 55%, #5a42d2);
  box-shadow: inset 0 -4px 16px #5140b369, inset 0 2px 8px #ffffff87, 0 14px 40px #8159ea60;
}
.orb svg { width: 48%; height: auto; fill: #fff; transform: rotate(9deg); filter: drop-shadow(0 3px 7px #5140b358); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 10px; color: var(--accent-text); font-weight: 750; letter-spacing: .16em; }
.eyebrow i { width: 5px; height: 5px; }
.hero h1 { font-size: clamp(36px, 5.7vw, 75px); line-height: .98; letter-spacing: -.075em; margin: 12px 0; font-weight: 740; }
.hero p { color: var(--muted); font-size: clamp(13px, 1.8vw, 16px); margin: 0; }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 24px auto 0; max-width: 670px; }
.quick-card { padding: 10px; border-radius: 15px; display: flex; align-items: center; gap: 9px; min-width: 0; text-align: left; }
.quick-card:hover { background: var(--strong-glass); }
.quick-card strong { display: block; font-size: 12px; }
.quick-card small { font-size: 11px; }
.tile-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; flex: none; }
.tile-icon svg { width: 16px; height: 16px; }
.tile-icon.violet { color: var(--accent-text); background: #997eff33; }
.tile-icon.blue { color: #285f9e; background: #79b6ff35; }
.tile-icon.rose { color: #973d76; background: #e884bc30; }
[data-theme="dark"] .tile-icon.blue { color: #a5ceff; }
[data-theme="dark"] .tile-icon.rose { color: #ffacd8; }
.compose-wrap { width: min(100%, 790px); align-self: center; padding: 7px 6px 0; }
.composer { padding: 10px; border-radius: 22px; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 32%, var(--edge)); }
.composer textarea { display: block; width: 100%; min-height: 38px; max-height: 170px; resize: none; field-sizing: content; border: 0; outline: none; background: transparent; padding: 7px 5px; font-size: 16px; }
.compose-controls { display: flex; align-items: center; gap: 5px; }
.compose-spacer { flex: 1; }
.attachment-btn { border: 1px solid var(--line); }
.tool-btn { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 9px; color: var(--muted); font-size: 12px; border-radius: 10px; }
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn.selected { color: var(--accent-text); background: var(--wash); }
.send { width: 37px; height: 37px; display: grid; place-items: center; padding: 0; border-radius: 12px; color: white; background: linear-gradient(145deg, #8668f3, #5d43ce); box-shadow: inset 0 1px 0 #ffffff50; }
.compose-caption { text-align: center; font-size: 10px; color: var(--muted); margin-top: 7px; }
.status { padding: 0 7px 6px; color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }
.attachments { display: flex; gap: 5px; flex-wrap: wrap; padding: 0 0 6px; }
.chip { display: inline-flex; gap: 5px; align-items: center; padding: 3px 7px; border-radius: 9px; background: var(--wash); font-size: 12px; max-width: 100%; }
.chip .icon-btn { width: 25px; height: 25px; }
.chip svg { width: 14px; height: 14px; }
.archived-note { padding: 11px; border-radius: 13px; text-align: center; font-size: 13px; }
.archived-note button { color: var(--accent-text); font-weight: 700; }
.thread, .library { width: min(100%, 790px); margin: 0 auto; padding: 22px 13px; overflow-wrap: anywhere; }
.thread { display: flex; flex-direction: column; gap: 20px; }
.message { max-width: 100%; }
.message.user { align-self: end; max-width: min(88%, 640px); padding: 10px 14px; border-radius: 18px 18px 5px 18px; background: var(--wash); border: 1px solid var(--line); }
.message.assistant { width: 100%; }
.message-label { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.message-label img { width: 22px; height: 22px; }
.message-text { white-space: pre-wrap; }
.message-text p { margin: 0 0 10px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text pre { white-space: pre; overflow: auto; background: var(--wash); padding: 11px; border: 1px solid var(--line); border-radius: 11px; }
.message-text code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; }
.message-text h3, .message-text h4 { margin: 13px 0 5px; }
.message-actions, .asset-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 5px; }
.sources { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 8px; }
.sources a { font-size: 12px; border-radius: 7px; background: var(--wash); padding: 4px 7px; }
.message-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.message-files .asset-card { width: min(100%, 290px); }
.asset-card { padding: 9px; min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--glass); }
.asset-preview { display: grid; width: 100%; padding: 0; border-radius: 10px; overflow: hidden; background: var(--wash); aspect-ratio: 4 / 3; place-items: center; color: var(--accent-text); }
.asset-preview img { width: 100%; height: 100%; object-fit: cover; }
.asset-title { font-size: 12px; display: block; margin-top: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.asset-card small { font-size: 11px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 9px; }
.library h1 { margin: 0; font-size: 34px; letter-spacing: -.055em; }
.library > p { color: var(--muted); margin: 2px 0 17px; }
.library-empty { padding: 28px; text-align: center; border-radius: 19px; color: var(--muted); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 15px; }
.panel-heading .action, .profile-card .action { flex: none; }
.panel-heading p { color: var(--muted); margin: 2px 0 0; }
.project-grid, .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.project-card { display: grid; gap: 5px; align-content: start; text-align: left; padding: 13px; min-height: 108px; border-radius: 15px; }
.project-card:hover { background: var(--strong-glass); }
.project-instructions { padding: 11px; margin-bottom: 10px; border-radius: 13px; }
.project-instructions p { color: var(--muted); margin: 4px 0 0; white-space: pre-wrap; }
.profile-card, .profile-preview-row { display: flex; align-items: center; gap: 10px; }
.profile-card { padding: 13px; margin-bottom: 12px; border-radius: 16px; }
.cloud-card { padding: 13px; margin-bottom: 12px; border-radius: 16px; }
.cloud-card h2 { margin: 0 0 7px; font-size: 16px; }
.cloud-card p { color: var(--muted); font-size: 13px; margin: 6px 0; }
.cloud-card details { font-size: 12px; margin-top: 8px; }
.cloud-card pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-identity { flex: 1; min-width: 0; }
.profile-identity strong, .profile-preview-name { display: block; font-size: 20px; overflow-wrap: anywhere; }
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-tile { padding: 10px; border-radius: 12px; min-width: 0; }
.stat-tile small { font-size: 11px; line-height: 1.2; margin-bottom: 5px; }
.stat-tile strong { font-size: clamp(15px, 2.4vw, 22px); overflow-wrap: anywhere; }
.usage-chart { margin-top: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 14px; }
.usage-chart h2 { font-size: 14px; margin: 0 0 9px; }
.usage-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.usage-day { display: grid; justify-items: center; gap: 4px; color: var(--accent); }
.usage-day svg { width: 20px; height: 54px; }
.usage-day small { font-size: 10px; }
.usage-day .usage-count { color: var(--accent-text); font-weight: 650; }
.library > .profile-footnote { font-size: 11px; margin-top: 9px; }
.filters { display: flex; gap: 6px; margin-bottom: 11px; }
.gate { position: fixed; inset: 0; width: min(360px, calc(100% - 32px)); height: fit-content; margin: auto; padding: 26px; border-radius: 24px; text-align: center; }
.gate h1 { margin: 5px 0; }
.gate p { color: var(--muted); }
.dialog { color: var(--ink); width: min(420px, calc(100vw - 26px)); max-height: 85dvh; padding: 15px; border-radius: 20px; background: var(--strong-glass); }
.dialog::backdrop { background: #1a102b51; backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog p { color: var(--muted); }
.dialog form { display: grid; gap: 9px; }
.dialog input, .dialog select, .dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--strong-glass); }
.dialog textarea { resize: vertical; }
.field-label { display: grid; gap: 3px; font-size: 13px; font-weight: 650; }
.field-label small { font-weight: 400; }
.preset-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.avatar-choice { cursor: pointer; }
.avatar-choice[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.symbol-choice { min-width: 33px; }
.action { padding: 7px 10px; border-radius: 9px; background: var(--wash); font-size: 13px; font-weight: 650; }
.action.primary { color: white; background: #674ed4; }
.action.danger, .list-option.danger { color: var(--danger); }
.list-option { display: flex; width: 100%; min-height: 39px; align-items: center; justify-content: space-between; gap: 7px; text-align: left; padding: 7px 8px; border-radius: 9px; overflow-wrap: anywhere; }
.list-option.selected { background: var(--wash); color: var(--accent-text); }
.list-option small { margin-top: 2px; font-size: 11px; }
.model-list { margin-top: 5px; max-height: 48dvh; overflow: auto; }
.image-full { display: block; width: 100%; max-height: 64dvh; object-fit: contain; border-radius: 10px; background: var(--wash); }
.toast { position: fixed; z-index: 6; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); padding: 8px 13px; border-radius: 11px; background: var(--strong-glass); font-size: 13px; }
@media (max-width: 820px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .sidebar { padding-left: 10px; padding-right: 10px; }
  .quick-card { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 650px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 0; padding-inline: 8px; }
  .sidebar {
    position: fixed; z-index: 4; left: 7px; top: var(--top-inset); bottom: var(--bottom-inset);
    width: min(305px, calc(100vw - 31px)); visibility: hidden; transform: translateX(calc(-100% - 10px));
    transition: transform .18s ease, visibility .18s; background: var(--strong-glass);
  }
  .sidebar.open { transform: none; visibility: visible; }
  .veil { display: block; z-index: 3; position: fixed; inset: 0; background: #1a102b52; }
  .mobile-only { display: inline-grid; }
  .brand-row .mobile-only { margin-left: auto; }
  .top { min-height: 50px; padding: 5px; gap: 5px; border-radius: 15px; }
  #model-name { max-width: 40vw; }
  .private-tag span:last-child { display: none; }
  .hero { padding-inline: 4px; }
  .quick { gap: 4px; }
  .quick-card { padding: 6px; gap: 5px; border-radius: 11px; }
  .quick-card strong { font-size: 11px; }
  .quick-card small { display: none; }
  .tile-icon { width: 26px; height: 26px; }
  .compose-wrap { padding-inline: 0; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-card .avatar-preview { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
  .profile-identity strong { font-size: 16px; }
}
@media (max-height: 520px) {
  .orb { width: 50px; margin-bottom: 11px; }
  .hero { padding-block: 12px; }
  .hero h1 { font-size: 32px; }
  .quick { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
