:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #171b1c;
  --muted: #5f696b;
  --line: #d8dfdd;
  --line-strong: #aebbb8;
  --teal: #0f6b67;
  --teal-2: #084c49;
  --blue: #235d83;
  --green: #477044;
  --gold: #9a6b16;
  --red: #9d3f37;
  --shadow: 0 16px 40px rgba(31, 46, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--teal-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
textarea,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(216, 223, 221, 0.9);
  background: rgba(246, 247, 244, 0.94);
  backdrop-filter: blur(14px);
}

.topbar__inner {
  width: min(1240px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 0.82rem;
}

.topbar__links {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.workbench,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workbench {
  overflow: hidden;
}

.question {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8faf8);
}

.question__label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.question textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
}

.question textarea:focus,
.context-grid input:focus,
.context-grid select:focus {
  outline: 3px solid rgba(15, 107, 103, 0.16);
  border-color: var(--teal);
}

.action-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ask-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  padding: 9px 13px;
  color: #fff;
  background: var(--teal);
  font-weight: 760;
  cursor: pointer;
}

.ask-button:hover {
  background: var(--teal-2);
}

.ask-button svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
}

.samples {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sample-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.86rem;
}

.sample-button:hover {
  border-color: var(--teal);
}

.sample-button--edge {
  background: #fff7e8;
  border-color: #e6cf9d;
}

.answer-zone {
  padding: 18px;
}

.answer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.answer-head span,
.meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.answer-text {
  min-height: 320px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  color: #111719;
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.trace {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.handback {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.handback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.handback p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.trace-list {
  display: grid;
  gap: 8px;
}

.trace-item {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  background: #e4f1ef;
  color: var(--teal-2);
  font-weight: 780;
  font-size: 0.84rem;
}

.trace-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.side {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 16px;
}

.context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.context-field {
  display: grid;
  gap: 5px;
}

.context-field label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.context-field input,
.context-field select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
}

.doc-list {
  display: grid;
  gap: 8px;
}

.gate-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.gate-list {
  display: grid;
  gap: 8px;
}

.gate-item {
  padding: 9px;
  border: 1px solid #e3d3b8;
  border-radius: 8px;
  background: #fff8eb;
}

.gate-item strong,
.gate-item span {
  display: block;
}

.gate-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.doc-item--gated {
  border-style: dashed;
  background: #faf7f0;
  opacity: 0.82;
}

.doc-item strong {
  display: block;
  font-size: 0.93rem;
}

.doc-item span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 780;
  background: #e7ecea;
  color: #344442;
}

.badge--employee {
  background: #e6eff8;
  color: var(--blue);
}

.badge--privileged {
  background: #f8ead4;
  color: var(--gold);
}

.badge--gated {
  background: #f4e0dc;
  color: var(--red);
}

.corpus-map {
  width: 100%;
  height: auto;
  margin: 4px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.map-label {
  font: 700 12px Inter, system-ui, sans-serif;
  fill: #253033;
}

.map-small {
  font: 500 10px Inter, system-ui, sans-serif;
  fill: #657174;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 700px) {
  .topbar__inner,
  .layout {
    width: min(100% - 20px, 1240px);
  }

  .topbar__inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }

  .side,
  .context-grid,
  .handback-grid {
    grid-template-columns: 1fr;
  }

  .trace-item {
    grid-template-columns: 1fr;
  }
}
