:root {
  --bg-base: #070913;
  --bg-surface: #0e1222;
  --bg-card: rgba(20, 26, 48, 0.7);
  --bg-card-hover: rgba(28, 36, 66, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(245, 158, 11, 0.4);
  
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --primary-glow: rgba(245, 158, 11, 0.35);
  --accent-cyan: #38bdf8;
  --accent-purple: #818cf8;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-serif: 'Cinzel', serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(245, 158, 11, 0.08) 0%, transparent 45%);
}

/* Resume Banner */
.resume-banner {
  background: linear-gradient(90deg, #1e1b4b, #312e81);
  border-bottom: 1px solid rgba(129, 140, 248, 0.3);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  animation: slideDown 0.3s ease;
}

.resume-banner.hidden {
  display: none;
}

.resume-content {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.resume-icon {
  font-size: 1.2rem;
}

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

.btn-resume-primary {
  background: var(--primary);
  color: #000;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}

.btn-resume-primary:hover {
  transform: scale(1.04);
}

.btn-resume-dismiss {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1.1rem;
  padding: 4px 8px;
  cursor: pointer;
}

/* App Header */
.app-header {
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(7, 9, 19, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 90;
}

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

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: contain;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.2) 0%, rgba(9, 13, 22, 0.8) 70%);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  flex-shrink: 0;
}

.brand-logo-img:hover {
  transform: scale(1.08) rotate(4deg);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.6);
}

.sphere-logo {
  position: relative;
  width: 38px;
  height: 38px;
}

.sphere-glow {
  position: absolute;
  inset: -4px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(4px);
  animation: pulseGlow 4s infinite alternate;
}

.sphere-core {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 50%, #451a03 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.5), 0 0 12px var(--primary-glow);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #fff;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-install-pwa {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0b0f19;
  font-weight: 700;
  font-size: 0.82rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
  transition: all 0.2s ease;
  animation: pulseInstall 3s infinite alternate;
}

.btn-install-pwa:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.6);
}

.btn-install-pwa.hidden {
  display: none !important;
}

@keyframes pulseInstall {
  0% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.3); }
  100% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.6); }
}

.btn-external-dify {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.btn-external-dify:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.mobile-toggle-btn {
  display: none;
  padding: 8px 14px;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  font-size: 0.82rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Main Container Layout */
.main-container {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  flex: 1;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  height: calc(100vh - 75px);
  overflow: hidden;
}

/* Left Column: Player Panel */
.player-panel {
  padding: 24px 36px;
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.player-panel::-webkit-scrollbar {
  width: 6px;
}
.player-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Cover & Visualizer */
.cover-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 20px;
}

.celestial-orb-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 10px auto 18px;
}

.celestial-halo {
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.3) 0%, rgba(56, 189, 248, 0.15) 50%, transparent 75%);
  filter: blur(12px);
  transition: all 0.5s ease;
}

.celestial-orb {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fde047 0%, #f59e0b 35%, #1e1b4b 85%);
  box-shadow: 
    inset 0 4px 10px rgba(255, 255, 255, 0.6),
    0 10px 30px rgba(0, 0, 0, 0.6),
    0 0 25px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s ease;
}

body.is-playing .celestial-orb {
  animation: rotateOrb 40s linear infinite;
}

body.is-playing .celestial-halo {
  animation: pulseHalo 3s ease-in-out infinite alternate;
}

.orb-symbol {
  font-size: 2.5rem;
  color: #fff;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.celestial-orb-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.6));
  pointer-events: none;
}

.badge-live-chapter {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--border-accent);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 20px;
  margin-bottom: 8px;
}

.current-track-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #fff;
  line-height: 1.3;
}

.current-track-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.4;
}

/* Scrubber Timeline */
.scrubber-container {
  margin: 15px 0;
}

.scrubber-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  cursor: pointer;
  overflow: visible;
}

.scrubber-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  width: 0%;
}

.scrubber-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 4px;
  width: 0%;
}

.scrubber-handle {
  position: absolute;
  right: -7px;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px var(--primary);
  transform: scale(0);
  transition: transform 0.15s ease;
}

.scrubber-bar:hover .scrubber-handle {
  transform: scale(1);
}

.scrubber-timestamps {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Controls */
.controls-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 20px;
}

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

.secondary-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 110px;
}

.secondary-controls.right {
  justify-content: flex-end;
}

.control-btn-play {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--primary-glow);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.control-btn-play:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5);
}

.control-btn-icon {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease;
}

.control-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--primary);
}

.control-btn-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-btn-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.timer-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--primary);
  color: #000;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
}

/* Tabs */
.section-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Chapters List */
.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chapter-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(3px);
}

.chapter-item.active {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--primary);
}

.chapter-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chapter-number {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 28px;
}

.chapter-text h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.chapter-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.chapter-time {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 12px;
}

/* Bookmarks List */
.bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bookmark-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.bookmark-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bookmark-time {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.85rem;
}

.bookmark-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-delete-bookmark {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}

.btn-delete-bookmark:hover {
  color: #ef4444;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 30px 20px;
}

/* Right Column: AI Assistant Panel */
.assistant-panel {
  display: flex;
  flex-direction: column;
  background: rgba(14, 18, 34, 0.6);
  backdrop-filter: blur(8px);
  height: 100%;
}

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

.assistant-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.assistant-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.assistant-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-clear-chat {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.btn-clear-chat:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 90%;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.message-bubble p {
  margin-bottom: 8px;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}
.message-bubble ul, .message-bubble ol {
  margin-left: 18px;
  margin-bottom: 8px;
}
.message-bubble strong {
  color: #fff;
}
.message-bubble em {
  color: var(--primary);
  font-style: italic;
}

.message.typing .message-bubble::after {
  content: '▋';
  display: inline-block;
  margin-left: 4px;
  animation: blink 0.8s infinite;
  color: var(--primary);
}

/* Quick Chips */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--primary);
  color: #fff;
}

/* Chat Input Area */
.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(7, 9, 19, 0.9);
}

.audio-context-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.audio-context-pill strong {
  color: var(--primary);
}

.context-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.context-toggle input {
  accent-color: var(--primary);
  cursor: pointer;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  transition: border-color 0.2s ease;
}

.chat-form:focus-within {
  border-color: var(--primary);
}

.chat-form textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  max-height: 80px;
}

.btn-send {
  background: var(--primary);
  border: none;
  color: #000;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.btn-send:hover {
  transform: scale(1.08);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.hidden {
  display: none;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

.timer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn-timer-opt {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.btn-timer-opt:hover {
  border-color: var(--primary);
  background: rgba(245, 158, 11, 0.12);
}

.btn-timer-opt.cancel {
  grid-column: span 2;
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.input-text {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  margin: 12px 0 16px;
}

.input-text:focus {
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Animations */
@keyframes pulseGlow {
  0% { transform: scale(0.9); opacity: 0.4; }
  100% { transform: scale(1.15); opacity: 0.8; }
}

@keyframes pulseHalo {
  0% { transform: scale(0.95); opacity: 0.5; }
  100% { transform: scale(1.1); opacity: 0.9; }
}

@keyframes rotateOrb {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

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

.hidden {
  display: none !important;
}

/* Responsive Media Queries */
@media (max-width: 900px) {
  .main-container {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .player-panel {
    border-right: none;
    padding: 18px 20px;
    height: auto;
  }

  .mobile-toggle-btn {
    display: block;
  }

  .assistant-panel {
    display: none; /* Toggled on mobile */
    position: fixed;
    inset: 60px 0 0 0;
    z-index: 100;
    background: #070913;
  }

  .assistant-panel.mobile-active {
    display: flex;
  }
}
