:root {
      /* Compact Sizing Tokens (Clean & Balanced for Streaming Workflows) */
      --phi: 1.5;
      --space-xxs: 2px;
      --space-xs: 4px;
      --space-sm: 8px;
      --space-md: 12px;
      --space-lg: 18px;
      --space-xl: 28px;

      --font-xs: 9.5px;
      --font-sm: 11.5px;
      --font-md: 13px;
      --font-lg: 14.5px;
      --font-xl: 18px;

      --radius-sm: 6px;
      --radius-md: 9px;
      --radius-lg: 14px;
      --radius-xl: 18px;
      --radius-full: 9999px;

      /* Authentic Monochrome Dark Architecture (Black, White & Neutral Grays) */
      --bg: #08090a;               /* Deep Zinc Black */
      --bg-pattern: none;
      --surface: #0f1011;          /* Elevated Surface */
      --surface-solid: #161718;    /* Card Surface */
      --surface-hover: #23252a;    /* Hover State */
      --border: #23252a;           /* Crisp Neutral Border */
      --border-light: #383b3f;     /* Subtle Highlight Border */

      --text-primary: #ffffff;     /* Pure Crisp White (High Readability) */
      --text-secondary: #e8e8e8;   /* Mid Gray (Accessible Contrast) */
      --text-muted: #64748b;       /* Charcoal Gray */

      --accent-tt: #e8e8e8;
      --accent-yt: #e8e8e8;
      --accent-tw: #e8e8e8;
      --primary: #ffffff;          /* Pure White Action Button */
      --primary-hover: #e8e8e8;
      --primary-text: #08090a;     /* Text on Primary Button */

      --green: #27a644;            /* Status Indicators */
      --red: #eb5757;
      --input-bg: #0f1011;
      --input-bg-focus: #161718;
      --tab-active-bg: #23252a;
      --btn-danger-bg: rgba(239, 68, 68, 0.12);
      --btn-danger-border: rgba(239, 68, 68, 0.25);
      --btn-danger-bg-hover: rgba(239, 68, 68, 0.22);
      --btn-danger-border-hover: rgba(239, 68, 68, 0.4);

      --glow-tt: none;
      --glow-yt: none;
      --glow-primary: none;
      --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
      --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    }

    body.light-theme {
      --bg: #f8fafc;               /* Clean Light Slate Background */
      --bg-pattern: none;
      --surface: #ffffff;          /* Pure White Elevated Surface */
      --surface-solid: #ffffff;    /* Card Surface */
      --surface-hover: #f1f5f9;    /* Crisp Light Hover State */
      --border: #e2e8f0;           /* Clear Light Border */
      --border-light: #e2e8f0;     /* Distinct Focus Border */

      --text-primary: #0f172a;     /* Pure Dark Slate (High Readability) */
      --text-secondary: #475569;   /* Deep Neutral Gray (WCAG AAA) */
      --text-muted: #64748b;       /* Muted Slate Gray */
      --input-bg: #ffffff;
      --input-bg-focus: #ffffff;
      --primary: #08090a;          /* Solid Dark Slate Button */
      --primary-hover: #161718;
      --primary-text: #ffffff;     /* Text on Primary Button */
      --accent-tt: #08090a;
      --accent-yt: #08090a;
      --accent-tw: #08090a;
      --green: #27a644;
      --red: #eb5757;
      --tab-active-bg: #e8e8e8;
      --btn-danger-bg: rgba(220, 38, 38, 0.08);
      --btn-danger-border: rgba(220, 38, 38, 0.2);
      --btn-danger-bg-hover: rgba(220, 38, 38, 0.15);
      --btn-danger-border-hover: rgba(220, 38, 38, 0.3);
      --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
      --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    }

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

    body {
      font-family: "Inter", system-ui, sans-serif;
      background-color: var(--bg);
      background-image: var(--bg-pattern);
      background-attachment: fixed;
      color: var(--text-primary);
      height: 100vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      font-size: var(--font-md);
      line-height: var(--phi);
      -webkit-font-smoothing: antialiased;
    }

    /* App Header */
    .app-header {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 0 var(--space-lg) 0 0;
      height: 48px;
      min-height: 48px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      z-index: 10;
    }

    .header-left {
      display: flex;
      align-items: center;
      height: 100%;
    }

    .toggle-btn {
      width: 56px;
      height: 48px;
      background: transparent;
      border: none;
      color: var(--text-secondary);
      font-size: 15px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.2s, background 0.2s;
      flex-shrink: 0;
      padding: 0;
      margin: 0;
    }

    .toggle-btn:hover {
      color: var(--text-primary);
      background: var(--surface-hover);
    }

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

    .header-toggle-btn {
      background: var(--surface-solid);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      height: 30px;
      padding: 0 10px;
      border-radius: var(--radius-sm);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      font-size: 11.5px;
      font-weight: 700;
      letter-spacing: 0.5px;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    }

    .header-toggle-btn:hover {
      background: var(--surface-hover);
      color: var(--text-primary);
      border-color: var(--border-light);
      transform: translateY(-1px);
    }

    .header-toggle-btn:active {
      transform: scale(0.95);
    }

    .header-toggle-btn i {
      font-size: 12px;
    }

    #theme-toggle-btn {
      width: 32px;
      padding: 0;
    }

    #theme-toggle-btn i {
      font-size: 13px;
    }

    .app-body {
      display: flex;
      flex-direction: row;
      flex: 1;
      overflow: hidden;
    }

    /* Sidebar */
    .sidebar {
      width: 220px;
      background: var(--surface);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      height: 100%;
      transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
      overflow: hidden;
      flex-shrink: 0;
    }

    @media (min-width: 769px) {
      .sidebar.collapsed {
        width: 56px;
      }

      .sidebar.collapsed .tab-text {
        display: none;
      }
      
      .sidebar.collapsed .tabs.sidebar-tabs {
        padding: 8px 0;
        align-items: center;
        gap: 6px;
      }

      .sidebar.collapsed .nav-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 4px;
      }

      .sidebar.collapsed .nav-group-header {
        display: none;
      }

      .sidebar.collapsed .nav-group-items {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        width: 100%;
        max-height: none !important;
        opacity: 1 !important;
      }

      .sidebar.collapsed .tab {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        padding: 0;
        margin: 0 auto;
        justify-content: center;
        border-radius: 8px;
      }

      .sidebar.collapsed .tab i {
        font-size: 15px;
        width: auto;
      }

      .sidebar.collapsed .tab.tab-settings-bottom {
        margin-top: auto !important;
        margin-bottom: 6px;
        border-top: none;
        padding-top: 0;
        position: relative;
      }

      .sidebar.collapsed .tab.tab-settings-bottom::before {
        content: "";
        position: absolute;
        top: -4px;
        left: 4px;
        right: 4px;
        height: 1px;
        background: var(--border);
      }
    }

    /* =========================================
       APP SPLASH / STARTUP LOADER
       ========================================= */
    .app-splash-loader {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: #0f1011;
      z-index: 99999;
      display: flex;
      justify-content: center;
      align-items: center;
      transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.5s;
    }

    .app-splash-loader.hidden {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }

    .splash-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      animation: splashFadeIn 0.8s ease forwards;
    }

    .splash-logo-wrap {
      position: relative;
      width: 170px;
      height: 170px;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-bottom: var(--space-lg);
    }

    .splash-logo {
      width: 140px;
      height: 140px;
      object-fit: contain;
      z-index: 2;
      filter: drop-shadow(0 0 28px rgba(255, 255, 255, 0.5));
      animation: splashLogoPulse 2.4s ease-in-out infinite;
    }

    .splash-pulse-ring {
      position: absolute;
      width: 160px;
      height: 160px;
      border-radius: 50%;
      border: 1.5px solid rgba(255, 255, 255, 0.2);
      animation: splashRingPulse 2.4s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
      z-index: 1;
    }

    .splash-title {
      font-size: 28px;
      font-weight: 800;
      letter-spacing: 0.25em;
      color: #ffffff;
      margin-bottom: 6px;
      text-shadow: 0 0 16px rgba(255, 255, 255, 0.25);
    }

    .splash-subtitle {
      font-size: 14px;
      color: #b3b3b3;
      letter-spacing: 0.06em;
      margin-bottom: 32px;
    }

    .splash-bar-wrap {
      width: 240px;
      height: 3px;
      background: rgba(255, 255, 255, 0.12);
      border-radius: 999px;
      overflow: hidden;
      position: relative;
    }

    .splash-bar-fill {
      width: 40%;
      height: 100%;
      background: #ffffff;
      border-radius: 999px;
      animation: splashBarIndeterminate 1.4s infinite ease-in-out;
    }

    @keyframes splashLogoPulse {
      0%, 100% { transform: scale(1); filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.3)); }
      50% { transform: scale(1.06); filter: drop-shadow(0 0 32px rgba(255, 255, 255, 0.7)); }
    }

    @keyframes splashRingPulse {
      0% { transform: scale(0.85); opacity: 0.8; }
      50% { transform: scale(1.3); opacity: 0; }
      100% { transform: scale(1.3); opacity: 0; }
    }

    @keyframes splashBarIndeterminate {
      0% { transform: translateX(-100%); width: 30%; }
      50% { width: 60%; }
      100% { transform: translateX(250%); width: 30%; }
    }

    @keyframes splashFadeIn {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .toggle-btn {
      background: transparent;
      border: none;
      color: var(--text-secondary);
      font-size: var(--font-lg);
      cursor: pointer;
      padding: var(--space-xs);
      transition: color 0.2s;
    }

    .toggle-btn:hover {
      color: var(--text-primary);
    }

    .logo {
      font-size: var(--font-lg);
      font-weight: 800;
      display: flex;
      align-items: center;
      gap: var(--space-sm);
      letter-spacing: -0.02em;
      color: var(--text-primary);
      white-space: nowrap;
    }

    .app-logo-img {
      width: 32px;
      height: 32px;
      object-fit: contain;
      display: block;
      transition: filter 0.2s ease;
    }

    body:not(.light-theme) .app-logo-img {
      filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));
    }

    body.light-theme .app-logo-img {
      filter: invert(1) brightness(0.15);
    }

    .logo i {
      color: var(--primary);
    }

    .version {
      font-size: var(--font-xs);
      background: var(--surface-hover);
      padding: var(--space-xxs) var(--space-xs);
      border-radius: var(--radius-sm);
      font-weight: 600;
      letter-spacing: 0.05em;
      border: 1px solid var(--border);
      -webkit-text-fill-color: var(--text-secondary);
    }

    /* Main Content Wrapper */
    .main-wrapper {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .mobile-header {
      display: none; /* Only show on mobile */
      background: var(--surface);
      padding: var(--space-md) var(--space-lg);
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid var(--border);
    }

    @media (max-width: 768px) {
      body {
        flex-direction: column;
      }
      .sidebar {
        display: none; /* Hide sidebar completely on mobile */
      }
      .sidebar.mobile-open {
        display: flex;
        position: absolute;
        height: 100vh;
        z-index: 100;
        width: 260px;
        box-shadow: none;
      }
      .mobile-header {
        display: flex;
      }
      .chat-preview {
        min-height: 25vh;
      }
      main {
        padding: var(--space-md);
        gap: var(--space-md);
      }
    }

    /* Tabs & Nav Groups */
    .tabs.sidebar-tabs {
      display: flex;
      flex-direction: column;
      flex: 1;
      height: 100%;
      padding: var(--space-xs) var(--space-sm) var(--space-sm);
      gap: 6px;
      overflow-y: auto;
    }

    .nav-group {
      display: flex;
      flex-direction: column;
      width: 100%;
    }

    .nav-group-header {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 8px 6px 10px;
      background: transparent;
      border: none;
      border-radius: var(--radius-sm);
      color: var(--text-muted, #9a9a9a);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.6px;
      cursor: pointer;
      user-select: none;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-group-header:hover {
      color: var(--text-primary);
      background: rgba(255, 255, 255, 0.03);
    }

    .nav-group-title {
      display: flex;
      align-items: center;
      gap: 7px;
    }

    .nav-group-icon {
      font-size: 10px;
      opacity: 0.75;
    }

    .nav-group-chevron {
      font-size: 10px;
      transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
      opacity: 0.6;
    }

    .nav-group-header:hover .nav-group-chevron {
      opacity: 1;
    }

    .nav-group.collapsed .nav-group-chevron {
      transform: rotate(-90deg);
    }

    .nav-group-items {
      display: flex;
      flex-direction: column;
      gap: 3px;
      overflow: hidden;
      transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
      max-height: 400px;
      opacity: 1;
      padding-top: 2px;
    }

    .nav-group.collapsed .nav-group-items {
      max-height: 0;
      opacity: 0;
      padding-top: 0;
      pointer-events: none;
    }

    .tab {
      padding: 7px 12px;
      cursor: pointer;
      font-weight: 500;
      color: var(--text-secondary);
      border-radius: var(--radius-sm);
      background: transparent;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      align-items: center;
      gap: 9px;
      font-size: 12.5px;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .tab.tab-settings-bottom {
      margin-top: auto !important;
      border-top: 1px solid var(--border);
      padding-top: 10px;
      border-radius: var(--radius-sm);
    }

    .tab:hover {
      color: var(--text-primary);
      background: var(--surface-hover);
    }

    .tab:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    .tab.active {
      color: var(--primary);
      font-weight: 600;
      background: var(--tab-active-bg);
    }

    .tab.active i {
      text-shadow: none;
    }

    /* Main Content */
    main {
      flex: 1;
      display: flex;
      flex-direction: column;
      padding: 16px 20px;
      gap: 16px;
      overflow-y: auto;
      scroll-behavior: smooth;
    }

    .panel {
      display: none;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 18px 22px;
    }

    .panel.active {
      display: block;
    }

    @keyframes slideUpFade {
      from {
        opacity: 0;
        transform: translateY(var(--space-md));
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    h2 {
      font-size: var(--font-xl);
      font-weight: 700;
      letter-spacing: -0.02em;
      margin-bottom: var(--space-sm);
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-primary);
    }

    /* Standardized Panel Header & Typography System */
    .panel-header {
      margin-bottom: 20px;
    }

    .panel-header h2,
    .panel-title {
      font-size: var(--font-xl);
      font-weight: 700;
      letter-spacing: -0.02em;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-primary);
    }

    .panel-header p,
    .panel-desc {
      color: var(--text-muted);
      font-size: 0.88rem;
      line-height: 1.5;
      margin: 0;
    }

    /* Standardized Card & Surface System */
    .surface-box,
    .panel-card {
      background: var(--surface-solid);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 18px 20px;
      box-shadow: var(--shadow-md);
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    /* Global Focus & Accessibility Standards (WCAG 2.1 AA/AAA) */
    :focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    button:focus-visible,
    a:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    [role="button"]:focus-visible,
    [role="tab"]:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    /* Interactive States & Tap Target Standards (min 36-44px for desktop stream controller) */
    button,
    .btn,
    .tab,
    .header-toggle-btn {
      min-height: 34px;
      touch-action: manipulation;
      user-select: none;
    }

    button:disabled,
    .btn:disabled,
    input:disabled,
    select:disabled,
    textarea:disabled {
      opacity: 0.5;
      cursor: not-allowed !important;
      pointer-events: none;
    }

    /* Skeleton Loading / Shimmer State */
    .skeleton {
      background: linear-gradient(
        90deg,
        var(--surface-solid) 25%,
        var(--surface-hover) 50%,
        var(--surface-solid) 75%
      );
      background-size: 200% 100%;
      animation: skeletonShimmer 1.5s infinite ease-in-out;
      border-radius: var(--radius-sm);
    }

    @keyframes skeletonShimmer {
      0% {
        background-position: 200% 0;
      }
      100% {
        background-position: -200% 0;
      }
    }

    /* Smooth Micro-transitions */
    .panel,
    .surface-box {
      animation: smoothFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes smoothFadeIn {
      from {
        opacity: 0;
        transform: translateY(4px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    /* Form Elements */
    .form-group {
      margin-bottom: 12px;
    }

    label {
      display: block;
      font-size: var(--font-sm);
      font-weight: 600;
      color: var(--text-secondary);
      margin-bottom: var(--space-xs);
      letter-spacing: 0.01em;
    }

    input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
    select,
    textarea {
      width: 100%;
      min-height: 36px;
      background: var(--input-bg);
      border: 1px solid var(--border);
      color: var(--text-primary);
      padding: 8px 12px;
      border-radius: var(--radius-sm);
      font-family: inherit;
      font-size: 13px;
      transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    }

    input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus,
    select:focus,
    textarea:focus {
      outline: none;
      border-color: var(--border-light);
      background: var(--input-bg-focus);
      box-shadow: 0 0 0 1px var(--border-light);
    }

    input::placeholder,
    textarea::placeholder {
      color: var(--text-muted);
    }

    .btn-group {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-sm);
      margin-top: 12px;
    }

    button {
      padding: 8px 16px;
      border: none;
      border-radius: var(--radius-sm);
      font-family: inherit;
      font-weight: 600;
      font-size: 12.5px;
      cursor: pointer;
      transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      letter-spacing: 0.01em;
      white-space: nowrap;
    }

    button:active {
      transform: scale(0.98);
    }

    .btn-primary {
      background: var(--primary);
      color: var(--primary-text);
      font-weight: 700;
      border: 1px solid var(--border-light);
    }

    .btn-primary:hover {
      background: var(--primary-hover);
      color: var(--primary-text);
      border-color: var(--border-light);
      transform: translateY(-1px);
    }

    .btn-secondary {
      background: var(--surface-hover);
      color: var(--text-primary);
      border: 1px solid var(--border);
    }

    .btn-secondary:hover {
      background: #383b3f;
      border-color: var(--border-light);
    }

    .btn-warning {
      background: #383b3f;
      color: #e5e5e6;
      border: 1px solid #9a9a9a;
    }

    .btn-warning:hover {
      background: #9a9a9a;
      color: #ffffff;
    }

    .hidden {
      display: none;
    }

    .btn-tt {
      background: var(--text-primary);
      color: var(--bg);
    }

    .btn-tt:hover {
      background: var(--text-secondary);
      color: var(--bg);
    }

    .btn-yt {
      background: var(--accent-yt);
      color: var(--bg);
    }

    .btn-yt:hover {
      background: #b3b3b3;
    }

    .btn-danger {
      background: var(--btn-danger-bg);
      color: var(--red);
      border: 1px solid var(--btn-danger-border);
    }

    .btn-danger:hover {
      background: var(--btn-danger-bg-hover);
      border-color: var(--btn-danger-border-hover);
    }

    /* Status Indicator */
    .status-bar {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 14px;
      background: var(--surface-solid);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      margin-bottom: 12px;
      font-size: 12.5px;
      font-weight: 500;
      color: var(--text-primary);
    }

    .dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--text-muted);

    }

    .dot.connected,
    .dot.dot-success {
      background: var(--green);
      box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    }
    .dot.dot-warning {
      background: #f59e0b;
      box-shadow: 0 0 8px rgba(234, 179, 8, 0.6);
    }
    .dot.dot-danger {
      background: #eb5757;
      box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    }
    .dot.dot-purple {
      background: #ffffff;
      box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
    }

    @keyframes pulse {
      0% {
        transform: scale(0.95);
        opacity: 0.8;
      }
      50% {
        transform: scale(1.15);
        opacity: 1;
      }
      100% {
        transform: scale(0.95);
        opacity: 0.8;
      }
    }

    /* Live Chat Preview (Hidden by default, shown only on dedicated stream tabs) */
    .chat-preview {
      display: none;
      flex: 1;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      flex-direction: column;
      overflow: hidden;
      margin-top: auto;
      min-height: 40vh;
    }

    .chat-header {
      padding: var(--space-sm) var(--space-md);
      background: transparent;
      border-bottom: 1px solid var(--border);
      font-weight: 600;
      font-size: var(--font-sm);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .chat-list {
      flex: 1;
      overflow-y: auto;
      padding: var(--space-sm);
      display: flex;
      flex-direction: column;
      gap: var(--space-xs);
    }

    /* Custom Scrollbar */
    ::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: var(--border-light);
      border-radius: var(--radius-full);
    }

    ::-webkit-scrollbar-thumb:hover {
      background: var(--text-muted);
    }

    /* Chat Message Items */
    .msg-item {
      display: flex;
      align-items: flex-start;
      gap: var(--space-sm);
      padding: var(--space-sm) var(--space-md);
      border-radius: var(--radius-md);
      background: rgba(255, 255, 255, 0.02);
      border-left: 3px solid transparent;
      cursor: pointer;
      transition: all 0.2s ease;
      word-break: break-word;
      font-size: var(--font-md);
    }

    .msg-item:hover {
      background: rgba(255, 255, 255, 0.06);
      transform: translateX(4px);
    }

    .msg-item.tt {
      border-left-color: var(--primary);
    }

    .msg-item.yt {
      border-left-color: var(--accent-yt);
    }

    .msg-item.tw {
      border-left-color: var(--accent-tw);
    }

    .msg-item.dimmed {
      opacity: 0.4;
    }

    body.hide-dimmed .msg-item.dimmed {
      display: none !important;
    }

    .msg-item.donation {
      border: 1px solid var(--border-light);
      background: var(--surface-hover);
    }

    .msg-avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      object-fit: cover;

    }

    .msg-content {
      flex: 1;
      line-height: 1.4;
    }

    .msg-name {
      font-weight: 600;
      margin-right: var(--space-xs);
      font-size: var(--font-sm);
    }

    .msg-text {
      color: var(--text-primary);
      margin-top: 2px;
    }

    .msg-text img {
      height: 1.4em;
      vertical-align: -0.2em;
    }

    .msg-text.with-emotes img.chat-emote {
      height: 1.5em;
      width: auto;
      vertical-align: middle;
      margin: 0 3px;
      border-radius: 4px;
    }

    .msg-meta {
      font-size: var(--font-xs);
      color: var(--text-secondary);
      margin-top: 4px;
      font-weight: 500;
    }

    .plat-icon {
      font-size: var(--font-xs);
      margin-right: 4px;
    }

    .msg-badges {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      margin-right: 4px;
      vertical-align: middle;
    }

    .msg-badges:empty {
      display: none;
    }

    .msg-badges .custom-badge {
      display: inline-flex;
      align-items: center;
      gap: 2px;
      padding: 1px 5px 1px 2px;
      border-radius: 9px;
      font-size: 10px;
      font-weight: 700;
      line-height: 1;
      color: #ffffff;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
      white-space: nowrap;
    }

    .msg-badges .custom-badge.level {
      background: linear-gradient(90deg, rgba(37, 99, 235, 0.8), rgba(59, 130, 246, 0.8));
      border: 1px solid rgba(59, 130, 246, 0.9);
    }

    .msg-badges .custom-badge.fan {
      background: linear-gradient(90deg, rgba(219, 39, 119, 0.8), rgba(236, 72, 153, 0.8));
      border: 1px solid rgba(236, 72, 153, 0.9);
    }

    .msg-badges .custom-badge.mod {
      background: linear-gradient(90deg, rgba(16, 185, 129, 0.8), rgba(52, 211, 153, 0.8));
      border: 1px solid rgba(52, 211, 153, 0.9);
    }

    .msg-badges .custom-badge img,
    .msg-badges img.badge {
      height: 13px;
      width: auto;
      border-radius: 50%;
      display: inline-block;
      vertical-align: middle;
    }

    .msg-badges .rank-label {
      display: inline-block;
      background: linear-gradient(135deg, #f59e0b, #d97706);
      color: #ffffff;
      font-size: 9px;
      font-weight: 800;
      padding: 1px 4px;
      border-radius: 7px;
      border: 1px solid #fbbf24;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
      box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
    }

    .header-section {
      margin-bottom: var(--space-md);
    }

    .header-section h2 {
      margin: 0 0 var(--space-xs) 0;
    }

    .header-section p {
      margin: 0;
      color: var(--text-muted);
      font-size: var(--font-sm);
    }

    .controls-container {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: var(--space-md);
    }

    .search-box {
      position: relative;
      width: 320px;
    }

    .search-box input {
      padding-left: var(--space-xl);
    }

    .search-box i {
      position: absolute;
      left: var(--space-md);
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-muted);
    }

    .btn-new {
      background-color: var(--text-primary);
      color: var(--bg);
      border: none;
      padding: var(--space-sm) var(--space-lg);
      border-radius: 4px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;

    }

    .btn-new:hover {
      background-color: var(--text-secondary);

      transform: translateY(-1px);
    }

    .table-container {
      background-color: var(--surface-solid);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      overflow: hidden;

    }

    table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
    }

    th {
      font-size: var(--font-xs);
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-secondary);
      padding: var(--space-md);
      border-bottom: 1px solid var(--border);
      background: rgba(0, 0, 0, 0.2);
    }

    td {
      padding: var(--space-md);
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }

    tr:last-child td {
      border-bottom: none;
    }

    tr:hover td {
      background: rgba(255, 255, 255, 0.02);
    }

    /* Toggle Switch */
    .switch,
    .toggle-switch {
      position: relative;
      display: inline-block;
      width: 40px;
      height: 22px;
      flex-shrink: 0;
      cursor: pointer;
    }

    .switch input,
    .toggle-switch input {
      opacity: 0;
      width: 0;
      height: 0;
      position: absolute;
    }

    .slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: var(--surface-hover);
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: var(--radius-full);
      border: 1px solid var(--border-light);
    }

    .slider:before {
      position: absolute;
      content: "";
      height: 16px;
      width: 16px;
      left: 2px;
      bottom: 2px;
      background-color: var(--text-muted);
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 50%;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    input:checked + .slider {
      background-color: var(--green);
      border-color: var(--green);
    }

    input:checked + .slider:before {
      transform: translateX(18px);
      background-color: #ffffff;
    }

    .timer-info {
      display: flex;
      flex-direction: column;
      gap: var(--space-xxs);
    }

    .timer-name {
      font-weight: 600;
      font-size: var(--font-md);
      color: var(--text-primary);
    }

    .timer-msg {
      color: var(--text-muted);
      font-size: var(--font-sm);
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .actions {
      display: flex;
      gap: var(--space-sm);
      justify-content: flex-end;
    }

    .action-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      cursor: pointer;
      font-size: var(--font-sm);
      width: 32px;
      height: 32px;
      border-radius: var(--radius-md);
      transition: all 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
    }

    .action-btn:hover {
      color: var(--text-primary);
      background: var(--surface-hover);
      border-color: var(--border-light);
    }

    .footer-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: var(--space-md);
      border-top: 1px solid var(--border);
      font-size: var(--font-sm);
      color: var(--text-secondary);
      background: rgba(0, 0, 0, 0.1);
    }

    .footer-bar select {
      width: auto;
      padding: var(--space-xs) var(--space-md);
    }

    .pagination-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      padding: var(--space-xs) var(--space-sm);
      border-radius: var(--radius-sm);
      color: var(--text-secondary);
      cursor: pointer;
    }

    .pagination-btn:hover {
      background: var(--surface-hover);
      color: var(--text-primary);
    }

    /* Modal Styles - Unified & Polished across Dark and Light Themes */
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.72);
      backdrop-filter: blur(8px);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 10000;
      animation: fadeIn 0.2s ease forwards;
    }

    body.light-theme .modal-overlay {
      background: rgba(15, 23, 42, 0.45);
      backdrop-filter: blur(6px);
    }

    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    .modal {
      background: var(--surface-solid);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-lg);
      width: 90%;
      max-width: 440px;
      padding: 24px;
      box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
      animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      position: relative;
      color: var(--text-primary);
    }

    body.light-theme .modal {
      background: #ffffff;
      border: 1px solid var(--border);
      box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    @keyframes modalSlideIn {
      from {
        opacity: 0;
        transform: scale(0.95) translateY(12px);
      }
      to {
        opacity: 1;
        transform: scale(1) translateY(0);
      }
    }

    .confirm-dialog {
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    .modal-header-icon {
      width: 52px;
      height: 52px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.4rem;
      margin-bottom: 14px;
    }

    .modal-header-icon.danger {
      background: rgba(239, 68, 68, 0.15);
      color: #eb5757;
      border: 1px solid rgba(239, 68, 68, 0.35);
    }

    .modal-header-icon.info {
      background: var(--surface-hover);
      color: var(--text-primary);
      border: 1px solid rgba(59, 130, 246, 0.35);
    }

    body.light-theme .modal-header-icon.danger {
      background: rgba(220, 38, 38, 0.1);
      color: #eb5757;
      border: 1px solid rgba(220, 38, 38, 0.25);
    }

    body.light-theme .modal-header-icon.info {
      background: var(--surface-hover);
      color: var(--text-primary);
      border: 1px solid rgba(37, 99, 235, 0.25);
    }

    .modal h2 {
      margin: 0 0 8px 0;
      font-size: 1.15rem;
      font-weight: 700;
      color: var(--text-primary);
    }

    .confirm-modal-msg {
      color: var(--text-secondary);
      font-size: 0.88rem;
      line-height: 1.5;
      margin: 0 0 20px 0;
      word-break: break-word;
    }

    .modal-actions {
      display: flex;
      justify-content: center;
      gap: 10px;
      width: 100%;
      margin-top: 14px;
    }

    .modal-actions .btn-cancel {
      flex: 1;
      background: var(--surface-hover);
      border: 1px solid var(--border);
      color: var(--text-primary);
      padding: 9px 16px;
      border-radius: var(--radius-md);
      font-weight: 600;
      font-size: 0.88rem;
      cursor: pointer;
      transition: all 0.15s;
    }

    .modal-actions .btn-cancel:hover {
      background: var(--border);
      border-color: var(--border-light);
    }

    body.light-theme .modal-actions .btn-cancel {
      background: #e5e5e6;
      border-color: #e8e8e8;
      color: #23252a;
    }

    body.light-theme .modal-actions .btn-cancel:hover {
      background: #e8e8e8;
      border-color: #b3b3b3;
      color: #08090a;
    }

    .modal-actions .btn-danger {
      flex: 1;
      background: #eb5757;
      border: 1px solid rgba(239, 68, 68, 0.8);
      color: #ffffff;
      padding: 9px 16px;
      border-radius: var(--radius-md);
      font-weight: 600;
      font-size: 0.88rem;
      cursor: pointer;
      transition: all 0.15s;
      box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    }

    .modal-actions .btn-danger:hover {
      background: #eb5757;
      box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
    }

    body.light-theme .modal-actions .btn-danger {
      background: #eb5757;
      border-color: #eb5757;
      color: #ffffff;
      box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
    }

    body.light-theme .modal-actions .btn-danger:hover {
      background: #eb5757;
      box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-save {
      flex: 1;
      background: var(--primary);
      border: 1px solid var(--primary);
      color: var(--primary-text);
      padding: 9px 16px;
      border-radius: var(--radius-md);
      font-weight: 700;
      font-size: 0.88rem;
      cursor: pointer;
      transition: all 0.15s;
    }

    .modal-actions .btn-primary:hover,
    .modal-actions .btn-save:hover {
      background: var(--primary-hover);
      border-color: var(--primary-hover);
    }

    /* Toast Notifications - Top Center Floating Pill */
    #toast-container {
      position: fixed;
      top: 56px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      z-index: 11000;
      pointer-events: none;
    }

    .toast {
      background: rgba(24, 24, 27, 0.94);
      color: #ffffff;
      padding: 9px 20px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      gap: 10px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      transform: translateY(-16px) scale(0.96);
      opacity: 0;
      transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      pointer-events: auto;
      font-size: 13px;
      font-weight: 600;
      max-width: 90vw;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      user-select: none;
    }

    body.light-theme .toast {
      background: rgba(255, 255, 255, 0.96);
      color: #08090a;
      border: 1px solid rgba(203, 213, 225, 0.8);
      box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
    }

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

    .toast i {
      font-size: 15px;
      color: #27a644;
      flex-shrink: 0;
    }

    .toast-error i {
      color: #eb5757;
    }

    body.light-theme .toast-error i {
      color: #eb5757;
    }

    .toast-info i { 
      color: #e8e8e8;
    }

    body.light-theme .toast-info i { 
      color: #e8e8e8;
    }

    /* Custom New Modal Styles */
    .modal.large {
      max-width: 600px;
      padding: var(--space-xl);
    }
    
    .modal-close {
      position: absolute;
      top: var(--space-md);
      right: var(--space-md);
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: var(--font-lg);
      padding: var(--space-xs);
    }
    .modal-close:hover {
      color: var(--text-primary);
    }

    .custom-checkbox-wrapper {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      margin-bottom: var(--space-xs);
      cursor: pointer;
      user-select: none;
    }
    
    .custom-checkbox {
      -webkit-appearance: none;
      appearance: none;
      width: 18px !important;
      height: 18px !important;
      min-width: 18px !important;
      max-width: 18px !important;
      min-height: 18px !important;
      max-height: 18px !important;
      border-radius: 4px;
      border: 1.5px solid var(--border-light);
      background: var(--surface-solid);
      position: relative;
      cursor: pointer;
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin: 0 !important;
      padding: 0 !important;
      transition: all 0.15s ease;
      box-sizing: border-box;
    }
    
    .custom-checkbox:hover {
      border-color: var(--text-secondary);
      background: var(--surface-hover);
    }
    
    .custom-checkbox:checked {
      background: var(--primary) !important;
      border-color: var(--primary) !important;
    }
    
    .custom-checkbox:checked::after {
      content: '';
      position: absolute;
      top: 45%;
      left: 50%;
      width: 4px;
      height: 8px;
      border-right: 2px solid var(--primary-text);
      border-bottom: 2px solid var(--primary-text);
      transform: translate(-50%, -55%) rotate(45deg);
      box-sizing: border-box;
    }

    .custom-checkbox-label {
      font-weight: 600;
      font-size: 13.5px;
      color: var(--text-primary);
      cursor: pointer;
      user-select: none;
      line-height: 1.3;
    }

    .file-input-group {
      display: flex;
      align-items: center;
      gap: var(--space-sm);
      background: transparent;
      border: 1px solid var(--border-light);
      padding: 4px;
      border-radius: var(--radius-md);
      width: fit-content;
    }
    
    .file-btn {
      background: rgba(255,255,255,0.05);
      color: var(--text-primary);
      font-weight: 600;
      padding: 8px 16px;
      border: none;
      cursor: pointer;
      border-radius: 4px;
      font-size: var(--font-sm);
    }
    .file-btn:hover {
      background: rgba(255,255,255,0.1);
    }

    .file-text {
      color: var(--text-muted);
      font-size: var(--font-sm);
    }

    .helper-text {
      font-size: var(--font-sm);
      color: var(--text-muted);
      margin-top: var(--space-xs);
      line-height: 1.4;
    }
    
    .helper-text a {
      color: var(--text-primary);
      text-decoration: underline;
    }

    /* Universal Range Slider Styles (Clean, modern, slim track with responsive colors) */
    input[type="range"] {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 4px;
      background: var(--border-light) !important;
      border-radius: var(--radius-full);
      outline: none;
      margin: 0;
      padding: 0;
      cursor: pointer;
      vertical-align: middle;
      border: none !important;
      box-shadow: none !important;
    }

    input[type="range"]::-webkit-slider-runnable-track {
      width: 100%;
      height: 4px;
      cursor: pointer;
      background: var(--border-light);
      border-radius: var(--radius-full);
      border: none;
      margin: 0;
      padding: 0;
    }

    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--primary);
      border: 2px solid var(--surface);
      cursor: pointer;
      margin: 0;
      margin-top: -5px;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
      transition: transform 0.15s ease, background 0.15s ease;
    }

    input[type="range"]::-webkit-slider-thumb:hover {
      transform: scale(1.2);
    }

    input[type="range"]::-webkit-slider-thumb:active {
      transform: scale(1.3);
    }

    input[type="range"]::-moz-range-track {
      width: 100%;
      height: 4px;
      cursor: pointer;
      background: var(--border-light);
      border-radius: var(--radius-full);
      border: none;
      margin: 0;
      padding: 0;
    }

    input[type="range"]::-moz-range-thumb {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--primary);
      border: 2px solid var(--surface);
      cursor: pointer;
      margin: 0;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
      transition: transform 0.15s ease, background 0.15s ease;
    }

    input[type="range"]::-moz-range-thumb:hover {
      transform: scale(1.2);
    }

    .range-wrapper {
      display: flex;
      align-items: center;
      gap: var(--space-sm);
      width: 100%;
      margin: 0;
      padding: 0;
    }

    .range-wrapper input[type="range"] {
      flex: 1;
      margin: 0;
    }

    .range-wrapper .range-val {
      min-width: 45px;
      text-align: right;
      font-weight: 600;
      color: var(--text-primary);
      font-size: var(--font-sm);
      flex-shrink: 0;
    }

    .adv-box {
      background: rgba(255,255,255,0.02);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: var(--space-md);
      margin-top: var(--space-md);
    }
    
.adv-box.warning {
      border-color: var(--border-light);
      display: flex;
      gap: var(--space-sm);
      align-items: flex-start;
    }

    .adv-box.warning i {
      color: var(--text-secondary);
      margin-top: 2px;
    }

    .adv-box.info {
      border-color: var(--border-light);
      display: flex;
      gap: var(--space-sm);
      align-items: flex-start;
    }

    .adv-box.info i {
      color: var(--text-secondary);
      margin-top: 2px;
    }

    .surface-box {
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: var(--space-md);
    }
    
    .settings-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: var(--space-md) var(--space-lg);
      border-bottom: 1px solid var(--border);
    }
    
    .settings-item:last-child {
      border-bottom: none;
    }

    .sub-tabs {
      display: flex;
      gap: var(--space-sm);
      margin-bottom: var(--space-lg);
      border-bottom: 1px solid var(--border);
      padding-bottom: var(--space-md);
    }

    .sub-tab {
      background: transparent;
      border: none;
      color: var(--text-secondary);
      padding: var(--space-sm) var(--space-md);
      border-radius: var(--radius-sm);
      font-weight: 600;
      cursor: pointer;
      font-size: var(--font-sm);
      transition: all 0.2s;
      display: inline-flex;
      align-items: center;
      gap: var(--space-xs);
    }

    .sub-tab:hover {
      background: var(--surface-hover);
      color: var(--text-primary);
    }

    .sub-tab.active {
      background: var(--surface-hover);
      border: 1px solid var(--border);
      color: var(--text-primary);
    }
    
    .btn-block {
      width: 100%;
      margin-top: var(--space-lg);
      border-radius: var(--radius-full);
    }

    /* ── TTS Panel Styles ── */
    .tts-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: var(--text-muted);
      transition: all 0.3s ease;
      flex-shrink: 0;
    }

    .tts-dot.active {
      background: var(--green);

    }

    .tts-dot.speaking {
      background: var(--accent-tt);
    }

    .tts-queue-badge {
      background: var(--primary);
      color: var(--primary-text);
      font-size: 11px;
      font-weight: 700;
      min-width: 22px;
      height: 22px;
      border-radius: var(--radius-full);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 6px;
    }

    #tts-toggle.tts-active {
      background: var(--green);
      color: #ffffff;
    }

    #tts-toggle.tts-active:hover {
      background: #27a644;
      color: #ffffff;
    }

    #tts-toggle.tts-inactive {
      background: var(--surface-hover);
      color: var(--text-secondary);
      border: 1px solid var(--border);
    }

    #tts-toggle.tts-inactive:hover {
      background: var(--primary);
      color: var(--primary-text);
      border-color: var(--border-light);
    }

    /* Clean, professional alignment for Control Panels */
    #panel-tt .form-group,
    #panel-yt .form-group {
      max-width: 600px;
    }

    /* ==========================================================================
       DASHBOARD STATISTIK STYLES (POLISHED & BALANCED)
       ========================================================================== */
    .dashboard-metrics-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
      gap: 14px;
      margin-bottom: 24px;
    }

    @media (max-width: 900px) {
      .dashboard-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      }
    }

    @media (max-width: 580px) {
      .dashboard-metrics-grid {
        grid-template-columns: 1fr;
      }
    }

    .dashboard-stat-card {
      background: transparent;
      border: none;
      border-radius: 0;
      padding: 12px 4px;
      display: flex;
      align-items: center;
      gap: 14px;
      transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .dashboard-stat-card:hover {
      transform: translateY(-2px);
      border-color: var(--border-light);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    }

    .stat-card-icon {
      width: 44px;
      height: 44px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.25rem;
      flex-shrink: 0;
    }

    .stat-card-content {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .stat-card-label {
      color: var(--text-muted);
      font-size: 0.75rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.6px;
    }

    .stat-card-value {
      font-size: 1.6rem;
      font-weight: 800;
      color: var(--text-primary);
      line-height: 1.15;
      font-feature-settings: "tnum";
      font-variant-numeric: tabular-nums;
    }

    /* Active Sessions Section */
    .active-sessions-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
      gap: 14px;
    }

    .active-session-card {
      background: var(--surface-solid);
      border-radius: var(--radius-lg);
      padding: 16px 20px;
      border: 1px solid var(--border);
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .active-session-card.tiktok {
      border-left: 4px solid var(--accent-tt);
      background: linear-gradient(135deg, rgba(37, 244, 238, 0.05), var(--surface-solid));
    }

    .active-session-card.youtube {
      border-left: 4px solid var(--accent-yt);
      background: linear-gradient(135deg, rgba(255, 74, 74, 0.05), var(--surface-solid));
    }

    .active-session-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .active-session-header .platform-tag {
      font-size: 0.85rem;
      font-weight: 800;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .active-session-header .platform-tag.tiktok {
      color: var(--accent-tt);
    }

    .active-session-header .platform-tag.youtube {
      color: var(--accent-yt);
    }

    .live-pill {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      background: rgba(34, 197, 94, 0.15);
      color: #27a644;
      border: 1px solid rgba(34, 197, 94, 0.4);
      padding: 2px 8px;
      border-radius: 20px;
      font-size: 0.75rem;
      font-weight: 800;
      letter-spacing: 0.5px;
    }

    .live-ping {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #27a644;
      box-shadow: 0 0 6px #27a644;
      animation: pulseLive 1.5s infinite ease-in-out;
    }

    .live-indicator-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #27a644;
      display: inline-block;
      box-shadow: 0 0 6px #27a644;
    }

    .active-session-room {
      font-size: 1.05rem;
      font-weight: 700;
      color: var(--text-primary);
    }

    .active-session-metrics {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .active-metric-chip {
      background: var(--surface-hover);
      border: 1px solid var(--border);
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 0.8rem;
      font-weight: 600;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: var(--text-primary);
    }

    .active-metric-chip i {
      font-size: 0.75rem;
      color: var(--text-muted);
    }

    /* History Card & Toolbar */
    .dashboard-history-card {
      padding: 20px;
      margin-bottom: 24px;
    }

    .dashboard-history-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 12px;
      margin-bottom: 16px;
    }

    .dashboard-actions-toolbar {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .dashboard-actions-toolbar select {
      background: var(--surface-hover);
      color: var(--text-primary);
      border: 1px solid var(--border);
      padding: 8px 12px;
      border-radius: var(--radius-md);
      font-size: var(--font-sm);
      cursor: pointer;
    }

    .btn-warning-outline {
      background: transparent;
      color: #f59e0b;
      border: 1px solid rgba(245, 158, 11, 0.5);
      padding: 8px 14px;
      border-radius: var(--radius-md);
      font-weight: 600;
      font-size: var(--font-sm);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.2s;
    }

    .btn-warning-outline:hover {
      background: rgba(245, 158, 11, 0.15);
      border-color: #f59e0b;
    }

    .btn-danger-outline {
      background: transparent;
      color: #eb5757;
      border: 1px solid rgba(239, 68, 68, 0.5);
      padding: 8px 14px;
      border-radius: var(--radius-md);
      font-weight: 600;
      font-size: var(--font-sm);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.2s;
    }

    .btn-danger-outline:hover {
      background: rgba(239, 68, 68, 0.15);
      border-color: #eb5757;
    }

    /* History Table Badges & Text */
    .table-live-badge {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      background: rgba(34, 197, 94, 0.15);
      color: #27a644;
      border: 1px solid rgba(34, 197, 94, 0.4);
      padding: 2px 7px;
      border-radius: 12px;
      font-size: 0.75rem;
      font-weight: 700;
    }

    .table-live-dot {
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: #27a644;
    }

    .table-duration-badge {
      color: var(--text-secondary);
      font-size: 0.85rem;
      font-weight: 500;
    }

    .text-tt {
      color: var(--accent-tt);
    }

    .text-yt {
      color: var(--accent-yt);
    }

    .text-tw {
      color: var(--accent-tw);
    }

    /* ==========================================================================
       UNIVERSAL PROPORTIONAL & RESPONSIVE RULES ACROSS ALL TABS
       ========================================================================== */
    .panel {
      width: 100%;
      box-sizing: border-box;
      max-width: 100%;
    }

    /* Fluid Form & Grid Containers */
    .form-group, 
    .form-row,
    .controls-container,
    .surface-box {
      width: 100%;
      box-sizing: border-box;
    }

    /* Tables Universal Responsive Wrap */
    .table-container {
      width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      border-radius: var(--radius-md);
      box-sizing: border-box;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 500px;
    }

    /* Buttons & Actions Wrapping */
    .btn-group,
    .modal-actions,
    .controls-container,
    .dashboard-actions-toolbar,
    .m-controls,
    .m-btn-group,
    .tts-btn-group {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }

    /* Two-column responsive layouts in tabs (TTS, Simulator, Overlay Links) */
    .two-col-grid,
    .tab-columns,
    .settings-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
      gap: 16px;
      width: 100%;
    }

    /* Overlay Cards Grid */
    .overlay-grid,
    .links-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 14px;
      width: 100%;
    }

    /* Responsive Adaptations for Medium & Small Windows */
    @media (max-width: 960px) {
      main {
        padding: 12px 14px;
        gap: 12px;
      }
      .panel {
        padding: 14px 16px;
      }
      .search-box {
        width: 100%;
        max-width: 100%;
      }
      .controls-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
      }
      .dashboard-history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
      }
      .dashboard-actions-toolbar {
        width: 100%;
      }
    }

    @media (max-width: 640px) {
      .two-col-grid,
      .tab-columns,
      .settings-grid,
      .active-sessions-grid {
        grid-template-columns: 1fr;
      }
      .btn {
        flex: 1 1 auto;
      }
      .settings-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
      }
    }

    /* Multi-Connect Component Styles */
    .custom-toggle {
      display: inline-flex;
      align-items: center;
      cursor: pointer;
    }
    .custom-toggle input {
      display: none;
    }
    .custom-toggle-track {
      width: 38px;
      height: 20px;
      background: rgba(255, 255, 255, 0.15);
      border-radius: 999px;
      position: relative;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .custom-toggle-track::after {
      content: "";
      position: absolute;
      top: 2px;
      left: 2px;
      width: 16px;
      height: 16px;
      background: #fff;
      border-radius: 50%;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    }
    .custom-toggle input:checked + .custom-toggle-track {
      background: var(--primary, #27a644);
    }
    .custom-toggle input:checked + .custom-toggle-track::after {
      transform: translateX(18px);
    }

    .mc-badge-connected {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: #27a644;
    }
    .mc-badge-connected::before {
      content: "";
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #27a644;
      box-shadow: 0 0 8px #27a644;
    }

    .mc-badge-disconnected {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: var(--text-muted);
    }
    .mc-badge-disconnected::before {
      content: "";
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #9a9a9a;
    }

    .mc-badge-connecting {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: #eab308;
    }
    .mc-badge-connecting::before {
      content: "";
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #eab308;
      box-shadow: 0 0 8px #eab308;
      animation: mc-pulse 1.2s ease-in-out infinite;
    }
    @keyframes mc-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.35; }
    }

    /* Multi-Connect Card Action Buttons */
    .mc-card-actions {
      margin-top: auto;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .mc-card-actions .mc-btn-toggle {
      flex: 1 1 auto;
      min-width: 120px;
    }
    .mc-card-actions .mc-btn-signin {
      flex: 0 0 auto;
      white-space: nowrap;
    }
    .mc-card-actions .mc-btn-reconnect {
      white-space: nowrap;
    }

    /* Saat TikTok terhubung (ada 3 tombol: Putuskan, Reconnect, QR Login):
       Putuskan ditaruh di baris 1 (lebar penuh 100%),
       Reconnect & QR Login membagi rata baris 2 (50% masing-masing).
       Tidak akan ada yang dempet, teks tidak terhimpit, layout simetris & kokoh. */
    #mc-card-tt.is-connected #mc-btn-tt-toggle {
      flex: 1 1 100% !important;
      width: 100% !important;
    }
    #mc-card-tt.is-connected #mc-btn-tt-reconnect,
    #mc-card-tt.is-connected #mc-btn-tt-signin {
      flex: 1 1 calc(50% - 4px) !important;
      width: calc(50% - 4px) !important;
      justify-content: center !important;
      display: inline-flex !important;
    }

    .mc-card {
      transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    }
    .mc-card:hover {
      border-color: var(--border-light);
      transform: translateY(-2px);
      box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    }

    .timer-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: var(--text-muted);
      transition: all 0.3s ease;
      flex-shrink: 0;
    }
    .timer-dot.active {
      background: var(--green) !important;
      box-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
    }

    /* ==========================================================================
       Interactive Timeseries Chart (Google Finance Style)
       ========================================================================== */
    .timeseries-card {
      padding: 24px;
      border-radius: var(--radius-lg);
      position: relative;
    }

    .timeseries-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      flex-wrap: wrap;
      gap: 16px;
      margin-bottom: 16px;
    }

    .timeseries-hero {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .timeseries-hero-title {
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--text-secondary);
    }

    .timeseries-hero-val-row {
      display: flex;
      align-items: baseline;
      gap: 12px;
    }

    .timeseries-hero-val {
      font-size: 2.2rem;
      font-weight: 800;
      letter-spacing: -0.02em;
      color: var(--text-primary);
      line-height: 1.1;
      font-family: inherit;
    }

    .timeseries-hero-badge {
      font-size: 0.8rem;
      font-weight: 700;
      padding: 2px 8px;
      border-radius: 20px;
      background: rgba(34, 197, 94, 0.15);
      color: #27a644;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .timeseries-hero-badge.down {
      background: rgba(239, 68, 68, 0.15);
      color: #eb5757;
    }

    .timeseries-hero-subtitle {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .timeseries-controls {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 10px;
    }

    .timeseries-pills-group {
      display: inline-flex;
      background: var(--surface-hover);
      border: 1px solid var(--border);
      border-radius: 24px;
      padding: 3px;
      gap: 2px;
      flex-wrap: wrap;
    }

    .ts-pill, .ts-range-pill {
      background: transparent;
      border: none;
      color: var(--text-secondary);
      font-size: 0.8rem;
      font-weight: 600;
      padding: 5px 12px;
      border-radius: 20px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .ts-pill:hover, .ts-range-pill:hover {
      color: var(--text-primary);
      background: rgba(255, 255, 255, 0.05);
    }

    .ts-pill.active, .ts-range-pill.active {
      background: var(--primary);
      color: var(--primary-text);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    /* Chart SVG & Interactive Canvas */
    .timeseries-chart-wrapper {
      position: relative;
      width: 100%;
      height: 260px;
      margin-top: 10px;
      user-select: none;
    }

    .timeseries-svg {
      width: 100%;
      height: 100%;
      overflow: visible;
      cursor: crosshair;
    }

    .timeseries-y-label {
      fill: var(--text-muted);
      font-size: 0.68rem;
      font-variant-numeric: tabular-nums;
      user-select: none;
    }

    .timeseries-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 10px 18px;
      justify-content: flex-end;
      padding: 6px 10px 2px;
      font-size: 0.75rem;
      color: var(--text-secondary);
    }

    .heatmap-card {
      padding: 16px 16px 18px;
    }

    .heatmap-header {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }

    .heatmap-subtitle {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .heatmap-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
    }

    .heatmap-body {
      position: relative;
      overflow-x: auto;
      padding-bottom: 4px;
    }

    .heatmap-grid {
      display: grid;
      gap: 3px;
      min-width: max-content;
      align-items: center;
    }

    .heatmap-hour-label {
      font-size: 0.7rem;
      color: var(--text-muted);
      text-align: right;
      padding-right: 8px;
      font-variant-numeric: tabular-nums;
      line-height: 1;
    }

    .heatmap-day-label {
      font-size: 0.72rem;
      color: var(--text-secondary);
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.2;
      padding-bottom: 2px;
    }

    .heatmap-cell {
      aspect-ratio: 1;
      border-radius: 4px;
      cursor: pointer;
      border: 1px solid var(--border-light);
      min-height: 20px;
      transition: transform 0.08s ease, box-shadow 0.08s ease;
    }

    .heatmap-cell:hover {
      transform: scale(1.15);
      box-shadow: 0 0 0 1px var(--primary);
      z-index: 2;
    }

    .heatmap-tooltip {
      position: absolute;
      pointer-events: none;
      z-index: 30;
      background: var(--surface-solid);
      border: 1px solid var(--border-light);
      padding: 8px 12px;
      border-radius: 8px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      display: flex;
      flex-direction: column;
      gap: 2px;
      white-space: nowrap;
    }

    .heatmap-tooltip strong {
      font-weight: 700;
      font-size: 0.9rem;
      color: var(--text-primary);
    }

    .heatmap-tooltip span {
      font-size: 0.72rem;
      color: var(--text-secondary);
    }

    body.light-theme .heatmap-cell {
      border-color: #e8e8e8;
    }

    .legend-item {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
    }

    .legend-swatch {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 2px;
      background: var(--primary);
      opacity: 0.55;
    }

    .legend-swatch-ma {
      width: 14px;
      height: 0;
      border-radius: 0;
      background: transparent;
      border-top: 2px dashed var(--primary);
      opacity: 1;
    }

    .timeseries-tooltip {
      position: absolute;
      pointer-events: none;
      transform: translate(-50%, -100%);
      margin-top: -12px;
      background: var(--surface-solid);
      border: 1px solid var(--border-light);
      padding: 6px 12px;
      border-radius: 8px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      z-index: 20;
      display: flex;
      flex-direction: column;
      align-items: center;
      white-space: nowrap;
      transition: opacity 0.15s ease, transform 0.05s linear;
    }

    .timeseries-tooltip::after {
      content: "";
      position: absolute;
      bottom: -5px;
      left: 50%;
      transform: translateX(-50%);
      width: 0;
      height: 0;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      border-top: 5px solid var(--border-light);
    }

    .ts-tt-val {
      font-weight: 700;
      font-size: 0.95rem;
      color: var(--text-primary);
    }

    .ts-tt-ma {
      font-size: 0.72rem;
      color: var(--text-secondary);
      opacity: 0.85;
    }

    .ts-tt-time {
      font-size: 0.75rem;
      color: var(--text-secondary);
    }

    .timeseries-x-labels {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      display: flex;
      justify-content: space-between;
      pointer-events: none;
      font-size: 0.75rem;
      color: var(--text-muted);
      padding: 0 8px;
    }

    /* Simulator Panel Action Buttons */
    .btn-sim {
      background: var(--surface-hover);
      color: var(--text-primary);
      border: 1px solid var(--border);
      padding: 7px 14px;
      font-size: 12px;
      font-weight: 600;
      border-radius: var(--radius-sm);
      transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .btn-sim:hover {
      background: #383b3f;
      border-color: var(--border-light);
      color: #ffffff;
      transform: translateY(-1px);
    }

    body.light-theme .btn-sim {
      background: #e5e5e6;
      color: #08090a;
      border-color: #e8e8e8;
    }

    body.light-theme .btn-sim:hover {
      background: #e8e8e8;
      border-color: #b3b3b3;
      color: #08090a;
    }

    /* ==========================================================================
       Master Canvas Studio (Unified Overlay Artboard & Inspector)
       ========================================================================== */
    .cs-work-area {
      display: flex;
      gap: var(--space-md);
      align-items: flex-start;
      margin-bottom: var(--space-md);
    }

    .cs-stage-column {
      flex: 1.4;
      min-width: 0;
    }

    .cs-inspector-column {
      flex: 1;
      min-width: 300px;
    }

    @media (max-width: 1024px) {
      .cs-work-area {
        flex-direction: column;
      }
      .cs-stage-column, .cs-inspector-column {
        width: 100%;
      }
    }

    .cs-stage-container {
      background: #08090a;
      background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
      background-size: 20px 20px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
      overflow: hidden;
    }

    .cs-stage {
      position: relative;
      width: 100%;
      max-height: 480px;
      aspect-ratio: 16 / 9;
      background: rgba(18, 18, 22, 0.7);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 6px;
      overflow: hidden;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .cs-stage.vertical-mode {
      max-width: 280px;
      margin: 0 auto;
    }

    /* Draggable Widget Boxes on Stage */
    .cs-widget-box {
      position: absolute;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(139, 92, 246, 0.4);
      border-radius: 6px;
      cursor: grab;
      user-select: none;
      transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-sizing: border-box;
      transform-origin: center center;
    }

    .cs-widget-box:hover {
      background: rgba(139, 92, 246, 0.18);
      border-color: rgba(139, 92, 246, 0.65);
      box-shadow: 0 2px 10px rgba(139, 92, 246, 0.2);
    }

    .cs-widget-box:active {
      cursor: grabbing;
    }

    .cs-widget-box.selected {
      background: rgba(139, 92, 246, 0.22);
      border: 2px solid #ffffff;
      box-shadow: 0 0 12px rgba(139, 92, 246, 0.5), inset 0 0 6px rgba(255, 255, 255, 0.2);
    }

    .cs-widget-box.disabled {
      background: rgba(60, 60, 65, 0.12) !important;
      border: 1px dashed rgba(255, 255, 255, 0.2) !important;
      opacity: 0.35 !important;
    }

    .cs-box-inner {
      padding: 4px 6px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      height: 100%;
      pointer-events: none;
    }

    .cs-box-header {
      display: flex;
      align-items: center;
      gap: 4px;
      font-size: 10px;
      font-weight: 700;
      color: #ffffff;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .cs-box-title {
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .cs-box-coords {
      font-size: 9px;
      color: rgba(255, 255, 255, 0.75);
      font-family: monospace;
      white-space: nowrap;
    }

    /* Alignment Grid Button Pad */
    .cs-align-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 4px;
    }

    .cs-align-btn {
      background: var(--surface-hover);
      color: var(--text-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      font-size: 13px;
      padding: 6px 0;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s ease;
    }

    .cs-align-btn:hover {
      background: #ffffff;
      color: #ffffff;
      border-color: #ffffff;
    }

    /* Overview Checklist Grid */
    .cs-overview-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
      gap: 10px;
    }

    .cs-overview-card {
      background: var(--surface-hover);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .cs-overview-card:hover {
      border-color: var(--border-light);
      transform: translateY(-1px);
    }

    .cs-overview-card.selected {
      border-color: #ffffff;
      background: rgba(126, 105, 240, 0.08);
    }

    .cs-overview-card.disabled {
      opacity: 0.55;
    }

    .cs-toggle-badge {
      transition: transform 0.15s ease, filter 0.15s ease;
    }

    .cs-toggle-badge:hover {
      transform: scale(1.08);
      filter: brightness(1.2);
    }

    .cs-profile-tab {
      background: transparent;
      color: var(--text-secondary);
      border: 1px solid transparent;
      padding: 7px 16px;
      font-size: 12.5px;
      font-weight: 600;
      border-radius: var(--radius-sm);
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: all 0.18s ease;
    }

    .cs-profile-tab:hover {
      color: var(--text-primary);
      background: rgba(255, 255, 255, 0.05);
    }

    .cs-profile-tab.active {
      background: var(--surface-solid);
      color: var(--text-primary);
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
      border-color: var(--border-light);
    }

    /* Scrubbable Number Inputs (After Effects / Blender Style) */
    body.cs-is-scrubbing,
    body.cs-is-scrubbing * {
      cursor: ew-resize !important;
      user-select: none !important;
    }

    .cs-scrub-group {
      display: flex;
      align-items: center;
      position: relative;
      width: 100%;
    }

    .cs-scrub-handle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: rgba(255, 255, 255, 0.08);
      color: #ffffff;
      font-weight: 700;
      font-size: 11px;
      padding: 6px 10px;
      border: 1px solid var(--border);
      border-right: none;
      border-radius: var(--radius-sm) 0 0 var(--radius-sm);
      cursor: ew-resize;
      user-select: none;
      transition: all 0.15s ease;
      line-height: 1;
    }

    .cs-scrub-handle:hover,
    .cs-scrub-handle.scrubbing {
      background: #ffffff;
      color: #ffffff;
      box-shadow: 0 0 10px rgba(126, 105, 240, 0.6);
    }

    .cs-scrub-group input {
      border-top-left-radius: 0 !important;
      border-bottom-left-radius: 0 !important;
      flex: 1;
      min-width: 0;
    }

    .cs-scrub-label {
      cursor: ew-resize;
      user-select: none;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: 11.5px;
      color: var(--text-secondary);
      margin-bottom: 4px;
      transition: color 0.15s ease;
    }

    .cs-scrub-label:hover {
      color: #ffffff !important;
    }

    .cs-scrub-label i {
      font-size: 10px;
      opacity: 0.6;
    }

    /* Layer Stack Visual Drag and Drop List */
    .cs-layer-stack-list {
      max-height: 185px;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      background: rgba(0, 0, 0, 0.25);
      display: flex;
      flex-direction: column;
      gap: 3px;
      padding: 4px;
    }

    .cs-layer-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 5px 8px;
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid transparent;
      border-radius: 4px;
      font-size: 11px;
      cursor: pointer;
      user-select: none;
      transition: background 0.12s ease, border-color 0.12s ease, transform 0.15s ease;
      position: relative;
    }

    .cs-layer-item:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: var(--border);
    }

    .cs-layer-item.selected {
      background: rgba(255, 255, 255, 0.12);
      border-color: #ffffff;
      color: #ffffff;
    }

    .cs-layer-drag-handle {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 18px;
      height: 18px;
      color: var(--text-muted);
      cursor: grab;
      margin-right: 4px;
      border-radius: 3px;
      transition: color 0.15s ease, background 0.15s ease;
    }

    .cs-layer-drag-handle:hover {
      color: #ffffff;
      background: rgba(167, 139, 250, 0.15);
    }

    .cs-layer-drag-handle:active {
      cursor: grabbing;
    }

    .cs-layer-item.dragging {
      opacity: 0.35;
      background: rgba(255, 255, 255, 0.10);
      border: 1px dashed #6f6f6f;
      transform: scale(0.98);
    }

    .cs-layer-item.drag-over-above {
      border-top: 2px solid #ffffff !important;
      background: rgba(255, 255, 255, 0.10);
    }

    .cs-layer-item.drag-over-below {
      border-bottom: 2px solid #ffffff !important;
      background: rgba(255, 255, 255, 0.10);
    }

    .cs-layer-item .layer-rank-badge {
      font-size: 9px;
      font-weight: 700;
      padding: 1px 6px;
      border-radius: 3px;
      background: rgba(255, 255, 255, 0.06);
      color: var(--text-muted);
      letter-spacing: 0.3px;
    }

    .cs-layer-item .layer-rank-badge.top {
      background: rgba(255, 255, 255, 0.15);
      color: #ffffff;
      border: 1px solid rgba(167, 139, 250, 0.3);
    }

    .cs-layer-item .layer-rank-badge.bottom {
      background: rgba(255, 255, 255, 0.04);
      color: var(--text-muted);
    }

    .cs-layer-step-btn {
      opacity: 0.6;
      transition: opacity 0.15s ease, color 0.15s ease;
    }

    .cs-layer-step-btn:hover {
      opacity: 1;
      color: #ffffff !important;
    }




/* ==========================================================================
   Aksesibilitas: hormati preferensi reduced-motion
   ========================================================================== */

    
    /* ═══ User Menu (avatar dropdown pojok kanan atas) — theme-aware ═══ */
    #auth-user-badge { position: relative; }
    #auth-user-trigger {
      display: flex; align-items: center; gap: 8px;
      padding: 4px 10px 4px 4px; border-radius: var(--radius-full);
      background: var(--surface); border: 1px solid var(--border);
      cursor: pointer; color: var(--text-primary);
      transition: background 0.15s, border-color 0.15s;
    }
    #auth-user-trigger:hover {
      background: var(--surface-hover); border-color: var(--border-light);
    }
    #auth-user-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
    #auth-user-avatar-fallback {
      display: flex; width: 26px; height: 26px; border-radius: 50%;
      align-items: center; justify-content: center;
      background: linear-gradient(135deg,#3a3a3a,#1a1a1a);
      color: #fff; font-size: 0.75rem; font-weight: 700;
    }
    #auth-user-name {
      font-size: 0.82rem; font-weight: 600; max-width: 140px;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      color: var(--text-primary);
    }
    .user-menu-chevron { font-size: 0.65rem; opacity: 0.7; color: var(--text-secondary); }
    #auth-user-trigger[aria-expanded="true"] .user-menu-chevron { transform: rotate(180deg); }

    #user-menu-dropdown {
      position: absolute; right: 0; top: calc(100% + 8px);
      min-width: 230px; padding: 8px;
      background: var(--surface-solid); border: 1px solid var(--border-light);
      border-radius: var(--radius-lg);
      box-shadow: 0 12px 32px rgba(0,0,0,0.45);
      z-index: 4010;   /* level navbar (4000) +1 — ikut navbar, di bawah modal 26000 */
      animation: userMenuIn 0.16s cubic-bezier(0.16,1,0.3,1);
      transform-origin: top right;
    }
    body.light-theme #user-menu-dropdown { box-shadow: 0 12px 32px rgba(15,23,42,0.18); }
    @keyframes userMenuIn {
      from { opacity: 0; transform: scale(0.96) translateY(-4px); }
      to { opacity: 1; transform: scale(1) translateY(0); }
    }
    .user-menu-header {
      padding: 10px 12px; border-bottom: 1px solid var(--border);
      margin-bottom: 6px;
    }
    #user-menu-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
    #user-menu-email {
      font-size: 0.78rem; color: var(--text-muted);
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    #user-menu-plan {
      margin-top: 6px; display: inline-block; padding: 2px 10px;
      border-radius: var(--radius-full); font-size: 0.72rem;
      background: rgba(108,92,231,0.15); color: var(--text-secondary);
      border: 1px solid rgba(108,92,231,0.3);
    }
    .user-menu-item {
      display: flex; align-items: center; gap: 10px; width: 100%;
      text-align: left; padding: 10px 12px;
      background: transparent; border: none; border-radius: var(--radius-md);
      color: var(--text-primary); cursor: pointer; font-size: 0.88rem;
      transition: background 0.12s;
    }
    .user-menu-item i { width: 16px; opacity: 0.75; color: var(--text-secondary); }
    .user-menu-item:hover { background: var(--surface-hover); }
    .user-menu-item:active { background: var(--border); }
    .user-menu-item-danger {
      color: var(--red);
      border-top: 1px solid var(--border);
      margin-top: 4px;
    }
    .user-menu-item-danger i { color: var(--red); opacity: 1; }
    .user-menu-item-danger:hover { background: rgba(235,87,87,0.12); }

    /* ═══ MOBILE-FIRST: Auth gate & Login modal ═══ */
    @media (max-width: 640px) {
      /* Gate screen: konten di tengah, padding aman */
      #auth-gate-screen {
        padding: 16px;
      }
      .auth-gate-logo { font-size: 2.2rem; letter-spacing: 0.28em; }
      .auth-gate-sub { font-size: 0.78rem; }
      .auth-gate-msg { font-size: 0.85rem; margin-top: 1.2rem; }

      /* Modal (semua, incl. login): center vertikal + scroll internal */
      .modal-overlay {
        align-items: center;
        padding: 12px;
      }
      .modal-overlay .modal {
        max-height: 88vh;
        overflow-y: auto;
        width: 100%;
        max-width: 420px;
        margin: auto;
        -webkit-overflow-scrolling: touch;
      }

      /* Header: sembunyikan nama user text (cukup avatar + chevron) */
      #auth-user-name { display: none; }
      #auth-user-trigger { padding: 5px; gap: 6px; }
      #lang-toggle-btn span, #theme-toggle-btn span { display: none; }

      /* User menu dropdown: bottom-sheet style di mobile (class-based, theme-aware) */
      #user-menu-dropdown {
        position: fixed;
        left: 12px; right: 12px; top: auto; bottom: 12px;
        min-width: 0; width: auto;
        border-radius: var(--radius-xl);
        transform-origin: bottom center;
        animation: userMenuInMobile 0.18s cubic-bezier(0.16,1,0.3,1);
        z-index: 4010 !important;  /* ikut level navbar, bukan level modal */
      }
      @keyframes userMenuInMobile {
        from { opacity: 0; transform: translateY(8px); }
        to { opacity: 1; transform: translateY(0); }
      }
      .user-menu-item { padding: 13px 14px; font-size: 0.95rem; } /* touch target lebih besar */
    }

    
    /* ═══ Dashboard mobile-friendly ═══ */
    @media (max-width: 640px) {
      /* Hero value: angka besar tidak overflow */
      .timeseries-hero-val { font-size: 1.6rem !important; }
      .timeseries-hero-badge { font-size: 0.72rem; }
      .timeseries-hero-subtitle { font-size: 0.72rem; }

      /* Pills kontrol: WRAP rapi (2 baris jika perlu) — tidak pernah terpotong di tepi */
      .timeseries-pills-group, .heatmap-controls {
        flex-wrap: wrap !important;
        overflow: visible !important;
        max-width: 100%;
      }
      .timeseries-pills-group {
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        gap: 6px !important;
        display: flex !important;
      }
      .ts-pill, .ts-range-pill {
        flex-shrink: 0;
        white-space: nowrap;
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
      }

      /* Heatmap: cell lebih kecil di mobile, tetap scrollable horizontal */
      .heatmap-grid { gap: 2px; }
      .heatmap-cell { min-height: 14px; border-radius: 3px; border-width: 0; }
      .heatmap-hour-label { font-size: 0.58rem; padding-right: 4px; }
      .heatmap-day-label { font-size: 0.6rem; }
      .heatmap-card { padding: 12px 12px 14px !important; }

      /* History table: bisa scroll, jangan remuk */
      .dashboard-history-card { padding: 12px !important; }
      .dashboard-actions-toolbar { flex-wrap: wrap; gap: 8px; }

      /* Stat cards: 2 kolom tetap OK; angka lebih kecil */
      .dashboard-stat-card { padding: 12px 14px; }
      .stat-card-icon { width: 36px; height: 36px; }
    }

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