:root {
  --bg: #ede7dd;
  --bg-alt: #e3dccf;
  --surface: rgba(251, 248, 243, 0.95);
  --surface-strong: rgba(255, 252, 247, 0.99);
  --surface-soft: rgba(241, 235, 226, 0.78);
  --outline: rgba(25, 37, 61, 0.12);
  --rule: rgba(25, 37, 61, 0.08);
  --text: #172032;
  --text-soft: #5d6878;
  --accent: #2d56c5;
  --accent-strong: #1f43a0;
  --ink-panel: #1a2438;
  --ink-panel-soft: #22304a;
  --ink-panel-text: #f6f8fc;
  --success: #177245;
  --danger: #b34b41;
  --shadow: 0 24px 60px rgba(39, 32, 22, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --max-width: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  font-family: "Manrope", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(50% - 590px), rgba(23, 32, 50, 0.03) calc(50% - 590px), rgba(23, 32, 50, 0.03) calc(50% - 589px), transparent calc(50% - 589px), transparent calc(50% + 589px), rgba(23, 32, 50, 0.03) calc(50% + 589px), rgba(23, 32, 50, 0.03) calc(50% + 590px), transparent calc(50% + 590px));
}

a {
  color: inherit;
  text-decoration: none;
}

.site-shell {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
  padding: 1.6rem 0 3.8rem;
}

.site-topbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  border-radius: 0.95rem;
  border: 1px solid rgba(45, 86, 197, 0.16);
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-family: "JetBrains Mono", monospace;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(35, 46, 72, 0.08);
}

.brand strong,
.brand small,
.topnav a,
.panel-label,
.eyebrow {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand small,
.panel-label,
.eyebrow {
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.topnav a {
  padding: 0.6rem 0.85rem;
  border-radius: 999px;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.topnav a:hover,
.topnav a.active {
  background: rgba(255, 255, 255, 0.58);
  color: var(--text);
}

.stack-xl {
  display: grid;
  gap: 1.4rem;
  margin-top: 1.8rem;
}

.hero-block,
.tool-layout {
  margin-top: 1.8rem;
}

.hero-block {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  padding: 1.5rem;
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero-block::before,
.result-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, #6488df 70%, #c1cff5 100%);
}

.hero-copy h1,
.tool-lead h1 {
  margin: 0.35rem 0 0;
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(2rem, 3.6vw, 3.2rem);
  letter-spacing: -0.04em;
}

.hero-intro {
  margin: 0.9rem 0 0;
  max-width: 44rem;
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-note,
.result-panel,
.tool-card,
.stat-card,
.output-panel,
.tool-lead {
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
}

.hero-note {
  padding: 1.2rem;
  align-self: start;
}

.panel-value,
.tool-card h2 {
  margin: 0.55rem 0 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 1.12rem;
  line-height: 1.45;
}

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

.tool-card {
  padding: 1.2rem;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  box-shadow: 0 10px 26px rgba(33, 35, 44, 0.05);
}

.tool-card:hover,
.tool-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(45, 86, 197, 0.2);
  box-shadow: 0 18px 40px rgba(33, 35, 44, 0.08);
}

.tool-card p:last-child {
  margin: 0.7rem 0 0;
  color: var(--text-soft);
  line-height: 1.65;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  gap: 1.2rem;
  align-items: start;
}

.tool-lead,
.result-panel {
  position: relative;
  overflow: hidden;
}

.tool-lead {
  padding: 1.3rem;
  background: rgba(248, 244, 238, 0.92);
}

.tool-note {
  margin: 1rem 0 0;
  color: var(--text-soft);
  line-height: 1.65;
}

.result-panel {
  padding: 1.35rem;
  box-shadow: var(--shadow);
}

.result-topline {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
}

.status-line {
  margin: 0.45rem 0 0;
  color: var(--text-soft);
}

.result-banner {
  margin-top: 1rem;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(23, 32, 50, 0.1);
  background: var(--ink-panel);
  position: relative;
  overflow: hidden;
}

.result-banner::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.48rem;
  background: linear-gradient(180deg, var(--accent) 0%, #7d9eed 100%);
}

.result-primary {
  position: relative;
  margin: 0;
  color: var(--ink-panel-text);
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(1.75rem, 4vw, 3.8rem);
  line-height: 1.06;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}

.result-primary[data-state="loading"] {
  opacity: 0.72;
}

.result-primary[data-state="error"] {
  color: #ffe0d8;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  appearance: none;
  border: 1px solid rgba(25, 37, 61, 0.12);
  border-radius: 999px;
  padding: 0.9rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button:focus-visible {
  outline: 3px solid rgba(45, 86, 197, 0.16);
  outline-offset: 3px;
}

.button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.button.primary {
  background: var(--accent);
  color: #f7f9ff;
}

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

.button.secondary {
  background: rgba(255, 255, 255, 0.62);
  color: var(--text);
}

.button.secondary:hover,
.button.secondary:focus-visible {
  background: rgba(255, 255, 255, 0.9);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-card {
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.stat-value,
.kv-value,
.header-key,
.header-value,
.record-value {
  font-family: "JetBrains Mono", monospace;
}

.stat-value {
  margin: 0.5rem 0 0;
  font-size: 1.06rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.panel-help,
.empty-state,
.muted {
  color: var(--text-soft);
  line-height: 1.6;
}

.panel-help {
  margin: 0.6rem 0 0;
  font-size: 0.92rem;
}

.tool-form {
  display: grid;
  gap: 1rem;
}

.field-grid {
  display: grid;
  gap: 1rem;
}

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

.field {
  display: grid;
  gap: 0.5rem;
}

.field span {
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(25, 37, 61, 0.14);
  border-radius: 14px;
  padding: 0.92rem 1rem;
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  outline: 3px solid rgba(45, 86, 197, 0.12);
  border-color: rgba(45, 86, 197, 0.28);
}

.output-panel {
  margin-top: 1rem;
  padding: 1.15rem;
  background: rgba(248, 244, 238, 0.92);
}

.empty-state {
  margin: 0;
}

.result-stack {
  display: grid;
  gap: 1rem;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.kv-card,
.record-card,
.headers-table,
.chain-card {
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
}

.kv-card,
.record-card,
.chain-card {
  padding: 0.95rem 1rem;
}

.kv-label {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kv-value {
  margin: 0.45rem 0 0;
  font-size: 0.98rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.record-list,
.chain-list {
  display: grid;
  gap: 0.75rem;
}

.record-card h3,
.output-heading {
  margin: 0 0 0.65rem;
  font-size: 0.98rem;
}

.record-value {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.headers-table {
  overflow: hidden;
}

.headers-table table {
  width: 100%;
  border-collapse: collapse;
}

.headers-table td {
  padding: 0.72rem 0.9rem;
  border-top: 1px solid var(--rule);
  vertical-align: top;
}

.headers-table tr:first-child td {
  border-top: none;
}

.header-key {
  width: 34%;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.header-value {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.55;
}

.status-good {
  color: var(--success);
}

.status-bad {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .hero-block,
  .tool-layout,
  .tool-grid,
  .stat-grid,
  .field-grid.two,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .site-topbar {
    align-items: start;
    flex-direction: column;
  }

  .topnav {
    justify-content: flex-start;
  }

  .result-topline {
    flex-direction: column;
  }
}

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

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
