:root{
  color-scheme: light;

  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f3;

  --border-subtle: rgba(0,0,0,0.08);
  --border: rgba(0,0,0,0.12);

  --text: #0f172a;
  --text-muted: rgba(15,23,42,0.65);
  --text-subtle: rgba(15,23,42,0.45);

  --accent: #10a37f;
  --accent-strong: #0e8c6f;
  --focus-ring: rgba(16,163,127,0.28);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark){
  :root{
    color-scheme: dark;

    --bg: #0b0f14;
    --surface: #0f141b;
    --surface-2: #0b0f14;

    --border-subtle: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.14);

    --text: rgba(255,255,255,0.92);
    --text-muted: rgba(255,255,255,0.62);
    --text-subtle: rgba(255,255,255,0.45);
  }
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height:1.55;
}

.shell{
  max-width: 920px;
  margin: 20px auto 36px;
  padding: 0 16px;
}

/* Top bar */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:16px 18px;
  border-radius: var(--radius-lg);
  border:1px solid var(--border-subtle);
  background: var(--surface);
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
}

.logo{
  width:40px;
  height:40px;
  display:grid;
  place-items:center;
  border-radius:10px;
  font-weight:700;
  background: rgba(16,163,127,0.12);
  color: var(--accent);
}

.brand-text h1{
  margin:0;
  font-size:18px;
  font-weight:600;
}

.brand-text p{
  margin:4px 0 0;
  font-size:13px;
  color: var(--text-muted);
}

.status-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  color: var(--text-muted);
  padding:6px 10px;
  border-radius:999px;
  background: var(--surface-2);
  border:1px solid var(--border-subtle);
}

.status-pill .dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background: #22c55e;
}

.status-pill[data-state="busy"] .dot{
  background: #f59e0b;
}

.status-pill[data-state="offline"] .dot{
  background: #ef4444;
}

.status-banner{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:12px 14px;
  border-radius: var(--radius-md);
  background: rgba(239,68,68,0.12);
  border:1px solid rgba(239,68,68,0.24);
  color: #b91c1c;
  font-size:13px;
  margin-bottom:12px;
}

.status-banner-text{
  flex:1;
}

/* Panel */
.assistant-panel{
  margin-top:20px;
  border-radius: var(--radius-lg);
  border:1px solid var(--border-subtle);
  background: var(--surface);
  padding:18px;
  display:flex;
  flex-direction:column;
  min-height: 70vh;
}

.chat-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.chat-head h2{
  margin:0;
  font-size:17px;
  font-weight:600;
}

.model-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:6px;
  margin-bottom:10px;
}

.model-pill{
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border-subtle);
  background: var(--surface-2);
}

.model-meta{
  font-size:13px;
  color: var(--text-muted);
}

/* Chat */
.chat-scroll{
  flex:1;
  overflow-y:auto;
}

.messages{
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:10px 2px;
}

.msg{
  display:flex;
  gap:10px;
  align-items:flex-start;
}

.avatar{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:10px;
  border:1px solid var(--border-subtle);
  font-weight:600;
  font-size:12px;
  color: var(--text-muted);
}

.msg.me .avatar{
  background: rgba(16,163,127,0.12);
  color: var(--accent);
}

.bubble{
  max-width: 720px;
  padding:12px 14px;
  border-radius: var(--radius-md);
  border:1px solid var(--border-subtle);
  background: var(--surface);
  font-size:14.5px;
  white-space: pre-wrap;
}

.msg.me .bubble{
  background: rgba(16,163,127,0.10);
  border-color: rgba(16,163,127,0.2);
}

/* Composer */
.composer{
  margin-top:12px;
  border-top:1px solid var(--border-subtle);
  padding-top:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

textarea{
  width:100%;
  resize:none;
  border-radius: var(--radius-lg);
  border:1px solid var(--border-subtle);
  padding:14px;
  font-family: var(--font);
  background: var(--surface-2);
  font-size:14px;
}

textarea:focus-visible{
  outline:none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.composer-actions{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}

.hint{
  font-size:12px;
  color: var(--text-muted);
}

.primary{
  border-radius:999px;
  padding:10px 18px;
  border:none;
  background: var(--accent);
  color:#fff;
  cursor:pointer;
}

.primary:hover{
  background: var(--accent-strong);
}

.ghost{
  background:none;
  border:1px solid var(--border-subtle);
  padding:8px 12px;
  border-radius: var(--radius-sm);
  cursor:pointer;
}

.footer{
  margin-top:28px;
  padding:14px;
  font-size:12px;
  color: var(--text-muted);
  display:flex;
  flex-wrap:wrap;
  gap:8px 16px;
  justify-content:space-between;
  border-top:1px solid var(--border-subtle);
}

.footer-link{
  color: var(--accent);
  text-decoration:none;
  font-weight:600;
}

.footer-link:hover{
  color: var(--accent-strong);
}

.feedback-panel{
  gap:14px;
}

.feedback-note{
  margin:0;
  font-size:14px;
  color: var(--text-muted);
}

.survey-shell{
  display:flex;
  justify-content:center;
  border:1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding:14px;
  background: var(--surface-2);
}

.survey-shell iframe{
  width:min(100%, 640px);
  border:0;
}

kbd{
  font-family: var(--mono);
  font-size:11px;
  padding:2px 6px;
  border-radius:6px;
  border:1px solid var(--border-subtle);
  background: var(--surface);
}
