:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #1b2330;
  --muted: #667085;
  --line: #d8dde7;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #c2410c;
  --amber: #b7791f;
  --soft-teal: #e7f5f2;
  --soft-coral: #fff0e8;
  --shadow: 0 18px 45px rgba(25, 35, 52, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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 rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.10), transparent 36%),
    linear-gradient(315deg, rgba(194, 65, 12, 0.10), transparent 34%),
    var(--bg);
}

.gate-panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

.gate-panel h1,
.topbar h1,
.tool-heading h2,
.reasoning-head h2 {
  margin-bottom: 0;
}

.gate-copy {
  color: var(--muted);
  line-height: 1.5;
}

.passcode-form label,
.input-label,
.control-label {
  display: block;
  font-weight: 700;
  color: var(--ink);
}

.passcode-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 8px;
}

.passcode-row input,
.tool-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.passcode-row input {
  min-height: 44px;
  padding: 0 12px;
}

.passcode-row button,
#runButton,
.secondary-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.secondary-button {
  background: #263344;
}

.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-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(--soft-teal);
  color: var(--teal-dark);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.is-warning {
  background: var(--soft-coral);
  color: var(--coral);
}

.disclaimer {
  max-width: 1500px;
  margin: 0 auto 12px;
  padding: 10px 12px;
  border: 1px solid #f0d6bc;
  border-radius: 8px;
  background: #fff9f2;
  color: #68420d;
  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(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.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(--ink);
  text-align: left;
  border: 1px solid transparent;
}

.tool-tab span {
  display: block;
  font-weight: 800;
}

.tool-tab small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.tool-tab.is-active {
  background: var(--soft-teal);
  border-color: rgba(15, 118, 110, 0.30);
}

.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-form {
  display: grid;
  gap: 12px;
}

.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 34px;
}

.control-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.tool-form textarea {
  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(--muted);
}

.results {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.empty-state,
.result-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

.empty-state p,
.result-section p,
.result-section li {
  color: var(--muted);
  line-height: 1.55;
}

.answer {
  color: var(--ink) !important;
  font-size: 1.03rem;
}

.result-section h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.source-list {
  display: grid;
  gap: 10px;
}

.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.source-card h4,
.detail-block h4 {
  margin-bottom: 5px;
}

.source-meta {
  color: var(--teal-dark) !important;
  font-size: 0.84rem;
  font-weight: 700;
}

.detail-block {
  margin-top: 12px;
}

.timeline-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
}

.timeline-list li {
  padding-left: 4px;
}

.timeline-list span {
  display: block;
  color: var(--teal-dark);
  font-weight: 700;
}

.timeline-list small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.redacted-output {
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  line-height: 1.55;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 0;
  list-style: none;
}

.pill-list li {
  border-radius: 999px;
  background: var(--soft-teal);
  color: var(--teal-dark);
  padding: 6px 10px;
}

.result-disclaimer {
  margin: 0;
  color: #68420d;
}

.muted {
  color: var(--muted);
}

.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;
}

.trace-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.trace-status {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--teal);
}

.trace-status.running {
  background: var(--amber);
}

.trace-status.warning {
  background: var(--coral);
}

.trace-status.waiting {
  background: #98a2b3;
}

@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) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .tool-rail {
    flex-direction: row;
    overflow-x: auto;
  }

  .tool-tab {
    min-width: 150px;
  }

  .tool-panel,
  .reasoning-panel {
    min-height: auto;
  }

  .passcode-row {
    grid-template-columns: 1fr;
  }
}
