 @import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Mono:wght@300;400&display=swap');

  :root {
    --bg: #0a0a0f;
    --surface: #111118;
    --surface2: #1a1a24;
    --border: #ffffff0f;
    --accent: #7c6aff;
    --accent2: #ff6a9e;
    --cat: #38bdf8;
    --text: #f5f5ff;
    --muted: #9898b0;
    --green: #4ade80;
    --red: #f87171;
  }

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

  body {
    font-family: 'Syne', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
  }

  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
  }

  .logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
  }

  .channel-count {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--surface2);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
  }

  /* PLAYLIST BAR */
  .playlist-bar {
    padding: 10px 24px;
    background: #0d0d15;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
  }

  .playlist-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
    color: var(--cat);
    white-space: nowrap;
  }

  .playlist-select {
    flex: 1;
    min-width: 180px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
  }

  .playlist-select:focus { border-color: var(--accent); }

  .btn-playlist-load {
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--accent);
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
  }

  .btn-playlist-load:hover { background: var(--accent); color: #fff; }

  .playlist-status {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted);
    white-space: nowrap;
  }

  /* M3U BAR */
  .m3u-bar {
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
  }

  .m3u-bar input {
    flex: 1;
   background: var(--bg);
   border: 1px solid var(--border);
   border-radius: 8px;
   padding: 10px 14px;
 //color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    outline: none;
   transition: border-color 0.2s;
  }

  .m3u-bar input:focus { border-color: var(--accent); }
  .m3u-bar input::placeholder { color: var(--muted); }

  .btn-load {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    color: #fff;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s, transform 0.1s;
  }

  .btn-load:hover { opacity: 0.88; }
  .btn-load:active { transform: scale(0.97); }

  .btn-file {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
  }

  .btn-file:hover { background: var(--surface); }
  #fileInput { display: none; }

  /* LAYOUT */
  .main {
    flex: 1;
    display: flex;
    overflow: hidden;
    height: calc(100vh - 160px);
  }

  /* SIDEBAR */
  .sidebar {
    width: 300px;
    min-width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
  }

  .search-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-family: 'Syne', sans-serif;
    font-size: 0.82rem;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
  }

  .search-input:focus { border-color: var(--accent); }
  .search-input::placeholder { color: var(--muted); }

  .group-filter {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .group-filter::-webkit-scrollbar { display: none; }

  .group-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-family: 'DM Mono', monospace;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    flex-shrink: 0;
  }

  .group-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .channel-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  .channel-list::-webkit-scrollbar { width: 4px; }
  .channel-list::-webkit-scrollbar-track { background: transparent; }
  .channel-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
  }

  .channel-item:hover { background: var(--surface2); }
  .channel-item.active { background: rgba(124,106,255,0.12); border-left: 3px solid var(--accent); }

  .ch-logo {
    width: 36px; height: 36px;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    overflow: hidden;
  }

  .ch-logo img { width: 100%; height: 100%; object-fit: contain; }
  .ch-info { flex: 1; min-width: 0; }

  .ch-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
  }

  .ch-group {
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    color: var(--cat);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .fav-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 4px;
    flex-shrink: 0;
    opacity: 0.35;
    transition: opacity 0.15s, transform 0.15s;
    line-height: 1;
  }

  .fav-btn:hover { opacity: 1; transform: scale(1.2); }
  .fav-btn.active { opacity: 1; }

  /* PLAYER */
  .player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .video-wrap {
    position: relative;
    background: #000;
    width: 100%;
    aspect-ratio: 16/9;
    max-height: 65%;
    flex-shrink: 0;
  }

  video {
    width: 100%; height: 100%;
    background: #000;
    display: block;
  }

  .overlay-msg {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.9rem;
    pointer-events: none;
  }

  .overlay-msg .big-icon { font-size: 48px; opacity: 0.3; }
  .overlay-msg span { opacity: 0.6; }

  .now-playing {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
  }

  .now-logo {
    width: 44px; height: 44px;
    border-radius: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
  }

  .now-logo img { width: 100%; height: 100%; object-fit: contain; }
  .now-info { flex: 1; min-width: 0; }
  .now-title { font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .now-group { font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

  .status-badge {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid;
    flex-shrink: 0;
  }

  .status-badge.live    { color: var(--green); border-color: var(--green); background: rgba(74,222,128,0.08); }
  .status-badge.loading { color: var(--accent); border-color: var(--accent); background: rgba(124,106,255,0.08); }
  .status-badge.error   { color: var(--red); border-color: var(--red); background: rgba(248,113,113,0.08); }
  .status-badge.idle    { color: var(--muted); border-color: var(--muted); background: transparent; }

  .controls {
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
  }

  .ctrl-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text);
    font-family: 'Syne', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.15s;
  }

  .ctrl-btn:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
  .ctrl-btn.danger:hover { border-color: var(--red); color: var(--red); }

  .vol-wrap { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .vol-label { font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--muted); }

  input[type=range] {
    -webkit-appearance: none;
    width: 90px; height: 4px;
    background: var(--surface2);
    border-radius: 4px;
    outline: none;
  }

  input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
  }

  .empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    padding: 40px;
    text-align: center;
  }

  .empty-state .big { font-size: 48px; opacity: 0.3; }
  .empty-state .title { font-size: 1rem; font-weight: 700; color: var(--text); }
  .empty-state .sub { font-size: 0.82rem; line-height: 1.5; }

  .loading-bar {
    padding: 14px 16px;
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    display: none;
  }

  .spinner {
    display: inline-block;
    width: 10px; height: 10px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  .toast {
    position: fixed;
    bottom: 20px; right: 20px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 0.82rem;
    max-width: 280px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
    z-index: 999;
    font-family: 'DM Mono', monospace;
  }

  .toast.show { opacity: 1; transform: translateY(0); }

  @media (max-width: 640px) {
    .main { flex-direction: column; height: auto; overflow-y: auto; }
    .sidebar { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
    .video-wrap { max-height: unset; }
    .m3u-bar { flex-wrap: wrap; }
    .m3u-bar input { min-width: 0; }
    .playlist-bar { gap: 8px; }
  }