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

  :root {
    --bg: #0d0d0d;
    --surface: #161616;
    --surface2: #1e1e1e;
    --border: #2a2a2a;
    --text: #e8e8e8;
    --text-muted: #888;
    --accent: #7c6cfc;
    --accent-glow: rgba(124,108,252,0.3);
    --demonstrated: #7c6cfc;
    --near-term: #f59e0b;
    --future: #374151;
    --future-border: #555;
  }

  html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, -apple-system, sans-serif; overflow: hidden; }

  /* HEADER */
  #header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    flex-shrink: 0;
  }
  #header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  #header-title { display: flex; align-items: baseline; gap: 12px; }
  #header-title h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #7c6cfc, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  #header-title p { font-size: 12px; color: var(--text-muted); }
  #legend {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-muted);
    align-items: center;
  }
  .legend-item { display: flex; align-items: center; gap: 5px; }
  .legend-dot-d { color: var(--demonstrated); font-size: 14px; }
  .legend-dot-n { color: var(--near-term); font-size: 14px; }
  .legend-dot-f { color: var(--future-border); font-size: 14px; }

  /* STATS BAR */
  #stats-bar {
    display: flex;
    gap: 24px;
    padding: 8px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    flex-shrink: 0;
  }
  .stat { display: flex; flex-direction: column; }
  .stat-value { font-size: 18px; font-weight: 700; color: var(--accent); line-height: 1; }
  .stat-label { color: var(--text-muted); font-size: 10px; margin-top: 2px; }

  /* FILTERS */
  #filters {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
  }
  #search-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 5px 10px;
    font-size: 13px;
    width: 200px;
    outline: none;
    transition: border-color 0.2s;
  }
  #search-input:focus { border-color: var(--accent); }
  #search-input::placeholder { color: var(--text-muted); }

  .filter-group { display: flex; gap: 4px; }
  .filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .filter-btn:hover { border-color: var(--accent); color: var(--text); }
  .filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

  #category-filters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
  }
  .cat-chip {
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    opacity: 0.5;
  }
  .cat-chip.active { opacity: 1; }
  .cat-chip:hover { opacity: 0.8; }

  /* MAIN CONTENT */
  #app {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  #main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
  }

  /* TREEMAP */
  #treemap-container {
    flex: 1;
    overflow: hidden;
    position: relative;
  }
  #treemap-svg {
    width: 100%;
    height: 100%;
  }

  /* Cell styles */
  .cell rect {
    stroke-width: 2px;
    transition: opacity 0.2s;
  }
  .cell rect.status-demonstrated {
    stroke-dasharray: none;
    filter: drop-shadow(0 0 4px currentColor);
  }
  .cell rect.status-near-term {
    stroke-dasharray: 5 3;
  }
  .cell rect.status-future {
    stroke-dasharray: 2 4;
    stroke-width: 1.5px;
    opacity: 0.6;
  }
  .cell text {
    pointer-events: none;
    user-select: none;
  }
  .cell:hover rect { opacity: 0.85; cursor: pointer; }
  .cell.filtered-out rect { opacity: 0.1; }
  .cell.filtered-out text { opacity: 0.1; }

  .category-label {
    pointer-events: none;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    fill: rgba(255,255,255,0.5);
  }

  /* TOOLTIP */
  #tooltip {
    position: fixed;
    background: rgba(20,20,20,0.97);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1000;
    max-width: 240px;
    backdrop-filter: blur(8px);
  }
  #tooltip.visible { opacity: 1; }
  .tt-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
  .tt-row { display: flex; justify-content: space-between; gap: 12px; color: var(--text-muted); margin-top: 2px; }
  .tt-badge {
    display: inline-block;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
  }
  .badge-demonstrated { background: rgba(124,108,252,0.2); color: #a78bfa; border: 1px solid rgba(124,108,252,0.4); }
  .badge-near-term { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
  .badge-future { background: rgba(55,65,81,0.4); color: #9ca3af; border: 1px solid rgba(75,85,99,0.5); }

  /* SIDE PANEL */
  #side-panel {
    width: 380px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    z-index: 20;
    box-shadow: -8px 0 32px rgba(0,0,0,0.5);
  }
  #side-panel.open { transform: translateX(0); }
  #panel-content { padding: 20px; }
  #panel-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  #panel-close:hover { color: var(--text); border-color: var(--accent); }
  #panel-task-name { font-size: 20px; font-weight: 700; margin-bottom: 10px; line-height: 1.2; padding-right: 36px; }
  #panel-category { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

  .panel-section { margin-bottom: 16px; }
  .panel-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
  .panel-value { font-size: 13px; color: var(--text); }

  .difficulty-dots { display: flex; gap: 4px; }
  .diff-dot { width: 10px; height: 10px; border-radius: 50%; }
  .diff-dot.filled { background: var(--accent); }
  .diff-dot.empty { background: var(--surface2); border: 1px solid var(--border); }

  .trl-bar-bg {
    background: var(--surface2);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-top: 4px;
  }
  .trl-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #10b981, #7c6cfc); }
  .trl-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

  .panel-desc { font-size: 13px; color: #ccc; line-height: 1.5; }

  .companies-list { display: flex; flex-wrap: wrap; gap: 4px; }
  .company-pill {
    background: rgba(124,108,252,0.1);
    border: 1px solid rgba(124,108,252,0.25);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    color: #a78bfa;
  }

  .tags-list { display: flex; flex-wrap: wrap; gap: 4px; }
  .tag-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-muted);
  }

  .panel-source { font-size: 12px; }
  .panel-source a { color: var(--accent); text-decoration: none; }
  .panel-source a:hover { text-decoration: underline; }

  .divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

  /* Empty state */
  #empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    text-align: center;
    color: var(--text-muted);
    display: none;
  }
  #empty-state.visible { display: block; }


  /* VIEW TOGGLE BUTTONS */
  .view-toggle {
    display: flex;
    gap: 4px;
    margin-right: 8px;
  }
  .view-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .view-btn:hover { border-color: var(--accent); color: var(--text); }
  .view-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

  /* GENERALIST PICKS BUTTON */
  #generalist-picks-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
  }
  #generalist-picks-btn:hover { border-color: var(--accent); color: var(--text); }
  #generalist-picks-btn.active {
    background: rgba(124,108,252,0.15);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
  }

  /* LIST VIEW */
  #list-container {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 0;
  }
  #list-container.active { display: block; }

  #list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  #list-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface2);
  }
  #list-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  #list-table th:hover { color: var(--text); }
  #list-table th.sort-asc::after { content: ' ▲'; color: var(--accent); }
  #list-table th.sort-desc::after { content: ' ▼'; color: var(--accent); }
  #list-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.1s;
  }
  #list-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
  #list-table tbody tr:hover { background: rgba(124,108,252,0.08); }
  #list-table td {
    padding: 8px 12px;
    vertical-align: middle;
  }
  .list-task-name { font-weight: 500; color: var(--text); }
  .list-category-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    flex-shrink: 0;
  }
  .list-category-cell { display: flex; align-items: center; color: var(--text-muted); white-space: nowrap; }
  .list-video-icon { color: var(--text-muted); font-size: 12px; }
  .list-video-icon.has-video { color: #f59e0b; }

  /* STATUS BADGES in table */
  .badge-sm {
    display: inline-block;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* SIMILAR TASKS in panel */
  .similar-tasks-list { display: flex; flex-direction: column; gap: 6px; }
  .similar-task-link {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .similar-task-link:hover { border-color: var(--accent); background: rgba(124,108,252,0.08); }
  .similar-task-status { font-size: 10px; color: var(--text-muted); }

  /* WHY GENERALIST section */
  .why-generalist-box {
    background: rgba(124,108,252,0.08);
    border: 1px solid rgba(124,108,252,0.25);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: #c4b5fd;
    line-height: 1.4;
    margin-bottom: 14px;
  }
  .why-generalist-box strong { color: var(--accent); }

  /* VIDEO THUMBNAIL (lazy) */
  .video-thumb-wrapper {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 16/9;
    background: #111;
  }
  .video-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
  }
  .video-thumb-wrapper:hover img { opacity: 0.85; }
  .video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    pointer-events: none;
    border: 2px solid rgba(255,255,255,0.3);
  }
  .video-iframe-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 6px;
  }
  .video-iframe-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: 0;
  }

  /* MOBILE RESPONSIVE */
  @media (max-width: 768px) {
    #stats-bar { gap: 12px; padding: 6px 12px; flex-wrap: wrap; }
    .stat-value { font-size: 14px; }
    /* mobile stat labels: keep but shrink */
    .stat-label { font-size: 9px; }
    .stat-value { font-size: 14px; }
    #stats-bar { gap: 10px; padding: 6px 12px; flex-wrap: wrap; }
    /* hide subtitle on mobile */
    #header-subtitle { display: none; }
    #filters { padding: 6px 10px; gap: 6px; }
    #search-input { width: 120px; }
    #category-filters { display: none; }
    #category-filters.mobile-open { display: flex; }
    #mobile-filter-toggle {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-muted);
      padding: 4px 8px;
      font-size: 12px;
      cursor: pointer;
    }
    #side-panel { width: 100%; }
    html, body { overflow: hidden; }
    /* on mobile, hide less important list columns */
    #list-table th[data-col="trl"],
    #list-table td.col-trl,
    #list-table th[data-col="companies"],
    #list-table td.col-companies,
    #list-table th[data-col="videos"],
    #list-table td.col-videos,
    #list-table th[data-col="dexterityRequired"],
    #list-table td.col-dex { display: none; }
    /* fixed column widths on mobile so status badge always fits */
    .list-task-name { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #list-table th[data-col="status"] { width: 56px; }
    #list-table th[data-col="category"] { width: auto; }
    /* panel badges: smaller on mobile */
    .tt-badge { font-size: 10px; padding: 2px 6px; }
  }
  @media (min-width: 769px) {
    #mobile-filter-toggle { display: none; }
  }

  /* scrollbar */
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
