:root {
  color-scheme: light;
  --bg: #eef5f1;
  --surface: #fcfffd;
  --surface-strong: #ffffff;
  --ink: #17211d;
  --muted: #66746d;
  --line: #cad8d1;
  --field: #f5faf7;
  --field-focus: #ffffff;
  --green: #1f7a52;
  --green-strong: #115f3e;
  --red: #bd3b2f;
  --amber: #a96f12;
  --blue: #266d91;
  --gray: #69727b;
  --shadow: 0 24px 70px rgba(22, 44, 34, 0.15);
  --radius: 8px;
  font-family: Avenir Next, Aptos, Segoe UI, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(31, 122, 82, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 109, 145, 0.06) 1px, transparent 1px),
    linear-gradient(135deg, #eef5f1 0%, #f4f9ff 54%, #fff5ef 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

button,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1040px, 100%);
  height: min(860px, calc(100vh - 64px));
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(252, 255, 253, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(252, 255, 253, 0.95);
}

.topbar-copy {
  min-width: 0;
}

.model-strip {
  display: flex;
  flex: 1 1 260px;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-left: auto;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid rgba(23, 33, 29, 0.08);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
}

.model-label {
  color: var(--ink);
  font-weight: 800;
}

.model-value {
  min-width: 0;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(31, 122, 82, 0.28);
  border-radius: var(--radius);
  color: var(--green-strong);
  background: #e7f2e6;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  font-weight: 760;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding: 26px;
  scroll-behavior: smooth;
}

.message {
  display: grid;
  gap: 8px;
  max-width: 86%;
  animation: rise-in 240ms ease-out both;
}

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

.assistant-message {
  align-self: start;
}

.message-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

.message-body {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  line-height: 1.55;
  box-shadow: 0 10px 24px rgba(46, 40, 29, 0.08);
}

.user-message .message-body {
  border-color: rgba(38, 109, 145, 0.26);
  background: #e9f3f6;
  padding: 14px 16px;
  white-space: pre-wrap;
}

.assistant-message > .message-body {
  padding: 16px;
}

.result-body {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

/* The result itself is drawn by the shared renderer; this maps its palette hooks
   onto the web app's tokens. Structure lives in shared/result-view.css. */
.fx-result {
  --fx-bg: var(--surface-strong);
  --fx-surface: var(--surface);
  --fx-line: var(--line);
  --fx-ink: var(--ink);
  --fx-muted: var(--muted);
  --fx-dim: var(--muted);
  --fx-accent: var(--blue);
  --fx-radius: var(--radius);
  --fx-supported: var(--green);
  --fx-contradicted: var(--red);
  --fx-mixed: var(--amber);
  --fx-unverifiable: var(--gray);
}

.fx-result .fx-hero {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.plain-text {
  margin: 0;
  line-height: 1.62;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-item {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c8c0b1;
}

.status-item.active .status-dot {
  background: var(--blue);
  box-shadow: 0 0 0 7px rgba(38, 109, 145, 0.12);
}

.status-item.done .status-dot {
  background: var(--green);
}

.composer {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(252, 255, 253, 0.96);
}

textarea {
  width: 100%;
  min-height: 112px;
  max-height: 220px;
  resize: vertical;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--field);
  line-height: 1.5;
  outline: none;
}

textarea:focus {
  border-color: var(--blue);
  background: var(--field-focus);
  box-shadow: 0 0 0 4px rgba(38, 109, 145, 0.12);
}

.composer-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.composer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.char-count {
  color: var(--muted);
  font-size: 0.84rem;
}

.run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 132px;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  color: #fcfffd;
  background: var(--green-strong);
  cursor: pointer;
  font-weight: 800;
}

.run-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.run-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.search-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(38, 109, 145, 0.28);
  border-radius: var(--radius);
  color: var(--blue);
  background: #edf7fa;
  cursor: pointer;
  font-weight: 800;
}

.search-button:hover:not(:disabled) {
  border-color: var(--blue);
  background: #e2f1f5;
}

.search-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.saved-search-shell {
  display: grid;
  gap: 12px;
}

.saved-search-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.saved-search-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}

.saved-search-card:hover {
  border-color: var(--blue);
  background: #f5fbfd;
}

.saved-search-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}

.saved-search-topline strong {
  flex: 1 1 240px;
}

.saved-search-similarity {
  color: var(--green-strong);
  font-size: 0.8rem;
  font-weight: 800;
}

.saved-search-tldr {
  color: var(--muted);
  font-size: 0.9rem;
}

.error-box {
  border-color: rgba(189, 59, 47, 0.34);
  color: #5a1e18;
  background: #fff1ee;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 0;
  }

  .model-strip {
    flex-basis: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .model-value {
    max-width: 200px;
  }

  .workspace {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    padding: 14px 16px;
  }

  .topbar p {
    display: none;
  }

  .chat-window {
    gap: 14px;
    padding: 18px 14px;
  }

  .message {
    max-width: 96%;
  }

  .composer {
    padding: 12px;
  }

  .composer-actions {
    align-items: stretch;
  }

  .composer-buttons {
    flex: 1;
  }

  .search-button,
  .run-button {
    flex: 1;
    min-width: 116px;
  }
}
