:root {
  color-scheme: light;
  --bg: #eef3fb;
  --bg-deep: #07152f;
  --card: rgba(255, 255, 255, 0.9);
  --card-solid: #ffffff;
  --text: #142033;
  --muted: #667085;
  --line: #d9e2f0;
  --line-strong: #c6d2e4;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e9f0ff;
  --accent: #18b6a5;
  --accent-soft: #dcfbf6;
  --ok: #12805c;
  --warn: #b54708;
  --bad: #b42318;
  --soft: #f3f7ff;
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.14);
  --shadow-soft: 0 14px 34px rgba(15, 23, 42, 0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.2), transparent 32rem),
    radial-gradient(circle at 78% 12%, rgba(24, 182, 165, 0.18), transparent 28rem),
    linear-gradient(180deg, #f7faff 0%, #edf3fb 48%, #f8fafc 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 70%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 860px;
  font-size: clamp(38px, 6vw, 68px);
  letter-spacing: -0.055em;
  line-height: 0.96;
}

h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
}

h3 {
  margin-top: 22px;
  font-size: 18px;
}

code {
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 8px;
  padding: 1px 5px;
  background: rgba(37, 99, 235, 0.06);
  color: #173b80;
  font-family: var(--mono);
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  align-items: end;
  padding: 58px min(6vw, 76px) 88px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(7, 21, 47, 0.98), rgba(15, 45, 101, 0.96) 58%, rgba(12, 101, 130, 0.92)),
    radial-gradient(circle at 12% 18%, rgba(80, 141, 255, 0.5), transparent 24rem);
  color: #fff;
}

.hero::before,
.hero::after {
  position: absolute;
  border-radius: 999px;
  content: "";
  filter: blur(2px);
  pointer-events: none;
}

.hero::before {
  right: -120px;
  top: -120px;
  width: 360px;
  height: 360px;
  background: rgba(24, 182, 165, 0.22);
}

.hero::after {
  left: min(10vw, 150px);
  bottom: -190px;
  width: 520px;
  height: 280px;
  background: rgba(37, 99, 235, 0.3);
}

.hero-copy,
.hero-card {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #bcd7ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(24, 182, 165, 0.9);
  content: "";
}

.subtitle {
  max-width: 900px;
  margin-top: 20px;
  color: #dce9ff;
  font-size: 16px;
  line-height: 1.8;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.hero-tags span,
.reference-grid span {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #eaf2ff;
  font-size: 13px;
  font-weight: 700;
}

.hero-card {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
}

.hero-card span {
  display: block;
  margin-bottom: 12px;
  color: #bcd7ff;
  font-size: 13px;
  font-weight: 800;
}

.hero-card strong {
  display: block;
  color: #ffffff;
  font-size: 18px;
  line-height: 1.85;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  gap: 24px;
  margin-top: -52px;
  padding: 0 min(6vw, 76px) 28px;
}

.panel {
  border: 1px solid rgba(198, 210, 228, 0.72);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.input-panel {
  position: sticky;
  top: 18px;
  align-self: start;
}

.result-panel {
  min-width: 0;
}

.panel-title {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.panel-title.compact {
  margin-bottom: 0;
}

.panel-title p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.panel-icon {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #19a7ce);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.24);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

label {
  display: block;
  margin: 18px 0 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

select {
  min-height: 46px;
  padding: 9px 40px 9px 14px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #667085 50%),
    linear-gradient(135deg, #667085 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

textarea {
  min-height: 174px;
  padding: 14px;
  font-family: var(--mono);
  line-height: 1.65;
  resize: vertical;
}

select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.8);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  outline: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary), #1aa8c8);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.2);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover {
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: #eaf1ff;
  box-shadow: none;
  color: var(--primary-dark);
}

button.secondary:hover {
  background: #dce8ff;
  box-shadow: none;
}

button.ghost {
  grid-column: 1 / -1;
  background: #f3f6fb;
  box-shadow: none;
  color: #475467;
}

button.ghost:hover {
  background: #e9eef6;
  box-shadow: none;
}

.hint,
.message {
  margin-top: 18px;
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: 18px;
  padding: 13px 15px;
  background: rgba(243, 247, 255, 0.92);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.hint strong {
  color: #244c9d;
}

.message.warn {
  border-color: #fedf89;
  background: #fffaeb;
  color: var(--warn);
}

.message.bad {
  border-color: #fecdca;
  background: #fff1f3;
  color: var(--bad);
}

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

#decoder-summary {
  color: var(--muted);
}

.badge {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 900;
}

.badge.idle {
  background: #eef2f6;
  color: #475467;
}

.badge.ok {
  background: #dcfae6;
  color: var(--ok);
}

.badge.bad {
  background: #fee4e2;
  color: var(--bad);
}

.output {
  min-width: 0;
}

.output.empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(24, 182, 165, 0.05)),
    rgba(255, 255, 255, 0.48);
  color: var(--muted);
  font-weight: 700;
}

.byte-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--card-solid);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}

.byte-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  background: linear-gradient(135deg, #edf4ff, #f5fbff);
  color: #173b80;
  font-weight: 900;
}

.data-table,
.bitmap-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.data-table {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--card-solid);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}

.data-table caption {
  padding: 13px 15px;
  background: linear-gradient(135deg, #edf4ff, #f7fbff);
  color: #173b80;
  text-align: left;
  font-weight: 900;
}

.data-table td:first-child {
  width: 210px;
  color: #475467;
  font-weight: 800;
}

.data-table code {
  white-space: normal;
  word-break: break-all;
}

.data-table.compact td:first-child {
  width: auto;
}

.data-table.compact th,
.data-table.compact td {
  white-space: nowrap;
}

.data-table.compact td:last-child,
.data-table.compact th:last-child {
  white-space: normal;
}

.data-table th,
.data-table td,
.bitmap-table th,
.bitmap-table td {
  border-top: 1px solid var(--line);
  padding: 11px;
  text-align: left;
  vertical-align: top;
}

.data-table th,
.bitmap-table th {
  background: #fbfdff;
  color: #475467;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.data-table tbody tr:nth-child(even),
.bitmap-table tbody tr:nth-child(even) {
  background: #fbfdff;
}

.bitmap-table th:not(:last-child),
.bitmap-table td:not(:last-child) {
  width: 54px;
  text-align: center;
}

.bitmap-table td:last-child {
  min-width: 280px;
}

.bit-toggle {
  display: inline-flex;
  min-width: 32px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.bit-toggle:hover {
  border-color: rgba(37, 99, 235, 0.75);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.set {
  background: var(--accent-soft);
  color: var(--ok);
  font-weight: 900;
}

.unset {
  background: #f1f5f9;
  color: #667085;
}

.rfu {
  color: #98a2b3;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.reference {
  margin: 0 min(6vw, 76px) 40px;
}

.reference-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.reference-grid span {
  border-color: rgba(37, 99, 235, 0.14);
  background: #f3f7ff;
  color: #244c9d;
}

@media (max-width: 980px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-bottom: 78px;
  }

  .layout {
    margin-top: -42px;
  }

  .input-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .hero,
  .layout,
  .reference {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero {
    padding-top: 36px;
  }

  .hero-card,
  .panel {
    border-radius: 22px;
  }

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

  button.ghost {
    grid-column: auto;
  }

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

  .data-table,
  .bitmap-table {
    display: block;
    overflow-x: auto;
    font-size: 13px;
  }
}
