:root {
  --ink: #13262f;
  --ink-soft: #3a5560;
  --paper: #edf3f5;
  --paper-2: #d7e4e8;
  --foam: rgba(255, 255, 255, 0.72);
  --brass: #b7791f;
  --brass-deep: #8a5a12;
  --signal: #1a7a6d;
  --signal-bright: #2a9b8c;
  --danger: #9b2c2c;
  --warn: #9a6700;
  --ok: #1a6b4a;
  --line: rgba(19, 38, 47, 0.12);
  --shadow: 0 18px 50px rgba(19, 38, 47, 0.12);
  --radius: 4px;
  --font-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.55;
  background:
    radial-gradient(ellipse 90% 60% at 10% -10%, rgba(42, 155, 140, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(183, 121, 31, 0.14), transparent 50%),
    linear-gradient(165deg, #f4f8f9 0%, var(--paper) 40%, var(--paper-2) 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60' viewBox='0 0 120 60'%3E%3Cpath d='M0 30 Q15 10 30 30 T60 30 T90 30 T120 30' fill='none' stroke='%231a7a6d' stroke-opacity='0.12' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 120px 60px;
  animation: wave-drift 28s linear infinite;
  z-index: 0;
}

@keyframes wave-drift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 120px 0;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.65;
  }
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

/* ——— Hero ——— */
.hero {
  min-height: 100vh;
  display: grid;
  align-content: center;
  padding: 3.5rem 0 4rem;
  animation: rise-in 0.8s ease both;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 10vw, 6.5rem);
  letter-spacing: -0.04em;
  line-height: 0.92;
  margin: 0 0 1.25rem;
  color: var(--ink);
}

.brand span {
  color: var(--signal);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.15em;
  vertical-align: middle;
}

.brand-mark i {
  display: block;
  width: 0.18em;
  height: 0.18em;
  border-radius: 50%;
  background: var(--brass);
  animation: pulse-dot 1.8s ease-in-out infinite;
}

.brand-mark i:nth-child(2) {
  width: 0.55em;
  height: 0.18em;
  border-radius: 999px;
  animation-delay: 0.25s;
}

.brand-mark i:nth-child(3) {
  animation-delay: 0.5s;
}

.hero-lead {
  max-width: 34rem;
  margin: 0 0 2rem;
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  color: var(--ink-soft);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 0.85rem 1.35rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--ink);
  color: #f3f8f9;
}

.btn-primary:hover:not(:disabled) {
  background: #0c1a21;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(19, 38, 47, 0.22);
}

.btn-secondary {
  background: transparent;
  border-color: rgba(19, 38, 47, 0.28);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--signal);
  color: var(--signal);
  transform: translateY(-1px);
}

.btn-brass {
  background: var(--brass);
  color: #fffaf0;
}

.btn-brass:hover:not(:disabled) {
  background: var(--brass-deep);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(183, 121, 31, 0.28);
}

.btn.is-playing {
  background: var(--signal);
  border-color: var(--signal);
  color: #fff;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2.5rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
}

.ghost-link:hover {
  color: var(--signal);
}

/* ——— Sections ——— */
.panel-section {
  padding: 0 0 4.5rem;
  animation: rise-in 0.7s ease both;
}

.panel-section:nth-of-type(2) {
  animation-delay: 0.05s;
}

.section-head {
  margin-bottom: 1.25rem;
}

.section-kicker {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-deep);
}

.section-head h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.section-head p {
  margin: 0;
  max-width: 36rem;
  color: var(--ink-soft);
}

.workspace {
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
  background: var(--foam);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

@media (min-width: 860px) {
  .workspace.encode-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .workspace.decode-grid {
    grid-template-columns: 0.95fr 1.05fr;
  }
}

label.field-label {
  display: block;
  margin-bottom: 0.45rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1.5px solid rgba(19, 38, 47, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  padding: 0.9rem 1rem;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus,
input[type="text"]:focus,
.drop-zone:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(26, 122, 109, 0.18);
}

textarea {
  min-height: 160px;
}

.controls {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.slider-row {
  display: grid;
  gap: 0.35rem;
}

.slider-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
}

.slider-top span:last-child {
  color: var(--signal);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--signal);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.mono-box {
  min-height: 8rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px dashed rgba(19, 38, 47, 0.22);
  background: rgba(19, 38, 47, 0.04);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.7;
  letter-spacing: 0.04em;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--ink);
}

.mono-box.is-empty,
.mono-box:empty::before {
  color: var(--ink-soft);
  letter-spacing: 0;
}

.status {
  min-height: 1.4em;
  margin-top: 0.85rem;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 550;
  color: var(--ink-soft);
}

.status[data-type="ok"] {
  color: var(--ok);
}

.status[data-type="error"] {
  color: var(--danger);
}

.status[data-type="warn"] {
  color: var(--warn);
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.side-stack h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 650;
}

.meta {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ——— Drop zone ——— */
.drop-zone {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  min-height: 180px;
  padding: 1.5rem;
  border: 1.5px dashed rgba(19, 38, 47, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--signal);
  background: rgba(42, 155, 140, 0.08);
  transform: translateY(-1px);
}

.drop-zone strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.drop-zone span {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.file-name {
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ——— Footer ——— */
.site-footer {
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 640px) {
  .wrap {
    width: min(1100px, calc(100% - 1.25rem));
  }

  .hero {
    min-height: auto;
    padding-top: 2.5rem;
    padding-bottom: 3rem;
  }

  .workspace {
    padding: 1.1rem;
  }

  .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .cta-row {
    flex-direction: column;
  }
}
