:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --accent: #c9a87c;
  --accent-dim: rgba(201, 168, 124, 0.15);
  --accent-strong: #d4b48a;
  --success: #7dcea0;
  --danger: #e07a7a;
  --user-bubble: #2a3340;
  --bot-bubble: #1c2129;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #a88b5c);
  color: #1a140c;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  letter-spacing: -0.5px;
}

.brand-text h1 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: #3a4150;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.badge {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}

.total {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.item-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
}

.item-list li {
  padding: 10px 14px;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-list li:last-child {
  border-bottom: none;
}

.item-list .empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8rem;
  padding: 16px 14px;
}

.item-list .item-main {
  font-weight: 500;
}

.item-list .item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.item-list .amount {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Chat area */
.chat-area {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.message {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.message.bot {
  align-self: flex-start;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.45;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 5px;
  color: #f0f2f5;
}

.message.bot .bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.message .meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 6px;
}

.message.user .meta {
  text-align: right;
}

/* Input bar */
.input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

#userInput {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 16px;
  border-radius: 24px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

#userInput:focus {
  border-color: var(--accent);
}

#userInput::placeholder {
  color: #6b7280;
}

.mic-btn, .send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.mic-btn {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.mic-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.mic-btn.listening {
  background: var(--accent);
  color: #1a140c;
  border-color: var(--accent);
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 124, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(201, 168, 124, 0); }
}

.listening-pulse {
  display: none;
}

.send-btn {
  background: var(--accent);
  color: #1a140c;
}

.send-btn:hover {
  background: var(--accent-strong);
  transform: scale(1.04);
}

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

.hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0 16px 12px;
  background: var(--surface);
}

/* Welcome message special */
.welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.welcome h2 {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--text);
  font-weight: 400;
  margin-bottom: 8px;
}

.welcome p {
  font-size: 0.9rem;
  max-width: 360px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.example-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.example-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Mobile */
@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .sidebar {
    display: none; /* hide panels on small screens to keep chat primary */
    /* Could toggle later; for now chat-first */
  }

  .header {
    padding: 12px 14px;
  }

  .brand-text h1 {
    font-size: 1.1rem;
  }

  .messages {
    padding: 16px 12px;
  }

  .message {
    max-width: 92%;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #333842;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #454b57;
}
