:root {
  --md-primary-50: #E8F0FE;
  --md-primary-100: #D2E3FC;
  --md-primary-200: #AECBFA;
  --md-primary-300: #8AB4F8;
  --md-primary-400: #669DF6;
  --md-primary-500: #4285F4;
  --md-primary-600: #1A73E8;
  --md-primary-700: #1967D2;
  --md-primary-800: #185ABC;
  --md-primary-900: #174EA6;

  --md-grey-50: #F8F9FA;
  --md-grey-100: #F1F3F4;
  --md-grey-200: #E8EAED;
  --md-grey-300: #DADCE0;
  --md-grey-400: #BDC1C6;
  --md-grey-500: #9AA0A6;
  --md-grey-600: #80868B;
  --md-grey-700: #5F6368;
  --md-grey-800: #3C4043;
  --md-grey-900: #202124;

  --md-surface: #FFFFFF;
  --md-surface-variant: #F8F9FA;
  --md-background: #F1F3F4;
  --md-on-surface: #202124;
  --md-on-surface-variant: #5F6368;

  --md-green-600: #1E8E3E;
  --md-red-600: #D93025;
  --md-yellow-700: #F9AB00;
  --md-teal-600: #009688;

  --color-hn: #FF6600;
  --color-devto: #3B49DF;
  --color-reddit: #FF4500;
  --color-arxiv: #B31B1B;
  --color-semantic: #1857B6;
  --color-huggingface: #FF9D00;
  --color-rss: #EE802F;
  --color-github: #6E40C9;

  --elevation-0: none;
  --elevation-1: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
  --elevation-2: 0 1px 2px 0 rgba(60,64,67,0.3), 0 2px 6px 2px rgba(60,64,67,0.15);
  --elevation-3: 0 4px 8px 3px rgba(60,64,67,0.15), 0 1px 3px rgba(60,64,67,0.3);

  --font-primary: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Google Sans', 'Roboto', -apple-system, sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  background: var(--md-background);
  color: var(--md-on-surface);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--md-primary-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* App Bar */
.app-bar {
  background: var(--md-grey-900);
  border-bottom: none;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.app-bar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-bar__logo {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 1px 4px rgba(66, 133, 244, 0.3));
}

.app-bar__brand {
  display: flex;
  flex-direction: column;
}

.app-bar__title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #fff;
  line-height: 1.1;
}

.app-bar__title span {
  color: var(--md-primary-300);
}

.app-bar__tagline {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.3px;
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.last-updated {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.icon-btn .material-icons-outlined {
  font-size: 22px;
}

.icon-btn.spinning .material-icons-outlined {
  animation: spin 1s linear infinite;
}

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

/* ===== App Layout — Sidebar + Content ===== */
.app-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== Sidebar Navigation (desktop) ===== */
.nav-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--md-surface);
  border-right: 1px solid var(--md-grey-200);
  padding: 16px 8px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 500;
  color: var(--md-grey-700);
  border: none;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  text-align: left;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  background: var(--md-grey-50);
  color: var(--md-grey-900);
}

.nav-item.active {
  background: var(--md-primary-50);
  color: var(--md-primary-700);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--md-primary-600);
  border-radius: 0 3px 3px 0;
}

.nav-item .material-icons-outlined {
  font-size: 20px;
  flex-shrink: 0;
}

.nav-item__label {
  flex: 1;
  min-width: 0;
}

.nav-item .badge {
  background: var(--md-primary-50);
  color: var(--md-primary-700);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nav-item.active .badge {
  background: var(--md-primary-100);
}

/* Content */
.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
  max-width: 1200px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ===== Panel Brief (tab description — subtle helper text) ===== */
.panel-brief {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--md-grey-100);
}

.panel-brief .material-icons-outlined {
  font-size: 16px;
  color: var(--md-grey-400);
  flex-shrink: 0;
}

.panel-brief p {
  margin: 0;
  font-size: 12px;
  color: var(--md-grey-500);
  line-height: 1.5;
}

/* ===== Highlights Banner ===== */
.highlights {
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-grey-200);
  padding: 20px 24px;
}

.highlights__inner {
  max-width: 1400px;
  margin: 0 auto;
}

.highlights__section--full {
  width: 100%;
}

.highlights__heading {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--md-grey-700);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.highlights__heading .material-icons-outlined {
  font-size: 18px;
  color: var(--md-primary-600);
}

.highlights__empty {
  font-size: 13px;
  color: var(--md-grey-500);
  padding: 8px 0;
}

/* --- Desktop: wrapped flex cards --- */
.highlights__cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.highlight-card {
  background: var(--md-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-1);
  padding: 14px 18px;
  min-width: 220px;
  max-width: 280px;
  flex-shrink: 0;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow 0.2s, transform 0.1s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
}

.highlight-card:hover {
  box-shadow: var(--elevation-2);
  transform: translateY(-1px);
  text-decoration: none;
}

.highlight-card--model { border-left-color: var(--md-primary-500); }
.highlight-card--tool { border-left-color: var(--md-teal-600); }
.highlight-card--inference { border-left-color: #E65100; }

.highlight-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.highlight-card__logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-display);
  line-height: 1;
}

.highlight-card__logo--svg {
  background: var(--md-grey-50);
  border: 1px solid var(--md-grey-200);
}

.highlight-card__logo svg {
  width: 20px;
  height: 20px;
  display: block;
}

.highlight-card__logo--sm {
  font-size: 10px;
  letter-spacing: -0.5px;
}

.highlight-card__company {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--md-grey-700);
}

.highlight-card__title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--md-grey-900);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.highlight-card__meta {
  font-size: 11px;
  color: var(--md-grey-600);
  display: flex;
  align-items: center;
  gap: 4px;
}

.highlight-card__meta .material-icons-outlined {
  font-size: 13px;
}

.highlight-card__category {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  display: inline-block;
  width: fit-content;
}

.highlight-card__category--model { background: var(--md-primary-50); color: var(--md-primary-700); }
.highlight-card__category--tool { background: #E0F2F1; color: #00695C; }
.highlight-card__category--inference { background: #FFF3E0; color: #E65100; }

/* --- Mobile: horizontal scroll matching desktop layout --- */
@media (max-width: 600px) {
  .highlights {
    padding: 12px;
  }

  .highlights__heading {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .highlights__cards {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
    scrollbar-width: none;
  }

  .highlights__cards::-webkit-scrollbar {
    display: none;
  }

  .highlight-card {
    min-width: 200px;
    max-width: 220px;
    padding: 12px 14px;
    scroll-snap-align: start;
  }

  .highlight-card__logo {
    width: 26px;
    height: 26px;
    font-size: 12px;
    border-radius: 6px;
  }

  .highlight-card__logo svg {
    width: 17px;
    height: 17px;
  }

  .highlight-card__logo--sm {
    font-size: 9px;
  }

  .highlight-card__title {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .highlight-card__company {
    font-size: 9px;
  }

  .highlight-card__category {
    font-size: 9px;
    padding: 2px 6px;
  }
}

/* Panel Toolbar */
.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-toolbar .search-bar {
  flex: 1;
  margin-bottom: 0;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--md-grey-600);
}

.sort-control .material-icons-outlined {
  font-size: 18px;
}

.sort-select {
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 500;
  color: var(--md-grey-700);
  background: var(--md-surface);
  border: 1px solid var(--md-grey-300);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%235F6368'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.2s;
}

.sort-select:hover {
  border-color: var(--md-grey-400);
}

.sort-select:focus {
  border-color: var(--md-primary-500);
  box-shadow: 0 0 0 2px var(--md-primary-100);
}

/* Source Filter Bar */
.source-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 16px;
  flex-wrap: wrap;
}

.source-filters__label {
  font-size: 13px;
  color: var(--md-grey-600);
  font-weight: 500;
  margin-right: 4px;
}

/* Search Bar */
.search-bar {
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  max-width: 480px;
  height: 44px;
  border: 1px solid var(--md-grey-300);
  border-radius: var(--radius-full);
  padding: 0 16px 0 44px;
  font-size: 14px;
  font-family: var(--font-primary);
  color: var(--md-grey-900);
  background: var(--md-surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--md-primary-500);
  box-shadow: 0 0 0 2px var(--md-primary-100);
}

.search-bar {
  position: relative;
}

.search-bar .material-icons-outlined {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--md-grey-500);
  pointer-events: none;
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .card-grid.resources-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--md-grey-600);
}

.empty-state .material-icons-outlined {
  font-size: 64px;
  color: var(--md-grey-400);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--md-grey-800);
}

.empty-state p {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--md-grey-800);
}

.section-header .count {
  font-size: 13px;
  color: var(--md-grey-600);
}

/* ===== Responsive: Large Desktop (1200px+) ===== */
@media (min-width: 1200px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===== Responsive: Tablet Portrait & Landscape (601px - 1024px) ===== */
@media (max-width: 1024px) and (min-width: 601px) {
  .highlights__cards {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .highlight-card {
    min-width: 200px;
    max-width: 260px;
  }
}

/* ===== Responsive: Tablet (max-width: 900px) — Sidebar collapses to horizontal ===== */
@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }

  .nav-sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 64px;
    z-index: 90;
    flex-direction: row;
    padding: 0 8px;
    border-right: none;
    border-bottom: 1px solid var(--md-grey-200);
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
  }

  .nav-sidebar::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    font-size: 11px;
    border-radius: 0;
    white-space: nowrap;
    position: relative;
  }

  .nav-item .material-icons-outlined {
    font-size: 20px;
  }

  .nav-item.active::before {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  .nav-item.active {
    background: transparent;
  }

  .nav-item .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 9px;
    padding: 1px 5px;
  }
}

/* ===== Responsive: Small Tablet / Large Phone (601px - 768px) ===== */
@media (max-width: 768px) {
  .content {
    padding: 16px;
  }

  .search-input {
    max-width: 100%;
  }
}

/* ===== Responsive: Mobile (max-width: 600px) ===== */
@media (max-width: 600px) {
  /* App Bar */
  .app-bar {
    padding: 0 12px;
    height: 52px;
  }

  .app-bar__logo {
    width: 28px;
    height: 28px;
  }

  .app-bar__left {
    gap: 8px;
  }

  .app-bar__title {
    font-size: 19px;
    font-weight: 700;
  }

  .app-bar__tagline {
    font-size: 9px;
  }

  .last-updated {
    display: none;
  }

  /* Navigation (mobile) */
  .nav-sidebar {
    padding: 0 4px;
    top: 52px;
  }

  .nav-item {
    padding: 8px 10px;
    font-size: 10px;
    gap: 1px;
  }

  .nav-item .material-icons-outlined {
    font-size: 18px;
  }

  /* Content */
  .content {
    padding: 12px;
  }

  /* Panel Toolbar */
  .panel-toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .panel-toolbar .search-bar {
    width: 100%;
  }

  .search-input {
    max-width: 100%;
    height: 40px;
    font-size: 14px;
  }

  .sort-control {
    align-self: flex-end;
  }

  /* Source & Topic Filters */
  .source-filters {
    gap: 6px;
    padding: 0 0 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .source-filters::-webkit-scrollbar {
    display: none;
  }

  .topic-filters {
    gap: 6px;
    padding: 0 0 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .topic-filters::-webkit-scrollbar {
    display: none;
  }

  /* Card Grid */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Toast */
  .toast-container {
    left: 12px;
    right: 12px;
    transform: none;
    bottom: 16px;
  }

  .toast {
    max-width: 100%;
    font-size: 13px;
    padding: 10px 16px;
  }

  /* Empty State */
  .empty-state {
    padding: 40px 16px;
  }

  .empty-state .material-icons-outlined {
    font-size: 48px;
  }

  .empty-state h3 {
    font-size: 17px;
  }
}

/* ===== Responsive: Very Small Phones (max-width: 380px) ===== */
@media (max-width: 380px) {
  .nav-item {
    padding: 8px 6px;
    font-size: 9px;
  }

  .nav-item .badge {
    display: none;
  }

  .nav-item__label {
    display: none;
  }

  .app-bar__title {
    font-size: 16px;
  }

  .app-bar__tagline {
    font-size: 8px;
  }
}

/* ===== Touch Device Improvements ===== */
@media (hover: none) and (pointer: coarse) {
  .card:hover {
    box-shadow: var(--elevation-1);
    transform: none;
  }

  .highlight-card:hover {
    box-shadow: var(--elevation-1);
    transform: none;
  }

  .card:active {
    box-shadow: var(--elevation-2);
    transform: translateY(-1px);
  }

  .highlight-card:active {
    box-shadow: var(--elevation-2);
    transform: translateY(-1px);
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .filter-chip {
    padding: 8px 14px;
    min-height: 36px;
  }
}

/* ===== Safe Area (notch devices) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-bar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .content {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .toast-container {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}
