:root {
  color-scheme: light;
  --ink: #1f261f;
  --muted: #66715f;
  --paper: #f3efe2;
  --paper-deep: #e6ddc6;
  --panel: #fffaf0;
  --line: rgb(55 66 48 / 20%);
  --accent: #2f6f4e;
  --accent-strong: #174a31;
  --gold: #b9852a;
  --shadow: 0 18px 50px rgb(45 39 25 / 14%);
  --mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", Menlo, monospace;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgb(185 133 42 / 18%), transparent 30rem),
    linear-gradient(135deg, var(--paper), #fbf7ea 52%, var(--paper-deep));
}

button,
input,
textarea {
  font: inherit;
}

button,
input {
  min-height: 2.75rem;
}

button {
  cursor: pointer;
}

button:active {
  transform: scale(0.97);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(47 111 78 / 30%);
  outline-offset: 2px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  margin-bottom: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-size: clamp(2.45rem, 7vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  letter-spacing: -0.04em;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.65;
}

.stamp {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgb(255 250 240 / 72%);
  box-shadow: var(--shadow);
}

.stamp span {
  padding: 9px 10px;
  border-radius: 14px;
  background: rgb(47 111 78 / 9%);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.98fr);
  gap: 18px;
}

.panel,
.reference {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgb(255 250 240 / 86%);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

.panel-head {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 22px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgb(31 38 31 / 18%);
  border-radius: 16px;
  background: #fffdf7;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.96rem;
}

input {
  padding: 0 14px;
}

textarea {
  min-height: 310px;
  resize: vertical;
  padding: 16px;
  line-height: 1.65;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: #fffaf0;
  box-shadow: 0 10px 22px rgb(23 74 49 / 22%);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  padding: 0 15px;
  border: 1px solid rgb(47 111 78 / 20%);
  background: rgb(47 111 78 / 8%);
  color: var(--accent-strong);
  font-size: 0.9rem;
  white-space: nowrap;
}

.hint {
  min-height: 1.45em;
  margin: 12px 0 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.84rem;
}

.error {
  color: #a13d2d;
}

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

.metrics article {
  min-width: 0;
  padding: 16px;
  border-radius: 20px;
  background: rgb(230 221 198 / 52%);
}

.metrics span,
.metrics small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.metrics strong {
  display: block;
  margin: 6px 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: clamp(1.1rem, 4vw, 1.75rem);
}

.bit-card {
  padding: 16px;
  border-radius: 22px;
  background: #282b25;
  color: #f6edd6;
}

.bit-row {
  display: grid;
  grid-template-columns: 42fr 5fr 5fr 12fr;
  gap: 3px;
  margin-bottom: 14px;
}

.bit {
  min-width: 0;
  padding: 8px 5px;
  border-radius: 10px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.64rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time { background: #d7b66e; color: #282016; }
.dc { background: #7da583; color: #102316; }
.worker { background: #8aa2b5; color: #132331; }
.seq { background: #c7836d; color: #2b160f; }

#binary-output {
  display: block;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.7;
}

.reference {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  padding: clamp(18px, 3vw, 28px);
}

pre {
  margin: 0;
  overflow-x: auto;
  padding: 18px;
  border-radius: 20px;
  background: #282b25;
  color: #f6edd6;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.7;
}

@media (max-width: 860px) {
  .masthead,
  .workspace,
  .reference {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 24px 0;
  }

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

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

  textarea {
    min-height: 220px;
  }
}
