:root {
  color-scheme: dark;
  --bg: #080b09;
  --surface: #0e1310;
  --surface-strong: #121914;
  --line: #263029;
  --line-soft: #182019;
  --text: #f4f7f2;
  --muted: #879289;
  --dim: #566159;
  --accent: #adff2f;
  --accent-strong: #8ee600;
  --danger: #ff6b6b;
  --sidebar: 248px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); }
button, input, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font: 700 11px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-view {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(390px, 0.85fr);
  background:
    linear-gradient(rgba(173, 255, 47, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(173, 255, 47, 0.045) 1px, transparent 1px),
    var(--bg);
  background-size: 56px 56px;
}

.login-mark {
  position: relative;
  min-height: 100%;
  overflow: hidden;
}

.glow-core, .glow-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.glow-core {
  width: 120px;
  height: 120px;
  background: var(--accent);
  box-shadow: 0 0 80px rgba(173, 255, 47, 0.5), 0 0 180px rgba(173, 255, 47, 0.15);
  animation: breathe 3.2s ease-in-out infinite;
}

.glow-ring {
  width: 330px;
  height: 330px;
  border: 1px solid rgba(173, 255, 47, 0.25);
  box-shadow: inset 0 0 90px rgba(173, 255, 47, 0.04);
  animation: ring 3.2s ease-in-out infinite;
}

.login-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(44px, 8vw, 118px);
  border-left: 1px solid var(--line);
  background: rgba(8, 11, 9, 0.92);
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(46px, 6vw, 84px);
  line-height: 0.95;
  font-weight: 760;
  letter-spacing: 0;
}

.login-copy {
  max-width: 410px;
  margin: 24px 0 44px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

form label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input { height: 52px; padding: 0 15px; }
input:focus, textarea:focus {
  border-color: rgba(173, 255, 47, 0.65);
  box-shadow: 0 0 0 3px rgba(173, 255, 47, 0.08);
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.primary-button, .secondary-button {
  min-height: 48px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease;
}

.primary-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  background: var(--accent);
  color: #0a0d0b;
}

.primary-button:hover { background: var(--accent-strong); transform: translateY(-1px); }
.secondary-button { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.5; cursor: wait; transform: none !important; }

.app-view {
  min-height: 100svh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--line-soft);
  background: #0a0e0b;
  z-index: 10;
}

.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 42px; }
.brand-row strong { display: block; font-size: 15px; }
.brand-row span:last-child { display: block; margin-top: 3px; color: var(--dim); font: 700 9px/1 ui-monospace, monospace; }
.brand-light { width: 30px; height: 30px; border: 1px solid var(--accent); border-radius: 50%; background: var(--accent); box-shadow: 0 0 20px rgba(173, 255, 47, 0.4); }

nav { display: grid; gap: 6px; }
.nav-button {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.nav-button:hover, .nav-button.active { background: rgba(173, 255, 47, 0.08); color: var(--accent); }
.nav-button span { width: 20px; text-align: center; font-size: 17px; }

.sidebar-bottom { margin-top: auto; }
.service-state { display: flex; align-items: center; gap: 10px; padding: 15px 10px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.service-state strong, .service-state span { display: block; }
.service-state strong { font-size: 12px; }
.service-state span { margin-top: 4px; color: var(--dim); font-size: 10px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.state-dot.ready { background: var(--accent); box-shadow: 0 0 10px rgba(173, 255, 47, 0.7); }
.text-button { margin: 18px 10px 0; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.text-button:hover { color: var(--text); }

.workspace {
  grid-column: 2;
  width: min(100%, 1160px);
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 30px 42px 28px;
}

.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line-soft); }
.workspace-header h2, .panel-header h2 { margin: 0; font-size: 28px; letter-spacing: 0; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.model-chip { min-height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 12px; }
.web-toggle { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--muted); cursor: pointer; }
.web-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toggle-track { width: 38px; height: 22px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); transition: 160ms ease; }
.toggle-track span { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--dim); transition: 160ms ease; }
.web-toggle input:checked + .toggle-track { border-color: rgba(173, 255, 47, 0.55); background: rgba(173, 255, 47, 0.08); }
.web-toggle input:checked + .toggle-track span { transform: translateX(16px); background: var(--accent); }

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.icon-button:hover { border-color: var(--dim); color: var(--text); }

.messages { min-height: 0; overflow-y: auto; padding: 32px 0 24px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.empty-state { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; animation: appear 420ms ease both; }
.empty-state h3 { margin: 4px 0 12px; font-size: clamp(28px, 4vw, 44px); }
.empty-state > p { max-width: 500px; margin: 0; color: var(--muted); line-height: 1.6; }
.empty-light { width: 42px; height: 42px; margin-bottom: 26px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 30px rgba(173, 255, 47, 0.4); animation: breathe 3.2s ease-in-out infinite; }
.quick-prompts { max-width: 720px; margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.quick-prompts button { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; transition: 160ms ease; }
.quick-prompts button:hover { border-color: rgba(173, 255, 47, 0.5); color: var(--text); background: rgba(173, 255, 47, 0.05); }

.message { width: min(82%, 780px); margin-bottom: 30px; animation: appear 240ms ease both; }
.message.user { margin-left: auto; }
.message.assistant { margin-right: auto; }
.message-label { margin-bottom: 8px; color: var(--dim); font: 700 10px/1.3 ui-monospace, monospace; text-transform: uppercase; }
.message.user .message-label { text-align: right; }
.message-body { padding: 16px 18px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.message.user .message-body { border-color: rgba(173, 255, 47, 0.2); background: rgba(173, 255, 47, 0.055); }
.retry-button { width: auto; min-height: 38px; margin-top: 10px; padding: 0 14px; }
.action-card { margin-top: 10px; padding: 16px; border: 1px solid rgba(173, 255, 47, 0.24); border-radius: 6px; background: rgba(173, 255, 47, 0.04); }
.action-card > span { color: var(--accent); font: 700 10px/1.3 ui-monospace, monospace; }
.action-card p { margin: 12px 0 16px; line-height: 1.55; white-space: pre-wrap; }
.published-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.published-link:hover { text-decoration: underline; }
.sources { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.source-link { max-width: 100%; color: var(--accent); font-size: 12px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-link:hover { text-decoration: underline; }
.typing .message-body { color: var(--muted); }

.composer { position: sticky; bottom: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(14, 19, 16, 0.97); box-shadow: 0 -20px 40px var(--bg); }
.composer textarea { min-height: 60px; max-height: 180px; resize: none; padding: 14px; border: 0; background: transparent; box-shadow: none; line-height: 1.5; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 4px 0 12px; }
.composer-bottom span { color: var(--dim); font-size: 11px; }
.send-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--accent); color: #0a0d0b; font-size: 23px; font-weight: 800; cursor: pointer; }
.send-button:hover { background: var(--accent-strong); }

.side-panel { position: fixed; inset: 0 0 0 auto; width: min(470px, 100%); padding: 34px; border-left: 1px solid var(--line); background: #0b0f0c; z-index: 30; overflow-y: auto; animation: slide-in 220ms ease both; }
.panel-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62); z-index: 20; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-copy { margin: 34px 0; color: var(--muted); line-height: 1.65; }
.integration-block { padding: 26px 0; border-bottom: 1px solid var(--line-soft); }
.integration-block:first-of-type { padding-top: 34px; border-top: 1px solid var(--line-soft); }
.integration-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.integration-heading h3 { margin: 0; font-size: 20px; }
.status-badge { padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font: 700 10px/1 ui-monospace, monospace; }
.status-badge.ready { border-color: rgba(173, 255, 47, 0.4); color: var(--accent); }
.integration-block .primary-button { margin-top: 18px; }
.connection-list { margin: 0 0 34px; }
.connection-list div { padding: 18px 0; border-top: 1px solid var(--line-soft); }
.connection-list div:last-child { border-bottom: 1px solid var(--line-soft); }
.connection-list dt { color: var(--dim); font-size: 11px; }
.connection-list dd { margin: 8px 0 0; color: var(--text); font: 13px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.key-result { margin-top: 18px; padding: 16px; border: 1px solid rgba(173, 255, 47, 0.24); border-radius: 6px; background: rgba(173, 255, 47, 0.04); }
.key-result p { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.key-result code { display: block; margin-bottom: 14px; overflow-wrap: anywhere; color: var(--accent); }
.security-note { margin-top: 24px; color: var(--dim); font-size: 12px; line-height: 1.6; }

@keyframes breathe { 50% { transform: translate(-50%, -50%) scale(0.88); opacity: 0.78; } }
.empty-light { animation-name: breathe-static; }
@keyframes breathe-static { 50% { transform: scale(0.88); opacity: 0.78; } }
@keyframes ring { 50% { transform: translate(-50%, -50%) scale(1.08); opacity: 0.45; } }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .login-view { grid-template-columns: 1fr; }
  .login-mark { min-height: 32svh; }
  .glow-core { width: 72px; height: 72px; }
  .glow-ring { width: 190px; height: 190px; }
  .login-panel { min-height: 68svh; padding: 38px 24px max(38px, env(safe-area-inset-bottom)); border-left: 0; border-top: 1px solid var(--line); justify-content: flex-start; }
  .login-panel h1 { font-size: 48px; }
  .login-copy { margin: 18px 0 24px; }
  .app-view { display: block; }
  .sidebar { inset: auto 0 0; width: auto; height: calc(72px + env(safe-area-inset-bottom)); padding: 7px 10px env(safe-area-inset-bottom); flex-direction: row; align-items: center; border-right: 0; border-top: 1px solid var(--line); background: rgba(10, 14, 11, 0.97); backdrop-filter: blur(14px); }
  .brand-row { display: none; }
  nav { width: auto; flex: 1; display: flex; gap: 4px; }
  .nav-button { width: 50%; height: 56px; justify-content: center; flex-direction: column; gap: 5px; padding: 0 6px; font-size: 11px; }
  .nav-button span { width: auto; font-size: 17px; }
  .sidebar-bottom { margin: 0 0 0 4px; display: flex; align-items: center; gap: 2px; }
  .service-state { padding: 0 10px; border: 0; }
  .service-state div { display: none; }
  .text-button { min-width: 48px; height: 48px; margin: 0; font-size: 11px; }
  .workspace { grid-column: 1; padding: 22px 16px calc(92px + env(safe-area-inset-bottom)); }
  .workspace-header { align-items: center; padding-bottom: 18px; }
  .workspace-header h2 { font-size: 22px; }
  .workspace-header .eyebrow { display: none; }
  .model-chip { width: 38px; padding: 0; justify-content: center; }
  .model-chip > span:last-child { display: none; }
  .web-toggle > span:last-child { display: none; }
  .messages { padding-top: 22px; }
  .message { width: 94%; margin-bottom: 22px; }
  .message-body { padding: 14px; }
  .empty-state { min-height: 52vh; }
  .quick-prompts { margin-top: 22px; display: grid; width: 100%; }
  .quick-prompts button { width: 100%; }
  .composer { padding: 8px; }
  .composer textarea { min-height: 54px; padding: 12px; }
  .composer-bottom { padding-left: 8px; }
  .side-panel { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
