:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f2f5f8;
  --text: #17202a;
  --muted: #5f6b76;
  --line: #d8dee6;
  --dark: #0d1820;
  --dark-2: #14232f;
  --orange: #f97316;
  --orange-2: #ff9f1c;
  --orange-soft: #fff4ea;
  --blue: #1f5f97;
  --blue-soft: #eef6fd;
  --green: #198754;
  --green-soft: #e9f8f0;
  --red: #c83838;
  --red-soft: #fff0f0;
  --shadow: 0 12px 32px rgba(11, 24, 35, .08);
  --radius: 20px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 5%, rgba(249,115,22,.10), transparent 20rem),
    linear-gradient(180deg, #fff 0, var(--bg) 34rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .26;
  background-image:
    linear-gradient(rgba(249,115,22,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(249,115,22,.05) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, #000, transparent 65%);
}

button, input { font: inherit; }
a { color: inherit; }
code, pre, .mono { font-family: var(--mono); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 5vw;
  color: #fff;
  background: rgba(13, 24, 32, .96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.brand strong { color: var(--orange); }
.brand-mark { color: var(--orange); font-size: 1.8rem; line-height: 1; }
nav { display: flex; gap: 20px; flex-wrap: wrap; }
nav a { text-decoration: none; font-size: .92rem; color: #dfe7ed; }
nav a:hover { color: var(--orange-2); }

.section-shell { width: min(1180px, 92vw); margin: 0 auto; }
.hero {
  min-height: 570px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  align-items: center;
  gap: 54px;
  padding: 80px 0 56px;
}
.eyebrow { color: var(--orange); font-weight: 800; letter-spacing: .12em; font-size: .78rem; }
.hero h1 { margin: 8px 0 0; font-size: clamp(4.5rem, 12vw, 9rem); line-height: .88; letter-spacing: -.05em; }
.hero h2 { margin: 18px 0 14px; font-size: clamp(1.6rem, 3vw, 2.5rem); line-height: 1.08; max-width: 18ch; }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 60ch; line-height: 1.65; }
.cta, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 12px 18px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: .2s ease;
}
.cta { margin-top: 8px; background: var(--orange); color: white; box-shadow: 0 10px 22px rgba(249,115,22,.22); }
.cta:hover, .primary:hover { transform: translateY(-1px); filter: brightness(1.03); }

.hero-chain { display: flex; align-items: center; justify-content: center; min-height: 300px; }
.cube {
  width: 150px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 28px;
  transform: rotate(3deg);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 22px 36px rgba(13,24,32,.18);
}
.cube small { font-size: .78rem; letter-spacing: .15em; }
.cube strong { font-size: 2rem; }
.cube.muted { color: white; background: linear-gradient(145deg, #52606b, #202a32); }
.cube.active { color: white; background: linear-gradient(145deg, var(--orange-2), #ef5b0c); box-shadow: 0 0 0 8px rgba(249,115,22,.08), 0 24px 48px rgba(249,115,22,.28); }
.chain-link { font-size: 2.2rem; color: #58636c; margin: 0 -4px; position: relative; z-index: 2; }

.card-section {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  padding: 30px;
  scroll-margin-top: 82px;
}
.card-section.highlight { border-color: rgba(249,115,22,.55); }
.section-title { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.section-title h2 { margin: 0; font-size: clamp(1.45rem, 2vw, 2rem); }
.section-title p { margin: 5px 0 0; color: var(--muted); }
.step {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--orange);
  color: white;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 7px 16px rgba(249,115,22,.18);
}
.blue-step { background: var(--blue); box-shadow: 0 7px 16px rgba(31,95,151,.18); }
.two-columns, .lab-grid, .integrity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--surface);
}
.panel h3 { margin: 0 0 16px; }
.metadata-panel h3 { color: var(--orange); }
.ledger-panel h3 { color: var(--blue); }
.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-size: .83rem; font-weight: 800; color: #34404a; }
label input, table input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}
label input:focus, table input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.10); }
input[readonly] { background: var(--surface-2); }
.hint { color: var(--muted); font-weight: 500; }
.info-box { margin-top: 14px; border-radius: 10px; padding: 11px 13px; font-size: .88rem; line-height: 1.45; }
.info-box.orange { background: var(--orange-soft); border: 1px solid #ffd3b4; }
.info-box.blue { background: var(--blue-soft); border: 1px solid #c9def0; color: #184c78; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { background: var(--dark-2); color: white; text-align: left; padding: 10px; }
td { border-bottom: 1px solid var(--line); padding: 7px 10px; vertical-align: middle; }
td:first-child { font-weight: 800; white-space: nowrap; }
table input { margin: 0; padding: 7px 8px; border-color: transparent; background: transparent; }
table input:focus { background: white; }

.lab-grid { align-items: stretch; }
.hash-panel { background: linear-gradient(180deg, #fff, #fffaf6); }
.field-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf0f3;
}
.field-row > span { font-weight: 800; color: #3f4a54; }
.field-row code { overflow-wrap: anywhere; }
.field-row.stacked { grid-template-columns: 1fr; }
.difficulty-control { display: flex; align-items: center; gap: 12px; }
.difficulty-control input { margin: 0; accent-color: var(--orange); }
.payload {
  margin: 0;
  max-height: 190px;
  overflow: auto;
  background: #101b24;
  color: #dce6ee;
  padding: 12px;
  border-radius: 10px;
  font-size: .75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.hash-output {
  display: block;
  background: var(--orange-soft);
  color: #bd4d08;
  border: 1px solid #ffd0ad;
  padding: 12px;
  border-radius: 10px;
  font-weight: 800;
  word-break: break-all;
}
.validation { margin-top: 14px; border-radius: 10px; padding: 11px 13px; font-weight: 800; font-size: .9rem; }
.validation.invalid { background: var(--red-soft); color: var(--red); border: 1px solid #ffd0d0; }
.validation.valid { background: var(--green-soft); color: var(--green); border: 1px solid #bce8cf; }
.validation.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.button { padding: 10px 14px; }
.button.primary { background: var(--orange); color: white; }
.button.secondary { background: white; color: var(--text); border-color: var(--line); }
.button.danger { background: var(--red-soft); color: var(--red); border-color: #ffd0d0; }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stats > div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.stats span { display: block; color: var(--muted); font-size: .73rem; }
.stats strong { display: block; margin-top: 4px; }
.compare-block { margin-bottom: 12px; }
.compare-block span { display: block; color: var(--muted); font-size: .75rem; font-weight: 800; margin-bottom: 4px; }
.compare-block code { display: block; padding: 10px; background: var(--surface-2); border-radius: 9px; word-break: break-all; font-size: .75rem; }
.meter-label { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; font-size: .82rem; }
.meter { height: 12px; border-radius: 999px; background: #e8edf1; overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--orange-2), var(--orange)); transition: width .25s ease; }
.history-panel { margin-top: 18px; }
.history-head { display: flex; justify-content: space-between; align-items: center; }
.text-button { border: 0; background: transparent; color: var(--orange); cursor: pointer; font-weight: 800; }
.result-ok { color: var(--green); font-weight: 900; }
.result-no { color: var(--red); font-weight: 900; }

.chain-demo { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 14px; margin: 20px 0; }
.chain-card { min-width: 0; border-radius: 16px; padding: 18px; border: 1px solid var(--line); background: var(--surface-2); }
.chain-card span { display: block; font-size: 1.15rem; font-weight: 900; margin-bottom: 12px; }
.chain-card code { display: block; font-size: .76rem; word-break: break-all; }
.chain-card small { display: block; color: var(--muted); margin-bottom: 4px; }
.chain-card.current { background: linear-gradient(145deg, #fff5ec, #fff); border-color: #ffbe8d; box-shadow: 0 9px 22px rgba(249,115,22,.10); }
.arrow { align-self: center; font-size: 2rem; color: var(--orange); }

.steps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.steps-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 16px; position: relative; background: #fff; }
.steps-grid article > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--orange-soft); color: var(--orange); font-weight: 900; border: 1px solid #ffd0ad; }
.steps-grid h3 { margin: 12px 0 8px; }
.steps-grid p { color: var(--muted); margin: 0; line-height: 1.5; font-size: .9rem; }
.lesson-box { margin-top: 20px; background: linear-gradient(90deg, #fff5ec, #fff); border: 1px solid #ffd1ad; border-radius: 14px; padding: 16px; line-height: 1.6; }

footer {
  margin-top: 48px;
  min-height: 120px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 28px 5vw;
  background: var(--dark);
  color: #dbe4ea;
}
footer p { color: #acbac4; text-align: center; }
footer a { color: var(--orange-2); text-decoration: none; font-weight: 800; }

@media (max-width: 900px) {
  nav { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 58px; }
  .hero-chain { min-height: 220px; }
  .cube { width: 110px; border-radius: 20px; }
  .two-columns, .lab-grid, .integrity-grid { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr 1fr; }
  .chain-demo { grid-template-columns: 1fr; }
  .arrow { transform: rotate(90deg); justify-self: center; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 4vw; }
  .section-shell { width: min(94vw, 1180px); }
  .hero h1 { font-size: 5rem; }
  .hero-chain { transform: scale(.84); transform-origin: center; }
  .card-section { padding: 20px 14px; }
  .metadata-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; text-align: center; }
}
