:root {
  --bg: #08080d;
  --panel: #0e0f16;
  --panel-2: #141621;
  --panel-3: #1a1c29;
  --line: rgba(255,255,255,.09);
  --text: #f7f7fb;
  --muted: #a4a7b5;
  --accent: #8b5cf6;
  --accent-2: #4f46e5;
  --accent-3: #22d3ee;
  --good: #2dd4bf;
  --shadow: 0 18px 70px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 70% -10%, rgba(139,92,246,.12), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, textarea, input { font: inherit; }
button { color: inherit; }
.app-shell { display: grid; grid-template-columns: 270px 1fr; height: 100vh; }
.sidebar {
  background: rgba(11,11,17,.94);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 2px 6px 18px; }
.brand-mark, .welcome-orb {
  display: grid; place-items: center;
  background: linear-gradient(135deg, #7c3aed, #4f46e5 52%, #0891b2);
  box-shadow: 0 0 32px rgba(124,58,237,.28), inset 0 0 0 1px rgba(255,255,255,.18);
  font-weight: 800;
}
.brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.brand-name { font-weight: 750; letter-spacing: -.02em; }
.brand-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.new-chat {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; text-align: left; font-weight: 600; cursor: pointer;
  transition: .2s ease;
}
.new-chat:hover, .side-action:hover, .history-item:hover { background: var(--panel-3); }
.sidebar-label { color: #717586; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 700; margin: 20px 8px 8px; }
.history-list { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.history-item {
  width: 100%; background: transparent; border: 0; border-radius: 9px; cursor: pointer;
  padding: 9px 10px; color: #c9cad2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
  font-size: 13px;
}
.sidebar-bottom { flex: 0 0 auto; margin-top: auto; display: grid; gap: 5px; }
.side-action { background: transparent; border: 0; border-radius: 9px; padding: 9px 10px; text-align: left; cursor: pointer; }
.soon { float: right; font-size: 10px; color: var(--accent-3); border: 1px solid rgba(34,211,238,.3); padding: 2px 6px; border-radius: 999px; }
.cost-guard { margin-top: 10px; border: 1px solid rgba(45,212,191,.16); background: rgba(45,212,191,.06); border-radius: 12px; padding: 10px; display: flex; gap: 9px; align-items: flex-start; }
.cost-guard strong { font-size: 12px; display: block; }
.cost-guard small { color: #8fcfc3; display: block; margin-top: 3px; font-size: 10px; line-height: 1.35; }
.status-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--good); box-shadow: 0 0 12px var(--good); flex: 0 0 auto; }
.main { min-width: 0; display: grid; grid-template-rows: 58px 1fr auto; height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.045); backdrop-filter: blur(12px); }
.model-pill { border: 1px solid var(--line); background: rgba(20,22,33,.7); border-radius: 999px; padding: 8px 12px; cursor: pointer; font-weight: 600; color: #ddd; }
.spark { color: #a78bfa; margin-right: 5px; }
.chev { margin-left: 6px; color: var(--muted); }
.ghost-btn, .icon-button { background: transparent; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.ghost-btn { padding: 7px 11px; color: var(--muted); }
.icon-button { width: 36px; height: 36px; }
.chat { overflow-y: auto; padding: 28px 18px 140px; }
.welcome { max-width: 760px; margin: 7vh auto 0; text-align: center; }
.welcome-orb { width: 60px; height: 60px; border-radius: 19px; margin: 0 auto 20px; font-size: 23px; }
.welcome h1 { font-size: clamp(30px, 4vw, 46px); letter-spacing: -.045em; margin: 0 0 10px; }
.welcome > p { color: var(--muted); margin: 0 auto 28px; max-width: 590px; line-height: 1.65; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suggestion { min-height: 105px; background: rgba(20,22,33,.72); border: 1px solid var(--line); border-radius: 15px; padding: 14px; cursor: pointer; text-align: left; transition: .2s ease; }
.suggestion:hover { transform: translateY(-2px); border-color: rgba(139,92,246,.42); background: rgba(26,28,41,.9); }
.suggestion span { font-size: 20px; display: block; margin-bottom: 10px; }
.suggestion strong { display: block; font-size: 13px; }
.suggestion small { color: var(--muted); font-size: 11px; display: block; margin-top: 5px; }
.messages { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 12px; align-items: flex-start; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.message.user .avatar { background: #252837; }
.message.assistant .avatar { background: linear-gradient(135deg,#7c3aed,#2563eb); }
.message-body { min-width: 0; }
.message-head { font-size: 12px; font-weight: 700; margin: 2px 0 6px; color: #d8d8de; }
.message-content { color: #e8e8ed; line-height: 1.72; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.message.user .message-content { color: #cfcfd7; }
.message.assistant .message-content { white-space: normal; }
.message.assistant .message-content > div { white-space: pre-wrap; }
.message-content h3 { font-size: 15px; line-height: 1.5; margin: 14px 0 7px; }
.message-content h3:first-child { margin-top: 0; }
.message-content ul, .message-content ol { margin: 5px 0; padding-left: 24px; }
.message-content li { white-space: pre-wrap; padding-left: 2px; }
.message-content .darion-answer-gap { height: 10px; }
.message-content pre { white-space: pre; overflow-x: auto; margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.18); }
.message-content .darion-answer-task { list-style: none; }
.darion-answer-task-mark { display: inline-block; width: 20px; margin-left: -20px; color: #aa94f6; }
.typing { display: inline-flex; gap: 5px; align-items: center; height: 24px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #8b5cf6; animation: bounce 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .14s; } .typing i:nth-child(3) { animation-delay: .28s; }
@keyframes bounce { 0%,80%,100%{ transform: translateY(0); opacity:.45 } 40%{ transform: translateY(-5px); opacity:1 } }
.composer-wrap { position: fixed; left: 270px; right: 0; bottom: 0; padding: 18px 18px 9px; background: linear-gradient(to top, var(--bg) 58%, rgba(8,8,13,0)); }
.composer { max-width: 820px; margin: 0 auto; background: #141620; border: 1px solid rgba(255,255,255,.11); border-radius: 19px; box-shadow: var(--shadow); overflow: hidden; }
.composer:focus-within { border-color: rgba(139,92,246,.55); box-shadow: 0 16px 60px rgba(0,0,0,.42), 0 0 0 3px rgba(139,92,246,.08); }
textarea { width: 100%; resize: none; border: 0; outline: none; background: transparent; color: var(--text); padding: 14px 15px 8px; min-height: 48px; max-height: 180px; line-height: 1.5; }
textarea::placeholder { color: #757989; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 9px 10px; }
.composer-tools { display: flex; align-items: center; gap: 8px; }
.tool-btn { width: 30px; height: 30px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; }
.privacy-note { color: #6e7281; font-size: 10px; }
.send-btn { width: 34px; height: 34px; border-radius: 11px; border: 0; cursor: pointer; background: linear-gradient(135deg,#7c3aed,#4f46e5); font-size: 20px; line-height: 1; }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }
.disclaimer { text-align: center; color: #666a79; font-size: 10px; margin-top: 8px; }
.hidden { display: none !important; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(9px); display: grid; place-items: center; z-index: 20; padding: 18px; }
.modal { width: min(620px,100%); background: #11131c; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 100px rgba(0,0,0,.55); padding: 20px; }
.modal-head { display: flex; justify-content: space-between; gap: 20px; }
.modal h2 { margin: 0; font-size: 21px; }
.modal-head p, .setting-card p, .price-card p { color: var(--muted); line-height: 1.5; font-size: 12px; }
.setting-card { display: grid; grid-template-columns: 1fr 220px; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 14px; }
.setting-card.vertical { display: block; }
.setting-card ul { margin: 10px 0 0; color: #b2b4bf; font-size: 12px; line-height: 1.75; padding-left: 18px; }
.setting-card input { width: 100%; border: 1px solid var(--line); outline: none; background: #0b0c12; color: white; border-radius: 9px; padding: 10px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.primary-btn { border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; background: linear-gradient(135deg,#7c3aed,#4f46e5); }
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.price-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.price-card.featured { border-color: rgba(139,92,246,.45); background: rgba(139,92,246,.07); }
.plan { color: #c4b5fd; font-weight: 700; }
.price { font-size: 24px; font-weight: 800; margin-top: 14px; }
.price-card button { width: 100%; border: 1px solid var(--line); background: #1b1d29; border-radius: 9px; padding: 9px; color: #888b98; }
.mobile-only { display: none; }
.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: #1b1e2a; border:1px solid var(--line); color:#ddd; border-radius:10px; padding:9px 12px; z-index:50; font-size:12px; box-shadow:var(--shadow); }
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 280px; inset: 0 auto 0 0; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .composer-wrap { left: 0; }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { padding: 0 10px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { margin-top: 3vh; }
  .privacy-note { display: none; }
  .setting-card, .price-grid { grid-template-columns: 1fr; }
  .chat { padding-left: 12px; padding-right: 12px; }
}

/* M.E.L. visual refresh */
:root {
  --bg: #090b16;
  --panel: #101321;
  --panel-2: #171b2d;
  --panel-3: #20253b;
  --line: rgba(200, 208, 255, .11);
  --text: #f8f8ff;
  --muted: #a5acc4;
  --accent: #aa82ff;
  --accent-2: #615af4;
  --accent-3: #76e5dc;
  --good: #76e5dc;
}
body {
  background:
    radial-gradient(ellipse 45% 60% at 67% 32%, rgba(100, 70, 210, .14), transparent 72%),
    radial-gradient(ellipse 30% 50% at 95% 94%, rgba(41, 158, 179, .08), transparent 70%),
    var(--bg);
}
.app-shell, .main { height: 100vh; height: 100dvh; }
.app-shell { grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { background: #0d101c; padding: 25px 15px 17px; }
.brand-row { padding: 2px 6px 27px; }
.brand-mark, .welcome-orb {
  position: relative; background: linear-gradient(142deg, #b77dff 0%, #6a57dc 57%, #3ba8af 100%);
  color: #fff; box-shadow: inset 0 1px 1px rgba(255,255,255,.42), 0 13px 32px rgba(103,72,224,.28);
}
.brand-mark { width: 40px; height: 40px; border-radius: 13px; font-size: 21px; letter-spacing: -.08em; }
.brand-mark span { position: absolute; font-size: 10px; right: 6px; top: 3px; letter-spacing: 0; }
.brand-name { font-size: 15px; letter-spacing: .04em; }
.brand-sub { font-size: 11px; color: #8792b0; }
.new-chat { border-color: rgba(167,145,247,.23); background: linear-gradient(120deg, #272445, #1a2340); padding: 12px 13px; }
.new-chat span { font-size: 20px; line-height: 0; vertical-align: -2px; margin-right: 7px; color: #d6c5ff; }
.search-wrap { display: flex; align-items: center; gap: 8px; margin-top: 15px; padding: 0 10px; border-radius: 10px; background: #151a2a; border: 1px solid var(--line); color: #7d86a3; }
.search-wrap span { font-size: 22px; line-height: 1; }
.search-wrap input { min-width: 0; width: 100%; height: 36px; background: transparent; border: 0; outline: none; color: var(--text); font-size: 12px; }
.search-wrap input::placeholder { color: #778099; }
.sidebar-label { margin-top: 23px; font-size: 10px; color: #858da8; }
.mel-projects-section { flex: 0 1 auto; min-height: 0; max-height: min(28vh, 220px); overflow-y: auto; }
.history-empty { color: #78819b; font-size: 12px; line-height: 1.5; padding: 6px 10px; }
.history-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.history-row:hover, .history-row.active { background: #1a1e31; }
.history-item { flex: 1; min-width: 0; color: #c8cce0; }
.history-row.active .history-item { color: #fff; font-weight: 600; }
.history-more { border: 0; border-radius: 8px; background: transparent; color: #8d94ad; font-size: 18px; cursor: pointer; width: 30px; height: 30px; margin-right: 4px; }
.history-more:hover { background: #30354b; color: #fff; }
.history-menu { position: absolute; right: 3px; top: calc(100% - 2px); z-index: 8; width: 128px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: #252a3e; box-shadow: var(--shadow); }
.history-menu button { display: block; width: 100%; padding: 8px 10px; text-align: left; border: 0; border-radius: 6px; background: transparent; color: #e5e6f0; cursor: pointer; font-size: 12px; }
.history-menu button:hover { background: #3a4058; }
.sidebar-bottom { padding-top: 15px; border-top: 1px solid var(--line); }
.side-action { color: #c8cce0; }
.cost-guard { margin-top: 14px; background: rgba(69, 207, 188, .065); }
.cost-guard small { color: #a0c9c7; }
.topbar { height: 66px; padding: 0 31px; border-color: var(--line); }
.main { grid-template-rows: 66px minmax(0, 1fr) auto; }
.model-pill { background: #171b2b; padding: 9px 14px; font-size: 12px; border-color: rgba(170,130,255,.24); }
.spark { color: #cba9ff; }
.top-actions { display: flex; gap: 9px; }
.ghost-btn { font-size: 12px; color: #b8bed1; padding: 8px 12px; }
.ghost-btn:hover { color: white; background: var(--panel-3); }
.ghost-btn:disabled { opacity: .36; cursor: default; }
.chat { padding: 26px 24px 160px; scroll-behavior: smooth; }
.welcome { margin: max(24px, 5vh) auto 0; max-width: 805px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; border: 1px solid rgba(187,165,255,.17); border-radius: 999px; padding: 8px 12px; color: #bcb3e6; font-size: 10px; font-weight: 700; letter-spacing: .14em; background: rgba(130,101,213,.08); }
.eyebrow-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #75e1d6; box-shadow: 0 0 10px rgba(117,225,214,.6); flex: 0 0 auto; }
.welcome-orb { width: 76px; height: 76px; border-radius: 25px; margin: 27px auto 28px; font-size: 43px; letter-spacing: -.09em; transform: rotate(-7deg); }
.welcome-orb span { position: absolute; font-size: 19px; top: 7px; right: 11px; letter-spacing: 0; }
.welcome h1 { font-size: clamp(34px, 4.3vw, 58px); line-height: 1.12; font-weight: 700; letter-spacing: -.055em; margin-bottom: 17px; }
.welcome h1 em { font-style: normal; background: linear-gradient(105deg, #c9adff, #84d3d5); color: transparent; background-clip: text; -webkit-background-clip: text; }
.welcome > p { max-width: 555px; color: #aeb5c9; line-height: 1.68; margin-bottom: 33px; font-size: 14px; }
.suggestions { gap: 12px; text-align: left; }
.suggestion { min-height: 131px; padding: 18px 20px; border-color: rgba(191,193,245,.13); background: linear-gradient(140deg, rgba(31,35,57,.82), rgba(22,27,45,.72)); }
.suggestion:hover { border-color: rgba(171,133,254,.55); background: #252741; }
.suggestion .card-icon { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(177,150,255,.3); border-radius: 9px; background: rgba(135,100,233,.15); color: #c5a7ff; font-size: 18px; margin-bottom: 16px; }
.suggestion strong { font-size: 14px; font-weight: 650; }
.suggestion small { margin-top: 7px; font-size: 11px; color: #9aa3bc; }
.suggestion small b { float: right; font-size: 16px; font-weight: 400; line-height: 10px; }
.messages { padding-top: 14px; gap: 27px; }
.message { gap: 15px; }
.message.user .avatar { background: #30344a; font-size: 10px; }
.message.assistant .avatar { background: linear-gradient(135deg,#a679ee,#5866cb); }
.message-content { font-size: 14px; color: #e2e5f0; }
.message-head { color: #f1efff; }
.composer-wrap { left: 260px; padding: 25px 24px 13px; background: linear-gradient(to top, #090b16 52%, rgba(9,11,22,0)); }
.composer { max-width: 820px; background: #191d2e; border-color: rgba(205,205,255,.19); border-radius: 17px; }
textarea { padding: 16px 17px 7px; }
.composer-bottom { padding: 0 11px 10px 16px; }
.composer-mode { display: flex; align-items: center; gap: 7px; color: #a6acc4; font-size: 11px; }
.send-btn { background: linear-gradient(135deg,#ad83fa,#655fe5); font-weight: 700; }
.disclaimer { color: #848ba2; margin-top: 10px; font-size: 10px; }
.modal { max-height: min(85vh, 720px); overflow-y: auto; }
.modal h2 { color: #fff; }
.price-card { background: #191c2c; }
.price-card.featured { background: rgba(116,89,222,.12); }
.mobile-scrim { display: none; }
.close-sidebar { margin-left: auto; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #b595ff; outline-offset: 2px; }
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: min(305px, 86vw); }
  .mobile-scrim:not(.hidden) { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.62); }
  .topbar { padding: 0 12px; }
  .top-actions { gap: 4px; }
  .ghost-btn { padding: 8px; }
  .chat { padding: 20px 14px 155px; }
  .welcome { margin: 17px auto 0; }
  .welcome-orb { width: 62px; height: 62px; border-radius: 21px; font-size: 36px; margin: 23px auto; }
  .welcome h1 { font-size: clamp(31px, 8vw, 42px); }
  .welcome > p { font-size: 12px; margin-bottom: 20px; }
  .suggestions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .suggestion { min-height: 116px; padding: 12px; }
  .suggestion .card-icon { margin-bottom: 10px; }
  .suggestion strong { font-size: 12px; }
  .suggestion small { font-size: 10px; line-height: 1.4; }
  .composer-wrap { left: 0; padding: 18px 10px 9px; }
  .disclaimer { font-size: 9px; }
  .modal { padding: 17px; }
}
@media (max-width: 370px) {
  .model-pill { padding: 8px; }
  .ghost-btn { font-size: 11px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome-orb { display: none; }
  .welcome h1 { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Account setup */
.account-modal { width: min(470px, 100%); }
.account-notice { margin: 19px 0; border: 1px solid rgba(170,130,255,.2); background: rgba(170,130,255,.07); padding: 13px 14px; border-radius: 11px; color: #cdd1e0; font-size: 13px; line-height: 1.55; }
.account-notice strong { color: white; word-break: break-word; }
.auth-tabs { display: flex; gap: 7px; padding-top: 19px; }
.auth-tabs button { border: 1px solid var(--line); border-radius: 9px; background: transparent; color: #b1b6ca; padding: 9px 12px; cursor: pointer; font-size: 12px; }
.auth-tabs button.active { background: #272845; color: white; border-color: #7866c9; }
.auth-form { display: grid; gap: 15px; margin-top: 20px; }
.auth-form label { display: grid; gap: 7px; color: #ced2e0; font-size: 12px; font-weight: 600; }
.auth-form input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #0e1220; color: white; padding: 11px 12px; }
.auth-form .primary-btn { justify-self: start; margin-top: 3px; }
.auth-message { min-height: 20px; margin: 13px 0 0; color: #bfc5d6; font-size: 12px; line-height: 1.5; }
.account-links { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.auth-text-button { display: inline-block; margin-top: 14px; padding: 3px 0; border: 0; background: none; color: #c7b5ff; font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.auth-text-button:hover { color: #fff; }

/* Legal links */
.legal-links { display:flex; align-items:center; justify-content:center; gap:7px; margin-top:5px; font-size:10px; color:#737b95; }
.legal-links a { color:#8d95ad; text-decoration:none; }
.legal-links a:hover { color:#c8bfff; text-decoration:underline; }
