:root {
  color-scheme: light;
  --cream: #f5f0e5;
  --paper: #fffdf7;
  --ink: #17332b;
  --muted: #66736c;
  --green: #176b4b;
  --green-dark: #0b4932;
  --mint: #d9eadc;
  --line: #c9d0c4;
  --orange: #d27b42;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 300px;
  background:
    linear-gradient(rgba(23, 107, 75, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 107, 75, 0.045) 1px, transparent 1px),
    var(--cream);
  background-size: 32px 32px;
}

a {
  color: inherit;
}

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.wordmark {
  color: var(--green-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

main {
  padding-block: clamp(26px, 4vw, 44px) 64px;
}

.intro {
  max-width: 700px;
  margin-bottom: 24px;
}

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

h1 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 4vw, 2.625rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
}

.intro > p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.65;
}

.lab {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 22px 60px rgba(42, 54, 45, 0.1);
}

.controls,
.result-panel {
  padding: clamp(24px, 4vw, 42px);
}

.controls {
  border-right: 1px solid var(--line);
  background: rgba(217, 234, 220, 0.25);
}

.field + .field,
.sample-row + .field {
  margin-top: 24px;
}

label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid #9aaa9e;
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

select,
input {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

select:focus-visible,
textarea:focus-visible,
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(210, 123, 66, 0.45);
  outline-offset: 2px;
}

.hint,
.algorithm-note,
.status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.algorithm-note {
  min-height: 2.4em;
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.76rem;
}

.sample-row button {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--green-dark);
  cursor: pointer;
  font: inherit;
}

.sample-row button:hover {
  border-color: var(--green);
  background: var(--mint);
}

.run-button {
  width: 100%;
  min-height: 50px;
  margin-top: 28px;
  border: 1px solid var(--green-dark);
  border-radius: 2px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.run-button:hover:not(:disabled) {
  background: var(--green-dark);
}

.run-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.status.error {
  color: #a13f2e;
  font-weight: 700;
}

.result-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}

.contract {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.contract.verified {
  border-color: #8cb49a;
  background: var(--mint);
  color: var(--green-dark);
}

.sequence {
  min-height: 270px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  align-content: center;
  gap: 8px;
  margin-block: 36px;
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #f7f3e9;
}

.value-cell {
  min-width: 46px;
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid rgba(23, 51, 43, 0.2);
  border-radius: 2px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.value-cell.match {
  outline: 3px solid var(--orange);
  outline-offset: -3px;
}

.value-cell.insertion {
  border-left: 4px solid var(--orange);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: auto 0 0;
  border-top: 1px solid var(--line);
}

.metrics > div {
  min-width: 0;
  padding: 18px 16px 0 0;
}

.metrics dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metrics dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 800;
}

.result-detail {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

footer {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

footer a {
  color: var(--green-dark);
  font-weight: 800;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 22px;
}

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

  .controls {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sequence {
    min-height: 220px;
  }
}

@media (max-width: 480px) {
  .site-header,
  main,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .site-header span {
    text-align: right;
  }

  main {
    padding-block: 24px 48px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .controls,
  .result-panel {
    padding: 22px;
  }

  .result-heading {
    display: block;
  }

  .contract {
    display: inline-block;
    margin-top: 14px;
  }

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

  .metrics > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-top: 12px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 18px;
  }

  .footer-links {
    justify-content: flex-start;
  }
}

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