:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #0f1219;
  --panel-strong: #151923;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f5f7;
  --muted: #989eab;
  --accent: #a6ffcb;
  --accent-strong: #62e7a0;
  --accent-ink: #07130d;
  --danger: #ff8f9d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 72% 14%, rgba(69, 150, 116, 0.1), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { color: inherit; }
.is-hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 430px);
  padding: 46px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(22, 27, 37, 0.96), rgba(12, 15, 21, 0.98));
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, #d4ffe6, var(--accent-strong));
  box-shadow: 0 12px 35px rgba(82, 231, 155, 0.22);
  font-size: 25px;
}

.brand-mark.small { width: 32px; height: 32px; border-radius: 10px; font-size: 16px; }
.eyebrow { margin: 26px 0 8px; color: var(--accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.auth-card h1 { margin: 0; font-size: clamp(2rem, 7vw, 3rem); line-height: 1.02; letter-spacing: -0.045em; }
.auth-copy { margin: 14px 0 30px; color: var(--muted); line-height: 1.55; }
.auth-card label { display: block; margin: 0 0 9px; color: #d7dae0; font-size: 0.875rem; font-weight: 650; }

.password-row { position: relative; }
.password-row input {
  width: 100%; height: 52px; padding: 0 52px 0 16px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  outline: none; background: #090c12; color: var(--text);
  transition: border-color 160ms, box-shadow 160ms;
}
.password-row input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 4px rgba(98, 231, 160, 0.09); }
.icon-button { position: absolute; right: 7px; top: 7px; width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.06); color: var(--text); }
.form-error { min-height: 21px; margin: 8px 0; color: var(--danger); font-size: .84rem; }
.primary-button { width: 100%; height: 52px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 800; cursor: pointer; }
.primary-button:hover { background: #c1ffd9; }
.primary-button:disabled { opacity: .55; cursor: wait; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; padding: 24px 18px 18px; border-right: 1px solid var(--line); background: rgba(10, 12, 17, 0.82); backdrop-filter: blur(18px); z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.new-chat { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 28px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--panel); font-weight: 700; cursor: pointer; }
.new-chat:hover { border-color: rgba(166,255,203,.42); background: var(--panel-strong); }
.history { flex: 1; min-height: 0; overflow: auto; margin-top: 31px; }
.section-label { margin: 0 10px 10px; color: #6f7581; font-size: .72rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.conversation-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 10px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.conversation-item::before { content: "◇"; flex: 0 0 auto; color: #646b77; }
.conversation-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item:hover, .conversation-item.active { background: rgba(255,255,255,.055); color: var(--text); }
.conversation-item.active::before { color: var(--accent); }
.sidebar-footer { padding-top: 15px; border-top: 1px solid var(--line); }
.sidebar-action { width: 100%; display: flex; gap: 10px; padding: 11px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; text-align: left; }
.sidebar-action:hover { background: rgba(255,255,255,.05); color: var(--text); }
.backdrop { display: none; }

.workspace { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar { min-height: 92px; display: flex; align-items: center; gap: 18px; padding: 18px clamp(22px, 5vw, 64px); border-bottom: 1px solid var(--line); }
.topbar .eyebrow { margin: 0 0 4px; font-size: .65rem; }
.topbar h1 { margin: 0; max-width: min(52vw, 680px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.12rem; letter-spacing: -.02em; }
.status-pill { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .74rem; }
.status-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 12px rgba(98,231,160,.6); }
.mobile-menu { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); cursor: pointer; }

.messages { min-height: 0; overflow-y: auto; padding: 36px clamp(22px, 6vw, 82px) 48px; scroll-behavior: smooth; }
.messages-inner { width: min(100%, 840px); margin: 0 auto; }
.welcome { min-height: 100%; display: grid; align-content: center; justify-items: center; padding: 36px 0; text-align: center; }
.welcome-orbit { width: 82px; height: 82px; display: grid; place-items: center; border: 1px solid rgba(166,255,203,.18); border-radius: 50%; background: radial-gradient(circle, rgba(166,255,203,.16), transparent 68%); box-shadow: 0 0 60px rgba(82, 231, 155, .09); }
.welcome-orbit span { color: var(--accent); font-size: 31px; }
.welcome h2 { margin: 25px 0 9px; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1; letter-spacing: -.055em; }
.welcome > p { max-width: 500px; margin: 0; color: var(--muted); line-height: 1.55; }
.suggestions { width: min(100%, 700px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 34px; }
.suggestions button { display: flex; align-items: flex-end; justify-content: space-between; min-height: 92px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(18,22,30,.72); color: #daddE4; text-align: left; line-height: 1.35; cursor: pointer; }
.suggestions button span { color: var(--accent); }
.suggestions button:hover { transform: translateY(-2px); border-color: rgba(166,255,203,.3); background: var(--panel-strong); }

.message { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 13px; margin: 0 0 28px; }
.message.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-strong); color: var(--accent); font-size: 16px; }
.bubble { max-width: min(100%, 720px); color: #e9ebef; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .bubble { padding: 12px 16px; border-radius: 18px 18px 5px 18px; background: #202631; color: #f6f7f8; }
.bubble img { display: block; width: min(100%, 640px); border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.image-actions { margin-top: 10px; }
.image-actions a { color: var(--accent); font-size: .85rem; text-decoration: none; }
.thinking { color: var(--muted); }
.thinking::after { content: ""; display: inline-block; width: 1.1em; height: 1em; vertical-align: -.2em; margin-left: 6px; background: radial-gradient(circle closest-side, var(--accent) 85%, transparent) 0 50%/33% 33% repeat-x; animation: dots 1s steps(4) infinite; }
@keyframes dots { to { background-position: 133% 50%; } }

.composer-wrap { padding: 0 clamp(22px, 6vw, 82px) 22px; background: linear-gradient(transparent, var(--bg) 28%); }
.composer-wrap > * { width: min(100%, 840px); margin-left: auto; margin-right: auto; }
.mode-switch { display: flex; gap: 4px; margin-bottom: 9px; }
.mode-switch button { padding: 7px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 700; cursor: pointer; }
.mode-switch button.active { background: rgba(166,255,203,.1); color: var(--accent); }
.composer { position: relative; padding: 10px; border: 1px solid var(--line-strong); border-radius: 20px; background: rgba(19,23,31,.96); box-shadow: 0 16px 50px rgba(0,0,0,.28); }
.composer:focus-within { border-color: rgba(166,255,203,.38); box-shadow: 0 16px 50px rgba(0,0,0,.3), 0 0 0 4px rgba(98,231,160,.05); }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer textarea { width: 100%; max-height: 190px; resize: none; overflow-y: auto; padding: 8px 0; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.5; }
.composer textarea::placeholder { color: #747b87; }
.attach-button { flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 13px; background: rgba(255,255,255,.055); color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer; }
.attach-button:hover { background: rgba(166,255,203,.11); color: var(--accent); }
.attachment-tray { margin: 0 2px 9px; padding: 2px 4px 10px; border-bottom: 1px solid var(--line); }
.attachment-tray-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: .72rem; }
.attachment-tray-header button { padding: 3px 0; border: 0; background: transparent; color: var(--accent); font-size: .72rem; cursor: pointer; }
.attachment-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.attachment-chip { min-width: 0; flex: 0 0 min(230px, 72vw); display: grid; grid-template-columns: 38px minmax(0, 1fr) 25px; align-items: center; gap: 9px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.attachment-preview { width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; border-radius: 9px; background: rgba(166,255,203,.09); color: var(--accent); font-size: .62rem; font-weight: 800; }
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; }
.attachment-copy { min-width: 0; }
.attachment-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e3e6eb; font-size: .76rem; }
.attachment-size { display: block; margin-top: 2px; color: #737a86; font-size: .66rem; }
.attachment-remove { width: 25px; height: 25px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.attachment-remove:hover { background: rgba(255,255,255,.07); color: var(--text); }
.send-button { flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 13px; background: var(--accent); color: var(--accent-ink); font-size: 1.25rem; font-weight: 800; cursor: pointer; }
.send-button:hover { background: #c1ffd9; }
.send-button:disabled { opacity: .38; cursor: wait; }
.composer-note { margin-top: 9px; margin-bottom: 0; color: #686e79; font-size: .72rem; text-align: center; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.message-attachment { max-width: 260px; display: flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.045); color: #d8dce2; font-size: .73rem; }
.message-attachment span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-text { white-space: pre-wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: calc(100vw - 32px); padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 12px; background: #1d222c; color: var(--text); box-shadow: var(--shadow); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: 180ms; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(84vw, 310px); transform: translateX(-105%); transition: transform 180ms ease; box-shadow: 18px 0 55px rgba(0,0,0,.45); }
  .sidebar.open { transform: translateX(0); }
  .backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.55); }
  .backdrop.visible { display: block; }
  .workspace { min-height: 100vh; height: 100dvh; }
  .mobile-menu { display: grid; place-items: center; }
  .topbar { min-height: 78px; padding: 13px 16px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { max-width: 48vw; }
  .status-pill b { display: none; }
  .messages { padding: 26px 16px 32px; }
  .composer-wrap { padding: 0 12px 12px; }
  .suggestions { grid-template-columns: 1fr; max-width: 420px; }
  .suggestions button { min-height: 58px; }
  .welcome { align-content: start; padding-top: 10vh; }
}

@media (max-width: 480px) {
  .auth-card { padding: 34px 24px; border-radius: 22px; }
  .message { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .avatar { width: 30px; height: 30px; border-radius: 10px; }
  .composer-note { display: none; }
}

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