/* ── Token ─────────────────────────────────────────────────────── */
@property --ac {
  syntax: '<color>';
  inherits: true;
  initial-value: #cdd5ff;
}

:root {
  --ink: #060608;
  --panel: rgba(255, 255, 255, .045);
  --panel-hi: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .09);
  --text: #ececf1;
  --mute: #8d8d99;
  --ok: #4ade80;
  --bad: #fb7185;

  --ac: #cdd5ff;          /* aksen: mengikuti warna platform yang terdeteksi */
  --on-ac: #0a0a0f;       /* warna teks di atas aksen (diatur JS agar kontras) */

  --display: 'Bricolage Grotesque', 'SF Pro Display', ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;

  --spring: cubic-bezier(.34, 1.45, .5, 1);
  color-scheme: dark;
  transition: --ac .7s ease;
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017 19.9%, 1.077 22.8%,
      1.121 25.6%, 1.149 28.8%, 1.159 32.1%, 1.138 38.2%, 1.063 44.6%, 1.014 50%, 0.993 56%, 0.994 62%, 1.001 70%, 1);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.glow {
  position: fixed;
  inset: -10% -20% auto -20%;
  height: 75vh;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(55% 60% at 50% 0%, rgba(160, 170, 255, .2), transparent 72%);
  background: radial-gradient(55% 60% at 50% 0%, color-mix(in srgb, var(--ac) 26%, transparent), transparent 72%);
  filter: blur(24px);
}

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

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

.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

/* ── Dynamic Island ────────────────────────────────────────────── */
.island-wrap {
  position: fixed; z-index: 50; left: 0; right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: flex; justify-content: center;
  pointer-events: none;
}

.island {
  --w: 116px; --h: 34px;
  pointer-events: auto;
  position: relative;
  width: var(--w); height: var(--h);
  border-radius: 999px;
  background: #000;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .08),
    0 14px 40px -14px rgba(0, 0, 0, .9),
    0 0 36px -10px var(--ac);
  transition:
    width .75s var(--spring),
    height .75s var(--spring),
    border-radius .75s var(--spring),
    box-shadow .5s ease;
  will-change: width, height;
  -webkit-tap-highlight-color: transparent;
}

.island[data-state="detect"]  { --w: min(240px, calc(100vw - 24px)); --h: 42px; }
.island[data-state="loading"] { --w: min(280px, calc(100vw - 24px)); --h: 42px; }
.island[data-state="error"]   { --w: min(320px, calc(100vw - 24px)); --h: 42px; }
.island[data-state="toast"]   { --w: min(240px, calc(100vw - 24px)); --h: 42px; }
.island[data-state="success"] { --w: min(360px, calc(100vw - 24px)); --h: 80px; border-radius: 34px; }

.view {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  opacity: 0; filter: blur(8px); transform: scale(.9);
  pointer-events: none;
  transition: opacity .22s ease, filter .3s ease, transform .5s var(--spring);
}

.island[data-state="idle"]    .v-idle,
.island[data-state="detect"]  .v-detect,
.island[data-state="loading"] .v-loading,
.island[data-state="success"] .v-success,
.island[data-state="error"]   .v-error,
.island[data-state="toast"]   .v-toast {
  opacity: 1; filter: none; transform: none; pointer-events: auto;
  transition-delay: .1s;
}

.v-idle { justify-content: center; gap: 8px; }
.idle-name { font: 600 13px/1 var(--display); letter-spacing: .01em; color: rgba(255, 255, 255, .85); }
.breathe {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ac);
  box-shadow: 0 0 10px var(--ac);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(.55); opacity: .55; } }

.txt { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-error .txt { font-weight: 500; }

.tap-hint { font-size: 11px; color: rgba(255, 255, 255, .45); white-space: nowrap; }
@media (max-width: 380px) { .tap-hint { display: none; } }

.spin {
  width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .15); border-top-color: var(--ac);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ico.ok { color: var(--ok); }
.ico.bad { color: var(--bad); }
.island[data-state="error"] { box-shadow: 0 0 0 1px rgba(251, 113, 133, .35), 0 14px 40px -14px #000, 0 0 36px -10px var(--bad); }
.island[data-state="error"] { animation: nudge .45s ease; }
@keyframes nudge { 20% { translate: -5px 0; } 40% { translate: 5px 0; } 60% { translate: -3px 0; } 80% { translate: 2px 0; } }

.v-success { padding: 0 12px; gap: 12px; }
.isl-thumb { width: 56px; height: 56px; flex: none; border-radius: 18px; object-fit: cover; background: #15151b; }
.isl-thumb.broken { visibility: hidden; }
.isl-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.isl-meta strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.isl-meta span { font-size: 12px; color: rgba(255, 255, 255, .55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.isl-act {
  flex: none; height: 38px; padding: 0 18px; border-radius: 999px;
  background: var(--ac); color: var(--on-ac); font-weight: 650; font-size: 13.5px;
}
.isl-act:active { transform: scale(.94); }

/* ikon platform */
.pico {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 8px; overflow: hidden;
  background: #1a1a22;
  background: color-mix(in srgb, var(--c) 30%, #15151b);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
}
.pico b { font: 700 12px/1 var(--display); color: #fff; }
.pico img { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); }
.pico.has-img b { visibility: hidden; }
.pico-slot { display: inline-flex; }

/* ── Layout ────────────────────────────────────────────────────── */
.shell {
  width: min(680px, 100%);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 92px) 20px 56px;
}

.hero h1 {
  margin: 0;
  font: 700 clamp(2.2rem, 8.4vw, 3.7rem)/1.02 var(--display);
  letter-spacing: -.035em;
  font-variation-settings: 'opsz' 72;
  text-wrap: balance;
}
.hero .sub { margin: 16px 0 0; color: var(--mute); font-size: 16px; max-width: 46ch; }

/* ── Input ─────────────────────────────────────────────────────── */
.finder {
  display: flex; align-items: center; gap: 6px;
  margin-top: 32px; padding: 6px 6px 6px 18px;
  background: var(--panel);
  border-radius: 26px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .35s ease, background .35s ease;
}
.finder:focus-within {
  background: var(--panel-hi);
  box-shadow: inset 0 0 0 1.5px var(--ac), 0 0 0 6px color-mix(in srgb, var(--ac) 14%, transparent);
}
.finder.shake { animation: nudge .45s ease; }

.finder input {
  flex: 1; min-width: 0; height: 48px;
  background: none; border: 0; outline: 0; color: var(--text);
  font: 16px/1 var(--body); /* 16px mencegah zoom otomatis di iOS */
}
.finder input::placeholder { color: #5f5f6b; }

.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--mute); }
.icon-btn:hover { background: var(--panel-hi); color: var(--text); }
.icon-btn[hidden] { display: none; }

.paste {
  height: 44px; padding: 0 14px; border-radius: 20px; color: var(--text); font-weight: 550;
  background: var(--panel-hi);
}
.paste:active { transform: scale(.96); }

.go {
  height: 44px; padding: 0 22px; border-radius: 20px;
  background: var(--ac); color: var(--on-ac); font-weight: 700;
  transition: transform .2s var(--spring), opacity .2s;
}
.go:active { transform: scale(.94); }
.go:disabled { opacity: .55; cursor: progress; }

@media (max-width: 440px) {
  .finder { padding-left: 14px; }
  .paste { padding: 0 11px; }
  .go { padding: 0 16px; }
}

.hint { margin: 10px 4px 0; font-size: 13px; color: var(--mute); min-height: 20px; }
.hint b { color: var(--text); font-weight: 600; }

/* ── Notice ────────────────────────────────────────────────────── */
.notice {
  margin-top: 20px; padding: 14px 16px; border-radius: 18px;
  background: rgba(251, 113, 133, .08);
  box-shadow: inset 0 0 0 1px rgba(251, 113, 133, .25);
}
.notice p { margin: 0; color: #ffd5db; }
.notice details { margin-top: 10px; font-size: 13px; color: var(--mute); }
.notice summary { cursor: pointer; }
.notice ul { margin: 8px 0 0; padding-left: 18px; }
.notice code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.notice[hidden], .result[hidden], .history[hidden] { display: none; }

/* ── Hasil ─────────────────────────────────────────────────────── */
.result {
  margin-top: 24px; padding: 16px; border-radius: 28px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  animation: rise .55s var(--spring);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.media { display: flex; gap: 14px; align-items: center; }
.thumb {
  width: 96px; height: 96px; flex: none; border-radius: 22px; overflow: hidden; background: #15151b;
  box-shadow: 0 10px 30px -12px var(--ac);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img.broken { visibility: hidden; }
.meta { min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px;
  background: var(--panel-hi); font-size: 12.5px; font-weight: 600;
}
.badge .pico { width: 20px; height: 20px; border-radius: 7px; }
.badge .pico img { inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); }
.title {
  margin: 0; font: 650 17px/1.3 var(--display);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.author { margin: 0; color: var(--mute); font-size: 13.5px; }

.dl-list, .items { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }

.dl {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 14px; border-radius: 20px;
  background: rgba(255, 255, 255, .035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.dl .ico.kind { color: var(--ac); }
.dl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dl-main strong { font-size: 14.5px; font-weight: 600; }
.dl-main span { font-size: 12.5px; color: var(--mute); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 16px; text-decoration: none;
  font-weight: 650; font-size: 14px; white-space: nowrap;
  transition: transform .2s var(--spring);
}
.btn:active { transform: scale(.94); }
.btn.primary { background: var(--ac); color: var(--on-ac); }
.btn.ghost { background: var(--panel-hi); color: var(--text); }
.btn.icon { width: 40px; padding: 0; }
.btn .ico { width: 18px; height: 18px; }
.dl-actions { display: flex; gap: 6px; }

/* koleksi (playlist / album) */
.items-title { margin: 20px 4px 0; font-size: 13.5px; color: var(--mute); }
.item {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 8px 8px 8px; border-radius: 18px; background: rgba(255, 255, 255, .035);
}
.item .it-thumb { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: #15151b; }
.item .it-thumb.broken { visibility: hidden; }
.it-meta { min-width: 0; }
.it-meta strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it-meta span { display: block; font-size: 12.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .dl-actions { grid-column: 2 / -1; flex-wrap: wrap; }
.item .dl-actions:empty { display: none; }
.item .btn { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 14px; }
.item .btn.icon { width: 36px; padding: 0; }
.item .it-err { grid-column: 2 / -1; font-size: 12.5px; color: var(--bad); }

/* ── Platform ──────────────────────────────────────────────────── */
.platforms { margin-top: 48px; }
.platforms h2, .history h2 { margin: 0 0 14px; font: 650 15px/1.2 var(--display); color: var(--mute); }
.group + .group { margin-top: 18px; }
.group h3 { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: #6f6f7b; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 7px; border-radius: 999px;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13.5px; font-weight: 550; color: #cfcfd8;
  transition: background .25s ease, box-shadow .25s ease, transform .3s var(--spring), color .25s;
}
.chip:hover { background: var(--panel-hi); }
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"], .chip.is-detected {
  background: color-mix(in srgb, var(--c) 16%, #0c0c10);
  box-shadow: inset 0 0 0 1.5px var(--c);
  color: #fff;
}
.chip.off { opacity: .4; }

/* ── Riwayat ───────────────────────────────────────────────────── */
.history { margin-top: 44px; }
.history-head { display: flex; justify-content: space-between; align-items: baseline; }
.link-btn { font-size: 13px; color: var(--mute); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }
#historyList { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.h-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 8px 12px 8px 8px; border-radius: 16px; background: var(--panel);
}
.h-row:hover { background: var(--panel-hi); }
.h-row span.t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }

.foot { margin-top: 56px; color: #6f6f7b; font-size: 12.5px; }
.foot p { margin: 4px 0; max-width: 56ch; }
.foot a { text-underline-offset: 3px; }

/* ── Gerak dikurangi ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
