:root {
  --bg: #f6f3ec;
  --paper: #fffdf8;
  --ink: #15130f;
  --ink-2: #302b20;
  --muted: #766f62;
  --muted-2: #a79d8c;
  --border: #d9cfbc;
  --grid: rgba(21, 19, 15, .045);
  --yellow: #ffd21f;
  --yellow-soft: #fff2a8;
  --blue: #2f60d7;
  --green: #1f8a5b;
  --red: #be4138;
  --shadow-soft: 0 8px 22px rgba(21, 19, 15, .08);
  --radius: 8px;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 1100px;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(1240px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.flow-header {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, .94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--yellow);
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 950;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 14px;
}

.subtitle {
  max-width: 760px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.nav-pill,
.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.nav-pill,
.button {
  padding: 0 12px;
}

.nav-pill.active,
.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--yellow);
}

.icon-button {
  width: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.artifact-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff9d9;
  box-shadow: var(--shadow-soft);
}

.artifact-status p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-current {
  background: #dff3e8;
  border-color: #94cdb1;
  color: #12563b;
}

.status-reference {
  background: #e5ecff;
  border-color: #b9c9f5;
  color: #244caa;
}

.status-candidate,
.status-open {
  background: #fff2a8;
  border-color: #d7aa00;
  color: #5b4700;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.doc-section,
.chat-sidebar,
.terminal-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, .95);
  box-shadow: var(--shadow-soft);
}

.doc-section {
  padding: 14px;
}

.panel-head,
.terminal-head,
.panel-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.agent-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.chat-sidebar {
  min-height: 680px;
  padding: 12px;
  overflow: hidden;
}

.chat-list {
  display: grid;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}

.chat-item {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 9px 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink-2);
  text-align: left;
}

.chat-item.active {
  border-color: var(--ink);
  background: var(--yellow-soft);
}

.chat-item strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item span {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 680px;
  padding: 12px;
}

.terminal-head {
  padding: 10px 12px;
  border: 1px solid #2d2a24;
  border-radius: 7px;
  background: #181713;
  color: #fff8d7;
}

.terminal-head .eyebrow {
  color: #bdb497;
}

.messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  max-height: 520px;
  margin: 0 0 12px;
  padding: 12px;
  overflow: auto;
  border: 1px solid #2d2a24;
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 210, 31, .04) 1px, transparent 1px),
    #181713;
  background-size: 100% 26px;
}

.message {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 253, 248, .12);
  border-radius: 7px;
  background: rgba(255, 253, 248, .055);
}

.message-role {
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.message-body {
  color: #fffdf8;
  font-size: 13px;
  line-height: 1.48;
  min-width: 0;
}

.message.user .message-body {
  white-space: pre-wrap;
}

.message.user .message-body {
  color: #fff2a8;
}

.markdown-body p {
  margin: 0 0 10px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin: 12px 0 7px;
  color: #fff8d7;
  font-size: 14px;
  line-height: 1.25;
}

.markdown-body h3:first-child,
.markdown-body h4:first-child,
.markdown-body h5:first-child {
  margin-top: 0;
}

.markdown-body ol,
.markdown-body ul {
  margin: 8px 0 12px;
  padding-left: 22px;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body strong {
  color: #fff8d7;
}

.markdown-body code {
  padding: 1px 4px;
  border: 1px solid rgba(255, 253, 248, .14);
  border-radius: 4px;
  background: rgba(255, 253, 248, .08);
  color: var(--yellow);
  font-family: var(--mono);
  font-size: .92em;
}

.markdown-body pre {
  max-width: 100%;
  margin: 10px 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid rgba(255, 253, 248, .14);
  border-radius: 7px;
  background: rgba(0, 0, 0, .24);
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre;
}

.markdown-body a {
  color: var(--yellow-soft);
  text-decoration: underline;
}

.message-sources {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-chip {
  display: inline-flex;
  max-width: 220px;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 253, 248, .18);
  border-radius: 999px;
  color: #d6cfbd;
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-actions {
  grid-column: 2;
  display: flex;
  gap: 6px;
  align-items: center;
}

.feedback-button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(255, 253, 248, .2);
  border-radius: 999px;
  background: rgba(255, 253, 248, .06);
  color: #d6cfbd;
  font-size: 11px;
  font-weight: 850;
}

.feedback-button:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}

.feedback-form {
  grid-column: 2;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 253, 248, .16);
  border-radius: 7px;
  background: rgba(255, 253, 248, .06);
}

.feedback-form label {
  color: #d6cfbd;
}

.feedback-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

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

.voice-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
}

textarea {
  min-height: 40px;
  padding: 9px 10px;
  resize: vertical;
}

input,
select {
  min-height: 34px;
  padding: 0 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.scenarios-grid,
.docs-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.scenarios-grid {
  grid-template-columns: minmax(0, 1.28fr) minmax(360px, .72fr);
}

.docs-grid {
  grid-template-columns: 360px minmax(0, 1fr);
}

.filters.compact {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 90px 130px;
  gap: 8px;
  margin-bottom: 10px;
}

.table-wrap {
  max-height: 660px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 12px;
}

.doc-table th,
.doc-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  line-height: 1.35;
}

.doc-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1eadc;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.dense-table tbody tr {
  cursor: pointer;
}

.dense-table tbody tr:hover,
.dense-table tbody tr.active {
  background: #fff9d9;
}

.scenario-title {
  display: block;
  max-width: 360px;
  color: var(--ink);
  font-weight: 850;
}

.scenario-sub {
  display: block;
  max-width: 360px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-editor {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 126px);
  overflow: auto;
}

.scenario-form,
.comment-form {
  display: grid;
  gap: 9px;
}

.form-grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.comments-panel {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.comments-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.comment {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff9d9;
}

.comment strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.comment p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.42;
  white-space: pre-wrap;
}

.comment time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.docs-list-panel {
  position: sticky;
  top: 104px;
}

.docs-list {
  display: grid;
  gap: 7px;
  max-height: 650px;
  margin-top: 10px;
  overflow: auto;
}

.doc-item {
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--paper);
  text-align: left;
}

.doc-item.active {
  border-color: var(--ink);
  background: var(--yellow-soft);
}

.doc-item strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
}

.doc-item span {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-content {
  max-height: 690px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #2d2a24;
  border-radius: 7px;
  background: #181713;
  color: #fffdf8;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.48;
  white-space: pre-wrap;
}

.corrections-panel {
  max-width: 980px;
  margin: 0 auto;
}

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

.correction-card,
.empty-state {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.correction-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.correction-head {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.correction-block {
  padding: 9px 10px;
  border: 1px solid rgba(217, 207, 188, .82);
  border-radius: 7px;
  background: rgba(246, 243, 236, .72);
}

.correction-block.client {
  background: #fff9d9;
}

.correction-block strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.correction-block p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.42;
  white-space: pre-wrap;
}

.correction-analysis {
  padding: 10px;
  border: 1px solid rgba(47, 96, 215, .18);
  border-radius: 7px;
  background: #f4f6ff;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}

.correction-analysis.markdown-body h3,
.correction-analysis.markdown-body h4,
.correction-analysis.markdown-body h5,
.correction-analysis.markdown-body strong {
  color: var(--ink);
}

.correction-analysis.markdown-body code {
  color: #244caa;
  background: rgba(47, 96, 215, .08);
  border-color: rgba(47, 96, 215, .18);
}

.login-body {
  min-width: 320px;
}

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

.login-card {
  width: min(460px, 100%);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, .96);
  box-shadow: var(--shadow-soft);
}

.login-copy {
  margin: 16px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 10px;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

[hidden] {
  display: none !important;
}
