:root {
  --accent: #0F6E56;
  --accent-dark: #0B5342;
  --accent-tint: #E1F5EE;
  --bg: #FFFFFF;
  --bg-soft: #F7F8F7;
  --text: #1A1D1B;
  --text-secondary: #5F6660;
  --border: #E4E7E4;
  --bubble-bot: #F1F3F1;
  --danger: #C0392B;
}

html[data-theme="dark"] {
  --bg: #141615;
  --bg-soft: #1C1F1D;
  --text: #EDEFEC;
  --text-secondary: #9BA39D;
  --border: #2B2F2C;
  --bubble-bot: #22261F;
  --accent-tint: #16332B;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-soft);
}

.icon-btn.upload-btn {
  background: var(--accent-tint);
  color: var(--accent);
}

.icon-btn.upload-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Chat area */
.chat-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg ul {
  margin: 6px 0;
  padding-left: 18px;
}

.msg li {
  margin: 2px 0;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.typing {
  display: flex;
  gap: 4px;
  align-items: center;
}

.msg.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: blink 1.2s infinite ease-in-out;
}

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

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Starter chips */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

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

/* Input bar */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.input-bar textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  max-height: 120px;
  background: var(--bg-soft);
  color: var(--text);
}

.input-bar textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.send-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

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

/* Floating CTA */
.cta-btn {
  position: absolute;
  right: 16px;
  bottom: 90px;
  border: none;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

/* Upload panel */
.upload-panel {
  position: absolute;
  top: 56px;
  right: 12px;
  left: 12px;
  z-index: 20;
  max-width: 420px;
  margin-left: auto;
}

.upload-panel.hidden { display: none; }

.upload-panel-inner {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upload-panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.upload-panel-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0 10px;
}

#pasteInput {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-soft);
  color: var(--text);
  resize: vertical;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.file-label {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}

.file-label input { display: none; }

.file-list {
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.context-status {
  font-size: 12px;
  color: var(--accent);
  margin: 8px 0 0;
  min-height: 14px;
}

/* Buttons */
.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
}

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

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
}

.full-width { width: 100%; margin-top: 6px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 360px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.modal h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal input,
.modal textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-soft);
  color: var(--text);
  resize: vertical;
}

.modal input:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}
