:root {
      --font-primary: 'Fredoka', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
      
      /* Light Mode Palette */
      --bg-primary: #FAF6F0;
      --bg-secondary: #FFFDFB;
      --bg-card: #FFFFFF;
      --text-primary: #4A3E3D;
      --text-secondary: #8E7A77;
      --accent-primary: #FF8A65;
      --accent-secondary: #F06292;
      --accent-gradient: linear-gradient(135deg, #FF8A65, #F06292);
      --accent-gradient-hover: linear-gradient(135deg, #FFA07A, #F48FB1);
      --border-color: #EFE8E2;
      --shadow-sm: 0 4px 12px rgba(220, 205, 195, 0.35);
      --shadow-md: 0 8px 24px rgba(220, 205, 195, 0.45);
      --shadow-lg: 0 16px 40px rgba(220, 205, 195, 0.55);
      --overlay-bg: rgba(250, 246, 240, 0.96);
      --glass-bg: rgba(255, 255, 255, 0.85);
      --glass-border: rgba(255, 255, 255, 0.6);
      --badge-bg: #FFEBE7;
      --badge-text: #FF7A59;
    }

    [data-theme="dark"] {
      /* Dark/Night Mode Palette */
      --bg-primary: #0C0A17;
      --bg-secondary: #120F24;
      --bg-card: #1C1736;
      --text-primary: #E2E0EE;
      --text-secondary: #9B98B3;
      --accent-primary: #B39DFF;
      --accent-secondary: #EC4899;
      --accent-gradient: linear-gradient(135deg, #7C3AED, #EC4899);
      --accent-gradient-hover: linear-gradient(135deg, #8B5CF6, #F472B6);
      --border-color: #27214B;
      --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
      --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
      --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
      --overlay-bg: rgba(12, 10, 23, 0.98);
      --glass-bg: rgba(28, 23, 54, 0.85);
      --glass-border: rgba(255, 255, 255, 0.05);
      --badge-bg: #2D2357;
      --badge-text: #B39DFF;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      outline: none;
    }

    body {
      font-family: var(--font-primary);
      background-color: var(--bg-primary);
      color: var(--text-primary);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      overflow-x: hidden;
      transition: background-color 0.4s, color 0.4s;
    }

    /* Scrollbar Style */
    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }
    ::-webkit-scrollbar-track {
      background: transparent;
    }
    ::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 4px;
    }
    ::-webkit-scrollbar-thumb:hover {
      background: var(--text-secondary);
    }

    /* Header */
    .header {
      background: var(--glass-bg);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-bottom: 1px solid var(--glass-border);
      position: sticky;
      top: 0;
      z-index: 50;
      box-shadow: var(--shadow-sm);
      transition: background-color 0.4s, border-color 0.4s;
    }
    
    .header-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 64px;
      max-width: 1400px;
      margin: 0 auto;
      padding: 0 20px;
      gap: 20px;
    }

    .logo-area {
      display: flex;
      align-items: center;
      gap: 10px;
      cursor: pointer;
      user-select: none;
    }

    .logo-area h1 {
      font-size: 20px;
      font-weight: 700;
      background: var(--accent-gradient);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      letter-spacing: 0.5px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .logo-area span {
      font-size: 11px;
      color: #fff;
      background: var(--accent-gradient);
      padding: 2px 8px;
      border-radius: 12px;
      font-weight: 500;
      box-shadow: 0 2px 6px rgba(240, 98, 146, 0.25);
    }

    /* Search Bar */
    .search-container {
      flex: 1;
      max-width: 460px;
      position: relative;
    }

    .search-input {
      width: 100%;
      height: 40px;
      background: var(--bg-primary);
      border: 1px solid var(--border-color);
      border-radius: 20px;
      padding: 0 16px 0 42px;
      font-family: var(--font-primary);
      font-size: 14px;
      color: var(--text-primary);
      transition: all 0.3s;
    }

    .search-input:focus {
      border-color: var(--accent-primary);
      background: var(--bg-card);
      box-shadow: 0 0 0 3px rgba(255, 138, 101, 0.15);
    }

    .search-icon {
      position: absolute;
      left: 15px;
      top: 50%;
      transform: translateY(-50%);
      width: 18px;
      height: 18px;
      fill: var(--text-secondary);
      pointer-events: none;
      transition: fill 0.3s;
    }

    .search-input:focus + .search-icon {
      fill: var(--accent-primary);
    }

    /* Nav Buttons */
    .nav-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .nav-btn {
      background: transparent;
      border: none;
      color: var(--text-secondary);
      padding: 8px 16px;
      font-size: 14px;
      font-weight: 500;
      border-radius: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: all 0.3s;
      -webkit-tap-highlight-color: transparent;
    }

    .nav-btn svg {
      width: 18px;
      height: 18px;
      fill: currentColor;
    }

    .nav-btn:hover {
      color: var(--accent-primary);
      background: rgba(255, 138, 101, 0.08);
    }

    .nav-btn.active {
      color: #fff;
      background: var(--accent-gradient);
      box-shadow: 0 3px 10px rgba(240, 98, 146, 0.25);
    }

    .theme-toggle {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      border: 1px solid var(--border-color);
      background: var(--bg-card);
      color: var(--text-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.3s;
      flex-shrink: 0;
      box-shadow: var(--shadow-sm);
    }

    .theme-toggle:hover {
      border-color: var(--accent-primary);
      color: var(--accent-primary);
      transform: scale(1.05);
    }

    .theme-toggle svg {
      width: 20px;
      height: 20px;
      fill: currentColor;
    }

    /* Category Bar */
    .category-section {
      background: var(--bg-secondary);
      border-bottom: 1px solid var(--border-color);
      position: sticky;
      top: 64px;
      z-index: 40;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
      transition: background-color 0.4s, border-color 0.4s;
    }

    .category-inner {
      max-width: 1400px;
      margin: 0 auto;
      padding: 10px 20px;
      overflow-x: auto;
      overflow-y: hidden;
      white-space: nowrap;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none; /* Firefox */
      cursor: grab;
      user-select: none;
    }

    .category-inner::-webkit-scrollbar {
      display: none; /* Safari & Chrome */
    }

    .category-list {
      display: inline-flex;
      gap: 8px;
    }

    .category-tab {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 18px;
      font-size: 13px;
      font-weight: 500;
      color: var(--text-secondary);
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 20px;
      cursor: pointer;
      transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }

    .category-tab:hover {
      color: var(--accent-primary);
      border-color: var(--accent-primary);
      transform: translateY(-1px);
    }

    .category-tab.active {
      background: var(--accent-gradient);
      color: #fff;
      border-color: transparent;
      box-shadow: 0 4px 12px rgba(240, 98, 146, 0.25);
    }

    /* Content Area */
    .main-content {
      flex: 1;
      max-width: 1400px;
      width: 100%;
      margin: 0 auto;
      padding: 20px;
      display: flex;
      flex-direction: column;
    }

    .section-title {
      font-size: 20px;
      font-weight: 700;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .section-title span {
      color: var(--text-secondary);
      font-size: 13px;
      font-weight: 400;
    }

    /* Video Grid */
    .video-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: 20px;
    }

    @media (max-width: 640px) {
      .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
      }
      .main-content {
        padding: 12px;
      }
      .card-info {
        padding: 10px;
        height: 88px;
      }
      .card-title {
        font-size: 12px;
        height: 34px;
        line-height: 1.3;
      }
    }

    /* Video Card */
    .video-card {
      background: var(--bg-card);
      border-radius: 16px;
      overflow: hidden;
      box-shadow: var(--shadow-sm);
      border: 1px solid var(--border-color);
      cursor: pointer;
      position: relative;
      transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
      display: flex;
      flex-direction: column;
      -webkit-tap-highlight-color: transparent;
    }

    .video-card:hover {
      transform: translateY(-6px);
      box-shadow: var(--shadow-md);
      border-color: var(--accent-primary);
    }

    .video-card:active {
      transform: translateY(-2px) scale(0.98);
    }

    .card-img-wrap {
      aspect-ratio: 16/9;
      background: #e8e0d8;
      position: relative;
      overflow: hidden;
    }

    .card-img-wrap img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.4s;
    }

    .video-card:hover .card-img-wrap img {
      transform: scale(1.05);
    }

    /* Favorite Toggle Button on Card */
    .fav-card-btn {
      position: absolute;
      top: 6px;
      right: 6px;
      width: 36px;
      height: 36px;
      background: transparent;
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: rgba(255, 255, 255, 0.9);
      z-index: 10;
      transition: all 0.25s;
      -webkit-tap-highlight-color: transparent;
    }

    .fav-card-btn:hover {
      transform: scale(1.15);
      color: #fff;
    }

    .fav-card-btn svg {
      width: 22px;
      height: 22px;
      fill: currentColor;
      filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
      transition: all 0.25s;
    }

    .fav-card-btn.favorited {
      color: #FF5A79;
      background: transparent;
      box-shadow: none;
    }
    
    .fav-card-btn.favorited svg {
      filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
    }

    /* Play Badge Overlay */
    .play-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.2);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.3s;
      z-index: 5;
    }

    .video-card:hover .play-overlay {
      opacity: 1;
    }

    .play-overlay svg {
      width: 44px;
      height: 44px;
      fill: #fff;
      filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
      transform: scale(0.9);
      transition: transform 0.3s;
    }

    .video-card:hover .play-overlay svg {
      transform: scale(1);
    }

    /* Progress Bar on Card */
    .card-progress-bar {
      position: absolute;
      bottom: 0;
      left: 0;
      height: 4px;
      background: var(--accent-gradient);
      width: 0;
      z-index: 8;
      border-radius: 0 2px 2px 0;
    }

    /* Card Details */
    .card-info {
      padding: 12px;
      height: 96px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }

    .card-title {
      font-size: 13.5px;
      font-weight: 700;
      line-height: 1.4;
      color: var(--text-primary);
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      height: 38px;
    }

    .card-meta {
      display: flex;
      flex-direction: column;
      gap: 2px;
      margin-top: auto;
      overflow: hidden;
    }

    .card-image-badge {
      position: absolute;
      bottom: 8px;
      right: 8px;
      background: rgba(0, 0, 0, 0.6);
      color: #fff;
      padding: 2px 6px;
      border-radius: 6px;
      font-size: 10px;
      font-weight: 600;
      backdrop-filter: blur(2px);
      -webkit-backdrop-filter: blur(2px);
      z-index: 10;
      pointer-events: none;
    }

    .card-history-text {
      font-size: 11px;
      color: var(--accent-secondary);
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .card-category-text {
      font-size: 11px;
      color: var(--text-secondary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    @media (max-width: 640px) {
      .card-history-text,
      .card-category-text {
        font-size: 10px;
      }
    }

    /* Loading and Empty States */
    .loading-container {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 80px 20px;
      gap: 15px;
      color: var(--text-secondary);
    }

    .spinner {
      width: 40px;
      height: 40px;
      border: 4px solid var(--border-color);
      border-top-color: var(--accent-primary);
      border-radius: 50%;
      animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    .empty-state {
      text-align: center;
      padding: 60px 20px;
      color: var(--text-secondary);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
    }

    .empty-state svg {
      width: 60px;
      height: 60px;
      fill: var(--border-color);
    }

    /* Video Player Overlay */
    #playerOverlay {
      display: none;
      position: fixed;
      inset: 0;
      background: #06040A; /* Theater mode black-purple */
      z-index: 100;
      flex-direction: column;
      color: #fff;
    }

    #playerOverlay.active {
      display: flex;
    }

    .player-header {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      padding: 10px 16px;
      background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      z-index: 110;
      height: 60px;
      gap: 12px;
      transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease;
      pointer-events: auto;
    }

    .player-header.hidden {
      transform: translateY(-100%);
      opacity: 0;
      pointer-events: none;
    }

    .back-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: rgba(255,255,255,0.15);
      border: none;
      color: #fff;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.25s, transform 0.25s;
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      flex-shrink: 0;
    }

    .back-btn:hover {
      background: rgba(255,255,255,0.25);
      transform: scale(1.05);
    }

    .back-btn svg {
      width: 18px;
      height: 18px;
      fill: currentColor;
    }

    .cast-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: rgba(255,255,255,0.15);
      border: none;
      color: #fff;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.25s, transform 0.25s;
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      flex-shrink: 0;
      margin-right: 4px;
    }

    .cast-btn:hover {
      background: rgba(255,255,255,0.25);
      transform: scale(1.05);
    }

    .cast-btn svg {
      width: 20px;
      height: 20px;
      fill: currentColor;
    }

    /* Marquee title container */
    .player-title-container {
      flex: 1;
      overflow: hidden;
      position: relative;
      white-space: nowrap;
      mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 10px), transparent);
      -webkit-mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 10px), transparent);
    }

    .player-video-title {
      font-size: 16px;
      font-weight: 600;
      display: inline-block;
      white-space: nowrap;
      text-shadow: 0 2px 4px rgba(0,0,0,0.5);
      transition: transform 0.15s;
    }

    .player-video-title.scrollable {
      animation: titleMarquee 15s linear infinite;
    }

    @keyframes titleMarquee {
      0% { transform: translateX(0); }
      10% { transform: translateX(0); }
      45% { transform: translateX(var(--marquee-distance, -50%)); }
      55% { transform: translateX(var(--marquee-distance, -50%)); }
      90% { transform: translateX(0); }
      100% { transform: translateX(0); }
    }

    .player-main-layout {
      display: flex;
      flex: 1;
      height: 100%;
      min-height: 0;
      position: relative;
    }

    .player-left-col {
      flex: 3;
      position: relative;
      height: 100%;
      min-height: 0;
      background: #000;
    }

    #playerWrap {
      width: 100%;
      height: 100%;
      min-height: 0;
      background: #000;
    }

    #playerWrap .artplayer-app {
      width: 100% !important;
      height: 100% !important;
    }

    /* Sidebar Playlist */
    .player-sidebar {
      flex: 1;
      min-width: 280px;
      max-width: 380px;
      background: rgba(18, 14, 30, 0.95);
      border-left: 1px solid rgba(255,255,255,0.06);
      display: flex;
      flex-direction: column;
      padding-top: 0;
    }

    .sidebar-tabs {
      display: flex;
      border-bottom: 1px solid rgba(255,255,255,0.06);
      padding: 0 16px;
    }

    .sidebar-tab {
      padding: 12px 16px;
      font-size: 13.5px;
      background: transparent;
      border: none;
      color: rgba(255, 255, 255, 0.5);
      cursor: pointer;
      font-weight: 500;
      position: relative;
      transition: color 0.3s;
    }

    .sidebar-tab.active {
      color: #fff;
    }

    .sidebar-tab.active::after {
      content: '';
      position: absolute;
      bottom: -1px;
      left: 16px;
      right: 16px;
      height: 2px;
      background: var(--accent-gradient);
    }

    .sidebar-content-pane {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
    }

    /* Episode List (Row list instead of tight grid) */
    .episode-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .ep-btn {
      width: 100%;
      min-height: 48px;
      height: auto;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.03);
      color: rgba(255,255,255,0.85);
      font-family: var(--font-primary);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.25s;
      padding: 8px 12px;
      display: flex;
      align-items: center;
      gap: 10px;
      text-align: left;
      position: relative;
      -webkit-tap-highlight-color: transparent;
    }

    .ep-btn:hover {
      border-color: var(--accent-primary);
      color: #fff;
      background: rgba(255,138,101,0.08);
    }

    .ep-btn.active {
      background: var(--accent-gradient);
      border-color: transparent;
      color: #fff;
      font-weight: 600;
      box-shadow: 0 4px 12px rgba(240, 98, 146, 0.25);
    }

    .ep-num {
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.1);
      color: rgba(255, 255, 255, 0.7);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: bold;
      flex-shrink: 0;
    }

    .ep-btn.active .ep-num {
      background: rgba(255, 255, 255, 0.25);
      color: #fff;
    }

    .ep-name-text {
      flex: 1;
      white-space: normal;
      word-break: break-word;
      line-height: 1.35;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .ep-btn.watched .ep-name-text {
      color: rgba(255,255,255,0.4);
    }

    .ep-btn.watched .ep-num {
      background: rgba(16, 185, 129, 0.15);
      color: #10B981;
      border: 1px solid rgba(16, 185, 129, 0.25);
    }

    .ep-btn.loading {
      opacity: 0.6;
      pointer-events: none;
      animation: pulse 1s ease-in-out infinite;
    }

    .ep-btn.error {
      border-color: rgba(244, 67, 54, 0.4);
      background: rgba(244, 67, 54, 0.08);
      color: #EF5350;
    }

    @keyframes pulse {
      0%, 100% { opacity: 0.6; transform: scale(1); }
      50% { opacity: 0.3; transform: scale(0.97); }
    }

    /* Player Options Pane */
    .player-options-list {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .option-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 0;
      border-bottom: 1px solid rgba(255,255,255,0.04);
    }

    .option-item label {
      font-size: 13.5px;
      color: rgba(255,255,255,0.7);
    }

    /* Toggle Switch */
    .switch {
      position: relative;
      display: inline-block;
      width: 44px;
      height: 24px;
    }

    .switch input { 
      opacity: 0;
      width: 0;
      height: 0;
    }

    .slider {
      position: absolute;
      cursor: pointer;
      inset: 0;
      background-color: rgba(255,255,255,0.15);
      transition: .3s;
      border-radius: 24px;
    }

    .slider:before {
      position: absolute;
      content: "";
      height: 18px;
      width: 18px;
      left: 3px;
      bottom: 3px;
      background-color: white;
      transition: .3s;
      border-radius: 50%;
    }

    input:checked + .slider {
      background: var(--accent-gradient);
    }

    input:checked + .slider:before {
      transform: translateX(20px);
    }

    /* Mobile Player Layout Adaptations */
    @media (max-width: 900px) {
      .player-main-layout {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        background: #000;
        height: 100%;
      }
      .player-left-col {
        width: 100%;
        height: 100%;
        flex: 1;
        position: relative;
      }
      #playerWrap {
        width: 100%;
        height: 100%;
      }
      .player-sidebar {
        display: none; /* Hide on mobile by default */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65vh; /* Drawer taking up 65% of screen height */
        background: #120e1e;
        border-top: 1px solid rgba(255,255,255,0.1);
        border-radius: 20px 20px 0 0;
        z-index: 200; /* Float above player layer */
        padding-top: 0; /* Remove top padding since close button is inside tabs */
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
        animation: slideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        flex-direction: column;
        width: 100%;
        max-width: 100%;
      }
      .player-sidebar.active {
        display: flex !important;
      }
      .player-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        z-index: 110;
        background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
        border-bottom: none;
      }
      .sidebar-close-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.08);
        border: none;
        color: rgba(255, 255, 255, 0.7);
        width: 30px;
        height: 30px;
        border-radius: 50%;
        cursor: pointer;
        margin-left: auto; /* Push to the right */
        margin-right: 12px; /* Spacing from right edge */
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s;
      }
      .sidebar-close-btn:hover {
        background: rgba(255,255,255,0.18);
        color: #fff;
      }
      .sidebar-close-btn svg {
        width: 14px;
        height: 14px;
        fill: currentColor;
      }
      
      .sidebar-tabs {
        display: flex;
        align-items: center;
        width: 100%;
      }

      @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
      }
    }
    
    .sidebar-close-btn {
      display: none; /* Hide close button on desktop */
    }

    /* Mobile Bottom Navigation Bar Styles */
    .bottom-nav {
      display: none;
    }

    @media (max-width: 768px) {
      body {
        padding-bottom: 60px; /* Space for sticky bottom bar */
      }
      
      .nav-actions {
        display: none !important; /* Hide header menu actions on mobile */
      }

      .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
        z-index: 49;
        justify-content: space-around;
        align-items: center;
        padding: 0 8px;
        transition: background-color 0.4s, border-color 0.4s;
      }

      .bottom-nav-btn {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 10.5px;
        font-weight: 500;
        font-family: var(--font-primary);
        cursor: pointer;
        flex: 1;
        height: 100%;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.3s;
      }

      .bottom-nav-btn svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
      }

      .bottom-nav-btn.active {
        color: var(--accent-primary);
      }
    }

    /* Mobile Header Layout Adaptations (Search bar in row 2) */
    @media (max-width: 600px) {
      .header {
        position: relative; /* Let header scroll away on mobile */
      }
      .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 14px;
        gap: 12px;
      }
      .logo-area {
        order: 1;
      }
      .theme-toggle {
        order: 2;
      }
      .search-container {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin-top: 2px;
      }
      .category-section {
        position: sticky;
        top: 0; /* Sticky to very top on mobile since header scrolls away */
      }
    }

    /* Settings and Parent Gate View */
    .settings-view {
      max-width: 680px;
      margin: 0 auto;
      background: var(--bg-card);
      border-radius: 20px;
      padding: 30px;
      box-shadow: var(--shadow-md);
      border: 1px solid var(--border-color);
      width: 100%;
    }

    .parent-gate {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      gap: 20px;
      padding: 20px 0;
    }

    .parent-gate-icon {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background: var(--badge-bg);
      color: var(--badge-text);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .parent-gate-icon svg {
      width: 28px;
      height: 28px;
      fill: currentColor;
    }

    .parent-gate h3 {
      font-size: 18px;
      font-weight: 700;
    }

    .parent-gate p {
      font-size: 13.5px;
      color: var(--text-secondary);
      max-width: 320px;
      line-height: 1.5;
    }

    .math-formula {
      font-size: 32px;
      font-weight: 700;
      color: var(--accent-primary);
      background: var(--bg-primary);
      padding: 12px 30px;
      border-radius: 16px;
      letter-spacing: 2px;
      margin: 10px 0;
      border: 1px dashed var(--border-color);
    }

    .parent-gate input {
      width: 100%;
      max-width: 220px;
      height: 48px;
      border-radius: 12px;
      border: 1.5px solid var(--border-color);
      background: var(--bg-primary);
      text-align: center;
      font-size: 20px;
      font-weight: 700;
      color: var(--text-primary);
      transition: all 0.3s;
    }

    .parent-gate input:focus {
      border-color: var(--accent-primary);
      background: var(--bg-card);
      box-shadow: 0 0 0 3px rgba(255, 138, 101, 0.15);
    }

    .primary-btn {
      background: var(--accent-gradient);
      color: #fff;
      border: none;
      height: 46px;
      padding: 0 32px;
      border-radius: 12px;
      font-weight: 600;
      font-size: 14.5px;
      cursor: pointer;
      box-shadow: 0 4px 12px rgba(240, 98, 146, 0.35);
      transition: all 0.3s;
    }

    .primary-btn:hover {
      box-shadow: 0 6px 16px rgba(240, 98, 146, 0.45);
      transform: translateY(-1px);
    }

    .primary-btn:active {
      transform: translateY(1px);
    }

    /* Settings Panel */
    .settings-panel {
      display: flex;
      flex-direction: column;
      gap: 24px;
    }

    .settings-group {
      border-bottom: 1px solid var(--border-color);
      padding-bottom: 20px;
    }

    .settings-group:last-child {
      border-bottom: none;
      padding-bottom: 0;
    }

    .settings-group-title {
      font-size: 15px;
      font-weight: 700;
      margin-bottom: 12px;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .settings-group-title svg {
      width: 18px;
      height: 18px;
      fill: var(--accent-primary);
    }

    .timer-options {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
      gap: 8px;
    }

    .timer-btn {
      height: 40px;
      border-radius: 10px;
      border: 1px solid var(--border-color);
      background: var(--bg-primary);
      color: var(--text-primary);
      font-family: var(--font-primary);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.25s;
    }

    .timer-btn:hover {
      border-color: var(--accent-primary);
      color: var(--accent-primary);
    }

    .timer-btn.active {
      background: var(--accent-gradient);
      color: #fff;
      border-color: transparent;
      box-shadow: 0 3px 8px rgba(240, 98, 146, 0.2);
    }

    .settings-item-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 0;
    }

    .settings-item-row label {
      font-size: 13.5px;
      color: var(--text-primary);
    }

    .settings-item-desc {
      font-size: 11px;
      color: var(--text-secondary);
      margin-top: 2px;
    }

    .danger-btn {
      background: #FF5A66;
      color: #fff;
      border: none;
      padding: 8px 16px;
      border-radius: 10px;
      font-family: var(--font-primary);
      font-size: 12.5px;
      cursor: pointer;
      transition: all 0.25s;
    }

    .danger-btn:hover {
      background: #EF4452;
      box-shadow: 0 3px 8px rgba(239, 68, 82, 0.25);
    }

    /* Device List Grid */
    .dev-list {
      max-height: 150px;
      overflow-y: auto;
      border: 1px solid var(--border-color);
      border-radius: 10px;
      padding: 8px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      background: var(--bg-primary);
      font-size: 11px;
      font-family: monospace;
    }

    .dev-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: var(--text-secondary);
    }

    .dev-item.active {
      color: var(--accent-primary);
      font-weight: bold;
    }

    /* Device Status Widget */
    .status-widget {
      position: fixed;
      bottom: 16px;
      right: 16px;
      z-index: 30;
      background: var(--glass-bg);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border: 1px solid var(--glass-border);
      box-shadow: var(--shadow-sm);
      color: var(--text-secondary);
      font-size: 11px;
      padding: 6px 12px;
      border-radius: 20px;
      display: flex;
      align-items: center;
      gap: 6px;
      pointer-events: none;
      transition: all 0.4s;
    }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #10B981; /* Green */
      animation: pulse-dot 1.5s infinite;
    }

    @keyframes pulse-dot {
      0% { opacity: 0.4; }
      50% { opacity: 1; }
      100% { opacity: 0.4; }
    }

    /* Screen Lock Overlay (Eye Protection Timer) */
    #lockOverlay {
      display: none;
      position: fixed;
      inset: 0;
      background: var(--overlay-bg);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      z-index: 999;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      padding: 20px;
      color: var(--text-primary);
      animation: fadeIn 0.4s;
    }

    #lockOverlay.active {
      display: flex;
    }

    .lock-logo {
      font-size: 80px;
      animation: bounce-logo 2s infinite ease-in-out;
      margin-bottom: 20px;
    }

    @keyframes bounce-logo {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-12px); }
    }

    .lock-title {
      font-size: 26px;
      font-weight: 700;
      margin-bottom: 12px;
      color: var(--accent-secondary);
    }

    .lock-desc {
      font-size: 15px;
      color: var(--text-secondary);
      max-width: 400px;
      line-height: 1.6;
      margin-bottom: 30px;
    }

    /* Toast */
    #toast {
      position: fixed;
      bottom: 80px;
      left: 50%;
      transform: translateX(-50%) translateY(20px);
      background: rgba(0, 0, 0, 0.85);
      color: #fff;
      padding: 10px 24px;
      border-radius: 12px;
      font-size: 13.5px;
      z-index: 1000;
      opacity: 0;
      visibility: hidden;
      transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      max-width: 85%;
      text-align: center;
      box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    }

    #toast.show {
      opacity: 1;
      visibility: visible;
      transform: translateX(-50%) translateY(0);
    }

    /* Global Transitions */
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }