/* ============================================================
   ditto — 세대 공감 오디오 플레이어
   듀얼 테마: [data-theme="modern"] 민트×오렌지 미니멀
             [data-theme="retro"]  Y2K 카세트테이프 아날로그
   캔버스: 390 × 985
   ============================================================ */

:root {
  /* 공통 토큰 */
  --color-accent: #F5793A;
  --color-beige: #E5D5AE;
  --radius-card: 12px;
  --pad-screen: 16px;
  --gap-v: 16px;
  --nav-h: 64px;
  --header-h: 52px;
  --font-sans: "IBM Plex Sans KR", -apple-system, sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;
}

[data-theme="modern"] {
  --color-bg-primary: #BFE3D0;          /* 민트 그린 */
  --color-bg-deep: #A9D6C0;
  --color-card-bg: #1F2D27;             /* 다크 카드 패널 */
  --color-card-bg-2: #2A3B33;
  --color-nav-bg: #142019;
  --color-text-primary: #16211C;
  --color-text-on-card: #F4F1E8;
  --color-text-muted: #5E7268;
  --color-progress-track: rgba(244, 241, 232, 0.18);
  --color-progress-fill: var(--color-accent);
  --grain-opacity: 0;
}

[data-theme="retro"] {
  --color-bg-primary: #E8D5A3;          /* 빛바랜 베이지 */
  --color-bg-deep: #D9C188;
  --color-card-bg: #3B2C20;             /* 카세트 브라운 */
  --color-card-bg-2: #4A382A;
  --color-nav-bg: #2A1F16;
  --color-text-primary: #3B2C20;
  --color-text-on-card: #F2E6C9;
  --color-text-muted: #8A7351;
  --color-progress-track: rgba(242, 230, 201, 0.22);
  --color-progress-fill: #E0552C;
  --grain-opacity: 0.35;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #2c2c2c;
  font-family: var(--font-sans);
  display: flex;
  justify-content: center;
}

.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.hidden { display: none !important; }

/* ===== 폰 캔버스 ===== */
.phone {
  position: relative;
  width: 390px;
  height: 985px;
  max-height: 100vh;
  overflow: hidden;
  background: var(--color-bg-primary);
  background-image: radial-gradient(circle at 20% 0%, rgba(255,255,255,.35), transparent 55%);
  box-shadow: 0 0 60px rgba(0,0,0,.5);
  transition: background-color .5s ease;
  display: flex;
  flex-direction: column;
}

/* 레트로 그레인 */
.phone::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 1px, transparent 1px 3px);
  z-index: 5;
  transition: opacity .5s ease;
}

/* ===== Header ===== */
.header {
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad-screen);
  z-index: 6;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}
.logo-dot { color: var(--color-accent); }
.icon-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--color-text-primary);
  font-size: 19px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,.08); }
.header .icon-btn:first-child { margin-right: auto; }
.header .logo { position: absolute; left: 50%; transform: translateX(-50%); }
.header #btn-settings { margin-left: auto; }

/* ===== Screens ===== */
.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 var(--pad-screen) calc(var(--nav-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: var(--gap-v);
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }

/* ===== Discovery Badge ===== */
.badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.badge-discovery {
  margin-left: auto;
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: 20px;
  font-family: var(--font-mono);
}
.hero-caption {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  opacity: .75;
}

/* ===== Hero Card ===== */
.hero-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--color-text-on-card);
  transition: background-color .5s ease;
}
.hero-art {
  width: 84px; height: 84px;
  flex: 0 0 84px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-accent), #8a3d1c);
  background-size: cover;
  background-position: center;
}
.hero-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.hero-sub { font-size: 12px; opacity: .7; line-height: 1.5; margin-bottom: 10px; }
.hero-play {
  border: none;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-sans);
}

/* ===== View Toggle (RETRO / grid / MODERN) ===== */
.view-toggle {
  align-self: center;
  display: flex;
  background: var(--color-card-bg);
  border-radius: 20px;
  padding: 4px;
  gap: 4px;
}
.vt-btn {
  border: none;
  background: transparent;
  color: var(--color-text-on-card);
  opacity: .55;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  letter-spacing: .06em;
}
.vt-btn.active {
  background: var(--color-accent);
  color: #fff;
  opacity: 1;
}

/* ===== Pair list ===== */
.section-title {
  font-size: 17px;
  color: var(--color-text-primary);
  margin-top: 4px;
}
.pair-list { display: grid; gap: 12px; }
.pair-list.grid { grid-template-columns: 1fr 1fr; }
.pair-list.list { grid-template-columns: 1fr; }

.pair-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-card);
  padding: 12px;
  color: var(--color-text-on-card);
  cursor: pointer;
  transition: transform .15s ease, background-color .5s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pair-list.list .pair-card { flex-direction: row; align-items: center; }
.pair-card:hover { transform: translateY(-2px); }
.pair-art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--color-card-bg-2);
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}
.pair-list.list .pair-art { width: 56px; height: 56px; flex: 0 0 56px; aspect-ratio: auto; }
.pair-years {
  position: absolute;
  left: 6px; bottom: 6px;
  background: rgba(0,0,0,.65);
  color: var(--color-beige);
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 10px;
}
.pair-title { font-size: 13px; font-weight: 700; line-height: 1.3; }
.pair-sub { font-size: 11px; opacity: .65; line-height: 1.4; }
.pair-remove {
  margin-left: auto;
  border: none; background: transparent;
  color: var(--color-text-on-card);
  opacity: .5; cursor: pointer; font-size: 16px;
}

/* ===== Search ===== */
.search-box { display: flex; gap: 8px; }
.search-box input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: rgba(255,255,255,.75);
  color: #1c1c1c;
  outline: none;
}
.search-box button {
  border: none;
  border-radius: 20px;
  padding: 0 18px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}
.search-hint {
  font-size: 11px;
  color: var(--color-text-primary);
  opacity: .6;
  line-height: 1.5;
}
.search-results { display: flex; flex-direction: column; gap: 10px; }
.result-row {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--color-card-bg);
  color: var(--color-text-on-card);
  border-radius: var(--radius-card);
  padding: 10px 12px;
  cursor: pointer;
}
.result-art { width: 48px; height: 48px; border-radius: 6px; background-size: cover; flex: 0 0 48px; }
.result-meta { min-width: 0; }
.result-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-sub { font-size: 11px; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-year { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--color-beige); }

/* ===== Player ===== */
.player-badge-row { margin-top: 4px; }
.mode-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--color-card-bg);
  color: var(--color-beige);
}
[data-theme="retro"] .mode-chip { color: #FFD9A0; }

.album-card {
  align-self: center;
  background: var(--color-card-bg);
  border-radius: var(--radius-card);
  padding: 16px;
  transition: background-color .5s ease;
}
.album-art {
  width: 200px; height: 200px;
  border-radius: 12px;
  background: var(--color-card-bg-2);
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}

/* 카세트 오버레이 — 레트로 모드 전용 */
.cassette-overlay {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 12px;
  background: linear-gradient(transparent 40%, rgba(30,18,8,.78));
}
[data-theme="retro"] .cassette-overlay { display: flex; }
.cassette-window {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20,12,6,.85);
  border: 1px solid rgba(242,230,201,.3);
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 6px;
}
.reel {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px dashed var(--color-beige);
}
.playing .reel { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tape-line { width: 46px; height: 3px; background: #6b4e2e; border-radius: 2px; }
.cassette-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .18em;
  color: var(--color-beige);
}

.song-info { text-align: center; }
.song-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}
.song-subtitle { font-size: 13px; color: var(--color-text-primary); opacity: .65; }
.source-tag {
  margin-top: 8px;
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-primary);
  opacity: .55;
  border: 1px solid currentColor;
  border-radius: 12px;
  padding: 2px 10px;
}

/* ===== Progress ===== */
.progress-area { padding: 0 4px; }
.progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--color-progress-fill) 0%,
    var(--color-progress-fill) var(--pct, 0%),
    var(--color-progress-track) var(--pct, 0%),
    var(--color-progress-track) 100%);
  outline: none;
  cursor: pointer;
}
.progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
}
.progress::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
}
.time-row { display: flex; justify-content: space-between; margin-top: 6px; }
.time { font-size: 11px; color: var(--color-text-primary); opacity: .7; }

/* ===== Controls ===== */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}
.ctrl-btn {
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s ease;
}
.ctrl-btn:active { transform: scale(.93); }
.ctrl-btn.small {
  width: 40px; height: 40px;
  background: var(--color-card-bg);
  color: var(--color-text-on-card);
  font-size: 15px;
}
.ctrl-btn.play {
  width: 56px; height: 56px;
  background: var(--color-accent);
  color: #fff;
  font-size: 21px;
  box-shadow: 0 6px 18px rgba(245,121,58,.45);
}
.signal-caption {
  text-align: center;
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--color-text-primary);
  opacity: .55;
  margin-top: -6px;
}

/* ===== Year Selector / Time Shuttle ===== */
.year-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-card-bg);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  transition: background-color .5s ease;
}
.year-side { display: flex; flex-direction: column; gap: 2px; min-width: 58px; }
.year-side.selected { text-align: right; }
.year-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .14em;
  opacity: .6;
}
.year-side.original .year-label,
.year-side.original .year-value { color: var(--color-beige); }
.year-side.selected .year-label,
.year-side.selected .year-value { color: var(--color-accent); }
.year-value { font-size: 18px; font-weight: 700; }

.shuttle {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--color-beige), var(--color-accent));
  outline: none;
  cursor: grab;
}
.shuttle:active { cursor: grabbing; }
.shuttle::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--color-accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.shuttle::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--color-accent);
}
.shuttle:disabled { opacity: .35; cursor: not-allowed; }
.shuttle-caption {
  text-align: center;
  font-size: 10px;
  letter-spacing: .26em;
  color: var(--color-text-primary);
  opacity: .5;
  margin-top: -8px;
}

/* ===== FAB ===== */
.fab {
  position: absolute;
  right: 16px;
  bottom: calc(var(--nav-h) + 16px);
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  z-index: 7;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--nav-h);
  background: var(--color-nav-bg);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 24px;
  z-index: 8;
  transition: background-color .5s ease;
}
.nav-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,.55);
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: .06em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 6px 14px;
}
.nav-ico { font-size: 18px; }
.nav-btn.active { color: var(--color-accent); }

/* ===== Glitch overlay ===== */
.glitch-overlay {
  position: absolute; inset: 0;
  z-index: 20;
  background: rgba(10, 8, 6, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: glitch-flicker .12s steps(2) infinite;
}
.glitch-scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg,
    rgba(255,255,255,.07) 0 2px, transparent 2px 5px);
  animation: scan-roll .35s linear infinite;
}
.glitch-text {
  color: var(--color-beige);
  font-size: 15px;
  letter-spacing: .3em;
  text-shadow: 2px 0 #F5793A, -2px 0 #3AB5F5;
  animation: glitch-jitter .1s steps(2) infinite;
}
@keyframes glitch-flicker { 50% { opacity: .85; } }
@keyframes scan-roll { to { transform: translateY(5px); } }
@keyframes glitch-jitter {
  25% { transform: translate(-2px, 1px); }
  75% { transform: translate(2px, -1px); }
}

/* ===== Modal ===== */
.modal {
  position: absolute; inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  width: 100%;
  background: #FDF8EC;
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #2a2a2a;
}
.modal-card h3 { font-size: 17px; margin-bottom: 4px; }
.field-label { font-size: 12px; font-weight: 600; margin-top: 6px; }
.modal-card input, .modal-card select {
  border: 1px solid #d8cfb8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  background: #fff;
  outline: none;
}
.field-help { font-size: 11px; color: #8a8068; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btn {
  border: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}
.btn.primary { background: var(--color-accent); color: #fff; }
.btn.ghost { background: transparent; color: #6b6352; }

/* ===== Toast ===== */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--nav-h) + 76px);
  transform: translateX(-50%);
  background: rgba(20,20,20,.9);
  color: #fff;
  font-size: 12px;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 25;
  white-space: nowrap;
}

/* ===== YouTube hidden mounts ===== */
.yt-mount {
  position: absolute;
  width: 1px; height: 1px;
  bottom: 0; left: 0;
  opacity: 0.01;
  pointer-events: none;
  overflow: hidden;
}

/* ===== Loading skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.06) 25%, rgba(255,255,255,.16) 50%, rgba(255,255,255,.06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
