.decoder-hero {
  position: relative;
  overflow: hidden;
  padding: 3rem 0 8.5rem;
  background:
    radial-gradient(circle at 15% 12%, rgba(0, 115, 170, .14), transparent 32%),
    radial-gradient(circle at 88% 80%, rgba(0, 115, 170, .08), transparent 29%),
    linear-gradient(180deg, var(--tool-page), var(--tool-surface));
}

.decoder-hero::before,
.decoder-hero::after {
  position: absolute;
  color: rgba(0, 115, 170, .055);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.decoder-hero::before {
  content: "01";
  top: 2rem;
  left: max(1rem, calc(50% - 620px));
  font-size: 7rem;
  transform: rotate(-8deg);
}

.decoder-hero::after {
  content: "{  }";
  right: max(1rem, calc(50% - 620px));
  bottom: 2rem;
  font-size: 6rem;
  transform: rotate(6deg);
}

.decoder-hero h1 {
  max-width: 800px;
  margin: 0 auto .85rem;
  color: var(--tool-ink);
  font-size: var(--tool-title-size);
  line-height: 1.12;
}

.privacy-pill {
  width: max-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: .42rem;
  margin: 1.1rem auto 0;
  padding: .35rem .75rem;
  color: #376d4a;
  background: rgba(237, 249, 241, .86);
  border: 1px solid rgba(43, 155, 85, .14);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}

.privacy-pill span {
  color: #2b9b55;
  font-size: .6rem;
}

.decoder-section {
  position: relative;
  z-index: 2;
  margin-top: -6.1rem;
  padding-bottom: 4rem;
}

.decoder-shell {
  display: grid;
  grid-template-columns: minmax(350px, .82fr) minmax(480px, 1.18fr);
  align-items: start;
  overflow: hidden;
  background: var(--tool-surface);
  border: 1px solid var(--tool-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.input-panel,
.result-panel {
  min-width: 0;
  padding: 1.35rem;
}

.input-panel {
  background: var(--tool-page);
  border-right: 1px solid var(--tool-border);
}

.result-panel {
  min-height: 720px;
  background: #fff;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-heading h2 {
  margin: .08rem 0 0;
  color: #17374d;
  font-size: 1.25rem;
  line-height: 1.25;
}

.step-label {
  color: var(--brand);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.55rem 1rem;
  text-align: center;
  background: #fff;
  border: 2px dashed #bbd7e5;
  border-radius: 16px;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.drop-zone.is-dragging {
  background: #edf8fd;
  border-color: var(--brand);
  transform: scale(1.01);
}

.drop-zone svg {
  width: 52px;
  height: 52px;
  margin-bottom: .65rem;
  fill: none;
  stroke: var(--brand);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.drop-zone h3 {
  margin-bottom: .15rem;
  color: #17374d;
  font-size: 1rem;
}

.drop-zone p {
  margin-bottom: .9rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.5;
}

.input-actions,
.paste-actions,
.toolbar-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.decoder-button,
.text-button,
.decoder-link-button {
  appearance: none;
  border: 0;
  font: inherit;
}

.decoder-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .52rem .9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 750;
}

.decoder-button.primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 4px 10px rgba(0, 115, 170, .16);
}

.decoder-button.primary:hover {
  background: var(--brand-dark);
}

.decoder-button.secondary {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-color: rgba(0, 115, 170, .14);
}

.decoder-button.ghost {
  color: #536a76;
  background: #fff;
  border-color: #dce5e9;
}

.text-button,
.decoder-link-button {
  padding: .25rem .18rem;
  color: var(--brand);
  background: transparent;
  font-size: .76rem;
  font-weight: 750;
}

.text-button:hover,
.decoder-link-button:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.danger-text {
  color: #9c3e37;
}

.input-divider {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 1rem 0;
  color: #82929a;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.input-divider::before,
.input-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #e4eaed;
}

.field-label {
  display: block;
  margin-bottom: .35rem;
  color: #314c5b;
  font-size: .78rem;
  font-weight: 750;
}

.paste-input,
.paste-actions select,
.field-filter input {
  width: 100%;
  color: #17374d;
  background: #fff;
  border: 1px solid #d6e1e6;
  border-radius: 10px;
  font: inherit;
}

.paste-input {
  min-height: 128px;
  display: block;
  resize: vertical;
  padding: .75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .76rem;
  line-height: 1.5;
}

.paste-input::placeholder,
.field-filter input::placeholder {
  color: #94a2a9;
}

.paste-actions {
  align-items: stretch;
  margin-top: .65rem;
}

.paste-actions label {
  flex: 1 1 190px;
}

.paste-actions select {
  height: 42px;
  padding: 0 2rem 0 .65rem;
  font-size: .76rem;
}

.decoder-settings {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid #e0e8eb;
  border-radius: 11px;
}

.decoder-settings > summary {
  padding: .7rem .8rem;
  color: #3e5967;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 750;
}

.settings-grid {
  display: grid;
  gap: .85rem;
  padding: 0 .8rem .8rem;
}

.range-setting > span {
  display: flex;
  justify-content: space-between;
  margin-bottom: .25rem;
  color: #526975;
  font-size: .73rem;
  font-weight: 650;
}

.range-setting output {
  color: var(--brand-dark);
  font-weight: 800;
}

.range-setting input {
  width: 100%;
  accent-color: var(--brand);
}

.check-setting {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  color: #344f5d;
  font-size: .76rem;
}

.check-setting input {
  margin-top: .22rem;
  accent-color: var(--brand);
}

.check-setting span,
.check-setting small {
  display: block;
}

.check-setting small {
  margin-top: .08rem;
  color: var(--muted);
  line-height: 1.45;
}

.decoder-status {
  display: flex;
  align-items: flex-start;
  gap: .48rem;
  margin-top: 1rem;
  padding: .65rem .75rem;
  color: #526975;
  background: #f3f6f7;
  border-radius: 9px;
  font-size: .75rem;
  line-height: 1.45;
}

.status-indicator {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: .34rem;
  background: #8da0a9;
  border-radius: 50%;
}

.decoder-status[data-kind="working"] .status-indicator {
  background: #d49120;
  box-shadow: 0 0 0 4px rgba(212, 145, 32, .12);
  animation: decoder-pulse 1.1s infinite alternate;
}

.decoder-status[data-kind="success"] .status-indicator {
  background: #2b9b55;
}

.decoder-status[data-kind="partial"] .status-indicator {
  background: #d49120;
}

.decoder-status[data-kind="error"] {
  color: #863a34;
  background: #fff4f2;
}

.decoder-status[data-kind="error"] .status-indicator {
  background: #ba4d44;
}

@keyframes decoder-pulse {
  to { opacity: .45; }
}

.result-heading {
  padding-bottom: .8rem;
  border-bottom: 1px solid #edf1f3;
}

.decoder-empty {
  min-height: 560px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 2rem;
  text-align: center;
  color: #748792;
}

.empty-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: .8rem;
  color: #8db8cc;
  background: #f0f8fb;
  border: 1px solid #e1f0f6;
  border-radius: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.4rem;
  font-weight: 800;
}

.decoder-empty h3 {
  margin-bottom: .2rem;
  color: #375260;
  font-size: 1rem;
}

.decoder-empty p {
  max-width: 420px;
  margin: 0;
  font-size: .8rem;
  line-height: 1.55;
}

.source-tabs {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  margin-bottom: .8rem;
  padding-bottom: .25rem;
}

.source-tabs[hidden],
.decoder-empty[hidden],
.result-view[hidden] {
  display: none !important;
}

.source-tab {
  flex: 0 0 auto;
  max-width: 220px;
  overflow: hidden;
  padding: .42rem .7rem;
  color: #556c78;
  background: #f3f6f7;
  border: 1px solid #e1e7ea;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-tab.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.decoder-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .45rem;
  margin-bottom: .75rem;
}

.summary-card {
  min-width: 0;
  padding: .58rem;
  background: #f7f9fa;
  border: 1px solid #edf1f3;
  border-radius: 9px;
}

.summary-card span,
.summary-card strong {
  display: block;
}

.summary-card span {
  overflow: hidden;
  color: #71838c;
  font-size: .62rem;
  font-weight: 700;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.summary-card strong {
  margin-top: .12rem;
  overflow: hidden;
  color: #17374d;
  font-size: .92rem;
  text-overflow: ellipsis;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  margin-bottom: .75rem;
}

.field-filter {
  flex: 1 1 250px;
}

.field-filter input {
  height: 38px;
  padding: 0 .65rem;
  font-size: .73rem;
}

.decode-tree {
  max-height: 760px;
  overflow: auto;
  padding-right: .15rem;
  scrollbar-color: #bdcbd2 transparent;
}

.payload-node,
.proto-field {
  background: #fff;
  border: 1px solid #dfe8ec;
  border-radius: 10px;
}

.payload-node + .payload-node,
.proto-field + .proto-field {
  margin-top: .48rem;
}

.payload-node.depth-1,
.payload-node.depth-2,
.payload-node.depth-3,
.payload-node.depth-4 {
  margin-top: .65rem;
  border-left: 3px solid #9fc9dc;
}

.payload-summary,
.proto-field-summary {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem .7rem;
  cursor: pointer;
  list-style: none;
}

.payload-summary::-webkit-details-marker,
.proto-field-summary::-webkit-details-marker {
  display: none;
}

.payload-summary::before,
.proto-field-summary::before {
  content: "›";
  flex: 0 0 auto;
  color: #72909f;
  font-size: 1rem;
  font-weight: 800;
  transform: rotate(0);
  transition: transform var(--transition);
}

details[open] > .payload-summary::before,
details[open] > .proto-field-summary::before {
  transform: rotate(90deg);
}

.payload-title {
  min-width: 0;
  flex: 1 1 auto;
}

.payload-title strong,
.payload-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payload-title strong {
  color: #244456;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .77rem;
}

.payload-title small {
  color: #798b94;
  font-size: .62rem;
}

.type-badge,
.wire-badge,
.decode-ok,
.decode-partial {
  flex: 0 0 auto;
  padding: .17rem .42rem;
  border-radius: 999px;
  font-size: .6rem;
  font-weight: 800;
}

.type-badge {
  max-width: 155px;
  overflow: hidden;
  color: #3f6576;
  background: #edf5f8;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-image { color: #6c3974; background: #f7edf9; }
.type-archive,
.type-compressed { color: #805913; background: #fff5df; }
.type-text { color: #376d4a; background: #edf9f1; }
.type-executable { color: #8a342e; background: #fff0ee; }

.payload-size,
.field-offset {
  flex: 0 0 auto;
  color: #7b8d96;
  font-size: .62rem;
  white-space: nowrap;
}

.payload-body,
.proto-field-body {
  padding: .75rem;
  border-top: 1px solid #edf1f3;
}

.payload-metadata,
.payload-inline-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem;
  margin-bottom: .65rem;
}

.payload-metadata code,
.payload-inline-meta code {
  max-width: 100%;
  overflow-x: auto;
  padding: .22rem .42rem;
  color: #536a76;
  background: #f5f7f8;
  border-radius: 5px;
  font-size: .62rem;
  white-space: nowrap;
}

.payload-inline-meta > span {
  color: #647984;
  font-size: .68rem;
  font-weight: 700;
}

.protobuf-message > .protobuf-heading,
.contained-payloads > h3 {
  margin-top: .2rem;
}

.protobuf-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .55rem;
}

.protobuf-heading h3,
.contained-payloads > h3 {
  margin-bottom: 0;
  color: #2a4a5b;
  font-size: .82rem;
  line-height: 1.35;
}

.decode-ok { color: #376d4a; background: #edf9f1; }
.decode-partial { color: #805913; background: #fff5df; }

.protobuf-fields {
  display: grid;
  gap: .4rem;
}

.proto-field {
  background: #fbfcfd;
  border-radius: 8px;
}

.proto-field-summary {
  gap: .42rem;
  padding: .48rem .55rem;
}

.field-number {
  color: #17374d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .72rem;
  font-weight: 800;
}

.wire-badge { color: #496675; background: #eaf1f4; }
.wire-0 { color: #315d85; background: #eaf3fb; }
.wire-1,
.wire-5 { color: #6e4a7a; background: #f4edf7; }
.wire-2 { color: #376d4a; background: #edf9f1; }
.wire-3 { color: #805913; background: #fff5df; }

.field-offset {
  margin-left: auto;
}

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

.decode-values > div {
  min-width: 0;
  padding: .38rem .45rem;
  background: #fff;
  border: 1px solid #edf1f3;
  border-radius: 6px;
}

.decode-values dt {
  color: #7b8c94;
  font-size: .58rem;
  font-weight: 750;
  text-transform: uppercase;
}

.decode-values dd {
  overflow-x: auto;
  margin: .06rem 0 0;
  color: #274858;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .7rem;
  white-space: nowrap;
}

.text-candidate,
.text-preview,
.packed-candidates {
  margin-top: .55rem;
  background: #fff;
  border: 1px solid #e4eaed;
  border-radius: 7px;
}

.text-candidate > summary,
.text-preview > summary,
.packed-candidates > summary {
  padding: .45rem .55rem;
  color: #526b77;
  cursor: pointer;
  font-size: .66rem;
  font-weight: 750;
}

.text-candidate pre,
.text-preview pre,
.packed-set pre {
  max-height: 250px;
  overflow: auto;
  margin: 0;
  padding: .55rem;
  color: #274858;
  background: #f7f9fa;
  border-top: 1px solid #e8edef;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .66rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.packed-set strong {
  display: block;
  padding: .4rem .55rem;
  color: #536a76;
  font-size: .64rem;
}

.decode-note,
.decode-warning {
  margin: .5rem 0;
  padding: .5rem .6rem;
  border-radius: 7px;
  font-size: .67rem;
  line-height: 1.5;
}

.decode-note {
  color: #536a76;
  background: #f4f7f8;
}

.decode-warning {
  color: #805913;
  background: #fff7e7;
  border-left: 3px solid #d9a647;
}

.contained-payloads {
  margin-top: .8rem;
  padding-top: .7rem;
  border-top: 1px solid #edf1f3;
}

.embedded-image {
  width: min(100%, 430px);
  margin: .7rem 0;
  padding: .7rem;
  background:
    linear-gradient(45deg, #edf0f2 25%, transparent 25%),
    linear-gradient(-45deg, #edf0f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0f2 75%),
    linear-gradient(-45deg, transparent 75%, #edf0f2 75%),
    #fff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  border: 1px solid #dce4e8;
  border-radius: 10px;
}

.embedded-image img {
  max-width: 100%;
  max-height: 360px;
  margin: 0 auto;
  object-fit: contain;
}

.embedded-image figcaption {
  margin: .55rem -.7rem -.7rem;
  padding: .4rem .55rem;
  color: #5c727d;
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid #dce4e8;
  font-size: .63rem;
  text-align: center;
}

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

.capability-grid article {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  background: #fff;
  border: 1px solid rgba(12, 56, 77, .08);
  border-radius: 12px;
}

.capability-grid article > span {
  position: absolute;
  top: .35rem;
  right: .6rem;
  color: rgba(0, 115, 170, .11);
  font-size: 1.7rem;
  font-weight: 850;
}

.capability-grid h3 {
  margin-bottom: .25rem;
  color: #274858;
  font-size: .92rem;
}

.capability-grid p {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.55;
}

.article-content code {
  padding: .08rem .28rem;
  color: #294b5c;
  background: #eaf1f4;
  border-radius: 4px;
  font-size: .88em;
}

.decoder-button:focus-visible,
.text-button:focus-visible,
.decoder-link-button:focus-visible,
.source-tab:focus-visible,
.paste-input:focus-visible,
.paste-actions select:focus-visible,
.field-filter input:focus-visible,
.drop-zone:focus-within {
  outline: 3px solid rgba(0, 115, 170, .24);
  outline-offset: 2px;
}

[aria-busy="true"] .result-view,
[aria-busy="true"] .decoder-empty {
  opacity: .58;
}

@media (max-width: 960px) {
  .decoder-shell {
    grid-template-columns: 1fr;
  }

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid #e5edf1;
  }

  .result-panel {
    min-height: 560px;
  }

  .decoder-empty {
    min-height: 380px;
  }
}

@media (max-width: 680px) {
  .decoder-hero {
    padding: 2.2rem 0 7.6rem;
  }

  .decoder-hero::before,
  .decoder-hero::after {
    font-size: 4.5rem;
  }

  .decoder-section {
    margin-top: -5.3rem;
  }

  .decoder-shell {
    margin-inline: -.25rem;
    border-radius: 16px;
  }

  .input-panel,
  .result-panel {
    padding: 1rem;
  }

  .input-actions,
  .paste-actions {
    width: 100%;
  }

  .input-actions .decoder-button,
  .paste-actions .decoder-button,
  .paste-actions label {
    width: 100%;
  }

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

  .result-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .field-filter {
    width: 100%;
    flex: 0 0 auto;
  }

  .toolbar-buttons {
    justify-content: space-between;
  }

  .payload-summary,
  .proto-field-summary {
    flex-wrap: wrap;
  }

  .payload-title {
    flex-basis: calc(100% - 1.6rem);
  }

  .payload-summary .type-badge {
    margin-left: 1.55rem;
  }

  .payload-size {
    margin-left: auto;
  }

  .field-offset {
    width: 100%;
    margin-left: 1.45rem;
  }

  .decode-values,
  .capability-grid {
    grid-template-columns: 1fr;
  }

  .decode-tree {
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .decoder-status[data-kind="working"] .status-indicator {
    animation: none;
  }
}
