:root {
  --paper: #f4f3ed;
  --ink: #20211e;
  --muted: #62645c;
  --lime: #e8ff70;
  --pink: #ed9dbe;
  --focus: #a33c6d;
  --rule: #d1d2c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.4 Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

::selection {
  background: var(--pink);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.num {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  top: -100px;
  left: 12px;
  padding: 14px;
  background: var(--lime);
  color: var(--ink);
  font-weight: 700;
  z-index: 30;
}

.skip:focus {
  top: 8px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 14px 12px;
}

.top-strip {
  min-height: 62px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 8px 0;
}

.brand-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  min-width: 0;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.divider {
  color: var(--muted);
  font-weight: 700;
}

h1 {
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0;
  font-weight: 900;
}

h1 > span {
  color: var(--focus);
}

.status-text {
  margin: 0 0 0 6px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.source-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.yt-form {
  display: flex;
  align-items: center;
  gap: 0;
  background: #ebe9e0;
  border: 1px solid #d1d2c8;
  border-radius: 5px;
  overflow: visible;
}
.yt-form:focus-within { border-color: var(--focus); }

.yt-input {
  width: clamp(180px, 22vw, 320px);
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 5px 0 0 5px;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--lime);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--lime);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.quiet-button, .load-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-weight: 600;
}
.icon-button { width: 44px; height: 44px; padding: 0; flex: 0 0 44px; }
.load-button { border-left: 1px solid var(--rule); border-radius: 0 4px 4px 0; }
.quiet-button:hover:not(:disabled), .load-button:hover:not(:disabled) {
  background: #e1e2d8;
  color: var(--ink);
}
.quiet-button[aria-pressed="true"] { background: var(--pink); color: var(--ink); }

.stage-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.notice {
  padding: 16px;
  border: 2px solid var(--ink);
  background: var(--pink);
  font-weight: 700;
}

/* Full-viewport visualizer stage */
.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: calc(100vh - 80px);
  min-height: 480px;
  background: #050608;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--ink);
  overflow: hidden;
  user-select: none;
}

#acid-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#acid-canvas:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: -3px;
}

.stage-wrap:fullscreen,
.stage-wrap.is-fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Integrated Look-Ahead Audio Player Bar */
.player-bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 14px;
  background: #20211e;
  color: var(--paper);
  border: 1px solid #51554a;
  border-radius: 4px;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.stage-wrap.player-idle .player-bar:not(:focus-within):not(:hover) {
  opacity: 0;
  pointer-events: none;
}

.player-btn {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 50%;
}
.player-btn:hover:not(:disabled) { background: var(--lime); color: var(--ink); }
.player-btn .icon-pause, .player-btn[data-playing="true"] .icon-play { display: none; }
.player-btn[data-playing="true"] .icon-pause { display: block; }
.player-bar :focus-visible { outline-color: var(--pink); }
.player-bar input[type="range"] { min-height: 44px; }

.track-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.track-title {
  font-weight: 700;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-wrap {
  flex: 1 1 220px;
  height: 44px;
  min-width: 140px;
  background: #111310;
  border: 1px solid #51554a;
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

#timeline-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.track-time {
  font-size: 13px;
  color: #c7cabd;
  white-space: nowrap;
}

.volume-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.volume-wrap input[type="range"] {
  width: 76px;
  accent-color: var(--lime);
  cursor: pointer;
}

@media (max-width: 820px) {
  .yt-form {
    width: 100%;
  }

  .yt-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }

  .stage-wrap {
    height: calc(100vh - 130px);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0 8px 8px;
  }

  .source-controls {
    width: 100%;
  }

  .source-controls > .quiet-button:not(.icon-button) { flex: 1 1 auto; }

  .track-title { max-width: 190px; }
  .player-bar { left: 8px; right: 8px; bottom: 8px; padding: 10px; gap: 8px 12px; }
  .timeline-wrap { flex-basis: 100%; order: 5; }
}
@media (prefers-reduced-motion: reduce) {
  .player-bar { transition: none; }
}
