@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  color-scheme: dark;
  font-family: 'DM Sans', sans-serif;
  color: #f0effa;
  background: #10111c;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #f0effa;
  --muted: #a0a2bb;
  --line: #2b2d42;
  --paper: #151624;
  --surface: #1c1e2d;
  --purple: #aa8cff;
  --blue: #70bdff;
  --sidebar: #10111c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 258px; flex: 0 0 258px; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; padding: 22px 14px 14px; background: var(--sidebar); color: #f0effa; transition: width .22s ease, flex-basis .22s ease; z-index: 5; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 3px 28px 8px; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: #f4f3ff; font-size: 19px; font-weight: 700; text-decoration: none; letter-spacing: 0; }
.brand-period { color: var(--blue); }
.brand-mark { height: 22px; width: 22px; display: flex; align-items: center; justify-content: center; gap: 2px; transform: rotate(-35deg); }
.brand-mark i { width: 5px; background: var(--purple); border-radius: 4px; display: block; }
.brand-mark i:nth-child(1) { height: 10px; opacity: .7; }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 12px; opacity: .8; background: var(--blue); }
.icon-button { border: 0; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; width: 34px; height: 34px; border-radius: 7px; font-size: 20px; line-height: 1; }
.icon-button:hover { background: #ffffff12; }
.sidebar-toggle { color: #a0a2bb; font-size: 24px; }
.new-chat { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 10px; color: #f0effa; background: #ffffff08; border: 1px solid #ffffff16; border-radius: 7px; text-align: left; cursor: pointer; font-size: 13px; }
.new-chat:hover { background: #ffffff12; }
.new-chat > span { font-size: 20px; color: var(--purple); font-weight: 400; }
kbd { font-family: 'Space Mono', monospace; font-size: 10px; font-weight: 400; }
.new-chat kbd { margin-left: auto; color: #969d97; border: 1px solid #ffffff20; border-radius: 4px; padding: 3px 5px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin: 30px 4px 9px 9px; color: #8589a4; font: 10px 'Space Mono', monospace; letter-spacing: .08em; }
.icon-button.small { width: 25px; height: 25px; font-weight: 700; color: #a0a2bb; letter-spacing: 1px; }
.conversation-list { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.history-row { display: flex; align-items: center; gap: 2px; min-width: 0; border-radius: 6px; }
.history-row:hover, .history-row:focus-within { background: #ffffff0d; }
.history-item { display: flex; align-items: center; gap: 8px; flex: 1; width: 0; min-width: 0; border: 0; background: transparent; color: #b6b7cd; padding: 9px 9px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 12px; }
.history-item:hover, .history-item.active { color: #f5f3ff; }
.history-item > span:first-child { color: #8589a4; font-size: 14px; }
.history-item .history-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.history-actions { display: flex; flex: 0 0 auto; padding-right: 3px; opacity: 0; transition: opacity .12s ease; }
.history-row:hover .history-actions, .history-row:focus-within .history-actions { opacity: 1; }
.history-action { width: 25px; height: 25px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #9da0b7; cursor: pointer; font-size: 15px; }
.history-action:hover { background: #34354c; color: #fff; }
.history-rename { display: flex; align-items: center; gap: 3px; width: 100%; padding: 4px; }
.history-rename input { min-width: 0; flex: 1; height: 30px; padding: 0 7px; border: 1px solid #62578b; border-radius: 4px; outline: 0; background: #141521; color: #f5f3ff; font: 11px 'DM Sans', sans-serif; }
.sidebar-bottom { margin-top: auto; }
.connection-status { display: flex; align-items: center; gap: 8px; padding: 12px 9px 14px; color: #a0a2bb; font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #dcaa69; box-shadow: 0 0 0 3px #dcaa691c; }
.status-dot.ready { background: var(--blue); box-shadow: 0 0 0 3px #70bdff22; }
.profile-button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px 8px; border: 0; border-top: 1px solid #ffffff16; background: transparent; color: #f0effa; text-align: left; cursor: pointer; }
.profile-avatar { width: 30px; height: 30px; display: grid; place-items: center; background: #302748; color: #d3c4ff; border-radius: 6px; font-weight: 700; font-size: 13px; }
.profile-copy { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.profile-copy strong { font-size: 11px; font-weight: 600; }
.profile-copy small { color: #9295ae; font-size: 10px; }
.profile-arrow { color: #9295ae; }
.main-panel { min-width: 0; flex: 1; height: 100vh; display: flex; flex-direction: column; background: var(--paper); position: relative; }
.topbar { height: 63px; flex: 0 0 63px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid #292b3e; }
.model-label { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; }
.model-indicator { width: 8px; height: 8px; background: linear-gradient(135deg, var(--purple), var(--blue)); border-radius: 2px; transform: rotate(45deg); }
.topbar-chevron { color: #9295ae; font-size: 15px; }
.top-settings { display: inline-flex; gap: 8px; align-items: center; padding: 7px 10px; border: 1px solid #34364c; border-radius: 6px; background: #1c1e2d; color: #c6c7d9; font-size: 11px; cursor: pointer; }
.top-settings:hover { border-color: #7164b7; }
.mobile-menu { display: none; }
.chat-view { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.welcome { width: min(660px, calc(100% - 48px)); margin: auto; padding: 24px 0 34px; animation: appear .55s both; }
.welcome-kicker, .settings-eyebrow { font: 10px 'Space Mono', monospace; color: #a392d5; letter-spacing: .1em; display: flex; align-items: center; gap: 9px; }
.kicker-line { width: 23px; height: 1px; background: var(--blue); }
h1 { margin: 22px 0 10px; font-size: clamp(38px, 5vw, 58px); line-height: 1.06; letter-spacing: 0; font-weight: 500; }
h1 span { background: linear-gradient(100deg, #bba5ff 5%, #78bdff 95%); color: transparent; background-clip: text; }
.welcome-logo { display: inline-flex; align-items: center; gap: 14px; margin-top: 0; color: #f4f3ff; font-size: 36px; font-weight: 700; line-height: 1; }
.welcome-logo .brand-mark { width: 40px; height: 40px; gap: 4px; }
.welcome-logo .brand-mark i { width: 8px; }
.welcome-logo .brand-mark i:nth-child(1) { height: 18px; }
.welcome-logo .brand-mark i:nth-child(2) { height: 31px; }
.welcome-logo .brand-mark i:nth-child(3) { height: 23px; }
.suggestions { display: grid; gap: 9px; margin-top: 35px; }
.suggestion { width: 100%; display: flex; align-items: center; gap: 13px; min-height: 67px; padding: 11px 14px; text-align: left; border: 1px solid #2d3044; border-radius: 7px; background: #1a1c2a; cursor: pointer; transition: border-color .16s ease, transform .16s ease; }
.suggestion:hover { border-color: #7867c2; transform: translateX(3px); }
.suggestion-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; font-size: 18px; }
.suggestion-icon.mint { background: #302648; color: #c0aaff; }
.suggestion-icon.coral { background: #1f3048; color: #86c3ff; }
.suggestion-icon.yellow { background: #29233d; color: #d1b4ff; }
.suggestion > span:nth-child(2) { display: grid; gap: 3px; }
.suggestion strong { font-size: 12px; font-weight: 600; }
.suggestion small { font-size: 11px; color: #999bb2; }
.suggestion-arrow { margin-left: auto; color: #8589a4; }
.messages { display: none; width: min(1100px, 100%); margin: 0 auto; padding: 32px 0 30px; }
.messages.visible { display: flex; flex-direction: column; gap: 24px; }
.message { display: flex; gap: 12px; align-items: flex-start; animation: appear .25s both; }
.message.user { flex-direction: row-reverse; }
.message-body { min-width: 0; flex: 1; }
.message-avatar { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 6px; font-size: 12px; font-weight: 700; }
.message.assistant .message-avatar { background: #302648; color: #c0aaff; }
.message.user .message-avatar { background: #1f3048; color: #91c8ff; }
.message-content { min-width: 0; max-width: none; padding-top: 4px; font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
.message.user .message-body { max-width: 80%; flex: 0 1 auto; }
.message.user .message-content { max-width: 100%; padding: 10px 14px; background: #202237; border-radius: 8px 2px 8px 8px; }
.message.assistant .message-content { flex: 1; }
.message-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 7px; }
.message-attachment { max-width: 100%; overflow: hidden; padding: 5px 8px; border: 1px solid #3a3d55; border-radius: 5px; color: #bfc1d7; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.message-content.error { color: #ff9eae; }
.token-usage { margin: 7px 0 0 40px; color: #898da6; font: 10px 'Space Mono', monospace; }
.response-notice { margin: 7px 0 0 40px; color: #e2b974; font-size: 11px; line-height: 1.5; }
.message-content code { font-family: 'Space Mono', monospace; font-size: 12px; background: #282a40; padding: 2px 5px; border-radius: 3px; }
.message-content strong { color: #f0edff; font-weight: 700; }
.message-content em { color: #d3c7f7; }
.message-content .markdown-heading { margin: 14px 0 7px; color: #f0edff; font-weight: 600; line-height: 1.35; }
.message-content .markdown-heading:first-child { margin-top: 0; }
.message-content h1.markdown-heading { font-size: 1.45em; }
.message-content h2.markdown-heading { font-size: 1.3em; }
.message-content h3.markdown-heading { font-size: 1.15em; }
.message-content h4.markdown-heading, .message-content h5.markdown-heading, .message-content h6.markdown-heading { font-size: 1em; }
.markdown-paragraph { margin: 0; white-space: pre-wrap; }
.markdown-spacer { height: 1.85em; flex: 0 0 1.85em; }
.code-block { width: max-content; max-width: none; margin: 12px 0; overflow: visible; border: 1px solid #34364c; border-radius: 7px; background: #12131d; }
.code-block-header { min-height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; border-bottom: 1px solid #2a2c3d; color: #a4a6ba; font: 10px 'Space Mono', monospace; }
.code-copy { border: 0; padding: 4px 7px; border-radius: 4px; background: transparent; color: #afb3ca; font: 10px 'DM Sans', sans-serif; cursor: pointer; }
.code-copy:hover { background: #292b40; color: #fff; }
.code-block pre { width: max-content; max-width: none; margin: 0; padding: 13px 15px; overflow: visible; white-space: pre; }
.message-content .code-block pre code { display: block; padding: 0; background: transparent; color: #d9dbeb; font-size: 12px; line-height: 1.6; white-space: pre; }
.typing-caret { display: inline-block; width: 6px; height: 15px; background: var(--purple); vertical-align: -2px; animation: blink .8s steps(2) infinite; }
.composer-wrap { width: min(740px, calc(100% - 48px)); margin: 0 auto; padding: 10px 0 18px; }
.composer { border: 1px solid #34364c; border-radius: 9px; padding: 13px 13px 9px 16px; background: #1a1c2a; box-shadow: 0 4px 24px #07081130; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #8570db; box-shadow: 0 0 0 3px #aa8cff20; }
.composer textarea { display: block; width: 100%; min-height: 28px; max-height: 160px; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; line-height: 1.6; }
.composer textarea::placeholder { color: #8589a4; }
.composer-entry { display: flex; align-items: center; gap: 9px; }
.composer-entry textarea { flex: 1; }
.attach-button { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border: 1px solid #393b52; border-radius: 6px; background: #222437; color: #b9a6ff; cursor: pointer; font-size: 19px; line-height: 1; }
.attach-button:hover { background: #2b2d43; }
.attach-button:disabled { opacity: .5; cursor: default; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 10px; }
.attachment-list[hidden] { display: none; }
.attachment-chip { display: flex; align-items: center; gap: 7px; max-width: 100%; padding: 4px 7px 4px 10px; border: 1px solid #393b52; border-radius: 5px; color: #c8c9dc; font-size: 10px; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { border: 0; background: transparent; color: #a4a6ba; cursor: pointer; font-size: 15px; line-height: 1; }
.attachment-remove:disabled { cursor: default; opacity: .5; }
.composer-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.composer-hint { color: #898da6; font-size: 10px; }
.send-button { width: 31px; height: 31px; display: grid; place-items: center; border: 0; border-radius: 6px; background: linear-gradient(135deg, #8965e8, #4c87dc); color: #fff; cursor: pointer; font-size: 18px; line-height: 1; transition: filter .15s, transform .15s; }
.send-button:hover { filter: brightness(1.15); transform: translateY(-1px); }
.send-button:disabled { opacity: .5; cursor: default; transform: none; }
.send-button.stop { background: #a84c70; }
.composer-foot { display: flex; justify-content: space-between; padding: 8px 2px 0; color: #8589a4; font-size: 10px; }
.keyboard-hint { display: flex; align-items: center; gap: 4px; }
.keyboard-hint kbd { font-size: 9px; }
.keyboard-hint i { font-style: normal; padding: 0 3px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: #080914c9; backdrop-filter: blur(3px); animation: fade .15s ease both; }
.modal-backdrop[hidden] { display: none; }
.settings-dialog { width: min(540px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px; border: 1px solid #34364c; border-radius: 9px; background: #191a29; box-shadow: 0 20px 70px #05060db0; animation: rise .2s ease both; }
.settings-header { display: flex; justify-content: space-between; align-items: flex-start; }
.settings-header h2 { margin: 9px 0 0; font-size: 22px; font-weight: 600; letter-spacing: 0; }
.settings-header .icon-button { color: #a0a2bb; font-size: 24px; }
.settings-intro { margin: 13px 0 23px; color: #a0a2b8; font-size: 12px; line-height: 1.6; }
.settings-dialog label { display: block; margin: 0 0 7px; color: #d6d5e7; font-size: 11px; font-weight: 600; }
.fixed-model { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: 2px; padding: 0 11px; border: 1px solid #383a51; border-radius: 5px; background: #11121e; }
.fixed-model span { color: #d6d5e7; font-size: 11px; font-weight: 600; }
.fixed-model strong { color: #b9a6ff; font: 10px 'Space Mono', monospace; }
.required-mark { color: #bc614d; }
.optional { color: #a0a59f; font-weight: 400; }
.settings-dialog input { width: 100%; height: 40px; padding: 0 11px; outline: none; border: 1px solid #383a51; border-radius: 5px; background: #11121e; color: #f0effa; font-size: 12px; }
.settings-dialog input:focus { border-color: #927be3; box-shadow: 0 0 0 3px #aa8cff25; }
.settings-dialog input::placeholder { color: #777c98; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.settings-field { min-width: 0; }
.settings-field label { display: flex; justify-content: space-between; gap: 8px; }
.settings-dialog input[type="range"] { height: 22px; padding: 0; border: 0; background: transparent; accent-color: var(--purple); }
.settings-dialog output { color: #b9a6ff; font-family: 'Space Mono', monospace; font-size: 10px; }
.field-hint { margin: 4px 0 0; color: #9295ad; font-size: 10px; line-height: 1.5; }
.number-field { display: flex; align-items: center; gap: 8px; }
.number-field input { min-width: 0; }
.number-field span { color: #9295ad; font-size: 10px; }
.settings-dialog textarea { display: block; width: 100%; min-height: 90px; margin-top: 0; padding: 10px 11px; resize: vertical; outline: none; border: 1px solid #383a51; border-radius: 5px; background: #11121e; color: #f0effa; font: 12px/1.6 'DM Sans', sans-serif; }
.settings-dialog textarea:focus { border-color: #927be3; box-shadow: 0 0 0 3px #aa8cff25; }
.settings-dialog textarea::placeholder { color: #777c98; }
.field-row { display: flex; gap: 13px; margin-top: 17px; }
.field-grow { min-width: 0; flex: 1; }
.privacy-note { margin: 15px 0 0; color: #999bb2; font-size: 10px; }
.privacy-note span { padding-right: 5px; color: var(--blue); }
.settings-error { margin-top: 13px; padding: 9px 10px; border-radius: 5px; background: #3c202e; color: #ffadbd; font-size: 11px; }
.turnstile-widget { position: fixed; right: 12px; bottom: 12px; z-index: 10000; }
.settings-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.cancel-button, .save-button { min-height: 37px; padding: 0 13px; border-radius: 5px; cursor: pointer; font-size: 11px; }
.cancel-button { border: 1px solid #393b50; background: #202132; color: #c4c5d8; }
.save-button { display: flex; align-items: center; gap: 10px; border: 1px solid #735ed1; background: linear-gradient(110deg, #7654d5, #3c74c0); color: #fff; }
.save-button:hover { filter: brightness(1.12); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; padding: 10px 14px; border-radius: 6px; background: #30264b; color: #f2edff; font-size: 12px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sidebar.collapsed { width: 68px; flex-basis: 68px; padding-left: 10px; padding-right: 10px; }
.sidebar.collapsed .brand > span:not(.brand-mark), .sidebar.collapsed .sidebar-toggle, .sidebar.collapsed .new-chat:not(:hover), .sidebar.collapsed .history-heading, .sidebar.collapsed .conversation-list, .sidebar.collapsed .sidebar-bottom { display: none; }
.sidebar.collapsed .sidebar-top { justify-content: center; padding: 0 0 28px; }
.sidebar.collapsed .new-chat { justify-content: center; padding: 10px 0; font-size: 0; }
.sidebar.collapsed .new-chat > span { font-size: 20px; }
.sidebar.collapsed .new-chat kbd { display: none; }

@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(7px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink { to { visibility: hidden; } }

@media (max-width: 700px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 258px; transition: transform .2s ease; }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 12px 0 30px #05060db0; }
  .sidebar.collapsed { width: 258px; flex-basis: 258px; }
  .sidebar.collapsed .brand > span:not(.brand-mark), .sidebar.collapsed .history-heading, .sidebar.collapsed .sidebar-bottom { display: flex; }
  .sidebar.collapsed .sidebar-toggle { display: grid; }
  .sidebar.collapsed .new-chat { justify-content: flex-start; padding: 10px; font-size: 13px; }
  .sidebar.collapsed .new-chat > span { font-size: 20px; }
  .sidebar.collapsed .new-chat kbd { display: block; }
  .main-panel { height: 100dvh; }
  .topbar { height: 56px; flex-basis: 56px; padding: 0 14px; }
  .mobile-menu { display: grid; margin-left: -6px; font-size: 17px; }
  .topbar { justify-content: flex-start; gap: 12px; }
  .top-settings { margin-left: auto; font-size: 0; border: 0; background: transparent; padding: 7px; }
  .top-settings span { font-size: 17px; }
  .welcome { width: calc(100% - 36px); padding: 32px 0 24px; }
  h1 { font-size: clamp(37px, 11vw, 51px); }
  .suggestions { margin-top: 26px; }
  .suggestion { min-height: 63px; padding: 9px 10px; gap: 10px; }
  .suggestion small { font-size: 10px; }
  .messages { width: calc(100% - 12px); }
  .composer-wrap { width: calc(100% - 28px); }
  .messages { padding-top: 22px; }
  .composer-wrap { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .composer-foot { font-size: 9px; }
  .keyboard-hint { display: none; }
  .settings-dialog { padding: 21px 18px; }
  .settings-grid { grid-template-columns: 1fr; gap: 15px; }
  .field-row { flex-direction: column; gap: 15px; }
}
