:root {
  color-scheme: dark;
  --bg: #212121;
  --sidebar: #171717;
  --surface: #2f2f2f;
  --surface-hover: #303030;
  --surface-soft: #272727;
  --border: #424242;
  --border-soft: rgba(255, 255, 255, .09);
  --text: #ececec;
  --muted: #b4b4b4;
  --subtle: #858585;
  --green: #10a37f;
  --sidebar-width: 260px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.is-hidden { display: none !important; }
.noise { display: none; }
.icon-button.mobile-only { display: none; }

.icon-button {
  width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.08); color: var(--text); }

.brand-mark { position: relative; width: 42px; height: 42px; display: inline-grid; place-items: center; }
.brand-mark::before, .brand-mark::after, .brand-mark span {
  content: ""; position: absolute; inset: 8px; border: 1.7px solid currentColor;
  border-radius: 9px 4px 9px 4px; transform: rotate(45deg);
}
.brand-mark::after { transform: rotate(105deg); }
.brand-mark span:first-child { transform: rotate(165deg); }
.brand-mark span:last-child { width: 6px; height: 6px; inset: auto; border: 0; border-radius: 50%; background: currentColor; }
.brand-mark.small { width: 28px; height: 28px; transform: scale(.75); color: #fff; }

/* Login */
.login-screen {
  min-height: 100dvh; display: grid; place-items: center; position: relative; overflow: hidden;
  padding: 24px; background: #171717;
}
.login-orb { display: none; }
.login-card {
  width: min(100%, 400px); padding: 38px; border: 1px solid #383838; border-radius: 18px;
  background: #212121; box-shadow: 0 24px 70px rgba(0,0,0,.32); text-align: center;
}
.login-card > .brand-mark { margin-bottom: 20px; color: #fff; }
.eyebrow { margin: 0 0 12px; color: var(--subtle); font-size: 10px; font-weight: 650; letter-spacing: .14em; }
.login-card h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -.035em; }
.login-copy { margin: 10px 0 30px; color: var(--muted); font-size: 14px; }
.password-field { display: grid; gap: 9px; text-align: left; color: #d0d0d0; font-size: 12px; }
.password-field input {
  width: 100%; min-height: 48px; border: 1px solid #4a4a4a; outline: 0; border-radius: 10px;
  padding: 0 14px; color: var(--text); background: #2b2b2b; transition: border-color .18s, box-shadow .18s;
}
.password-field input:focus { border-color: #8b8b8b; box-shadow: 0 0 0 2px rgba(255,255,255,.07); }
.form-error { min-height: 18px; margin: 8px 0 2px; color: #ff8585; font-size: 12px; text-align: left; }
.primary-button {
  width: 100%; min-height: 48px; border: 0; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; gap: 9px; color: white; background: var(--green); cursor: pointer; font-weight: 600;
}
.primary-button:hover { background: #0d8f70; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button svg { width: 17px; }
.secure-note { margin: 20px 0 0; display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--subtle); font-size: 10.5px; }
.secure-note svg { width: 13px; height: 13px; }

/* App shell */
.app { height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); background: var(--bg); }
.sidebar {
  min-width: 0; height: 100dvh; padding: 8px; display: flex; flex-direction: column;
  background: var(--sidebar); z-index: 20;
}
.sidebar-top { height: 48px; padding: 0 7px; display: flex; align-items: center; justify-content: space-between; }
.wordmark { display: flex; align-items: center; gap: 7px; color: #f5f5f5; text-decoration: none; font-size: 14px; font-weight: 600; }
.wordmark strong { font-weight: 600; }
.new-chat-button {
  width: 100%; min-height: 44px; padding: 0 10px; display: flex; align-items: center; gap: 10px;
  border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; text-align: left;
}
.new-chat-button:hover { background: #232323; }
.new-chat-button svg { width: 18px; }
.new-chat-button kbd { display: none; }
.history-label { padding: 21px 11px 7px; color: #8d8d8d; font-size: 11px; font-weight: 500; }
.conversation-list { min-height: 0; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3a3a transparent; }
.conversation-item {
  width: 100%; min-height: 40px; padding: 0 7px 0 10px; display: flex; align-items: center; gap: 9px;
  border: 0; border-radius: 8px; background: transparent; color: #d6d6d6; cursor: pointer; text-align: left; font-size: 12.5px;
}
.conversation-item:hover, .conversation-item.active { background: #242424; color: #fff; }
.conversation-item > svg { display: none; }
.mode-dot { width: 14px; height: 14px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 4px; color: #fff; font-size: 8px; font-weight: 700; }
.mode-dot.chat { width: 6px; height: 6px; margin: 0 4px; border-radius: 50%; background: #9b9b9b; }
.mode-dot.work { background: #6d5bd0; }
.conversation-item .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-item .delete-chat {
  width: 27px; height: 27px; display: none; place-items: center; border: 0; border-radius: 7px;
  background: transparent; color: var(--subtle); cursor: pointer;
}
.conversation-item:hover .delete-chat { display: grid; }
.delete-chat:hover { color: #ff8585 !important; background: rgba(255,255,255,.07) !important; }
.delete-chat svg { width: 14px; }
.sidebar-footer {
  min-height: 58px; margin-top: 8px; padding: 8px 6px; display: flex; align-items: center; gap: 9px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.model-status { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.model-status div { min-width: 0; display: grid; gap: 2px; }
.model-status strong { font-size: 12px; font-weight: 550; }
.model-status small { color: var(--subtle); font-size: 10px; }
.account-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #7c6cff; color: #fff; font-size: 12px; font-weight: 650; }

/* Main chat */
.main { min-width: 0; height: 100dvh; display: grid; grid-template-rows: 56px minmax(0, 1fr); position: relative; background: var(--bg); }
.topbar { height: 56px; padding: 0 18px; display: flex; align-items: center; gap: 8px; background: rgba(33,33,33,.92); z-index: 5; }
.conversation-title {
  max-width: 50vw; border: 0; padding: 7px 9px; border-radius: 8px; background: transparent;
  color: #f1f1f1; font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.conversation-title:hover { background: rgba(255,255,255,.06); }
.model-picker { position: relative; margin-left: auto; }
.topbar-model { padding: 7px 8px; display: flex; align-items: center; gap: 3px; border: 0; border-radius: 8px; background: transparent; color: #d7d7d7; font-size: 13px; font-weight: 550; cursor: pointer; }
.topbar-model:hover, .topbar-model[aria-expanded="true"] { background: rgba(255,255,255,.07); }
.topbar-model svg { width: 15px; height: 15px; }
.topbar-model[aria-expanded="true"] svg { transform: rotate(180deg); }
.model-menu {
  position: absolute; top: calc(100% + 5px); right: 0; z-index: 30; width: 260px; padding: 7px;
  border: 1px solid #444; border-radius: 14px; background: #2b2b2b; box-shadow: 0 16px 45px rgba(0,0,0,.38);
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: .15s; pointer-events: none;
}
.model-menu.open { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
.model-menu-option { width: 100%; min-height: 54px; padding: 9px 10px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.model-menu-option:hover, .model-menu-option.active { background: #3a3a3a; }
.model-menu-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.model-menu-copy strong { font-size: 12.5px; font-weight: 600; }
.model-menu-copy small { color: #999; font-size: 10px; }
.model-check { width: 16px; height: 16px; opacity: 0; color: #ddd; }
.model-menu-option.active .model-check { opacity: 1; }
.chat { min-height: 0; overflow-y: auto; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: #555 transparent; }
.welcome {
  width: min(100%, 820px); min-height: 100%; margin: 0 auto; padding: 40px 26px 165px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.welcome-mark { width: 48px; height: 48px; margin-bottom: 22px; color: #f2f2f2; }
.welcome h2 { margin: 0 0 34px; font-size: clamp(28px, 3.1vw, 34px); line-height: 1.2; font-weight: 550; letter-spacing: -.04em; }
.welcome-badge { display: none; }
.welcome-copy { margin: -20px 0 30px; color: var(--muted); font-size: 13px; }
.welcome-copy.is-empty { display: none; }
.suggestions { width: min(100%, 660px); display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.suggestion {
  min-width: 0; min-height: 76px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border: 1px solid #424242; border-radius: 14px; background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.suggestion:hover { background: #292929; }
.suggestion > span:first-child { min-width: 0; display: grid; gap: 4px; }
.suggestion strong { font-size: 12.5px; font-weight: 550; }
.suggestion small { color: var(--subtle); font-size: 10.5px; }
.suggestion-arrow { flex: 0 0 auto; color: #777; font-size: 15px; }

.messages { width: min(100%, 780px); margin: 0 auto; padding: 34px 20px 160px; }
.message { margin: 0 0 30px; animation: message-in .2s ease both; }
@keyframes message-in { from { opacity: 0; transform: translateY(3px); } }
.message.assistant { display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 13px; }
.message.user { display: flex; justify-content: flex-end; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-size: 11px; font-weight: 650; }
.message.assistant .avatar { color: #101010; background: #fff; }
.message.user .avatar { display: none; }
.message-content { min-width: 0; }
.message.user .message-content { max-width: min(72%, 570px); padding: 10px 15px; border-radius: 20px; background: var(--surface); }
.message-head { min-height: 28px; display: flex; align-items: center; gap: 8px; }
.message-head strong { font-size: 12.5px; font-weight: 600; }
.message-time { color: #747474; font-size: 9.5px; }
.message.user .message-head { display: none; }
.copy-message { margin-left: auto; width: 28px; height: 28px; opacity: 0; }
.message:hover .copy-message { opacity: 1; }
.copy-message svg { width: 14px; }
.message-body { color: var(--text); font-size: 14px; line-height: 1.72; overflow-wrap: anywhere; }
.message.user .message-body { white-space: pre-wrap; line-height: 1.55; }
.message-body p { margin: 6px 0 13px; }
.message-body p:first-child { margin-top: 2px; }
.message-body h1, .message-body h2, .message-body h3 { margin: 22px 0 10px; color: #fff; line-height: 1.35; }
.message-body h1 { font-size: 20px; } .message-body h2 { font-size: 17px; } .message-body h3 { font-size: 15px; }
.message-body ul, .message-body ol { margin: 8px 0 14px; padding-left: 23px; }
.message-body li { margin: 4px 0; }
.message-body a { color: #8ab4f8; text-decoration: underline; text-underline-offset: 3px; }
.message-body blockquote { margin: 13px 0; padding: 2px 0 2px 14px; border-left: 2px solid #747474; color: #c0c0c0; }
.message-body code:not(pre code) { padding: 2px 5px; border-radius: 5px; color: #f0f0f0; background: #343434; font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.code-block { position: relative; margin: 16px 0; border: 1px solid #414141; border-radius: 9px; overflow: hidden; background: #171717; }
.code-label { height: 34px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #373737; color: #a1a1a1; font-size: 9.5px; text-transform: uppercase; }
.copy-code { border: 0; background: transparent; color: #b4b4b4; cursor: pointer; font-size: 10px; }
.code-block pre { margin: 0; padding: 15px; overflow-x: auto; }
.code-block code { color: #e7e7e7; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #b4b4b4; animation: typing 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,60%,100% { opacity:.3; transform:translateY(0); } 30% { opacity:1; transform:translateY(-3px); } }

/* Composer */
.composer-wrap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; padding: 24px 22px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent 0, var(--bg) 36%); pointer-events: none;
}
.mode-switch {
  width: max-content; margin: 0 auto 8px; padding: 4px; display: flex; gap: 3px; border: 1px solid #424242;
  border-radius: 15px; background: rgba(33,33,33,.96); box-shadow: 0 8px 25px rgba(0,0,0,.18); pointer-events: auto;
}
.mode-option {
  min-width: 105px; min-height: 38px; padding: 5px 10px; display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 11px; background: transparent; color: #a8a8a8; cursor: pointer; text-align: left;
}
.mode-option:hover { color: #ececec; background: rgba(255,255,255,.05); }
.mode-option.active { color: #fff; background: #3a3a3a; }
.mode-option[data-mode="work"].active { background: #4a416e; }
.mode-option svg { width: 16px; height: 16px; flex: 0 0 auto; }
.mode-option > span { display: grid; gap: 1px; }
.mode-option strong { font-size: 11.5px; font-weight: 600; }
.mode-option small { color: #8f8f8f; font-size: 8.5px; }
.mode-option.active small { color: #c4c4c4; }
body[data-mode="work"] .send-button:not(:disabled) { color: #fff; background: #6d5bd0; }
body[data-mode="work"] .tool-label { border-color: #62578b; color: #d7d1f5; }
.composer {
  width: min(100%, 768px); margin: 0 auto; padding: 12px 12px 9px 16px; border: 1px solid #424242; border-radius: 26px;
  background: var(--surface); box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.18); pointer-events: auto;
}
.composer:focus-within { border-color: #555; }
.composer textarea {
  width: 100%; max-height: 180px; min-height: 25px; padding: 2px 4px 8px; display: block; resize: none;
  border: 0; outline: 0; color: var(--text); background: transparent; font-size: 14px; line-height: 1.5; scrollbar-width: thin;
}
.composer textarea::placeholder { color: #a0a0a0; }
.composer-bottom { min-height: 32px; display: flex; align-items: center; gap: 10px; }
.composer-tools { display: flex; align-items: center; gap: 8px; color: #c7c7c7; }
.tool-plus { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #515151; border-radius: 50%; font-size: 19px; font-weight: 300; }
.tool-label { padding: 6px 10px; border: 1px solid #515151; border-radius: 15px; font-size: 10.5px; }
.composer-hint { margin-left: auto; color: #767676; font-size: 9.5px; }
.send-button {
  width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 50%;
  color: #1e1e1e; background: #fff; cursor: pointer;
}
.send-button:hover { background: #e3e3e3; }
.send-button:disabled { color: #777; background: #484848; cursor: default; }
.send-button svg { grid-area: 1/1; width: 17px; }
.stop-icon { display: none; }
.composer.is-streaming .send-icon { display: none; }
.composer.is-streaming .stop-icon { display: block; }
.disclaimer { width: min(100%, 768px); margin: 8px auto 0; color: #777; text-align: center; font-size: 9.5px; pointer-events: auto; }
.toast { position: fixed; left: 50%; bottom: 118px; z-index: 60; padding: 9px 14px; border: 1px solid #444; border-radius: 10px; background: #303030; color: #ececec; box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: 11px; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sidebar-scrim { display: none; }

@media (max-width: 760px) {
  .icon-button.mobile-only { display: grid; }
  .app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 310px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 18px 0 55px rgba(0,0,0,.36); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.5); opacity: 0; visibility: hidden; transition: .2s; }
  .sidebar.open + .sidebar-scrim { opacity: 1; visibility: visible; }
  .main { height: 100dvh; grid-template-rows: 52px minmax(0,1fr); }
  .topbar { height: 52px; padding: 0 9px; }
  .conversation-title { font-size: 13px; }
  .topbar-model { padding: 6px; font-size: 11px; }
  .topbar-model svg { width: 13px; height: 13px; }
  .model-menu { width: min(260px, calc(100vw - 20px)); }
  .welcome { padding: 34px 17px 152px; }
  .welcome-mark { width: 42px; height: 42px; margin-bottom: 18px; }
  .welcome h2 { margin-bottom: 27px; font-size: 27px; }
  .welcome-copy { margin-top: -15px; margin-bottom: 23px; font-size: 12px; }
  .suggestions { grid-template-columns: 1fr; gap: 8px; }
  .suggestion { min-height: 62px; padding: 10px 13px; }
  .suggestion:nth-child(n+3) { display: none; }
  .messages { padding: 24px 13px 150px; }
  .message.assistant { grid-template-columns: 27px minmax(0,1fr); gap: 10px; }
  .avatar { width: 26px; height: 26px; }
  .message.user .message-content { max-width: 86%; }
  .message-body { font-size: 13.5px; }
  .composer-wrap { padding: 18px 8px max(7px, env(safe-area-inset-bottom)); }
  .mode-switch { margin-bottom: 6px; }
  .mode-option { min-width: 94px; min-height: 35px; padding: 4px 8px; }
  .mode-option small { display: none; }
  .composer { border-radius: 24px; padding-left: 14px; }
  .composer-hint { display: none; }
  .tool-label { display: none; }
  .disclaimer { margin-top: 6px; font-size: 8.5px; }
  .login-card { padding: 32px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
