/* =========================================================================
   CloudStream — Universal Cloud Video Player
   Stylesheet (dark + light, responsive, modern minimalist)
   ========================================================================= */

/* ---- design tokens ---- */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', ui-monospace, Menlo, Monaco, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --tap: 40px;

  --sb-w: 286px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --accent: #7c5cff;
  --accent-2: #4ea8ff;
  --accent-grad: linear-gradient(120deg, #7c5cff 0%, #4ea8ff 100%);
  --danger: #ff5c7c;
  --success: #2dd4a7;
  --warning: #ffb454;
}

/* ---- dark theme (default) ---- */
[data-theme='dark'] {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --bg-3: #161b28;
  --bg-elev: #1b2230;
  --surface: #161b28;
  --surface-2: #1f2636;
  --border: #232b3d;
  --border-soft: #1a2030;
  --text: #e8edf6;
  --text-2: #aeb8cc;
  --muted: #6b7689;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 70px -20px rgba(0, 0, 0, 0.7);
  --glow: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 8px 30px -8px rgba(124, 92, 255, 0.4);
  --player-bg: #05070c;
  --sub-bg: rgba(0, 0, 0, 0.65);
}

/* ---- light theme ---- */
[data-theme='light'] {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --bg-3: #eef1f7;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --border: #e2e7f0;
  --border-soft: #edf1f7;
  --text: #1a2030;
  --text-2: #4a5568;
  --muted: #8a94a8;
  --shadow: 0 8px 30px -10px rgba(20, 30, 60, 0.12);
  --shadow-lg: 0 20px 55px -18px rgba(20, 30, 60, 0.2);
  --glow: 0 0 0 1px rgba(124, 92, 255, 0.3), 0 8px 30px -8px rgba(124, 92, 255, 0.3);
  --player-bg: #05070c;
  --sub-bg: rgba(0, 0, 0, 0.55);
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---- helpers ---- */
.cs-muted { color: var(--muted); }
.cs-grad {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cs-hidden { display: none !important; }
.cs-icon, .cs-svg { display: inline-block; vertical-align: middle; }
.cs-icon.cs-inline .cs-svg { width: 16px; height: 16px; }
.cs-svg { width: 20px; height: 20px; fill: currentColor; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- app shell ---- */
.cs-app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.cs-sidebar-wrap { flex: 0 0 var(--sb-w); height: 100%; overflow: hidden; }
.cs-main { flex: 1; min-width: 0; height: 100%; overflow-y: auto; overflow-x: hidden; position: relative; }

/* ---- sidebar ---- */
.cs-sidebar {
  width: var(--sb-w);
  height: 100%;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 14px 14px;
  gap: 6px;
}
.cs-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 8px 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.cs-brand-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(124, 92, 255, 0.6);
}
.cs-brand-logo .cs-svg { width: 22px; height: 22px; }
.cs-brand-text { display: flex; flex-direction: column; }
.cs-brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.2px; }
.cs-brand-sub { font-size: 11px; color: var(--muted); }

.cs-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.cs-nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.cs-nav-item:hover { background: var(--bg-3); color: var(--text); }
.cs-nav-item.cs-active { background: var(--surface-2); color: var(--text); }

.cs-side-section { padding: 8px 0; display: flex; flex-direction: column; gap: 3px; }
.cs-side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 11px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
}
.cs-side-count {
  background: var(--surface-2); color: var(--text-2);
  padding: 1px 7px; border-radius: 20px; font-size: 10px;
}
.cs-side-empty { padding: 4px 11px 8px; font-size: 12.5px; }

.cs-provider-item { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); }
.cs-provider-item.cs-active { background: var(--surface-2); }
.cs-provider-link { flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.cs-provider-glyph {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 15px; color: #fff;
  flex-shrink: 0;
}
.cs-provider-glyph.cs.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 13px; }
.cs-provider-meta { display: flex; flex-direction: column; min-width: 0; }
.cs-provider-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-provider-account { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-icon-btn { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); transition: 0.15s; flex-shrink: 0; }
.cs-icon-btn:hover { background: var(--bg-3); color: var(--text); }
.cs-icon-btn .cs-svg { width: 17px; height: 17px; }
.cs-icon-btn.cs-active { color: var(--warning); }

.cs-history-item {
  display: flex; gap: 10px; padding: 8px; border-radius: var(--radius-sm);
  text-align: left; transition: background 0.15s; align-items: center;
}
.cs-history-item:hover { background: var(--bg-3); }
.cs-history-thumb {
  width: 44px; height: 30px; border-radius: 6px;
  background: var(--surface-2); display: grid; place-items: center;
  color: var(--muted); flex-shrink: 0; overflow: hidden;
}
.cs-history-thumb.cs-fav { color: var(--warning); }
.cs-history-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cs-history-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-history-meta { font-size: 11px; display: flex; gap: 5px; }
.cs-history-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.cs-history-bar-fill { height: 100%; background: var(--accent-grad); transition: width 0.3s var(--ease); }

.cs-sidebar-footer { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border-soft); }

/* ---- buttons ---- */
.cs-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14px;
  border: 1px solid var(--border);
  transition: transform 0.1s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.cs-btn:hover { background: var(--bg-3); border-color: var(--muted); }
.cs-btn:active { transform: translateY(1px); }
.cs-btn.cs-primary { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: 0 6px 18px -8px rgba(124,92,255,0.6); }
.cs-btn.cs-primary:hover { box-shadow: 0 8px 24px -8px rgba(124,92,255,0.75); filter: brightness(1.05); }
.cs-btn.cs-danger { color: var(--danger); border-color: var(--border); }
.cs-btn.cs-danger:hover { background: rgba(255,92,124,0.12); border-color: var(--danger); }
.cs-btn.cs-ghost { background: transparent; border-color: transparent; }
.cs-btn.cs-ghost:hover { background: var(--bg-3); }
.cs-btn-block { width: 100%; }
.cs-btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
.cs-btn-add { border-style: dashed; color: var(--accent); background: transparent; }
.cs-btn-add:hover { background: rgba(124,92,255,0.1); border-color: var(--accent); }
.cs-btn-back { padding: 6px 10px; font-size: 13px; }
.cs-modal-close { width: 34px; height: 34px; padding: 0; font-size: 22px; line-height: 1; border-radius: 8px; color: var(--muted); background: transparent; border: 0; }
.cs-modal-close:hover { background: var(--bg-3); color: var(--text); }

/* ---- inputs ---- */
.cs-input {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cs-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,0.18); }
.cs-input::placeholder { color: var(--muted); }
.cs-mono { font-family: var(--mono); font-size: 12.5px; }
select.cs-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7689'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 34px; }
.cs-color-input { width: 56px; height: 38px; padding: 3px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg); cursor: pointer; }

/* ---- mobile menu toggle (hidden on desktop) ---- */
.cs-mobile-menu { display: none; position: fixed; top: 12px; left: 12px; z-index: 50; width: 42px; height: 42px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); place-items: center; }

/* =========================================================================
   HOME
   ========================================================================= */
.cs-home { max-width: 1180px; margin: 0 auto; padding: 28px 32px 60px; }

.cs-hero {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px;
  align-items: center; padding: 28px 0 40px;
}
.cs-hero-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 30px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  margin-bottom: 20px;
}
.cs-hero-badge .cs-svg { width: 15px; height: 15px; color: var(--success); }
.cs-hero-title { font-size: clamp(32px, 5vw, 52px); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.cs-hero-sub { margin-top: 18px; font-size: 16px; max-width: 540px; color: var(--text-2); }
.cs-hero-actions { margin-top: 26px; display: flex; gap: 12px; flex-wrap: wrap; }

.cs-hero-visual { display: grid; place-items: center; }
.cs-hero-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg);
}
.cs-hero-card-bar { display: flex; gap: 6px; padding: 12px 14px; background: var(--bg-3); }
.cs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.cs-hero-card-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.cs-hero-player {
  aspect-ratio: 16/9; border-radius: 12px; background: var(--player-bg);
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.cs-hero-play {
  width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.15);
  backdrop-filter: blur(6px); display: grid; place-items: center; color: #fff;
}
.cs-hero-play .cs-svg { width: 28px; height: 28px; }
.cs-hero-subs { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
.cs-hero-row { display: flex; gap: 7px; flex-wrap: wrap; }
.cs-hero-chip { padding: 5px 11px; border-radius: 20px; background: var(--bg-3); border: 1px solid var(--border); font-size: 12px; font-weight: 500; }

.cs-home-section { margin-top: 42px; }
.cs-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.cs-section-head h2 { font-size: 21px; font-weight: 700; }
.cs-link-btn { font-size: 13px; color: var(--muted); padding: 4px; }
.cs-link-btn:hover { color: var(--text); }

.cs-provider-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.cs-provider-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 13px 8px 8px;
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border);
  transition: 0.15s;
}
.cs-provider-chip:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.cs-provider-chip-meta { display: flex; flex-direction: column; }
.cs-provider-chip-name { font-size: 13.5px; font-weight: 600; }

.cs-history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.cs-history-card {
  text-align: left; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  transition: 0.18s var(--ease); display: flex; flex-direction: column;
}
.cs-history-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.cs-history-card-thumb {
  aspect-ratio: 16/9; background: var(--bg-3); display: grid; place-items: center;
  color: var(--muted); position: relative; overflow: hidden;
}
.cs-history-card-thumb .cs-svg { width: 30px; height: 30px; }
.cs-history-card-thumb.cs-fav { color: var(--warning); }
.cs-history-card-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,0.35); opacity: 0; transition: 0.2s;
}
.cs-history-card-play .cs-svg { width: 38px; height: 38px; color: #fff; }
.cs-history-card:hover .cs-history-card-play { opacity: 1; }
.cs-history-card-info { padding: 10px 11px 11px; display: flex; flex-direction: column; gap: 5px; }
.cs-history-card-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-history-card-meta { font-size: 11.5px; }

.cs-provider-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cs-provider-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: 0.18s;
}
.cs-provider-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.cs-provider-card-head { display: flex; align-items: center; gap: 10px; }
.cs-provider-card-name { font-size: 15px; font-weight: 700; }
.cs-provider-card-state { font-size: 11.5px; }
.cs-provider-card-desc { font-size: 13px; flex: 1; }
.cs-provider-card-foot { margin-top: auto; }

.cs-features .cs-feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cs-feature { display: flex; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cs-feature-icon {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: var(--accent-grad); color: #fff; display: grid; place-items: center;
}
.cs-feature-icon .cs-svg { width: 22px; height: 22px; }
.cs-feature-title { font-size: 15px; font-weight: 700; }
.cs-feature-desc { font-size: 13px; margin-top: 3px; }

.cs-home-foot { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border-soft); text-align: center; font-size: 12.5px; }

/* =========================================================================
   BROWSE VIEW
   ========================================================================= */
.cs-browse { max-width: 1180px; margin: 0 auto; padding: 28px 32px 60px; }
.cs-browse-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.cs-browse-title { display: flex; align-items: center; gap: 13px; }
.cs-browse-h { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.cs-browse-sub { font-size: 13px; }
.cs-browse-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.cs-search { position: relative; }
.cs-search-input { padding-left: 38px; width: 240px; }
.cs-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.cs-search-icon .cs-svg { width: 17px; height: 17px; }

.cs-view-toggle { display: flex; gap: 3px; }

.cs-crumbs { display: flex; align-items: center; gap: 4px; min-height: 32px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13.5px; }
.cs-crumb { color: var(--muted); font-weight: 500; padding: 5px 7px; border-radius: var(--radius-sm); transition: 0.15s; }
.cs-crumb:hover { background: var(--bg-3); color: var(--text); }
.cs-crumb-sep .cs-svg { width: 15px; height: 15px; color: var(--border); }

.cs-file-section-label { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 12px; margin-bottom: 2px; }
.cs-file-group { display: grid; grid-column: 1 / -1; grid-template-columns: inherit; gap: inherit; }
.cs-file-list { display: grid; gap: 14px; }
.cs-view-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.cs-view-list { grid-template-columns: 1fr; }

.cs-file-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: 0.18s var(--ease);
  display: flex; flex-direction: column;
}
.cs-file-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.cs-file-thumb {
  position: relative; aspect-ratio: 16/9; background: var(--bg-3);
  display: grid; place-items: center; color: var(--muted); overflow: hidden;
}
.cs-thumb-folder { aspect-ratio: 1; background: var(--bg-3); }
.cs-thumb-folder .cs-svg { width: 32px; height: 32px; color: var(--warning); }
.cs-thumb-video .cs-svg { width: 32px; height: 32px; }
.cs-thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cs-thumb-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,0.45); opacity: 0; transition: 0.2s;
}
.cs-thumb-play .cs-svg { width: 42px; height: 42px; color: #fff; }
.cs-thumb-duration {
  position: absolute; bottom: 7px; right: 7px;
  background: rgba(0,0,0,0.7); color: #fff;
  padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 700;
}
.cs-file-card:hover .cs-thumb-play { opacity: 1; }
.cs-file-body { padding: 10px 11px 11px; display: flex; flex-direction: column; gap: 4px; }
.cs-file-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-file-name-btn { text-align: left; color: var(--text); }
.cs-file-meta { font-size: 11.5px; }
.cs-file-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.cs-fav-btn .cs-svg { width: 17px; height: 17px; }
.cs-fav-btn.cs-active { color: var(--warning); }

/* list mode tweaks */
.cs-view-list .cs-file-card { flex-direction: row; align-items: center; }
.cs-view-list .cs-file-thumb { width: 90px; aspect-ratio: 16/9; flex-shrink: 0; border-radius: 0; }
.cs-view-list .cs-file-body { flex-direction: row; align-items: center; flex: 1; gap: 12px; padding: 10px 16px; }
.cs-view-list .cs-file-name { flex: 1; }
.cs-view-list .cs-file-meta { margin: 0; }
.cs-view-list .cs-file-card:hover { transform: translateX(2px) translateY(0); }

.cs-folder-card { cursor: pointer; }
.cs-folder-card .cs-file-thumb { aspect-ratio: 1; }

.cs-loading-state { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 64px 0; color: var(--muted); }
.cs-empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 80px 0; text-align: center; }
.cs-empty-icon { color: var(--border); margin-bottom: 4px; }
.cs-empty-icon .cs-svg { width: 56px; height: 56px; }

/* =========================================================================
   VIDEO PLAYER
   ========================================================================= */
.cs-player-view { display: flex; flex-direction: column; height: 100%; background: var(--player-bg); }
.cs-player-stage {
  position: relative; flex: 1; min-height: 0;
  background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cs-video { width: 100%; height: 100%; max-height: 100%; object-fit: contain; display: block; }

/* ---- subtitle overlay ---- */
.cs-sub-overlay {
  position: absolute; left: 0; right: 0; pointer-events: none; z-index: 15;
  bottom: var(--cs-sub-bottom, 8%); top: var(--cs-sub-top, auto);
  display: flex; justify-content: center; align-items: flex-end;
  text-align: center; padding: 0 5%;
  font-family: var(--cs-sub-font, Inter, sans-serif);
  font-size: var(--cs-sub-font-size, 20px);
}
.cs-subcue {
  display: inline-block; padding: 6px 14px; border-radius: 6px;
  color: var(--cs-sub-color, #fff); background: var(--cs-sub-bg, rgba(0,0,0,0.65));
  text-shadow: var(--cs-sub-shadow, none);
  -webkit-text-stroke: 0; font-weight: 600; line-height: 1.45;
  max-width: 86%;
}

/* ---- spinner ---- */
.cs-spinner { position: absolute; z-index: 20; display: flex; align-items: center; justify-content: center; inset: 0; pointer-events: none; }
.cs-spinner-ring {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3.5px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- big play btn ---- */
.cs-bigplay {
  position: absolute; z-index: 18; width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(8px);
  color: #fff; display: grid; place-items: center; border: 2px solid rgba(255,255,255,0.3);
  transition: transform 0.2s, background 0.2s;
}
.cs-bigplay:hover { background: rgba(255,255,255,0.25); transform: scale(1.08); }
.cs-bigplay .cs-svg { width: 36px; height: 36px; }

/* ---- controls overlay ---- */
.cs-controls {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 25;
  background: linear-gradient(0deg, rgba(0,0,0,0.78) 0%, transparent 100%);
  padding: 12px 12px 10px;
  opacity: 0; transition: opacity 0.25s var(--ease);
  transform: translateY(4px);
  display: flex; flex-direction: column; gap: 8px;
}
.cs-controls.cs-visible, .cs-player-stage:hover .cs-controls, .cs-player-stage.cs-paused .cs-controls { opacity: 1; transform: translateY(0); }

/* ---- progress bar ---- */
.cs-progress {
  position: relative; height: 5px; border-radius: 4px;
  background: rgba(255,255,255,0.15); cursor: pointer; margin: 0 2px;
  transition: height 0.2s;
}
.cs-controls:hover .cs-progress, .cs-progress:hover { height: 7px; }
.cs-progress-fill { height: 100%; border-radius: 4px; background: var(--accent-grad); pointer-events: none; }
.cs-progress-buffer { position: absolute; top: 0; left: 0; height: 100%; border-radius: 4px; background: rgba(255,255,255,0.2); pointer-events: none; transition: width 0.5s; }
.cs-seek {
  position: absolute; inset: -8px 0; opacity: 0; width: 100%; cursor: pointer;
}
.cs-seek-hover { position: absolute; top: -26px; pointer-events: none; padding: 3px 7px; background: rgba(0,0,0,0.75); border-radius: 5px; color: #fff; font-size: 11px; white-space: nowrap; }

/* ---- controls row ---- */
.cs-controls-row { display: flex; align-items: center; gap: 6px; }
.cs-ctrl-group { display: flex; align-items: center; gap: 2px; }
.cs-ctrl-right { margin-left: auto; }
.cs-btn-play .cs-svg, .cs-btn-back .cs-svg, .cs-btn-fwd .cs-svg,
.cs-btn-mute .cs-svg, .cs-btn-pip .cs-svg, .cs-btn-fullscreen .cs-svg {
  width: 22px; height: 22px;
}
.cs-btn-play, .cs-btn-back, .cs-btn-fwd, .cs-btn-mute,
.cs-btn-pip, .cs-btn-fullscreen {
  width: 38px; height: 38px; padding: 0; border-radius: 9px;
  background: transparent; border: 0;
  color: rgba(255,255,255,0.8); display: grid; place-items: center;
  transition: 0.15s;
}
.cs-btn-play:hover, .cs-btn-back:hover, .cs-btn-fwd:hover, .cs-btn-mute:hover,
.cs-btn-pip:hover, .cs-btn-fullscreen:hover { background: rgba(255,255,255,0.12); color: #fff; }
.cs-time { font-size: 12px; color: rgba(255,255,255,0.8); font-variant-numeric: tabular-nums; padding: 0 5px; white-space: nowrap; }

/* ---- volume ---- */
.cs-volume { display: flex; align-items: center; gap: 5px; }
.cs-volume-range { width: 80px; height: 4px; accent-color: var(--accent); }

/* ---- player menus ---- */
.cs-menu { position: relative; }
.cs-menu-trigger {
  width: 36px; height: 36px; padding: 0; border-radius: 9px;
  background: transparent; border: 0; color: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: 0.15s; font-size: 13px; font-weight: 700;
}
.cs-menu-trigger:hover { background: rgba(255,255,255,0.12); color: #fff; }
.cs-menu-trigger.cs-menu-speed { width: auto; padding: 0 8px; }
.cs-menu-label { font-size: 12.5px; font-weight: 700; }
.cs-menu-panel {
  position: absolute; bottom: calc(100% + 8px); right: 0;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  min-width: 170px; overflow: hidden; display: none; z-index: 50;
  max-height: 320px; overflow-y: auto;
}
.cs-menu-panel.cs-open { display: block; }
.cs-menu-title { padding: 9px 13px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border-soft); }
.cs-menu-item { display: block; width: 100%; text-align: left; padding: 10px 13px; font-size: 13.5px; color: var(--text); transition: 0.13s; border-radius: 0; display: flex; align-items: center; gap: 8px; }
.cs-menu-item:hover { background: var(--bg-3); }
.cs-menu-item.cs-active { color: var(--accent); font-weight: 700; }
.cs-menu-empty { padding: 10px 13px; font-size: 13px; color: var(--muted); }
.cs-menu-sep { border-top: 1px solid var(--border-soft); margin: 4px 0; }

.cs-seek-thumb { position: absolute; bottom: 80px; transform: translateX(-50%); pointer-events: none; z-index: 30; }
.cs-seek-thumb img { width: 120px; height: 68px; border-radius: 6px; object-fit: cover; box-shadow: var(--shadow); border: 2px solid var(--border); }

/* info panel below stage */
.cs-info-panel { padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border); }
.cs-player-error {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #fff; text-align: center; padding: 20px; background: rgba(0,0,0,0.7); z-index: 30;
}
.cs-player-error .cs-svg { width: 48px; height: 48px; color: var(--danger); }

/* =========================================================================
   SETTINGS
   ========================================================================= */
.cs-settings { max-width: 820px; margin: 0 auto; padding: 28px 32px 60px; }
.cs-page-head { margin-bottom: 28px; }
.cs-page-head h1 { font-size: 28px; }
.cs-page-head p { margin-top: 6px; }

.cs-settings-section { margin-bottom: 30px; }
.cs-settings-h { font-size: 18px; font-weight: 700; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.cs-settings-body { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cs-settings-field, .cs-settings-toggle, .cs-settings-row {
  display: flex; align-items: flex-start; gap: 16px; padding: 14px 18px;
  background: var(--surface); border-bottom: 1px solid var(--border-soft);
}
.cs-settings-body > :last-child { border-bottom: 0; }
.cs-settings-label { font-size: 14px; font-weight: 600; flex: 0 0 240px; padding-top: 2px; }
.cs-settings-control { flex: 1; min-width: 0; }
.cs-settings-desc { display: block; font-size: 12.5px; margin-top: 2px; }
.cs-settings-toggle { justify-content: space-between; align-items: center; }
.cs-settings-toggle-info { display: flex; flex-direction: column; }
.cs-settings-row { align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.cs-settings-row-info { display: flex; flex-direction: column; gap: 3px; }
.cs-settings-row-actions { display: flex; gap: 8px; }
.cs-settings-foot { margin-top: 24px; text-align: center; }

/* ---- switch toggle ---- */
.cs-switch { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.cs-switch input { display: none; }
.cs-switch-track {
  width: 44px; height: 24px; border-radius: 24px; background: var(--border); transition: 0.2s;
  position: relative;
}
.cs-switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.2s var(--ease); box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.cs-switch input:checked ~ .cs-switch-track { background: var(--accent); }
.cs-switch input:checked ~ .cs-switch-track::after { transform: translateX(20px); }

.cs-range-field { display: flex; align-items: center; gap: 10px; }
.cs-range-field input[type=range] { flex: 1; accent-color: var(--accent); }
.cs-range-val { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 48px; text-align: right; }

/* provider config rows */
.cs-provider-config-row { padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.cs-settings-body > .cs-provider-config-row:last-child { border-bottom: 0; }
.cs-provider-config-head { display: flex; align-items: center; gap: 12px; }
.cs-provider-config-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cs-provider-config-actions { margin-left: auto; }
.cs-provider-config-fields { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

/* =========================================================================
   MODALS
   ========================================================================= */
.cs-modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.cs-modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 500px; overflow: hidden; display: flex; flex-direction: column;
}
.cs-modal.cs-small { max-width: 380px; }
.cs-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; gap: 10px; }
.cs-modal-head h3 { font-size: 18px; }
.cs-modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.cs-modal-body h3 { font-size: 17px; }
.cs-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border-soft); }

/* ---- add provider modal ---- */
.cs-add-modal { max-width: 520px; }
.cs-add-intro { font-size: 13.5px; margin-bottom: 4px; }
.cs-add-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cs-add-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); text-align: left; transition: 0.15s;
}
.cs-add-card:hover { border-color: var(--accent); box-shadow: var(--glow); }
.cs-add-glyph { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; color: #fff; flex-shrink: 0; }
.cs-add-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cs-add-name { font-size: 15px; font-weight: 700; }
.cs-add-desc { font-size: 12.5px; }
.cs-add-go { color: var(--muted); flex-shrink: 0; }
.cs-add-go .cs-svg { width: 18px; height: 18px; }
.cs-add-form-intro { display: flex; flex-direction: column; gap: 12px; }
.cs-add-form-head { display: flex; align-items: center; gap: 13px; }
.cs-field { display: flex; flex-direction: column; gap: 6px; }
.cs-field-label { font-size: 13.5px; font-weight: 600; }
.cs-field-help { font-size: 12px; line-height: 1.4; }
.cs-field-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cs-field.cs-check { flex-direction: row; align-items: center; gap: 10px; }
.cs-radio { display: flex; gap: 6px; }
.cs-chip { padding: 6px 14px; border-radius: 20px; background: var(--bg-3); border: 1px solid var(--border); font-size: 13px; transition: 0.15s; }
.cs-chip.cs-active { background: var(--accent-grad); border-color: transparent; color: #fff; }
.cs-redirect-note { margin-top: 14px; padding: 10px 13px; background: var(--bg-3); border-radius: var(--radius-sm); font-size: 12.5px; }
.cs-redirect-note code { display: block; margin-top: 5px; font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 6px 10px; border-radius: 7px; border: 1px solid var(--border); cursor: pointer; user-select: all; }

/* ---- subtitle modals ---- */
.cs-sub-modal { max-width: 560px; max-height: 85vh; }
.cs-sub-body { overflow-y: auto; }
.cs-sub-searchbar { display: flex; gap: 8px; flex-wrap: wrap; }
.cs-sub-searchbar .cs-input { flex: 1; }
.cs-sub-status { min-height: 20px; font-size: 12.5px; }
.cs-sub-results { display: flex; flex-direction: column; gap: 4px; min-height: 40px; }
.cs-sub-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px;
  border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border); text-align: left; transition: 0.15s; width: 100%;
}
.cs-sub-row:hover { border-color: var(--accent); }
.cs-sub-row.cs-loading { opacity: 0.6; pointer-events: none; }
.cs-sub-row.cs-error { border-color: var(--danger); }
.cs-sub-row-main { flex: 1; min-width: 0; }
.cs-sub-release { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-sub-meta { font-size: 11.5px; }
.cs-sub-dl .cs-svg { width: 17px; height: 17px; color: var(--muted); }
.cs-sub-empty { padding: 16px; text-align: center; }
.cs-sub-loading { padding: 16px; text-align: center; color: var(--muted); }
.cs-sub-upload { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.cs-sub-settings { max-width: 420px; }

/* ---- sub settings panel ---- */
.cs-sub-settings .cs-field { flex-direction: row; align-items: center; gap: 10px; margin: 4px 0; }
.cs-sub-settings .cs-field .cs-field-label { min-width: 140px; font-size: 13px; }
.cs-sub-settings .cs-field input[type=range] { flex: 1; accent-color: var(--accent); }

/* =========================================================================
   TOASTS
   ========================================================================= */
.cs-toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.cs-toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600;
  max-width: 320px; pointer-events: none;
  transform: translateX(110%); opacity: 0;
  transition: transform 0.28s var(--ease), opacity 0.28s;
}
.cs-toast.cs-show { transform: translateX(0); opacity: 1; }
.cs-toast-error { border-color: var(--danger); }
.cs-toast-success { border-color: var(--success); }
.cs-toast-error .cs-svg { color: var(--danger); }
.cs-toast-success .cs-svg { color: var(--success); }
.cs-toast .cs-svg { width: 18px; height: 18px; flex-shrink: 0; }

/* =========================================================================
   OAUTH CALLBACK / ERROR STATES
   ========================================================================= */
.cs-oauth-callback {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 80px 40px; text-align: center; min-height: 60vh;
}
.cs-oauth-callback h2, .cs-error-state h2 { font-size: 22px; }
.cs-error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 80px 40px; text-align: center; min-height: 50vh;
}
.cs-error-state .cs-svg { width: 48px; height: 48px; color: var(--danger); }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 900px) {
  .cs-app { flex-direction: column; overflow: hidden; }
  .cs-sidebar-wrap { flex: 0; position: fixed; inset: 0; z-index: 80; transform: translateX(-100%); transition: transform 0.28s var(--ease); }
  .cs-nav-open .cs-sidebar-wrap { transform: translateX(0); }
  .cs-mobile-menu { display: grid; }
  .cs-main { height: 100dvh; padding-top: 0; }
  .cs-hero { grid-template-columns: 1fr; }
  .cs-hero-visual { display: none; }
  .cs-browse-head { flex-direction: column; gap: 12px; }
  .cs-search-input { width: 100%; }
  .cs-controls { display: flex; }
  .cs-volume-range { width: 55px; }
  .cs-settings-label { flex: 0 0 160px; }
  .cs-browse { padding: 20px 20px 50px; }
  .cs-home { padding: 16px 20px 50px; }
  .cs-settings { padding: 20px 20px 50px; }
}

@media (max-width: 600px) {
  .cs-history-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .cs-provider-cards { grid-template-columns: 1fr; }
  .cs-feature-grid { grid-template-columns: 1fr; }
  .cs-view-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
  .cs-hero-actions { flex-direction: column; }
  .cs-hero-actions .cs-btn { width: 100%; justify-content: center; }
  .cs-time { font-size: 11px; }
  .cs-modal { margin: 0; }
  .cs-modal-backdrop { align-items: flex-end; padding: 0; }
  .cs-sub-modal { max-height: 90dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .cs-settings-field, .cs-settings-toggle { flex-direction: column; }
  .cs-settings-label { flex: unset; }
}

/* =========================================================================
   FULLSCREEN PLAYER
   ========================================================================= */
:fullscreen .cs-player-view { background: #000; }
:fullscreen .cs-info-panel { display: none; }
:fullscreen .cs-controls { padding: 16px 20px 14px; }
:fullscreen .cs-sub-overlay { font-size: calc(var(--cs-sub-font-size, 20px) * 1.2); }

/* =========================================================================
   PRINT
   ========================================================================= */
@media print {
  .cs-sidebar-wrap, .cs-player-view { display: none; }
}
