@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg-cream: #f5f0e8;
  --bg-peach: #ffe6d6;
  --bg-mint: #d7f6ef;
  --ink: #1d1b16;
  --ink-soft: #564f44;
  --accent: #ff6b35;
  --accent-2: #2b7a78;
  --card: #ffffff;
  --border: rgba(29, 27, 22, 0.12);
  --shadow: 0 20px 60px rgba(28, 22, 14, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Space Grotesk', sans-serif;
  background: radial-gradient(circle at top left, var(--bg-peach), transparent 55%),
              radial-gradient(circle at bottom right, var(--bg-mint), transparent 55%),
              var(--bg-cream);
  color: var(--ink);
  min-height: 100vh;
}

.bg-orbit {
  position: fixed;
  inset: -20% 10% auto;
  height: 380px;
  background: radial-gradient(circle, rgba(255,107,53,0.25), transparent 60%);
  filter: blur(20px);
  z-index: 0;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.6;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  padding: 32px 6vw 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-family: 'Fraunces', serif;
  font-size: 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #ff905f);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.brand-title {
  font-family: 'Fraunces', serif;
  font-size: 24px;
}

.brand-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
}

.auth-status {
  display: flex;
  gap: 12px;
  align-items: center;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.8fr);
  gap: 24px;
}

/* Compact/collapsed sidebar styles (Command Center compact mode) */
.app.collapsed .layout {
  grid-template-columns: 1fr 88px;
}
.app.collapsed .sidebar {
  width: 88px;
}
.app.collapsed .card {
  padding: 10px;
}
.app.collapsed .card h3 {
  font-size: 13px;
}
.app.collapsed .mini-list,
.app.collapsed .card p,
.app.collapsed .intent-card,
.app.collapsed .status-grid,
.app.collapsed .mode-chip-group {
  display: none;
}
.app.collapsed .panel-header h2 { font-size: 16px; }

.chat,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
}

.subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-soft);
}

.mode-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mode-chip {
  background: #f3efe8;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.mode-chip.active,
.mode-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.08);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #faf8f5);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.status-label {
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-card strong {
  font-size: 14px;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.chat-log {
  background: #faf8f5;
  border-radius: 18px;
  padding: 14px;
  height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  padding: 12px 14px;
  border-radius: 16px;
  max-width: 85%;
  line-height: 1.4;
  font-size: 14px;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.bubble.bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--border);
}

.chat-form {
  margin-top: 16px;
  display: flex;
  gap: 12px;
}

.composer-tools {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-tray {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-tray.hidden {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(28, 22, 14, 0.06);
}

.attachment-thumb {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bg-peach), var(--bg-mint));
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  flex: 0 0 auto;
}

.attachment-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.attachment-meta strong {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.attachment-meta span {
  font-size: 12px;
  color: var(--ink-soft);
}

.attachment-remove {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #f3efe8;
  color: var(--ink-soft);
  padding: 0;
}

.attachment-remove:hover {
  background: #ffe2d4;
  color: var(--ink);
}

.tool-btn {
  font-size: 13px;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f3efe8;
  color: var(--ink-soft);
  font-size: 13px;
  border: 1px solid transparent;
}

.toggle-pill.active {
  color: var(--ink);
  border-color: var(--border);
}

.chat-form input,
.search-row input,
#lang-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
}

.search-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.results {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.result-item {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #faf8f5;
}

.result-item a {
  color: var(--accent-2);
  font-weight: 600;
  text-decoration: none;
}

button {
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #fff;
}

button.ghost {
  background: #f3efe8;
  color: var(--ink);
}

.card h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  margin-bottom: 8px;
}

.card p {
  font-size: 14px;
  color: var(--ink-soft);
}

.mini {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.5);
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal.hidden { display: none; }

.modal-card {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  font-family: 'Fraunces', serif;
  margin-bottom: 8px;
}

.stack {
  display: grid;
  gap: 12px;
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: #faf8f5;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.source-pill:hover {
  background: var(--bg-mint);
  border-color: var(--accent-2);
  color: var(--ink);
  transform: translateY(-2px);
}

.source-pill img {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  margin-top: 0;
}

.sidebar {
  display: grid;
  gap: 16px;
}

.mini-list {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.mini-list strong {
  color: var(--ink);
}

.message-meta {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-action {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f3efe8;
  color: var(--ink);
}

.message-action:hover {
  background: var(--bg-mint);
}

.message-action.danger {
  color: #9f1d1d;
  background: #fff0ea;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #faf8f5;
  padding: 9px 10px;
  color: var(--ink);
}

.history-item.active,
.history-item:hover {
  background: var(--bg-mint);
}

.history-item strong {
  font-size: 12px;
}

.history-item span {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.35;
}

.intent-card {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: #faf8f5;
  font-size: 13px;
  color: var(--ink-soft);
}

.sidebar .card {
  padding: 18px;
}

.sidebar .mini-list {
  font-size: 12px;
}

.intent-card strong {
  color: var(--ink);
}

.api-badge {
  display: inline-block;
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 12px;
  margin-right: 6px;
}
.api-badge.selected {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

.error {
  margin-top: 8px;
  color: #d11f1f;
  font-size: 13px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mode-chip-group {
    justify-content: flex-start;
  }
  .chat-log {
    height: 40vh;
  }
  .attachment-meta strong {
    max-width: 140px;
  }
}
