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

body {
  font-family: "Source Sans 3", sans-serif;
  background: #f0f4f3;
  color: #1b1b1b;
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #0f3d3a;
  color: #fff;
}

.logo {
  font-size: 1.2em;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.api-key-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-key-label {
  font-size: 0.8em;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.api-key-header input {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.85em;
  font-family: inherit;
  width: 220px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.api-key-header input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.api-key-header input:focus {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85em;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Main Layout ── */
.main-layout {
  display: flex;
  height: calc(100vh - 52px);
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #e0e6e5;
  padding: 20px 0;
  overflow-y: auto;
}

.modality-group {
  margin-bottom: 8px;
}

.modality-title {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0f3d3a;
  padding: 12px 20px 6px;
}

.component-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 20px 10px 28px;
  background: none;
  border: none;
  font-size: 0.92em;
  font-family: inherit;
  color: #444;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.component-btn:hover {
  background: #f0f4f3;
  color: #0f3d3a;
}

.component-btn.active {
  background: #e8f0ef;
  color: #0f3d3a;
  font-weight: 600;
  border-left-color: #0f3d3a;
}

/* ── Chat Area ── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 20px 32px;
  border-bottom: 1px solid #e0e6e5;
  background: #fff;
}

.chat-modality-label {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0f3d3a;
  background: #e8f0ef;
  padding: 3px 10px;
  border-radius: 4px;
}

.chat-header h2 {
  font-size: 1.3em;
  font-weight: 600;
  margin-top: 6px;
  color: #1b1b1b;
}

.component-desc {
  font-size: 0.88em;
  color: #777;
  margin-top: 4px;
}

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-message {
  margin: auto;
  text-align: center;
  color: #999;
  font-size: 0.95em;
  max-width: 560px;
  padding: 40px 0;
}

.examples-section {
  margin-top: 28px;
}

.examples-label {
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0f3d3a;
  margin-bottom: 14px;
}

.examples-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.example-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid #d8e3e1;
  border-radius: 12px;
  font-size: 0.88em;
  font-family: inherit;
  color: #444;
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.2s;
}

.example-card:hover {
  border-color: #0f3d3a;
  background: #f4f9f8;
  color: #0f3d3a;
  box-shadow: 0 2px 8px rgba(15, 61, 58, 0.08);
}

.message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 0.95em;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: #0f3d3a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
  color: #1b1b1b;
  border: 1px solid #e0e6e5;
  border-bottom-left-radius: 4px;
}

.message.error {
  align-self: center;
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  font-size: 0.88em;
}

.typing-indicator {
  align-self: flex-start;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid #e0e6e5;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #aaa;
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ── Input Area ── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 32px 20px;
  background: #fff;
  border-top: 1px solid #e0e6e5;
}

#user-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #d8e3e1;
  border-radius: 12px;
  font-size: 0.95em;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 150px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

#user-input:focus {
  border-color: #0f3d3a;
}

#send-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: #0f3d3a;
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

#send-btn:hover {
  background: #1a5c58;
}

#send-btn:disabled {
  background: #b0c4c2;
  cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 16px 16px;
  }

  .chat-header {
    padding: 16px;
  }

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