:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #f1f3f7;
  --text: #15171c;
  --muted: #687082;
  --line: #dce1e8;
  --primary: #0b6e69;
  --primary-strong: #07524e;
  --accent: #d99b2b;
  --shadow: 0 20px 48px rgba(25, 35, 55, 0.12);
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
}

body.dark {
  color-scheme: dark;
  --bg: #111317;
  --surface: #1b1f26;
  --surface-strong: #252b33;
  --text: #f4f6f8;
  --muted: #a5adba;
  --line: #333b47;
  --primary: #63d6cb;
  --primary-strong: #9be5dd;
  --accent: #f2bb55;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(11, 110, 105, 0.16), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.topbar,
.section-heading,
.transport,
.study-tools,
.timeline {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0 18px;
}

.brand-lockup,
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup > div {
  min-width: 0;
}

.header-actions {
  gap: 8px;
}

.app-logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--primary-strong);
  font-weight: 900;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(31, 42, 57, 0.12);
}

.app-logo img,
.about-logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.eyebrow,
.track-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(23px, 7vw, 28px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.icon-button,
.control-button,
.play-button,
.pill-button,
.upload-button,
.text-button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-button,
.control-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(31, 42, 57, 0.08);
}

.header-actions .icon-button {
  width: 44px;
  height: 44px;
}

.icon-button svg,
.control-button svg,
.play-button svg,
.pill-button svg,
.upload-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.control-button text {
  fill: currentColor;
  stroke: none;
  font-size: 7px;
  font-weight: 800;
}

.now-playing {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.artwork {
  display: grid;
  place-items: center;
  height: 178px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 84%, #ffffff), transparent 72%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent) 78%, #ffffff), transparent 60%),
    var(--surface-strong);
  overflow: hidden;
}

.waves {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 80px;
}

.waves span {
  width: 7px;
  height: 24px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  transform-origin: bottom;
}

.is-playing .waves span {
  animation: pulse 820ms ease-in-out infinite alternate;
}

.waves span:nth-child(2) {
  height: 44px;
  animation-delay: 90ms;
}

.waves span:nth-child(3) {
  height: 64px;
  animation-delay: 160ms;
}

.waves span:nth-child(4) {
  height: 38px;
  animation-delay: 220ms;
}

.waves span:nth-child(5) {
  height: 54px;
  animation-delay: 300ms;
}

.track-meta {
  padding-top: 18px;
}

.track-meta h2 {
  margin-bottom: 7px;
  font-size: 24px;
  line-height: 1.2;
}

#trackStatus {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.timeline {
  gap: 10px;
  padding: 18px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--primary);
}

.transport {
  justify-content: center;
  gap: 10px;
  padding: 10px 0 16px;
}

.control-button.small {
  width: 44px;
  height: 44px;
}

.play-button {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
}

.play-button svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  stroke: none;
}

.study-tools {
  justify-content: space-between;
  gap: 12px;
}

.speed-control {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.pill-button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 8px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.playlist-section,
.notes-section {
  padding-top: 24px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 19px;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.playlist {
  display: grid;
  gap: 10px;
}

.track-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 10px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(28, 38, 55, 0.06);
}

.track-row.active {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
}

.track-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--primary-strong);
  font-weight: 800;
}

.track-info strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.track-info span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.track-check {
  color: var(--primary);
  font-size: 18px;
  font-weight: 900;
}

.text-button {
  min-height: 44px;
  background: transparent;
  color: var(--primary-strong);
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 138px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 14px;
  font-size: 16px;
  line-height: 1.5;
}

.about-dialog {
  width: min(calc(100% - 36px), 420px);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  color: var(--text);
}

.about-dialog::backdrop {
  background: rgba(16, 22, 31, 0.42);
  backdrop-filter: blur(6px);
}

.about-card {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 58px 18px 18px;
  box-shadow: var(--shadow);
}

.about-logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
  color: var(--primary-strong);
  font-weight: 900;
}

.logo-loaded + span {
  opacity: 0;
}

.about-card h2,
.about-card p {
  margin-bottom: 4px;
}

.about-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.4;
}

.about-card .version {
  margin-bottom: 0;
  color: var(--primary-strong);
  font-weight: 800;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
}

button:focus-visible,
label:focus-within,
select:focus-visible,
textarea:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 3px;
}

button:active,
.upload-button:active,
.track-row:active {
  transform: scale(0.98);
}

@keyframes pulse {
  from {
    transform: scaleY(0.55);
    opacity: 0.75;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 36px;
  }

  .artwork {
    height: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
