:root {
  --bg-color: #070709;
  --panel-bg: rgba(22, 22, 30, 0.75);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent-cyan: #00f0ff;
  --accent-violet: #8a3ffc;
  --accent-glow: rgba(0, 240, 255, 0.4);
  --icon-muted: rgba(255, 255, 255, 0.6);
  --icon-active: #ffffff;
  --danger-color: #ff3366;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: #ffffff;
}

body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 50%, #11111a 0%, #060608 100%);
  position: relative;
}

/* TOP UTILITY BAR */
.top-bar {
  position: absolute;
  top: env(safe-area-inset-top, 14px);
  left: 0;
  right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 env(safe-area-inset-right, 24px) 0 env(safe-area-inset-left, 24px);
  z-index: 20;
  pointer-events: none;
}

.top-actions {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.top-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--icon-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.top-btn:active {
  transform: scale(0.88);
  background: rgba(255, 255, 255, 0.15);
  color: var(--icon-active);
}

.top-btn svg {
  width: 18px;
  height: 18px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00ff88;
  box-shadow: 0 0 10px #00ff88;
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.3s ease;
}

.status-indicator.offline {
  background: var(--danger-color);
  box-shadow: 0 0 10px var(--danger-color);
}

/* MAIN STAGE & APP DOCK */
.main-stage {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px env(safe-area-inset-right, 28px) 20px env(safe-area-inset-left, 28px);
}

.dock-container {
  max-width: 92%;
  max-height: 85%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dock-shelf {
  background: var(--panel-bg);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--panel-border);
  border-radius: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 18px 24px;
  gap: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.dock-shelf::-webkit-scrollbar {
  display: none;
}

/* APP TILE - High-Res Crisp Squircle */
.app-tile {
  flex-shrink: 0;
  width: 82px;
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.app-tile:active {
  transform: scale(0.85);
}

.app-icon-box {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  position: relative;
}

.app-icon-img {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}

.app-tile .active-indicator {
  position: absolute;
  bottom: 0px;
  width: 16px;
  height: 4px;
  background: var(--accent-cyan);
  border-radius: 4px;
  box-shadow: 0 0 14px var(--accent-cyan);
  opacity: 0;
  transform: scaleX(0.4);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.app-tile.active .app-icon-box {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.7);
  box-shadow: 0 12px 32px rgba(0, 240, 255, 0.4);
  transform: translateY(-6px);
}

.app-tile.active .active-indicator {
  opacity: 1;
  width: 28px;
  transform: scaleX(1);
}

/* SIDE DRAG TAB */
.side-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  cursor: pointer;
  padding: 16px 8px 16px 0;
}

.side-tab-pill {
  width: 38px;
  height: 84px;
  background: rgba(26, 26, 36, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-left: none;
  border-radius: 0 20px 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s ease, background 0.2s ease;
}

.side-tab:active .side-tab-pill {
  transform: scale(0.94);
  background: rgba(40, 40, 56, 0.95);
}

.tab-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-cyan);
}

.tab-wave {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 10px;
}

.tab-wave span {
  width: 2.5px;
  height: 3px;
  background: var(--accent-cyan);
  border-radius: 1px;
}

.tab-wave.active span {
  animation: tabBounce 1.2s infinite ease-in-out;
}

.tab-wave.active span:nth-child(2) { animation-delay: 0.2s; }
.tab-wave.active span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tabBounce {
  0%, 100% { height: 3px; }
  50% { height: 10px; }
}

/* SLIDE-OUT MEDIA DRAWER */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.media-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: rgba(18, 18, 26, 0.92);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 16px 0 50px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: env(safe-area-inset-top, 20px) 16px env(safe-area-inset-bottom, 20px) 16px;
}

.media-drawer.open {
  transform: translateX(0);
}

.drawer-drag-handle {
  width: 100%;
  display: flex;
  justify-content: center;
  cursor: pointer;
  padding: 8px 0;
}

.handle-bar {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
}

/* ROTARY VOLUME HUB & SPINNING DISK */
.rotary-hub {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.rotary-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* Start circular fill from 12 o'clock */
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 9;
}

.ring-fill {
  fill: none;
  stroke: url(#cyan-grad);
  stroke: var(--accent-cyan);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 477.5; /* 2 * PI * 76 */
  stroke-dashoffset: 238.7;
  filter: drop-shadow(0 0 8px var(--accent-cyan));
  transition: stroke-dashoffset 0.1s ease-out;
}

/* Center Vinyl Disc */
.vinyl-disc-wrap {
  width: 114px;
  height: 114px;
  position: relative;
  cursor: pointer;
  border-radius: 50%;
  z-index: 5;
}

.vinyl-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #111;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.vinyl-disc.spinning {
  animation: spinVinyl 8s linear infinite;
}

@keyframes spinVinyl {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.album-art {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #1a1a24;
}

.vinyl-center {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #08080a;
  border: 3px solid rgba(255, 255, 255, 0.25);
  z-index: 2;
}

.play-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0.85;
}

.play-overlay .action-icon {
  width: 32px;
  height: 32px;
  color: #ffffff;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.9));
}

/* DRAWER CONTROLS */
.drawer-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.drawer-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--icon-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.drawer-btn:active {
  transform: scale(0.88);
  background: rgba(255, 255, 255, 0.18);
  color: var(--icon-active);
}

.drawer-btn svg {
  width: 22px;
  height: 22px;
}

/* SETTINGS MODAL */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: #14141e;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 22px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-card input {
  background: #08080c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--accent-cyan);
  font-family: monospace;
  font-size: 14px;
  width: 280px;
  outline: none;
}

.modal-btns {
  display: flex;
  gap: 8px;
}

.modal-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon-btn svg {
  width: 20px;
  height: 20px;
}

.save-btn {
  background: var(--accent-cyan);
  color: #070709;
}

.cancel-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.hidden {
  display: none !important;
}

/* PORTRAIT ADAPTATION */
@media (orientation: portrait) {
  .dock-shelf {
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 12px;
    gap: 16px;
    max-height: 80vh;
  }

  .media-drawer {
    width: 280px;
  }
}
