:root {
  --ink: #17212a;
  --ink-muted: #53616d;
  --paper: #f4f7fa;
  --surface: #ffffff;
  --line: #c8d3dc;
  --line-strong: #8495a4;
  --primary: #164b79;
  --primary-deep: #0d3659;
  --accent: #b45309;
  --safe: #116149;
  --danger: #a62929;
  --focus: #e36b31;
  --shadow: 0 10px 30px rgba(20, 52, 77, 0.08);
  --radius-sm: 6px;
  --radius-md: 8px;
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.6;
}

button {
  min-height: 44px;
  font: inherit;
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  color: var(--surface);
  background: var(--primary-deep);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 22px clamp(18px, 4vw, 56px);
  color: var(--surface);
  background: var(--primary-deep);
  border-bottom: 5px solid var(--focus);
}

.topbar h1 {
  margin: 0;
  font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  font-stretch: condensed;
  letter-spacing: -0.025em;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 20px;
  font-size: 0.84rem;
}

.trust-strip span {
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  padding-left: 12px;
}

.intake-panel {
  width: min(1600px, calc(100% - 32px));
  margin: 20px auto 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.intake-panel .section-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 18px;
  align-items: baseline;
}

.intake-panel .section-heading .eyebrow {
  grid-row: 1 / 3;
}

.intake-panel .section-heading p:last-child {
  margin: 4px 0 0;
  color: var(--ink-muted);
}

.intake-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.6fr) minmax(220px, 0.8fr) minmax(240px, 0.9fr) minmax(220px, 0.7fr);
  gap: 14px;
  padding-top: 16px;
}

.intake-field {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
}

.intake-field > span {
  font-weight: 750;
}

.intake-field textarea,
.intake-field input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
}

.intake-field textarea {
  resize: vertical;
}

.intake-field small,
.intake-action p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.intake-action {
  display: grid;
  align-content: start;
  gap: 9px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(420px, 2fr) minmax(250px, 0.85fr);
  gap: 16px;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 40px) 32px;
}

.queue-panel,
.case-panel,
.inspector-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.queue-panel,
.inspector-panel {
  padding: 18px;
}

.case-panel {
  overflow: hidden;
}

.section-heading {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.section-heading h2,
.case-header h2 {
  margin: 0;
  font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
  font-size: 1.45rem;
}

.scenario-list {
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.scenario-button {
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.scenario-button:hover {
  background: var(--paper);
}

.scenario-button.is-selected {
  color: var(--primary-deep);
  background: #e8f0f7;
  border-color: #8eacc5;
  box-shadow: inset 4px 0 0 var(--primary);
}

.scenario-index {
  display: block;
  color: var(--ink-muted);
  font-family: Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.scenario-name {
  display: block;
  margin-top: 2px;
  font-weight: 700;
}

.case-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  min-height: 154px;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(22, 75, 121, 0.06) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--surface);
  border-bottom: 1px solid var(--line);
}

.lede {
  max-width: 66ch;
  margin: 8px 0 0;
  color: var(--ink-muted);
}

.primary-action {
  flex: 0 0 auto;
  padding: 10px 18px;
  color: var(--surface);
  background: var(--primary);
  border: 1px solid var(--primary-deep);
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 180ms ease-out;
}

.primary-action:hover {
  background: var(--primary-deep);
}

.primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.case-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #eef3f7;
}

.tab {
  min-width: max-content;
  padding: 10px 16px;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

.tab.is-active {
  color: var(--primary-deep);
  background: var(--surface);
  border-bottom-color: var(--focus);
  font-weight: 700;
}

.result-region {
  min-height: 520px;
  padding: 24px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  color: var(--ink-muted);
  text-align: center;
}

.empty-rule {
  width: 2px;
  height: 120px;
  background: linear-gradient(var(--primary), var(--focus));
}

.spine {
  position: relative;
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0 0 0 34px;
  list-style: none;
}

.spine::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  width: 2px;
  background: var(--line-strong);
}

.spine-event {
  position: relative;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.spine-event::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -30px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border: 3px solid var(--primary);
  border-radius: 50%;
  transition: opacity 180ms ease-out;
}

.spine-event strong {
  display: block;
}

.spine-event small {
  display: block;
  color: var(--ink-muted);
  font-family: Consolas, monospace;
}

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

.fact-card,
.action-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.agnes-enrichment {
  border-color: #8eacc5;
  background: #f2f7fb;
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  padding: 12px 18px;
  color: #fff;
  font-weight: 800;
  background: var(--primary-deep);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.small-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.fact-card dt {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.fact-card dd {
  margin: 4px 0 0;
  font-family: Consolas, monospace;
  font-weight: 700;
}

.safety-list {
  margin: 0;
}

.safety-list > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.safety-list dt {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.safety-list dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status.safe {
  color: var(--safe);
}

.status.blocked {
  color: var(--danger);
}

.live-inspector {
  margin-top: 18px;
  padding: 14px;
  background: var(--paper);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
}

.metric-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.metric-list dt {
  color: var(--ink-muted);
}

.metric-list dd {
  margin: 0;
  font-family: Consolas, monospace;
  font-weight: 700;
}

.approval-binding {
  display: grid;
  grid-template-columns: minmax(120px, 0.5fr) minmax(0, 1.5fr);
  gap: 6px 14px;
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.approval-binding dt {
  color: var(--ink-muted);
}

.approval-binding dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: Consolas, monospace;
}

.forbidden-notice {
  padding: 18px;
  color: #681919;
  background: #fff2f2;
  border: 2px solid #d88787;
  border-radius: var(--radius-sm);
}

.handoff-report {
  display: grid;
  gap: 12px;
}

.handoff-report section {
  padding: 14px;
  border-left: 3px solid var(--primary);
  background: var(--paper);
}

.handoff-report h3,
.diagnosis-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.handoff-report p,
.diagnosis-section p {
  margin: 0;
}

.inquiry-copy {
  margin-bottom: 22px !important;
  padding: 16px;
  background: var(--paper);
  border-left: 4px solid var(--focus);
  font-size: 1.05rem;
}

.error-box {
  padding: 18px;
  color: #681919;
  background: #fff2f2;
  border: 1px solid #d88787;
}

footer {
  padding: 10px 24px 28px;
  color: var(--ink-muted);
  text-align: center;
  font-size: 0.82rem;
}

@media (max-width: 1100px) {
  .intake-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: minmax(210px, 0.75fr) minmax(0, 2fr);
  }

  .inspector-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .topbar,
  .case-header {
    align-items: stretch;
    flex-direction: column;
  }

  .trust-strip {
    justify-content: flex-start;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    padding-inline: 12px;
  }

  .intake-panel {
    width: calc(100% - 24px);
    padding: 16px;
  }

  .intake-panel .section-heading,
  .intake-grid {
    grid-template-columns: 1fr;
  }

  .intake-panel .section-heading .eyebrow {
    grid-row: auto;
  }

  .queue-panel {
    order: 1;
  }

  .case-panel {
    order: 2;
  }

  .inspector-panel {
    order: 3;
  }

  .scenario-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .case-header {
    min-height: auto;
  }

  .fact-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .scenario-list {
    grid-template-columns: 1fr;
  }

  .result-region,
  .case-header {
    padding: 18px;
  }

  .approval-binding {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
