:root {
  --tb-primary: #f59e0b;
  --tb-primary-dark: #d97706;
  --tb-primary-light: #fef3c7;
  --tb-navy: #1a1a2e;
  --tb-navy-light: #16213e;
  --tb-text: #1f2937;
  --tb-text-muted: #6b7280;
  --tb-border: #e5e7eb;
  --tb-success: #10b981;
  --tb-error: #ef4444;
  --tb-bg: #f9fafb;
  --tb-white: #ffffff;
  --tb-radius: 8px;
  --tb-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--tb-bg);
  color: var(--tb-text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ── */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ── */

.tb-header {
  height: 60px;
  background: var(--tb-navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tb-header__wordmark {
  font-size: 20px;
  font-weight: 700;
  color: var(--tb-primary);
  letter-spacing: -0.3px;
}

.tb-header__version {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  font-family: 'SF Mono', 'Fira Mono', monospace;
}

/* ── Body (sidebar + main) ── */

.tb-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ── */

.tb-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--tb-white);
  border-right: 1px solid var(--tb-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.tb-sidebar__section {
  padding: 20px 16px;
  border-bottom: 1px solid var(--tb-border);
}

.tb-sidebar__section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tb-text-muted);
  margin-bottom: 14px;
}

.tb-field {
  margin-bottom: 12px;
}

.tb-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--tb-text);
  margin-bottom: 4px;
}

.tb-field input,
.tb-field select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  font-size: 13px;
  background: var(--tb-bg);
  color: var(--tb-text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
}

.tb-field input:focus,
.tb-field select:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.tb-field input::placeholder {
  color: var(--tb-text-muted);
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--tb-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 80ms ease;
  outline: none;
}

.tb-btn:active {
  transform: scale(0.98);
}

.tb-btn--primary {
  background: var(--tb-primary);
  color: var(--tb-white);
  width: 100%;
}

.tb-btn--primary:hover {
  background: var(--tb-primary-dark);
}

.tb-btn--primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Connection status ── */

.tb-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--tb-text-muted);
}

.tb-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tb-text-muted);
  flex-shrink: 0;
  transition: background 200ms ease;
}

.tb-status--connected .tb-status__dot {
  background: var(--tb-success);
}

.tb-status--connected .tb-status__text {
  color: var(--tb-success);
  font-weight: 500;
}

/* ── Quick actions (greyed) ── */

.tb-sidebar__placeholder {
  font-size: 12px;
  color: var(--tb-text-muted);
  font-style: italic;
}

/* ── Main chat area ── */

.tb-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--tb-bg);
}

.tb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Empty state ── */

.tb-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 40px;
}

.tb-empty-state__title {
  font-size: 32px;
  font-weight: 700;
  color: var(--tb-primary);
  letter-spacing: -0.5px;
}

.tb-empty-state__subtitle {
  font-size: 15px;
  color: var(--tb-text-muted);
  margin-bottom: 20px;
}

.tb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.tb-chip {
  padding: 7px 14px;
  background: var(--tb-white);
  border: 1px solid var(--tb-border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--tb-text);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.tb-chip:hover {
  background: var(--tb-primary-light);
  border-color: var(--tb-primary);
  color: var(--tb-primary-dark);
}

/* ── Message bubbles ── */

.tb-message {
  display: flex;
  max-width: 75%;
  animation: tb-fade-in 150ms ease;
}

@keyframes tb-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tb-message--user {
  align-self: flex-end;
}

.tb-message--ai {
  align-self: flex-start;
}

.tb-message__bubble {
  padding: 10px 14px;
  border-radius: var(--tb-radius);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--tb-shadow);
}

.tb-message--user .tb-message__bubble {
  background: var(--tb-primary);
  color: var(--tb-white);
  border-bottom-right-radius: 3px;
}

.tb-message--ai .tb-message__bubble {
  background: var(--tb-white);
  color: var(--tb-text);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--tb-border);
}

/* ── Tool status cards ── */

.tb-tool-card {
  align-self: stretch;
  padding: 10px 14px;
  border-radius: var(--tb-radius);
  border-left: 3px solid var(--tb-border);
  background: var(--tb-white);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--tb-shadow);
  animation: tb-fade-in 150ms ease;
}

.tb-tool-card--running {
  border-left-color: var(--tb-primary);
  color: var(--tb-text);
}

.tb-tool-card--done {
  border-left-color: var(--tb-success);
  color: var(--tb-success);
}

.tb-tool-card--error {
  border-left-color: var(--tb-error);
  color: var(--tb-error);
}

/* ── Typing indicator ── */

.tb-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--tb-white);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  border-bottom-left-radius: 3px;
  box-shadow: var(--tb-shadow);
}

.tb-typing.tb-hidden {
  display: none;
}

.tb-typing__dot {
  width: 7px;
  height: 7px;
  background: var(--tb-text-muted);
  border-radius: 50%;
  animation: tb-bounce 1.2s infinite ease-in-out;
}

.tb-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.tb-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes tb-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input bar ── */

.tb-input-bar {
  border-top: 1px solid var(--tb-border);
  background: var(--tb-white);
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.tb-input-bar__textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--tb-text);
  background: var(--tb-bg);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.tb-input-bar__textarea:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.tb-input-bar__textarea::placeholder {
  color: var(--tb-text-muted);
}

.tb-send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--tb-radius);
  background: var(--tb-primary);
  color: var(--tb-white);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms ease, transform 80ms ease;
  outline: none;
}

.tb-send-btn:hover {
  background: var(--tb-primary-dark);
}

.tb-send-btn:active {
  transform: scale(0.95);
}

.tb-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Scrollbar styling ── */

.tb-messages::-webkit-scrollbar,
.tb-sidebar::-webkit-scrollbar {
  width: 5px;
}

.tb-messages::-webkit-scrollbar-track,
.tb-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.tb-messages::-webkit-scrollbar-thumb,
.tb-sidebar::-webkit-scrollbar-thumb {
  background: var(--tb-border);
  border-radius: 3px;
}

.tb-messages::-webkit-scrollbar-thumb:hover {
  background: var(--tb-text-muted);
}
