:root {
  --ink: #171817;
  --muted: #747a73;
  --paper: #f2f4ee;
  --white: #fff;
  --line: #dfe3da;
  --green: #b7ec52;
  --green-dark: #2e4710;
  --orange: #ff7d51;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at 85% 10%, rgba(183, 236, 82, .13), transparent 20rem),
    var(--paper);
}

.shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

header {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 20px; font-weight: 800; }
.brand > span:nth-child(3) { margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--line); font-size: 15px; }
.brand-mark { width: 32px; height: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; transform: rotate(-12deg); }
.brand-mark i { display: block; border-radius: 3px; background: var(--ink); }
.brand-mark i:last-child { background: var(--green); }
.status { font-family: "DM Mono", monospace; font-size: 12px; letter-spacing: .12em; color: var(--muted); }
.status span { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 8px; background: var(--green); box-shadow: 0 0 0 3px rgba(183,236,82,.25); }

main { padding: 30px 0 70px; }
.algorithm-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.tab-button { position: relative; border: 0; background: transparent; padding: 14px 18px 13px; color: var(--muted); cursor: pointer; font: 700 14px "Manrope", sans-serif; }
.tab-button::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.tab-button.active { color: var(--ink); }
.tab-button.active::after { background: var(--green); }
.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }
.algorithm-description { margin-bottom: 18px; }
.algorithm-description h3 { margin: 0 0 8px; font-size: 18px; }
.algorithm-description p { max-width: 780px; margin: 0; color: var(--muted); line-height: 1.65; white-space: pre-line; }
.algorithm-empty { min-height: 430px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 18px; background: var(--white); text-align: center; }
.algorithm-empty[hidden] { display: none; }
.algorithm-empty div { padding: 40px; }
.algorithm-empty h2 { margin: 8px 0; font-size: 32px; }
.algorithm-empty p { margin: 0; color: var(--muted); }
.algorithm-empty .empty-label { font: 500 11px "DM Mono", monospace; letter-spacing: .12em; }
.intro { position: relative; max-width: 700px; margin-bottom: 43px; }
.eyebrow { margin: 0 0 14px; font-family: "DM Mono", monospace; font-size: 12px; letter-spacing: .16em; color: var(--muted); }
h1 { margin: 0; font-size: clamp(48px, 6vw, 78px); line-height: .98; letter-spacing: -.055em; }
h1 span { color: #96a18f; }
.lede { max-width: 590px; margin: 22px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.workspace { background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 50px rgba(40, 48, 35, .07); overflow: hidden; }
.input-panel { padding: 30px 34px 24px; border-bottom: 1px solid var(--line); }
.input-panel label { display: block; margin-bottom: 10px; font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.input-wrap { position: relative; }
input { width: 100%; height: 68px; border: 1px solid var(--line); border-radius: 10px; padding: 0 58px 0 20px; outline: none; font: 500 30px "DM Mono", monospace; letter-spacing: .08em; color: var(--ink); background: #fbfcf9; transition: .2s; }
input:focus { border-color: #a8c96d; box-shadow: 0 0 0 4px rgba(183,236,82,.16); }
input.invalid { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(255,125,81,.11); }
.clear-btn { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--paper); color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; }
.clear-btn:hover { background: var(--line); }
.hint { margin: 9px 0 0; font-size: 12px; color: var(--muted); }
.hint b { margin: 0 7px; color: #b6bbb1; }
.examples { display: flex; align-items: center; gap: 7px; margin-top: 19px; }
.examples > span { margin-right: 4px; font-size: 12px; color: var(--muted); }
.examples button { border: 1px solid var(--line); border-radius: 6px; padding: 7px 11px; background: var(--white); font: 500 12px "DM Mono", monospace; cursor: pointer; }
.examples button:hover { border-color: #b8c0b0; background: var(--paper); }

.flags { display: grid; grid-template-columns: 1fr 1fr; }
.flag-card { min-height: 170px; padding: 24px 34px; }
.a-card { border-right: 1px solid var(--line); }
.flag-heading { display: flex; align-items: baseline; justify-content: space-between; font-family: "DM Mono", monospace; }
.flag-heading span { font-size: 12px; letter-spacing: .12em; }
.flag-heading small { color: var(--muted); font-size: 11px; }
.bit-row { height: 96px; display: flex; align-items: flex-end; justify-content: space-between; }
.bit-row span { font: 500 46px "DM Mono", monospace; color: #cdd2c7; }
.bit-row strong { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 12px; background: var(--ink); color: var(--white); font: 500 38px "DM Mono", monospace; transition: .22s; }
.flag-card.active .bit-row strong { background: var(--green); color: var(--green-dark); transform: translateY(-5px); box-shadow: 0 8px 20px rgba(183,236,82,.28); }

.result { min-height: 100px; display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 14px; padding: 18px 34px; color: var(--green-dark); background: #eaf8cc; border-top: 1px solid var(--line); transition: .2s; }
.result[data-state="invalid"] { color: #6e351f; background: #fff0e8; }
.result[data-state="error"] { color: #6e351f; background: #fff0e8; }
.result-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--green); font-size: 24px; font-weight: 800; }
.result[data-state="invalid"] .result-icon, .result[data-state="error"] .result-icon { background: var(--orange); color: var(--white); }
.result p { margin: 0 0 2px; font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .12em; opacity: .7; }
.result h2 { margin: 0; font-size: 23px; }
.result-code { justify-self: end; font: 500 25px "DM Mono", monospace; }

.trace { border-top: 1px solid var(--line); padding: 22px 34px 28px; }
.trace-heading { height: 32px; display: flex; align-items: center; justify-content: space-between; font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.trace-heading button { border: 0; background: transparent; color: var(--ink); cursor: pointer; font: 500 11px "DM Mono", monospace; }
.trace-steps { min-height: 48px; display: flex; gap: 8px; align-items: center; overflow-x: auto; padding-top: 10px; }
.step { flex: 0 0 auto; height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); color: var(--muted); font: 500 12px "DM Mono", monospace; opacity: .45; }
.step.current { opacity: 1; border-color: #b8d77a; background: #f5fbe9; color: var(--ink); }
.step.done { opacity: 1; }
.step b { color: var(--ink); }
.initial-step { opacity: 1; border-style: dashed; }

.type3-display { min-height: 170px; display: grid; grid-template-columns: 1fr 280px; }
.pair-card, .type3-card { padding: 24px 34px; }
.pair-card { border-right: 1px solid var(--line); }
.pair-list { min-height: 96px; display: flex; align-items: flex-end; gap: 8px; overflow-x: auto; }
.pair-chip { flex: 0 0 auto; min-width: 62px; height: 54px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font: 500 22px "DM Mono", monospace; transition: .2s; }
.pair-chip.active { border-color: var(--green); background: var(--green); color: var(--green-dark); transform: translateY(-4px); }
.pair-chip.mismatch { border-color: var(--orange); }
.type3-card.active .bit-row strong { background: var(--green); color: var(--green-dark); transform: translateY(-5px); box-shadow: 0 8px 20px rgba(183,236,82,.28); }

@media (max-width: 700px) {
  .shell { width: min(100% - 28px, 1120px); }
  header { height: auto; min-height: 74px; gap: 12px; }
  .brand { font-size: 15px; }
  .brand > span:nth-child(3) { display: none; }
  .status { max-width: 150px; text-align: right; font-size: 9px; line-height: 1.5; }
  .tab-button { flex: 1; }
  main { padding-top: 20px; }
  .algorithm-description p { font-size: 14px; }
  h1 { font-size: 49px; }
  .lede { font-size: 15px; }
  .input-panel, .flag-card, .result, .trace { padding-left: 20px; padding-right: 20px; }
  .flags { grid-template-columns: 1fr; }
  .a-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .type3-display { grid-template-columns: 1fr; }
  .pair-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .pair-card, .type3-card { padding-left: 20px; padding-right: 20px; }
  .flag-card { min-height: 150px; }
  .bit-row { height: 78px; }
  .examples { flex-wrap: wrap; }
  .examples > span { width: 100%; }
}
