:root {
  --bg: #10100e;
  --bg-2: #171714;
  --ink: #ece8e1;
  --muted: #8d877b;
  --line: rgba(236, 232, 225, 0.08);
  --accent: #c4a574;
  --accent-ink: #1a1610;
  --danger: #d27a62;
  --hit: rgba(196, 165, 116, 0.16);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --display: "Syne", "Source Sans 3", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

body {
  background-image:
    radial-gradient(1200px 500px at 8% -10%, rgba(196, 165, 116, 0.08), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(90, 110, 92, 0.08), transparent 50%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  min-height: 100dvh;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--accent);
  background: rgba(196, 165, 116, 0.1);
  border: 1px solid rgba(196, 165, 116, 0.28);
  border-radius: 10px;
  margin-top: 2px;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tag {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.45s var(--ease), background 0.45s var(--ease), transform 0.2s var(--ease);
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  background: var(--ink);
  color: var(--accent-ink);
}

.tab:active {
  transform: scale(0.98);
}

.panel[hidden] {
  display: none;
}

.bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  justify-content: flex-end;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 1rem;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.4s var(--ease);
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: rgba(196, 165, 116, 0.55);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 0 8px 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s var(--ease), filter 0.3s var(--ease);
}

.cta:hover {
  filter: brightness(1.06);
}

.cta:active {
  transform: scale(0.98);
}

.cta:disabled {
  opacity: 0.55;
  cursor: wait;
  filter: none;
}

.cta-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(26, 22, 16, 0.16);
}

.status,
.error {
  margin: 14px 0 0;
  font-size: 0.92rem;
}

.status {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

.error {
  color: var(--danger);
  background: rgba(210, 122, 98, 0.08);
  border: 1px solid rgba(210, 122, 98, 0.22);
  border-radius: 12px;
  padding: 12px 14px;
}

.status[hidden],
.error[hidden] {
  display: none;
}

.empty {
  margin-top: 48px;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(280px, 4fr);
  gap: 16px;
  margin-top: 20px;
  min-height: 62vh;
}

.stage[hidden] {
  display: none;
}

.bezel {
  padding: 6px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.bezel-inner {
  height: 100%;
  min-height: 420px;
  border-radius: 16px;
  overflow: hidden;
  background: #0a0a09;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.player-bezel .bezel-inner {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 0;
  height: auto;
}

#player,
#player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.decode-shell {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: min(72vh, 760px);
}

.decode-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.clock {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.decode-list {
  overflow: auto;
  padding: 8px 0 16px;
  scroll-behavior: smooth;
}

.line {
  padding: 12px 16px;
  border-left: 2px solid transparent;
  transition: background 0.35s var(--ease), border-color 0.35s var(--ease);
}

.line.is-active {
  background: var(--hit);
  border-left-color: var(--accent);
}

.line-meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
}

.line-time {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  min-width: 4.6em;
}

.line-text {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.line-decode {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 58ch;
}

.static-list {
  margin-top: 22px;
  display: grid;
  gap: 2px;
}

.static-list[hidden] {
  display: none;
}

.static-item {
  padding: 16px 4px 18px;
  border-bottom: 1px solid var(--line);
}

.static-item .line-text {
  font-size: 1.05rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 860px) {
  .top {
    flex-direction: column;
    align-items: stretch;
  }

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

  .cta {
    width: 100%;
    justify-content: space-between;
  }

  .stage {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .decode-shell {
    max-height: 52vh;
    min-height: 280px;
  }

  .app {
    padding: 18px 16px 36px;
  }
}
