/* Tools workspace — local styles only what the UI kit needs.
   Tokens come from /colors_and_type.css; this file translates them into the
   class names the production CSS uses, so the markup matches the live site. */

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--dbn-bg);
  color: var(--dbn-ink);
  font-family: var(--dbn-font-sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: progress; opacity: 0.7; }
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--dbn-teal-ring);
  outline-offset: 2px;
}

/* eyebrow / shared */
.eyebrow {
  margin: 0 0 6px;
  color: var(--dbn-teal);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}
h1, h2, h3, h4, p { margin-top: 0; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.app-shell { min-height: 100vh; padding: 18px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  max-width: 1500px; margin: 0 auto 12px; padding: 10px 2px;
}
.topbar h1 { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--dbn-ink); line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill, .tool-badge {
  display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px;
  border-radius: 999px; background: var(--dbn-teal-soft); color: var(--dbn-teal-dark);
  font-size: 0.84rem; font-weight: 700; white-space: nowrap;
}
.status-pill.is-warning { background: var(--dbn-coral-soft); color: var(--dbn-coral); }
.secondary-button {
  min-height: 44px; border-radius: 8px; padding: 0 18px;
  background: #263344; color: #fff; font-weight: 700;
}

.disclaimer {
  max-width: 1500px; margin: 0 auto 12px; padding: 10px 12px;
  border: 1px solid var(--dbn-amber-edge); border-radius: 8px;
  background: var(--dbn-amber-soft); color: var(--dbn-amber-ink); font-size: 0.92rem;
}

.workspace {
  max-width: 1500px; margin: 0 auto;
  display: grid; grid-template-columns: 190px minmax(0, 1fr) 370px;
  gap: 14px; align-items: stretch;
}

.tool-rail, .tool-panel, .reasoning-panel {
  background: var(--dbn-panel); border: 1px solid var(--dbn-line); border-radius: 8px;
}

/* ── Tool rail ─────────────────────────────────────────────────────────── */
.tool-rail { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tool-tab {
  width: 100%; min-height: 68px; border-radius: 8px; padding: 11px;
  background: transparent; color: var(--dbn-ink); text-align: left;
  border: 1px solid transparent; cursor: pointer;
}
.tool-tab span { display: block; font-weight: 800; }
.tool-tab small { display: block; margin-top: 4px; color: var(--dbn-muted); }
.tool-tab.is-active { background: var(--dbn-teal-soft); border-color: rgba(0, 32, 91,0.30); }
.tool-tab:hover:not(.is-active) { background: var(--dbn-panel-tinted); }

/* ── Tool panel ─────────────────────────────────────────────────────────── */
.tool-panel { min-height: 720px; padding: 18px; }
.tool-heading, .reasoning-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.tool-heading h2, .reasoning-head h2 { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--dbn-ink); }

.tool-form { display: grid; gap: 12px; }
.control-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 34px;
}
.control-row .control-label,
.control-row label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--dbn-muted); font-weight: 700; font-size: 0.92rem;
}
.control-label { color: var(--dbn-ink) !important; }

.tool-form textarea {
  width: 100%; border: 1px solid var(--dbn-line); border-radius: 8px;
  background: #fff; color: var(--dbn-ink);
  resize: vertical; min-height: 220px; padding: 14px; line-height: 1.55;
}
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-status { min-height: 22px; margin: 0; color: var(--dbn-muted); font-size: 0.88rem; }

#runButton {
  min-height: 44px; border-radius: 8px; padding: 0 18px;
  background: var(--dbn-teal); color: #fff; font-weight: 700;
}

/* ── Results / sources ─────────────────────────────────────────────────── */
.results { margin-top: 18px; display: grid; gap: 12px; }
.empty-state, .result-section {
  border: 1px solid var(--dbn-line); border-radius: 8px; padding: 16px; background: var(--dbn-panel-tinted);
}
.empty-state h3, .result-section h3 { margin: 0 0 8px; font-size: 0.98rem; color: var(--dbn-ink); }
.empty-state p, .result-section p, .result-section li { color: var(--dbn-muted); line-height: 1.55; margin: 0; }
.answer { color: var(--dbn-ink) !important; font-size: 1.03rem; line-height: 1.65; }
.answer p { margin: 0 0 12px; }

.source-list { display: grid; gap: 10px; }
.source-card {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: start;
  border: 1px solid var(--dbn-line); border-radius: 8px; padding: 12px;
  background: var(--dbn-panel-tinted); cursor: pointer; text-align: left; width: 100%;
}
.source-card:hover { border-color: rgba(0, 32, 91,0.40); }
.source-card.is-highlight { border-color: var(--dbn-coral); background: var(--dbn-coral-soft); }
.source-number {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--dbn-coral-soft); color: var(--dbn-coral);
  font-weight: 900; font-variant-numeric: tabular-nums;
}
.source-title { font-weight: 800; color: var(--dbn-ink); line-height: 1.35; }
.source-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.source-tag {
  background: var(--dbn-teal-soft); color: var(--dbn-teal-dark);
  border-radius: 999px; font-size: 0.7rem; font-weight: 800; padding: 3px 8px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.source-tag--score { background: #eef3fb; color: var(--dbn-ink-soft); }
.source-excerpt { color: var(--dbn-muted); margin-top: 8px; line-height: 1.5; font-size: 0.92rem; }
.source-aside {
  align-self: stretch; display: grid; grid-template-rows: auto auto; gap: 6px;
  font-size: 0.78rem; color: var(--dbn-muted); text-align: right; min-width: 90px;
}
.source-aside b { color: var(--dbn-ink); font-variant-numeric: tabular-nums; font-size: 0.92rem; }

.cite-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; margin: 0 1px; padding: 0 5px;
  border-radius: 999px; background: var(--dbn-coral-soft); color: var(--dbn-coral);
  font-size: 0.72rem; font-weight: 800; font-variant-numeric: tabular-nums;
  cursor: pointer; border: 1px solid rgba(186, 12, 47,0.25); vertical-align: 1px;
}
.cite-chip:hover { background: var(--dbn-coral); color: #fff; }

/* ── Reasoning panel ───────────────────────────────────────────────────── */
.reasoning-panel { min-height: 720px; padding: 16px; }
.trace-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.trace-list li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; }
.trace-list strong { display: block; margin-bottom: 3px; color: var(--dbn-ink); }
.trace-list p { margin: 0; color: var(--dbn-muted); line-height: 1.45; font-size: 0.88rem; }
.trace-status { width: 10px; height: 10px; margin-top: 5px; border-radius: 999px; background: var(--dbn-teal); }
.trace-status.running { background: var(--dbn-amber); animation: trace-pulse 1.4s ease-in-out infinite; }
.trace-status.warning { background: var(--dbn-coral); }
.trace-status.waiting { background: var(--dbn-muted-2); }
@keyframes trace-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ── Upload zone ───────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--dbn-line); border-radius: 8px; padding: 18px 14px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--dbn-teal); background: #f7fdfb; }
.upload-icon { display: block; font-size: 1.8rem; line-height: 1; color: var(--dbn-teal); opacity: 0.55; margin-bottom: 6px; }
.upload-prompt p { margin: 4px 0 0; color: var(--dbn-muted); font-size: 0.88rem; }
.upload-browse { color: var(--dbn-teal); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.upload-hint { font-size: 0.76rem !important; opacity: 0.7; }

/* ── Lang switcher / pills ─────────────────────────────────────────────── */
.lang-switcher { display: flex; align-items: center; gap: 6px; }
.lang-btn {
  background: var(--dbn-bg); border: 1px solid var(--dbn-line); border-radius: 999px;
  color: var(--dbn-muted); cursor: pointer; font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.03em; padding: 4px 10px; transition: all .15s;
}
.lang-btn.is-active { background: var(--dbn-teal); border-color: var(--dbn-teal); color: #fff; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 170px minmax(0,1fr); }
  .reasoning-panel { grid-column: 1 / -1; min-height: auto; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .tool-rail { flex-direction: row; overflow-x: auto; }
  .tool-tab { min-width: 150px; }
}
