:root {
  --mobile-spacing: clamp(8px, 3vw, 16px);
  --mobile-font-size: clamp(11px, 2.5vw, 14px);
  --mobile-title-size: clamp(14px, 4vw, 18px);
  --mobile-main-padding: clamp(10px, 4vw, 16px);
}

@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: var(--mobile-font-size);
    line-height: 1.4;
  }

  .app {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    padding: var(--mobile-spacing);
    display: flex;
    align-items: center;
    gap: var(--mobile-spacing);
    flex-shrink: 0;
  }

  .search-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
  }

  .search {
    width: 100%;
    max-width: 220px;
    padding: 8px 12px 8px 36px;
    border-radius: 24px;
    background: var(--panel);
    border: 1px solid #ffffff12;
    font-size: 13px;
    outline: none;
  }

  .search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted);
  }

  .source-select {
    width: 70px;
    height: 32px;
    padding: 0 8px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid #ffffff12;
    font-size: 12px;
  }

  .main {
    flex: 1;
    overflow-y: auto;
    padding: var(--mobile-main-padding);
    padding-top: 60px;
    -webkit-overflow-scrolling: touch;
  }

  .main::-webkit-scrollbar {
    width: 6px;
  }

  .main::-webkit-scrollbar-track {
    background: transparent;
  }

  .main::-webkit-scrollbar-thumb {
    background: #ffffff12;
    border-radius: 3px;
  }

  .hero {
    min-height: 280px;
    margin-bottom: var(--mobile-spacing);
    border-radius: 16px;
    overflow: hidden;
  }

  .hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: 400% 400%;
    animation: gradientFlow 15s ease infinite;
  }

  @keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }

  .hero-content {
    position: relative;
    z-index: 1;
    padding: var(--mobile-spacing);
    display: flex;
    flex-direction: column;
    gap: var(--mobile-spacing);
  }

  .hero h1 {
    font-size: var(--mobile-title-size);
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
  }

  .hero p {
    font-size: var(--mobile-font-size);
    opacity: 0.9;
  }

  .hero-actions {
    display: flex;
    gap: var(--mobile-spacing);
    flex-wrap: wrap;
  }

  .primary, .ghost {
    flex: 1;
    min-width: 120px;
    padding: 10px 16px;
    font-size: 14px;
  }

  .mixes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--mobile-spacing);
    margin-bottom: var(--mobile-spacing);
  }

  .mix {
    aspect-ratio: 1.2;
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel);
    position: relative;
  }

  .cover {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
  }

  .mix-title {
    position: absolute;
    bottom: var(--mobile-spacing);
    left: var(--mobile-spacing);
    right: var(--mobile-spacing);
    font-size: var(--mobile-font-size);
    font-weight: 600;
    margin: 0;
    color: var(--text);
    background: linear-gradient(180deg transparent 60%, #ffffff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .mix-desc {
    position: absolute;
    bottom: var(--mobile-spacing);
    left: var(--mobile-spacing);
    font-size: 11px;
    color: #9995aa;
    margin: 0;
  }

  .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--mobile-spacing);
    padding-bottom: var(--mobile-spacing);
    border-bottom: 1px solid #ffffff12;
  }

  .section-head h2 {
    font-size: var(--mobile-title-size);
    margin: 0;
  }

  .seeall {
    font-size: 12px;
    opacity: 0.7;
  }

  .track-head {
    display: grid;
    grid-template-columns: 20px 1fr 40px;
    gap: 8px;
    padding: 8px;
    font-size: 12px;
    color: #7f8494;
    font-weight: 500;
  }

  .track {
    display: grid;
    grid-template-columns: 20px 1fr 40px;
    gap: 8px;
    padding: 10px;
    font-size: var(--mobile-font-size);
    border-radius: 10px;
    background: var(--panel);
    margin-bottom: var(--mobile-spacing);
    transition: all 0.2s ease;
  }

  .track:hover {
    background: var(--accent);
    color: var(--bg);
  }

  .track:hover .muted {
    color: var(--bg);
  }

  .track strong {
    font-weight: 600;
  }

  .track small {
    font-size: 11px;
    opacity: 0.8;
  }

  .track .thumb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #25253b, #725d8e);
    background-size: cover;
    background-position: center;
  }

  .player {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: linear-gradient(180deg var(--bg), #11141e);
    border-top: 1px solid #ffffff12;
    padding: 8px var(--mobile-spacing);
    display: flex;
    align-items: center;
    gap: var(--mobile-spacing);
  }

  .player-mini .now {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .player-mini .now .thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
  }

  .now strong {
    font-size: 12px;
    font-weight: 600;
    display: block;
    line-height: 1.2;
  }

  .now small {
    font-size: 10px;
    opacity: 0.7;
  }

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

  .ctrl {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
  }

  .ctrl.play {
    background: var(--accent);
    color: var(--bg);
  }

  .primary {
    flex: 1;
    min-width: 0;
  }

  .ghost {
    flex: 0 0 auto;
  }

  .timewrap {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    overflow: hidden;
  }

  .progress {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 80px;
  }

  .progress .bar {
    flex: 1;
    height: 4px;
    background: #ffffff12;
    border-radius: 2px;
    overflow: hidden;
  }

  .progress .bar i {
    height: 100%;
    width: var(--progress-width, 40%);
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.1s step-end;
  }

  #duration, #elapsed {
    font-size: 11px;
    white-space: nowrap;
    min-width: 3ch;
  }

  .skin-pill {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 16px;
  }

  #themes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--mobile-spacing);
  }

  .theme {
    aspect-ratio: 1.4;
    border-radius: 12px;
    padding: 12px;
  }

  .theme .swatch {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    margin-bottom: 8px;
  }

  .theme strong {
    font-size: 13px;
    margin: 0;
  }

  .theme small {
    font-size: 11px;
    opacity: 0.8;
    margin: 0;
  }

  .modal {
    margin: var(--mobile-spacing);
    border-radius: 16px;
    max-height: 80vh;
  }

  .modal-content {
    overflow-y: auto;
    padding: var(--mobile-spacing);
  }

  .toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 24px;
    background: rgba(0,0,0,0.9);
    color: var(--text);
    font-size: 13px;
    z-index: 1000;
    pointer-events: none;
    max-width: 90vw;
  }

  .toast.show {
    animation: toastShow 0.3s ease-out;
  }

  @keyframes toastShow {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }

  @media (max-width: 480px) {
    .topbar {
      padding: 6px;
    }

    .search {
      padding: 6px 10px 6px 32px;
      font-size: 12px;
    }

    .primary, .ghost {
      padding: 8px 12px;
      font-size: 12px;
    }

    .hero {
      min-height: 220px;
    }

    .hero-content {
      padding: 10px;
    }

    .theme {
      aspect-ratio: 1.3;
      padding: 10px;
    }

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

    .modal {
      margin: 6px;
      border-radius: 12px;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-bg {
    animation: none;
  }

  .oto-petal,
  .oto-blossom-branch,
  .oto-blossom {
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  .mobile-search shimmer {
    background: #ffffff12;
  }
}

@media (hover: none) and (pointer: coarse) {
  .track:hover {
    background: var(--panel);
  }

  .track:active {
    background: var(--accent);
    color: var(--bg);
  }
}