:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --border: #e2e5e9;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #0f6cbd;
  --accent-weak: #eaf2fb;
  --user-bubble: #0f6cbd;
  --agent-bubble: #f1f3f5;
  --danger: #b42318;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Login ---------- */
.login-view {
  height: 100vh;
  display: grid;
  place-items: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card p { color: var(--muted); }

button.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  cursor: pointer;
}
button.primary:hover { background: #0b5aa0; }
button.link {
  background: none; border: 0; color: var(--accent);
  cursor: pointer; font-size: 13px;
}
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- App shell ---------- */
.app-view { height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }

.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- Vertical tabs ---------- */
.tabs {
  flex: 0 0 260px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tab {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}
.tab:hover { background: var(--accent-weak); }
.tab.active {
  background: var(--accent-weak);
  border-color: var(--accent);
  font-weight: 600;
}
.tab .tab-desc {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-top: 3px;
}

/* ---------- Chat panels ---------- */
.panels { flex: 1 1 auto; min-width: 0; display: flex; }
.panel {
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  min-width: 0;
}
.panel.active { display: flex; }

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { max-width: 760px; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--agent-bubble); border-bottom-left-radius: 4px; }
.msg.error { align-self: flex-start; background: #fdecea; color: var(--danger); }
.msg.thinking { align-self: flex-start; color: var(--muted); font-style: italic; }

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  max-height: 160px;
  min-height: 42px;
}
.composer button {
  background: var(--accent);
  color: #fff; border: 0; border-radius: 8px;
  padding: 10px 18px; cursor: pointer; font-size: 14px;
}
.composer button:disabled { opacity: 0.5; cursor: default; }

.empty-hint { color: var(--muted); margin: auto; text-align: center; padding: 24px; }
