:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --ink: #17201a;
  --muted: #647069;
  --line: #dce3dd;
  --accent: #167a5b;
  --accent-strong: #0f5f48;
  --blue: #265e9b;
  --amber: #d58b1f;
  --soft: #eef4f1;
  --shadow: 0 18px 50px rgba(23, 32, 26, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(245, 247, 244, 0.9), rgba(245, 247, 244, 1)),
    repeating-linear-gradient(90deg, rgba(22, 122, 91, 0.08) 0 2px, transparent 2px 26px);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(22, 122, 91, 0.48);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-shell {
  width: min(960px, calc(100% - 32px));
  margin: 34px auto 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.file-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.drop-zone {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px dashed rgba(22, 122, 91, 0.48);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(22, 122, 91, 0.08);
}

.drop-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.drop-copy strong,
.drop-copy span {
  overflow-wrap: anywhere;
}

.drop-copy strong {
  font-size: 1.05rem;
}

.drop-copy span {
  color: var(--muted);
}

.player-surface {
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(220, 227, 221, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.transport-row {
  display: grid;
  grid-template-columns: minmax(92px, 128px) 58px 58px minmax(140px, 1fr);
  gap: 10px;
  align-items: center;
}

.primary-button {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  font-weight: 850;
}

.icon-button {
  font-weight: 760;
}

.time-readout {
  justify-self: end;
  min-width: 158px;
  padding: 0 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.timeline {
  position: relative;
  height: 34px;
}

.timeline-track,
.timeline-progress,
.timeline-segment {
  position: absolute;
  top: 10px;
  height: 14px;
  border-radius: 999px;
}

.timeline-track {
  right: 0;
  left: 0;
  background: #e8ede9;
}

.timeline-progress {
  left: 0;
  width: var(--progress);
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.timeline-segment {
  left: var(--segment-left);
  width: var(--segment-width);
  border: 2px solid var(--amber);
  background: rgba(213, 139, 31, 0.2);
}

.seek-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 34px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.marker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.marker-panel,
.loop-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.marker-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 760;
}

.marker-panel strong {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.marker-panel button,
.loop-panel button {
  width: 100%;
}

.loop-button.is-on {
  border-color: var(--blue);
  color: #ffffff;
  background: var(--blue);
}

.speed-panel {
  display: grid;
  gap: 14px;
  padding-top: 4px;
}

.speed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 780;
}

#speedValue {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.speed-controls {
  display: grid;
  grid-template-columns: 92px minmax(160px, 1fr) 92px;
  gap: 12px;
  align-items: center;
}

.step-button {
  padding: 0 10px;
  font-weight: 760;
}

#speedSlider {
  width: 100%;
  accent-color: var(--accent);
}

.speed-presets {
  display: grid;
  grid-template-columns: repeat(9, minmax(54px, 1fr));
  gap: 8px;
}

.speed-presets button {
  min-width: 0;
  padding: 0 8px;
  font-size: 0.9rem;
  font-weight: 760;
}

.speed-presets button.is-active {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.ad-footer {
  display: grid;
  width: min(960px, calc(100% - 32px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0 auto 30px;
}

.ad-slot {
  display: flex;
  min-height: 94px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(38, 94, 155, 0.08), rgba(22, 122, 91, 0.08)),
    #ffffff;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 960px);
    margin-top: 18px;
  }

  .topbar,
  .drop-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .file-button {
    width: 100%;
  }

  .player-surface {
    padding: 16px;
  }

  .transport-row,
  .marker-grid,
  .speed-controls,
  .ad-footer {
    grid-template-columns: 1fr;
  }

  .transport-row {
    grid-template-columns: 1fr 1fr;
  }

  .primary-button {
    grid-column: 1 / -1;
  }

  .time-readout {
    grid-column: 1 / -1;
    justify-self: stretch;
    text-align: center;
  }

  .speed-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .speed-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
