* {
  box-sizing: border-box;
}

/* UOAA / ostomy.org palette (Enfold theme) */
:root {
  --bg: #f0f0f0;
  --panel: #ffffff;
  --border: #e1e1e1;
  --text: #444444;
  --muted: #666666;
  --meta: #919191;
  --brand: #00539c;
  --brand-hover: #00317a;
  --brand-mid: #2275be;
  --brand-accent: #0e90d2;
  --brand-soft: #e7f4ff;
  --brand-border-soft: #bdd6ec;
  --assistant: #eeeeee;
  --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
}

.app {
  width: min(980px, calc(100vw - 32px));
  margin: 16px auto;
  height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

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

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-logo {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: 0.1px;
}

.header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #2d6b2f;
  background: #eef6ee;
  border: 1px solid #c5dcc6;
  padding: 6px 10px;
  border-radius: 3px;
  white-space: nowrap;
}

.pill.api {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: var(--brand-border-soft);
}

.chat {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 3px;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: min(84%, 760px);
  padding: 11px 13px;
  border-radius: 3px;
  line-height: 1.45;
  white-space: pre-wrap;
  border: 1px solid transparent;
  font-size: 15px;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--brand-mid), var(--brand));
  color: #fff;
  border-color: var(--brand-hover);
  box-shadow: 0 2px 8px rgba(0, 83, 156, 0.22);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--assistant);
  border-color: var(--border);
  color: var(--text);
}

.msg.assistant p {
  margin: 0 0 8px;
}

.msg.assistant strong {
  font-weight: 700;
}

.msg.assistant p:last-child {
  margin-bottom: 0;
}

.assistant-list {
  margin: 0;
  padding-left: 18px;
}

.assistant-list li {
  margin: 0 0 6px;
}

.assistant-list li:last-child {
  margin-bottom: 0;
}

.cite {
  color: var(--brand);
  font-weight: 600;
}

.msg.typing {
  color: var(--muted);
  font-style: italic;
}

.meta {
  font-size: 12px;
  color: var(--meta);
  padding-left: 4px;
  max-width: min(84%, 760px);
}

.sources {
  align-self: flex-start;
  max-width: min(84%, 760px);
  width: 100%;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border-soft);
  border-radius: 3px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sources-title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--brand);
}

.source-item {
  border: 1px solid var(--brand-border-soft);
  background: var(--panel);
  border-radius: 3px;
  padding: 8px 10px;
}

.source-top {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-hover);
  line-height: 1.35;
}

.source-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.composer {
  display: flex;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--panel);
  padding: 8px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  min-height: 40px;
  max-height: 160px;
  padding: 8px;
  font: inherit;
  color: var(--text);
}

button {
  border: 0;
  border-radius: 3px;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover:enabled {
  background: var(--brand-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-secondary {
  background: var(--panel);
  color: var(--brand);
  border: 1px solid var(--brand-border-soft);
  padding: 8px 12px;
  font-size: 13px;
}

.btn-secondary:hover:enabled {
  background: var(--brand-soft);
  border-color: var(--brand);
}

@media (max-width: 700px) {
  .app {
    width: calc(100vw - 12px);
    margin: 6px auto;
    height: calc(100vh - 12px);
    padding: 12px;
  }

  .header-logo {
    width: 40px;
    height: 40px;
  }

  .header h1 {
    font-size: 20px;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .pill {
    font-size: 11px;
    padding: 5px 8px;
  }

  .btn-secondary {
    font-size: 12px;
    padding: 7px 10px;
  }
}
