:root {
  color-scheme: light;
  --paper: #f2f6f4;
  --sheet: #fcfefd;
  --ink: #102c36;
  --ink-soft: #49636a;
  --line: #c7d5d2;
  --line-strong: #8da6a1;
  --teal: #08766a;
  --teal-dark: #04564e;
  --teal-wash: #e4f1ee;
  --coral: #e9543f;
  --coral-dark: #873125;
  --coral-wash: #fff0ec;
  --white: #ffffff;
  --shadow: 0 18px 42px rgba(16, 44, 54, 0.11);
  --radius: 14px;
  --content: 1180px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.masthead,
.safety-tape,
main,
footer {
  width: min(calc(100% - 40px), var(--content));
  margin-inline: auto;
}

.masthead {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.wordmark-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--teal-dark);
  border-radius: 9px;
}

.wordmark-mark svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.masthead-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.safety-tape {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  color: #5f2119;
  background: var(--coral-wash);
  border-block: 1px solid #f0afa5;
  text-align: center;
  font-size: 0.9rem;
}

main {
  padding-block: 34px 56px;
}

.run-sheet,
.result-sheet {
  background: var(--sheet);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.run-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr);
}

.run-brief {
  padding: clamp(34px, 4.2vw, 58px);
  display: flex;
  flex-direction: column;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1,
h2 {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -0.025em;
}

h1 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(2.35rem, 4.6vw, 4.05rem);
  line-height: 0.98;
  font-weight: 650;
}

.lede {
  max-width: 64ch;
  margin: 26px 0 0;
  color: var(--ink-soft);
  font-size: 1.04rem;
}

.case-ticket {
  margin-top: 32px;
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-block: 1px solid var(--line-strong);
}

.ticket-label {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ticket-tag,
.state-stamp,
.review-stamp,
.evidence-badge,
.field-state {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 27px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.ticket-tag {
  color: var(--teal-dark);
  background: var(--teal-wash);
}

.scope-copy {
  margin-top: 32px;
}

.scope-copy h2,
.panel-heading h2,
.safety-notes h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
}

.scope-copy ul {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
  list-style: none;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.scope-copy li {
  position: relative;
  padding-left: 17px;
}

.scope-copy li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.66em;
  width: 6px;
  height: 6px;
  background: var(--teal);
  border-radius: 50%;
}

.run-button {
  min-width: 190px;
  min-height: 52px;
  margin-top: 30px;
  padding: 13px 17px 13px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  color: var(--white);
  background: var(--teal-dark);
  border: 0;
  border-radius: 9px;
  box-shadow: 0 9px 20px rgba(4, 86, 78, 0.2);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.run-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.run-button:hover {
  background: #03483f;
  box-shadow: 0 12px 25px rgba(4, 86, 78, 0.26);
  transform: translateY(-1px);
}

.run-button:focus-visible,
.wordmark:focus-visible,
#result-sheet:focus-visible,
#failure-panel:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 4px;
}

.run-button:disabled {
  color: #dce9e6;
  background: #59736f;
  box-shadow: none;
  cursor: wait;
  transform: none;
}

.processing-copy {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.execution-panel {
  position: relative;
  padding: clamp(34px, 4.5vw, 58px);
  color: #dff2ee;
  background: var(--teal-dark);
  overflow: hidden;
}

.execution-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 23px;
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.panel-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.24);
}

.panel-heading h2 {
  color: var(--white);
  font-size: 1.35rem;
}

.state-stamp {
  color: #dff2ee;
  border: 1px solid rgba(255, 255, 255, 0.34);
}

.execution-list {
  position: relative;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.execution-list::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: rgba(255, 255, 255, 0.22);
}

.execution-list li {
  position: relative;
  min-height: 46px;
  padding: 3px 0 14px 38px;
  display: flex;
  align-items: flex-start;
  color: #bed5d1;
  font-size: 0.91rem;
}

.trace-mark {
  position: absolute;
  left: 0;
  top: 2px;
  width: 20px;
  height: 20px;
  background: var(--teal-dark);
  border: 1px solid #739a94;
  border-radius: 50%;
}

.execution-list li.is-complete {
  color: var(--white);
  font-weight: 650;
}

.execution-list li.is-complete .trace-mark {
  background: #a9eadc;
  border-color: #a9eadc;
}

.execution-list li.is-complete .trace-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: solid var(--teal-dark);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.execution-panel.is-running .execution-list li:first-child .trace-mark {
  border-color: #a9eadc;
  animation: pending-pulse 1.2s ease-in-out infinite;
}

.trace-footnote {
  margin: 16px 0 0;
  color: #aac5c0;
  font-size: 0.76rem;
  line-height: 1.5;
}

.failure-panel {
  margin-top: 24px;
  padding: 28px clamp(24px, 4vw, 42px);
  color: var(--coral-dark);
  background: var(--coral-wash);
  border: 1px solid #efb3aa;
  border-radius: var(--radius);
}

.failure-panel h2 {
  margin: 0;
  font-size: 1.35rem;
}

.failure-panel p {
  margin: 7px 0 0;
}

.failure-code {
  font-size: 0.82rem;
}

.failure-code code {
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.result-sheet {
  margin-top: 28px;
}

.result-heading {
  padding: 30px clamp(26px, 5vw, 56px) 26px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.result-heading h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  line-height: 1.05;
}

.result-heading p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.review-stamp {
  color: var(--coral-dark);
  background: var(--coral-wash);
  border: 1px solid #efb3aa;
}

.empty-result {
  min-height: 220px;
  padding: 56px 30px;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--ink-soft);
  text-align: center;
}

.empty-rule {
  width: 72px;
  height: 24px;
  border-block: 1px solid var(--line-strong);
}

.empty-result p {
  margin: 15px 0 0;
}

.reports.is-revealed {
  animation: sheet-reveal 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.report {
  padding: clamp(28px, 5vw, 54px);
}

.report + .report {
  border-top: 8px solid var(--paper);
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.report-header h3 {
  margin: 0;
  font-family: inherit;
  font-size: 1.06rem;
  letter-spacing: -0.01em;
}

.report-header span {
  color: var(--ink-soft);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-metadata {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
}

.metadata-field {
  min-height: 98px;
  padding: 18px 22px 20px 0;
  border-bottom: 1px solid var(--line);
}

.metadata-field:nth-child(odd) {
  padding-right: 28px;
  border-right: 1px solid var(--line);
}

.metadata-field:nth-child(even) {
  padding-left: 28px;
}

.metadata-field dt,
.narrative-label {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.metadata-field dd {
  margin: 9px 0 0;
  font-size: 1rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.narrative-field {
  padding-block: 28px;
  border-bottom: 1px solid var(--line);
}

.narrative-field:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.narrative-value {
  max-width: 74ch;
  margin: 10px 0 0;
  color: #173943;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.field-provenance {
  margin-top: 15px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.evidence-badge {
  gap: 7px;
  color: var(--teal-dark);
  background: var(--teal-wash);
}

.evidence-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--teal);
  border-radius: 50%;
}

.field-state {
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.field-state.is-missing {
  color: #725b2c;
  background: #fff8e7;
  border-color: #e3cf9c;
}

.safety-notes {
  margin-top: 32px;
  padding: 28px 0;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 30px;
  border-block: 1px solid var(--line-strong);
}

.safety-statements {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
}

.safety-statements p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

footer {
  min-height: 86px;
  padding-block: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
}

@keyframes pending-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(169, 234, 220, 0); }
  50% { box-shadow: 0 0 0 6px rgba(169, 234, 220, 0.17); }
}

@keyframes sheet-reveal {
  from {
    opacity: 0.55;
    clip-path: inset(0 0 100% 0);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    clip-path: inset(0);
    filter: blur(0);
  }
}

@media (max-width: 850px) {
  .run-sheet {
    grid-template-columns: 1fr;
  }

  .execution-panel {
    min-height: auto;
  }

  .safety-notes,
  .safety-statements {
    grid-template-columns: 1fr;
  }

  .safety-notes {
    gap: 8px;
  }
}

@media (max-width: 600px) {
  .masthead,
  .safety-tape,
  main,
  footer {
    width: min(calc(100% - 24px), var(--content));
  }

  .masthead {
    min-height: 72px;
  }

  .masthead-note {
    display: none;
  }

  .safety-tape {
    display: block;
  }

  .safety-tape span {
    display: block;
  }

  main {
    padding-top: 18px;
  }

  .run-brief,
  .execution-panel {
    padding: 30px 24px;
  }

  h1 {
    font-size: clamp(2.25rem, 10vw, 2.8rem);
    line-height: 1;
  }

  .scope-copy ul,
  .report-metadata {
    grid-template-columns: 1fr;
  }

  .case-ticket,
  .result-heading,
  .report-header,
  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .run-button {
    width: 100%;
    order: 1;
    margin-top: 24px;
  }

  .processing-copy {
    order: 2;
  }

  .scope-copy {
    order: 3;
    margin-top: 22px;
  }

  .result-heading,
  .report {
    padding: 26px 22px;
  }

  .metadata-field,
  .metadata-field:nth-child(odd),
  .metadata-field:nth-child(even) {
    min-height: auto;
    padding: 17px 0;
    border-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
