:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

  --user-bg: #0f766e;
  --user-text: #ffffff;

  --bot-bg: #f1f5f9;
  --bot-text: #0f172a;

  --primary: #0f766e;
}

* {
  box-sizing: border-box;
}

/* Make viewport-aware layout possible */
html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
}

/* Outer app wrapper – centers content, fills viewport */
.app {
  height: 100vh;
  display: flex;
  justify-content: center;
  background: var(--bg);
}

/* Main shell – constrained width, full-height column */
.app-shell.shell {
  width: min(1100px, 100%);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* Topbar */
.topbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow);
  flex-shrink: 0; /* do not shrink when height is tight */
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.brand-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 12px;
}

/* Controls row */
.controls {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 300px 200px 1fr;
  gap: 14px;
  align-items: start;
  flex-shrink: 0; /* keep controls visible */
}

.control label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
}

.examples {
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
}
.examples ul {
  margin: 0;
  padding-left: 18px;
}
.examples li {
  margin: 3px 0;
}

/* Main layout: chat | under-the-hood */
.main.main-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 320px);
  gap: 12px;
  flex: 1;          /* take remaining height */
  min-height: 0;    /* allow children to overflow inside */
  overflow: hidden; /* only inner panels scroll */
}

@media (max-width: 920px) {
  .controls {
    grid-template-columns: 1fr;
  }
  .main.main-layout {
    grid-template-columns: 1fr;
  }
}

/* Chat card / panel */
.chat-card.chat-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0; /* important for internal scroll */
}

/* Scrollable messages area */
.messages.chat-messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
}

.empty {
  color: var(--muted);
}
.empty-title {
  font-size: 18px;
  font-weight: 750;
  margin-bottom: 6px;
}
.empty-subtitle {
  font-size: 13px;
}

/* Message bubbles */
.message {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 14px;
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  margin-left: auto;
  background: var(--user-bg);
  color: var(--user-text);
  border-top-right-radius: 6px;
}

.message.bot {
  margin-right: auto;
  background: var(--bot-bg);
  color: var(--bot-text);
  border: 1px solid #e6edf7;
  border-top-left-radius: 6px;
}

/* Composer anchored at bottom of chat panel */
.composer-wrap.chat-input {
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  flex-shrink: 0;
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #d0d7e2;
}

#queryInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
}
#queryInput::placeholder {
  color: #93a0b2;
}

/* ChatGPT-like icon buttons */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #0f172a;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
}

.icon-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.icon-btn.primary {
  background: var(--primary);
  border: 1px solid var(--primary);
}
.icon-btn.primary svg {
  stroke: #ffffff;
}

.icon-btn.listening {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* Hint text under input */
.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Side panel / Under-the-hood */
.side-card.debug-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  overflow-y: auto;
  min-height: 0; /* allow it to scroll inside main-layout */
}

.side-title {
  font-weight: 800;
  margin-bottom: 10px;
}

.kv {
  padding: 10px 0;
}
.k {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.v {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.divider {
  height: 1px;
  background: var(--border);
}
