:root {
  color-scheme: dark;
  --bg: #11100f;
  --panel: #171614;
  --panel-2: #1e1c19;
  --line: #312e29;
  --text: #f5f1e8;
  --muted: #a49e92;
  --accent: #d7ff64;
  --accent-ink: #15170d;
  --danger: #ff8f82;
  --shadow: 0 30px 80px rgb(0 0 0 / 0.38);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 75% 10%, rgb(215 255 100 / 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

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

.login-card {
  width: min(100%, 460px);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgb(23 22 20 / 0.92);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 850;
  font-size: 24px;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.22);
}

.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
.eyebrow { margin: 30px 0 8px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(34px, 7vw, 52px); letter-spacing: -.045em; line-height: 1; }
.login-copy { color: var(--muted); line-height: 1.6; margin: 18px 0 30px; }

label { display: block; color: var(--muted); font-size: 13px; margin: 18px 0; }
input {
  width: 100%;
  margin-top: 8px;
  padding: 14px 15px;
  color: var(--text);
  background: #11100f;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: #6e7e3a; box-shadow: 0 0 0 3px rgb(215 255 100 / .09); }
.error-text { min-height: 20px; color: var(--danger); font-size: 13px; }
.primary-button {
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { padding: 20px; border-right: 1px solid var(--line); background: #0e0d0c; display: flex; flex-direction: column; justify-content: space-between; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.sidebar-brand div:last-child { min-width: 0; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.sidebar-button { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text); text-align: left; }
.sidebar-button:hover { background: var(--panel-2); }
.sidebar-footer { display: grid; gap: 12px; }
.identity { display: flex; align-items: center; gap: 11px; }
.identity strong, .identity span { display: block; }
.identity div span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #2d2a25; color: var(--accent); font-weight: 700; }
.text-button { padding: 6px 0; border: 0; background: none; color: var(--muted); text-align: left; font-size: 12px; }

.chat-panel { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto auto; }
.chat-header { min-height: 74px; display: flex; align-items: center; gap: 14px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgb(17 16 15 / .78); backdrop-filter: blur(20px); }
.chat-header h2 { margin: 0; font-size: 16px; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #7b766d; }
.status-dot.ready { background: var(--accent); box-shadow: 0 0 10px rgb(215 255 100 / .45); }
.stop-button { margin-left: auto; padding: 8px 12px; border: 1px solid #68443e; border-radius: 9px; background: transparent; color: var(--danger); }
.mobile-menu { display: none; border: 0; background: transparent; color: var(--text); font-size: 19px; }

.messages { overflow-y: auto; padding: 42px max(24px, calc((100vw - 260px - 820px) / 2)); scroll-behavior: smooth; }
.empty-state { max-width: 700px; margin: 10vh auto 0; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; margin: 0 auto 22px; border: 1px solid var(--line); border-radius: 20px; color: var(--accent); background: var(--panel); font-size: 24px; }
.empty-state h3 { margin: 0; font-size: 27px; letter-spacing: -.025em; }
.empty-state > p { color: var(--muted); line-height: 1.6; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 28px; }
.suggestions button { min-height: 88px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); text-align: left; line-height: 1.4; }
.suggestions button:hover { border-color: #5b6538; background: var(--panel-2); }

.message { max-width: 820px; margin: 0 auto 26px; }
.message-label { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.message.user .message-content { width: fit-content; max-width: 86%; margin-left: auto; padding: 12px 16px; border-radius: 17px 17px 4px 17px; background: #292620; }
.message.user .message-label { display: none; }
.message.assistant.commentary { padding-left: 15px; border-left: 2px solid #474338; color: #cbc5ba; }
.message.assistant.final_answer .message-label { color: var(--accent); }
.message.streaming .message-content::after { content: ""; display: inline-block; width: 7px; height: 16px; margin-left: 4px; vertical-align: -2px; background: var(--accent); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.activity { max-width: 820px; width: calc(100% - 48px); margin: 0 auto 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { width: min(820px, calc(100% - 48px)); margin: 0 auto 24px; position: relative; }
.composer textarea { width: 100%; min-height: 58px; max-height: 210px; resize: none; padding: 17px 58px 17px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); outline: none; line-height: 1.45; box-shadow: 0 14px 40px rgb(0 0 0 / .2); }
.composer button { position: absolute; right: 10px; top: 9px; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 21px; font-weight: 800; }
.composer button:disabled { opacity: .35; cursor: default; }
.composer p { margin: 7px 3px 0; color: #6f6a62; font-size: 10px; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: 270px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: block; }
  .chat-header { padding: 12px 16px; }
  .messages { padding: 28px 18px; }
  .suggestions { grid-template-columns: 1fr; }
  .composer { width: calc(100% - 24px); margin-bottom: 12px; }
  .login-card { padding: 30px 24px; }
}
