:root {
  /* Smooth Web Easings */
  --dur-snappy: 220ms;
  --ease-snappy: cubic-bezier(0.175, 0.885, 0.32, 1.1);

  --dur-swift: 800ms;
  --ease-spring: linear(
    0 0%, 0.06 1%, 0.217 2%, 0.432 3%, 0.669 4%, 0.895 5%,
    1.087 6%, 1.23 7%, 1.316 8%, 1.349 9%, 1.334 10%,
    1.283 11%, 1.21 12%, 1.128 13%, 1.048 14%, 0.979 15%,
    0.926 16%, 0.893 17%, 0.879 18%, 0.882 19%, 0.898 20%,
    0.923 21%, 0.952 22%, 0.979 23%, 1.003 24%, 1.02 25%,
    1.031 26%, 1.035 27%, 1.032 28%, 1.024 29%, 1.013 30%,
    1.0 69%
  );
  --ease-smooth: cubic-bezier(0.19, 1, 0.22, 1);

  /* Colors */
  --bg: #ffffff;
  --card-bg: #ffffff;
  --surface: rgba(0, 0, 0, 0.02);
  --surface-hover: rgba(0, 0, 0, 0.04);
  --line: rgba(0, 0, 0, 0.12);
  --line-soft: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.1);
  --text: #000000;
  --text-muted: rgba(0, 0, 0, 0.4);
  --text-dim: rgba(0, 0, 0, 0.3);
  --thumb: #000000;
  --shadow-border: rgba(0, 0, 0, 0.04);
  --tooltip-bg: rgba(0, 0, 0, 0.85);
  --tooltip-text: #ffffff;
  --blue: #007aff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --card-bg: #1c1c1e;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --line: rgba(255, 255, 255, 0.12);
    --line-soft: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.15);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-dim: rgba(255, 255, 255, 0.4);
    --thumb: #ffffff;
    --shadow-border: rgba(255, 255, 255, 0.1);
    --tooltip-bg: #ffffff;
    --tooltip-text: #000000;
  }

  .icon-btn img:not(#bgColorIcon),
  .dropzone:not(.dragover) .drop-icon img,
  .player-actions svg {
    filter: invert(1);
  }
}

@supports (color: color(display-p3 1 1 1)) {
  :root {
    --blue: color(display-p3 0.0392 0.4667 1);
  }
}

/* Typography */
@font-face {
  font-family: 'Open Runde';
  src: url('./assets/fonts/OpenRunde-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Open Runde';
  src: url('./assets/fonts/OpenRunde-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Open Runde';
  src: url('./assets/fonts/OpenRunde-Semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Open Runde';
  src: url('./assets/fonts/OpenRunde-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Open Runde', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── Page Layout ─── */
.page {
  width: 540px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
.header {
  position: absolute;
  top: 40px;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
  user-select: none;
  width: 100%;
}

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

.subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ─── Morph Stack (state container) ─── */
.morph-stack {
  width: 100%;
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}

/* ─── Empty State ─── */
.empty-state {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
}

.dropzone {
  position: relative;
  width: 100%;
  height: 358px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s var(--ease-smooth);
}

.dropzone:hover {
  background: var(--surface);
}

.dropzone:active {
  transform: scale(0.99);
}

.dropzone.dragover {
  border-color: var(--blue);
  background: rgba(0, 122, 255, 0.04);
}

.dropzone.dragover .drop-hint {
  color: var(--blue);
  opacity: 1;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.drop-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.drop-hint {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.28px;
}

/* Override Torph's injected styles for centered layouts */
[torph-root] {
  text-align: inherit !important;
}

/* ─── Player State ─── */
.player-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
}

.player-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}

.back-link {
  border: none;
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s ease;
}
.back-link:hover { opacity: 1; }

.player-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 4px;
}

.file-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.player-card {
  width: 100%;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--shadow-border);
}

.stage {
  width: 100%;
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  background-image: 
    linear-gradient(45deg, var(--surface) 25%, transparent 25%), 
    linear-gradient(-45deg, var(--surface) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, var(--surface) 75%), 
    linear-gradient(-45deg, transparent 75%, var(--surface) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  transition: background-color var(--dur-snappy) var(--ease-smooth);
}

.stage.bg-white { background-image: none; background-color: #fff; }
.stage.bg-black { background-image: none; background-color: #000; }

.stage-inner {
  width: 80%;
  height: 80%;
}

/* ─── Transport Controls ─── */
.transport {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  height: 32px;
}

.time {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: -0.26px;
  white-space: nowrap;
  flex-shrink: 0;
}

.scrub-shell {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scrubber {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 32px;
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  margin: 0;
  position: relative;
}

.scrubber::-webkit-slider-runnable-track {
  width: 100%;
  height: 32px;
  background: transparent;
  border-radius: 8px;
}

.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 32px;
  width: 8px;
  background: var(--thumb);
  border-radius: 2px;
  cursor: grab;
  transition: opacity 0.2s var(--ease-smooth);
}

.scrubber:active::-webkit-slider-thumb {
  cursor: grabbing;
}

/* Firefox */
.scrubber::-moz-range-track {
  width: 100%;
  height: 32px;
  background: var(--surface);
  border-radius: 8px;
  border: none;
}

.scrubber::-moz-range-thumb {
  height: 32px;
  width: 8px;
  background: var(--thumb);
  border-radius: 2px;
  border: none;
  cursor: grab;
}

.icon-btn {
  border: none;
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: all 0.2s var(--ease-smooth);
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--surface-hover); }
.icon-btn:active { transform: scale(0.9); }

.transport-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.hidden { display: none !important; }

/* ─── Error Message ─── */
.error {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff3b30;
  color: white;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 99px;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.2);
  margin: 0;
  white-space: nowrap;
}

/* ─── Footer ─── */
.footer {
  position: absolute;
  bottom: 27.5px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.24px;
  color: var(--text-dim);
  user-select: none;
}

/* ─── Tooltips ─── */
.tooltip {
  position: fixed;
  padding: 6px 10px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transform: translateY(4px) scale(0.95);
  transition: opacity 0.2s var(--ease-smooth), transform 0.2s var(--ease-smooth);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

