:root {
  --bg-primary: #0b0f19;
  --bg-surface: #151d2f;
  --bg-card: #1c263c;
  --bg-card-active: #253352;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.25);
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #2e3d5b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: calc(160px + var(--safe-bottom));
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px var(--accent-blue-glow);
}

.brand-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 500;
}

/* Pack Selector Pill */
.pack-selector-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pack-selector-btn:hover, .pack-selector-btn:active {
  border-color: var(--accent-blue);
  background: var(--bg-card);
}

.pack-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Pack Switcher Modal */
.pack-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pack-modal.open {
  display: flex;
}

.pack-modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.6);
  animation: modalScale 0.2s ease;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.pack-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pack-modal-title {
  font-size: 16px;
  font-weight: 700;
}

.pack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pack-item {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
}

.pack-item:hover {
  border-color: var(--accent-blue);
}

.pack-item.active {
  border-color: var(--accent-blue);
  background: var(--bg-card-active);
}

.pack-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  border-style: dashed;
}

.pack-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pack-item-name {
  font-size: 14px;
  font-weight: 700;
}

.pack-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.pack-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Category Tabs */
.tabs-container {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-container::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0 4px 12px var(--accent-blue-glow);
}

/* Playlist Info */
.playlist-header {
  padding: 6px 18px 12px;
}

.playlist-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 3px;
}

.playlist-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Track List */
.track-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.track-card:hover {
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.track-card.active {
  background: var(--bg-card-active);
  border-color: var(--accent-blue);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.2);
}

.track-index {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.track-card.active .track-index {
  background: var(--accent-blue);
  color: #fff;
  animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.9; }
  100% { transform: scale(1.05); opacity: 1; }
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-title {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-card.active .track-title {
  color: #60a5fa;
}

.track-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

/* Floating Bottom Player Bar */
.bottom-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(21, 29, 47, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 12px 18px calc(12px + var(--safe-bottom));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}

.time-label.right {
  text-align: right;
}

.progress-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  touch-action: none;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 4px;
  width: 0%;
  position: relative;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -4px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.player-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.now-playing {
  flex: 1;
  min-width: 0;
  margin-right: 12px;
}

.now-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.now-sub {
  font-size: 11.5px;
  color: var(--accent-cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.ctrl-btn:active {
  transform: scale(0.9);
  color: var(--text-primary);
}

.ctrl-btn.play-pause {
  width: 44px;
  height: 44px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 14px var(--accent-blue-glow);
}

/* Loop & Speed & Script Toolbar */
.player-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.tool-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.tool-btn.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border-color: var(--accent-blue);
}

.tool-btn.loop-1 {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: var(--accent-amber);
}

/* Script / Transcript Modal Drawer */
.script-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: flex-end;
}

.script-drawer.open {
  display: flex;
}

.drawer-content {
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 22px calc(24px + var(--safe-bottom));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.drawer-title {
  font-size: 16px;
  font-weight: 700;
}

.drawer-close {
  background: var(--bg-card);
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.tip-box {
  background: rgba(245, 158, 11, 0.1);
  border-left: 4px solid var(--accent-amber);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: #fde68a;
  line-height: 1.4;
}

.script-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.script-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-blue);
}

.script-en {
  font-size: 14.5px;
  line-height: 1.6;
  color: #f1f5f9;
  white-space: pre-line;
  background: var(--bg-card);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.script-vi {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-line;
  background: rgba(255,255,255,0.03);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

/* Toast notifications */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.toast.show {
  opacity: 1;
}
