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

  :root {
    --bg: #07070a;
    --surface: #0e0e13;
    --surface2: #161620;
    --surface3: #1e1e2a;
    --border: #262635;
    --text: #ededf0;
    --text2: #7a7a90;
    --text3: #45455a;
    --gold: #e8a838;
    --gold-hover: #f0b848;
    --gold-dim: rgba(232,168,56,0.10);
    --gold-bg: rgba(232,168,56,0.07);
    --red: #ef4444;
    --green: #22c55e;
    --radius: 10px;
    --sidebar-w: 350px;
  }

  html, body { height: 100%; overflow: hidden; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  button { font-family: inherit; }
  :focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 4px;
  }

  /* ========== LAYOUT ========== */
  .app { display: flex; height: 100%; width: 100%; }

  /* ========== SIDEBAR ========== */
  .sidebar {
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar-head {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* Brand */
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }
  .brand svg { flex-shrink: 0; }
  .brand h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, #e8a838, #f0d060);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .live-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--red);
    background: rgba(239, 68, 68, 0.12);
    padding: 2px 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .live-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--red);
    animation: livePulse 1.5s ease-in-out infinite;
  }
  @keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
  }

  /* Search */
  .search-wrap { position: relative; }
  .search-wrap .search-icon {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    pointer-events: none;
  }
  .search-wrap input {
    width: 100%;
    padding: 9px 32px 9px 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
  }
  .search-wrap input:focus { border-color: var(--gold); }
  .search-wrap input::placeholder { color: var(--text3); }
  .search-clear {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    width: 22px; height: 22px;
    border: none; border-radius: 50%;
    background: var(--surface3);
    color: var(--text2);
    font-size: 14px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s;
  }
  .search-clear:hover { background: var(--border); }
  .search-clear.visible { display: flex; }

  /* Channels area */
  .channels-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .categories {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
  }
  .categories::-webkit-scrollbar { display: none; }
  .cat-btn {
    flex-shrink: 0;
    padding: 5px 13px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text2);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
  }
  .cat-btn:hover {
    border-color: var(--text3);
    color: var(--text);
  }
  .cat-btn.active {
    background: var(--gold);
    color: #0a0a0c;
    border-color: var(--gold);
    font-weight: 600;
  }
  .cat-count {
    display: inline-block;
    min-width: 16px; height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    background: var(--surface3);
    color: var(--text3);
    margin-left: 4px;
    padding: 0 4px;
  }
  .cat-btn.active .cat-count {
    background: rgba(0, 0, 0, 0.15);
    color: #0a0a0c;
  }

  .channels {
    flex: 1;
    overflow-y: auto;
    padding: 2px 10px 12px;
    scroll-behavior: smooth;
  }
  .channels::-webkit-scrollbar { width: 5px; }
  .channels::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
  }
  .channels::-webkit-scrollbar-track { background: transparent; }

  /* Group */
  .ch-group { margin-bottom: 2px; }
  .ch-group-title {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 14px 6px 6px;
  }

  /* Channel card */
  .ch-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    position: relative;
  }
  .ch-card:hover { background: var(--surface2); }
  .ch-card:active { transform: scale(0.985); }
  .ch-card.active {
    background: var(--gold-bg);
    border-color: rgba(232, 168, 56, 0.25);
  }
  .ch-card.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--gold);
  }
  .ch-card.unsupported {
    opacity: 0.3;
    cursor: not-allowed;
  }
  .ch-card.unsupported:hover { background: transparent; }

  .ch-logo {
    width: 34px; height: 34px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--surface2);
    flex-shrink: 0;
  }
  .ch-info { flex: 1; min-width: 0; }
  .ch-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ch-type {
    font-size: 10px;
    color: var(--text3);
    margin-top: 1px;
  }
  .ch-play {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
  }
  .ch-play svg {
    color: var(--text3);
    transition: color 0.15s;
  }
  .ch-card:hover .ch-play { background: var(--surface3); }
  .ch-card.active .ch-play { background: var(--gold); }
  .ch-card.active .ch-play svg { color: #0a0a0c; }

  /* Skeleton loading */
  .skel-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
  }
  .skel {
    background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
  }
  .skel-logo { width: 34px; height: 34px; flex-shrink: 0; }
  .skel-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
  .skel-name { height: 12px; width: 70%; }
  .skel-sub { height: 9px; width: 40%; }
  @keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* ========== PLAYER AREA ========== */
  .player-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
    min-width: 0;
  }
  .video-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
  }
  .video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
  }

  /* Player overlay / placeholder */
  .player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: radial-gradient(ellipse at center, #0f0f18 0%, #07070a 70%);
    z-index: 1;
    transition: opacity 0.3s;
  }
  .player-overlay.hidden {
    opacity: 0;
    pointer-events: none;
  }
  .star-idle {
    width: 72px; height: 72px;
    color: var(--gold);
    animation: starFloat 4s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(232, 168, 56, 0.25));
  }
  @keyframes starFloat {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.7; }
    50% { transform: translateY(-8px) scale(1.06); opacity: 1; }
  }
  .overlay-title {
    font-size: 15px;
    color: var(--text2);
    font-weight: 500;
  }
  .overlay-sub {
    font-size: 12px;
    color: var(--text3);
  }
  .overlay-error { color: var(--red); }
  .overlay-retry {
    margin-top: 4px;
    padding: 7px 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
  }
  .overlay-retry:hover {
    border-color: var(--gold);
    color: var(--gold);
  }

  /* Mobile menu button */
  .mobile-menu {
    display: none;
    position: absolute;
    top: 10px; right: 10px;
    z-index: 6;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
  }
  .mobile-menu:hover { background: rgba(0, 0, 0, 0.75); }

  /* Now playing bar */
  .now-playing {
    flex-shrink: 0;
    padding: 10px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
  }
  .np-logo {
    width: 30px; height: 30px;
    border-radius: 6px;
    object-fit: contain;
    background: var(--surface2);
    flex-shrink: 0;
  }
  .np-info { flex: 1; min-width: 0; }
  .np-label {
    display: block;
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text3);
    letter-spacing: 0.8px;
    text-transform: uppercase;
  }
  .np-name {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .list-toggle {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
  }
  .list-toggle:hover {
    border-color: var(--gold);
    color: var(--gold);
  }
  .list-toggle svg { transition: transform 0.25s; }
  .list-toggle.open svg { transform: rotate(180deg); }

  /* Backdrop mobile */
  .backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Bottom sheet drag handle */
  .sheet-handle {
    display: none;
    width: 36px; height: 4px;
    border-radius: 2px;
    background: var(--text3);
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* Toast */
  .toast-container {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
  }
  .toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    animation: toastIn 0.3s ease forwards;
    max-width: 320px;
  }
  .toast.error { border-color: rgba(239, 68, 68, 0.3); color: var(--red); }
  .toast.success { border-color: rgba(34, 197, 94, 0.3); color: var(--green); }
  .toast.out { animation: toastOut 0.25s ease forwards; }
  @keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
  }
  @keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
  }

  /* Channel count footer */
  .ch-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 10px;
    color: var(--text3);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* ========== RESPONSIVE ========== */
  @media (max-width: 767px) {
    .app { flex-direction: column; }
    .sidebar {
      position: fixed;
      bottom: 0; left: 0; right: 0;
      width: 100%;
      height: 60%;
      border-right: none;
      border-top: 1px solid var(--border);
      border-radius: 16px 16px 0 0;
      z-index: 10;
      transform: translateY(100%);
      box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
    }
    .sidebar.open { transform: translateY(0); }
    .sheet-handle { display: block; }
    .mobile-menu { display: flex !important; }
    .player-main { flex: 1; }
    .sidebar-head { padding: 0 14px 8px; }
    .brand { margin-bottom: 10px; }
    .brand h1 { font-size: 18px; }
    .search-wrap input {
      padding: 8px 30px 8px 32px;
      font-size: 13px;
    }
    .categories { padding: 8px 14px; }
    .channels { padding: 2px 8px 8px; }
    .ch-card { padding: 7px 8px; gap: 9px; }
    .ch-logo { width: 30px; height: 30px; }
    .ch-name { font-size: 12px; }
    .now-playing { padding: 8px 12px; min-height: 44px; }
    .np-logo { width: 26px; height: 26px; }
    .np-name { font-size: 12.5px; }
    .list-toggle { padding: 5px 10px; font-size: 11px; }
  }
  @media (min-width: 768px) and (max-width: 1199px) {
    :root { --sidebar-w: 310px; }
  }
  @media (min-width: 1200px) {
    :root { --sidebar-w: 370px; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
  }
