/* === Glowstone Mirror — Material Design 3 === */
/* MD3 Design Tokens - Dark Theme with Glowstone Amber Primary */
:root {
  /* Primary - Glowstone Amber */
  --md-sys-color-primary: #ffb938;
  --md-sys-color-on-primary: #291a00;
  --md-sys-color-primary-container: #7a5510;
  --md-sys-color-on-primary-container: #ffdea5;

  /* Secondary - Warm Sand */
  --md-sys-color-secondary: #d8c093;
  --md-sys-color-on-secondary: #2a1e0a;
  --md-sys-color-secondary-container: #695736;
  --md-sys-color-on-secondary-container: #f5dfb8;

  /* Tertiary - Olive */
  --md-sys-color-tertiary: #b8cc92;
  --md-sys-color-on-tertiary: #1a240a;
  --md-sys-color-tertiary-container: #4a5a30;
  --md-sys-color-on-tertiary-container: #d0e4a8;

  /* Error */
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;

  /* Surface - Neutral Dark */
  --md-sys-color-surface: #141218;
  --md-sys-color-on-surface: #e7e0e8;
  --md-sys-color-surface-variant: #49454e;
  --md-sys-color-on-surface-variant: #cbc4ce;
  --md-sys-color-outline: #948f99;
  --md-sys-color-outline-variant: #49454e;

  /* Surface Containers (elevated) */
  --md-sys-color-surface-container-lowest: #0f0d13;
  --md-sys-color-surface-container-low: #1d1b20;
  --md-sys-color-surface-container: #211f26;
  --md-sys-color-surface-container-high: #2b2930;
  --md-sys-color-surface-container-highest: #36343b;

  /* Inverse */
  --md-sys-color-inverse-surface: #e7e0e8;
  --md-sys-color-inverse-on-surface: #1d1b20;
  --md-sys-color-inverse-primary: #7a5510;

  /* Shadows */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0px 1px 2px 0px rgba(0,0,0,0.3), 0px 1px 3px 1px rgba(0,0,0,0.15);
  --md-sys-elevation-2: 0px 1px 2px 0px rgba(0,0,0,0.3), 0px 2px 6px 2px rgba(0,0,0,0.15);
  --md-sys-elevation-3: 0px 4px 8px 3px rgba(0,0,0,0.15), 0px 1px 3px 0px rgba(0,0,0,0.3);
  --md-sys-elevation-4: 0px 6px 10px 4px rgba(0,0,0,0.15), 0px 2px 3px 0px rgba(0,0,0,0.3);
  --md-sys-elevation-5: 0px 8px 12px 6px rgba(0,0,0,0.15), 0px 4px 4px 0px rgba(0,0,0,0.3);

  /* Shape */
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* Typography - MD3 Type Scale */
  --md-sys-typescale-display-large: 400 57px/64px 'Lexend', sans-serif;
  --md-sys-typescale-display-medium: 400 45px/52px 'Lexend', sans-serif;
  --md-sys-typescale-display-small: 400 36px/44px 'Lexend', sans-serif;
  --md-sys-typescale-headline-large: 400 32px/40px 'Lexend', sans-serif;
  --md-sys-typescale-headline-medium: 400 28px/36px 'Lexend', sans-serif;
  --md-sys-typescale-headline-small: 400 24px/32px 'Lexend', sans-serif;
  --md-sys-typescale-title-large: 400 22px/28px 'Inter', sans-serif;
  --md-sys-typescale-title-medium: 500 16px/24px 'Inter', sans-serif;
  --md-sys-typescale-title-small: 500 14px/20px 'Inter', sans-serif;
  --md-sys-typescale-body-large: 400 16px/24px 'Inter', sans-serif;
  --md-sys-typescale-body-medium: 400 14px/20px 'Inter', sans-serif;
  --md-sys-typescale-body-small: 400 12px/16px 'Inter', sans-serif;
  --md-sys-typescale-label-large: 500 14px/20px 'Inter', sans-serif;
  --md-sys-typescale-label-medium: 500 12px/16px 'Inter', sans-serif;
  --md-sys-typescale-label-small: 500 11px/16px 'Inter', sans-serif;
}

/* === Light Theme (MD3 Light Color Scheme) === */
[data-theme="light"] {
  --md-sys-color-primary: #8b5000;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #ffdea5;
  --md-sys-color-on-primary-container: #2e1600;

  --md-sys-color-secondary: #705838;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #f5dfb8;
  --md-sys-color-on-secondary-container: #271900;

  --md-sys-color-tertiary: #4f6236;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #d0e4a8;
  --md-sys-color-on-tertiary-container: #101e00;

  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;

  --md-sys-color-surface: #fef7ff;
  --md-sys-color-on-surface: #1d1b20;
  --md-sys-color-surface-variant: #e7e0ec;
  --md-sys-color-on-surface-variant: #49454f;
  --md-sys-color-outline: #79747e;
  --md-sys-color-outline-variant: #cac4d0;

  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f7f2fa;
  --md-sys-color-surface-container: #f3edf7;
  --md-sys-color-surface-container-high: #ece6f0;
  --md-sys-color-surface-container-highest: #e6e0ea;

  --md-sys-color-inverse-surface: #322f35;
  --md-sys-color-inverse-on-surface: #f5eff7;
  --md-sys-color-inverse-primary: #ffb938;

  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0px 1px 2px 0px rgba(0,0,0,0.05), 0px 1px 3px 1px rgba(0,0,0,0.08);
  --md-sys-elevation-2: 0px 1px 2px 0px rgba(0,0,0,0.08), 0px 2px 6px 2px rgba(0,0,0,0.05);
  --md-sys-elevation-3: 0px 4px 8px 3px rgba(0,0,0,0.05), 0px 1px 3px 0px rgba(0,0,0,0.08);
  --md-sys-elevation-4: 0px 6px 10px 4px rgba(0,0,0,0.05), 0px 2px 3px 0px rgba(0,0,0,0.08);
  --md-sys-elevation-5: 0px 8px 12px 6px rgba(0,0,0,0.05), 0px 4px 4px 0px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --md-sys-color-primary: #8b5000;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #ffdea5;
    --md-sys-color-on-primary-container: #2e1600;

    --md-sys-color-secondary: #705838;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #f5dfb8;
    --md-sys-color-on-secondary-container: #271900;

    --md-sys-color-tertiary: #4f6236;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #d0e4a8;
    --md-sys-color-on-tertiary-container: #101e00;

    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error-container: #410002;

    --md-sys-color-surface: #fef7ff;
    --md-sys-color-on-surface: #1d1b20;
    --md-sys-color-surface-variant: #e7e0ec;
    --md-sys-color-on-surface-variant: #49454f;
    --md-sys-color-outline: #79747e;
    --md-sys-color-outline-variant: #cac4d0;

    --md-sys-color-surface-container-lowest: #ffffff;
    --md-sys-color-surface-container-low: #f7f2fa;
    --md-sys-color-surface-container: #f3edf7;
    --md-sys-color-surface-container-high: #ece6f0;
    --md-sys-color-surface-container-highest: #e6e0ea;

    --md-sys-color-inverse-surface: #322f35;
    --md-sys-color-inverse-on-surface: #f5eff7;
    --md-sys-color-inverse-primary: #ffb938;

    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0px 1px 2px 0px rgba(0,0,0,0.05), 0px 1px 3px 1px rgba(0,0,0,0.08);
    --md-sys-elevation-2: 0px 1px 2px 0px rgba(0,0,0,0.08), 0px 2px 6px 2px rgba(0,0,0,0.05);
    --md-sys-elevation-3: 0px 4px 8px 3px rgba(0,0,0,0.05), 0px 1px 3px 0px rgba(0,0,0,0.08);
    --md-sys-elevation-4: 0px 6px 10px 4px rgba(0,0,0,0.05), 0px 2px 3px 0px rgba(0,0,0,0.08);
    --md-sys-elevation-5: 0px 8px 12px 6px rgba(0,0,0,0.05), 0px 4px 4px 0px rgba(0,0,0,0.08);
  }
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font: var(--md-sys-typescale-body-large);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--md-sys-color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* === MD3 Typography === */
h1 { font: var(--md-sys-typescale-headline-large); }
h2 { font: var(--md-sys-typescale-headline-medium); }
h3 { font: var(--md-sys-typescale-headline-small); }
h4 { font: var(--md-sys-typescale-title-large); }

/* === Top App Bar (MD3) === */
.top-app-bar {
  background: var(--md-sys-color-surface-container);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-app-bar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  flex-shrink: 0;
}

.top-app-bar__brand img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.top-app-bar__brand span {
  font: var(--md-sys-typescale-title-large);
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.top-app-bar__brand:hover { text-decoration: none; }

.top-app-bar__spacer { flex: 1; }

/* Navigation tabs in top bar */
.top-app-bar__nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* MD3 Navigation Item */
.nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  gap: 8px;
}

.nav-item:hover {
  background: rgba(203, 196, 206, 0.08);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.nav-item:active {
  background: rgba(203, 196, 206, 0.12);
}

.nav-item--active {
  color: var(--md-sys-color-primary);
  background: rgba(255, 185, 56, 0.08);
}

/* MD3 Filled Button */
.md3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
}

.md3-btn:active { transform: scale(0.97); }

.md3-btn--filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md3-btn--filled:hover {
  background: #e5a82e;
  box-shadow: var(--md-sys-elevation-1);
  text-decoration: none;
}

.md3-btn--tonal {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.md3-btn--tonal:hover {
  background: #786746;
  box-shadow: var(--md-sys-elevation-1);
  text-decoration: none;
}

.md3-btn--outlined {
  background: none;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.md3-btn--outlined:hover {
  background: rgba(255, 185, 56, 0.08);
  text-decoration: none;
}

.md3-btn--text {
  background: none;
  color: var(--md-sys-color-primary);
}

.md3-btn--text:hover {
  background: rgba(255, 185, 56, 0.08);
  text-decoration: none;
}

.md3-btn--danger {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}

.md3-btn--danger:hover {
  background: #ff6855;
  box-shadow: var(--md-sys-elevation-1);
}

.md3-btn--danger-text {
  background: none;
  color: var(--md-sys-color-error);
}

.md3-btn--danger-text:hover {
  background: rgba(255, 180, 171, 0.08);
  text-decoration: none;
}

.md3-btn--small {
  height: 32px;
  padding: 0 12px;
  font: var(--md-sys-typescale-label-medium);
}

/* === FAB / Icon Button === */
.md3-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  font-size: 1.25rem;
  transition: background 0.15s;
}

.md3-icon-btn:hover {
  background: rgba(203, 196, 206, 0.08);
}

/* === User Menu Dropdown === */
.user-menu { position: relative; display: inline-flex; }
.user-menu summary { list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }

.user-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 8px 0 4px;
  border-radius: var(--md-sys-shape-corner-full);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-large);
  transition: background 0.15s;
}

.user-menu__trigger:hover {
  background: rgba(203, 196, 206, 0.08);
}

.user-menu__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font: var(--md-sys-typescale-title-small);
  font-weight: 700;
}

.user-menu__dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-small);
  min-width: 200px;
  box-shadow: var(--md-sys-elevation-3);
  overflow: hidden;
  z-index: 200;
}

.user-menu[open] > .user-menu__dropdown {
  display: block;
}

.user-menu__dropdown-header {
  padding: 12px 16px 8px;
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.user-menu__dropdown-header strong {
  color: var(--md-sys-color-primary);
}

.user-menu__dropdown a,
.user-menu__dropdown button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  text-decoration: none;
}

.user-menu__dropdown a:hover,
.user-menu__dropdown button:hover {
  background: rgba(203, 196, 206, 0.08);
  text-decoration: none;
}

/* Language switcher in nav */
.lang-switcher {
  position: relative;
  display: inline-flex;
}
.lang-switcher summary { list-style: none; }
.lang-switcher summary::-webkit-details-marker { display: none; }

.lang-switcher__dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-small);
  min-width: 160px;
  box-shadow: var(--md-sys-elevation-3);
  overflow: hidden;
  z-index: 200;
}

.lang-switcher[open] > .lang-switcher__dropdown {
  display: block;
}

.lang-switcher__dropdown a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  transition: background 0.15s;
}

.lang-switcher__dropdown a:hover {
  background: rgba(203, 196, 206, 0.08);
  text-decoration: none;
}

.lang-switcher__dropdown a.lang--active {
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

/* Material Icons */
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
}

/* Theme toggle button */
.theme-toggle {
  width: 40px;
  padding: 0;
}

.theme-toggle .material-icons {
  pointer-events: none;
}

/* Language flag icon */
.lang-flag {
  font-size: 18px;
  line-height: 1;
}

/* === Main Content === */
.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* === Hero === */
.hero {
  text-align: center;
  padding: 72px 24px 48px;
}

.hero__icon {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  margin: 0 auto 24px;
  filter: drop-shadow(0 0 32px rgba(255, 185, 56, 0.4));
  animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 24px rgba(255, 185, 56, 0.4)); }
  50% { filter: drop-shadow(0 0 48px rgba(255, 185, 56, 0.7)); }
}

.hero__title {
  font: var(--md-sys-typescale-display-small);
  color: var(--md-sys-color-primary);
  margin-bottom: 12px;
}

.hero__subtitle {
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface-variant);
  max-width: 480px;
  margin: 0 auto 32px;
}

/* === MD3 Search Bar === */
.search-bar {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  height: 56px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-full);
  box-shadow: var(--md-sys-elevation-1);
  transition: box-shadow 0.2s;
}

.search-bar:focus-within {
  box-shadow: var(--md-sys-elevation-2), 0 0 0 2px var(--md-sys-color-primary);
}

.search-bar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.search-bar__input {
  flex: 1;
  height: 100%;
  padding: 0 4px;
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
  outline: none;
}

.search-bar__input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.search-bar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  min-width: 48px;
  padding: 0 28px;
  margin-right: 4px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font: var(--md-sys-typescale-label-large);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.search-bar__btn:hover {
  background: #e5a82e;
  box-shadow: var(--md-sys-elevation-1);
}

/* === Sort Chips (MD3) === */
.sort-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sort-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline);
  background: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sort-chip:hover {
  background: rgba(203, 196, 206, 0.08);
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
}

.sort-chip--active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.sort-chip--active:hover {
  background: #786746;
}

/* === Resource Grid === */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* MD3 Card */
.md3-card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
  transition: box-shadow 0.2s, background 0.2s;
  box-shadow: var(--md-sys-elevation-1);
}

.md3-card:hover {
  box-shadow: var(--md-sys-elevation-3);
  background: var(--md-sys-color-surface-container);
}

.md3-card a {
  color: inherit;
  text-decoration: none;
  display: block;
}

.md3-card__media {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--md-sys-color-surface-container-highest);
}

.md3-card__media-placeholder {
  width: 100%;
  height: 180px;
  background: var(--md-sys-color-surface-container-highest);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 3rem;
}

.md3-card__body {
  padding: 16px;
}

.md3-card__title {
  font: var(--md-sys-typescale-title-medium);
  color: var(--md-sys-color-on-surface);
  margin-bottom: 4px;
}

.md3-card__subtitle {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 12px;
}

.md3-card__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

.md3-card__rating {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 32px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.page-btn:hover {
  background: rgba(203, 196, 206, 0.08);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.page-btn--active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.page-btn--active:hover {
  background: #e5a82e;
}

.page-btn--disabled {
  opacity: 0.38;
  pointer-events: none;
}

/* === Auth Pages === */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px - 60px);
  padding: 24px;
}

.auth-card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 40px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--md-sys-elevation-3);
}

.auth-card__title {
  font: var(--md-sys-typescale-headline-small);
  color: var(--md-sys-color-primary);
  text-align: center;
  margin-bottom: 8px;
}

.auth-card__subtitle {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  margin-bottom: 32px;
}

/* === MD3 Text Field === */
.md3-text-field {
  margin-bottom: 20px;
}

.md3-text-field__label {
  display: block;
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 6px;
  letter-spacing: 0.025em;
}

.md3-text-field__input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.md3-text-field__input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(255, 185, 56, 0.3);
}

.md3-text-field__input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.6;
}

.md3-text-field textarea.md3-text-field__input {
  height: auto;
  min-height: 120px;
  padding: 16px;
  resize: vertical;
}

.md3-text-field__hint {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}

/* === MD3 Checkbox === */
.md3-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  margin-bottom: 20px;
}

.md3-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-sys-color-primary);
}

/* === Alert / Error === */
.md3-alert {
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-corner-small);
  margin-bottom: 24px;
  font: var(--md-sys-typescale-body-small);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}

.md3-alert--error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.md3-alert--success {
  background: #1b3821;
  color: #a8df8e;
}

/* === Resource Detail === */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.detail-gallery {
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  background: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-1);
}

.detail-gallery__main {
  width: 100%;
  height: 400px;
  object-fit: cover;
}

.detail-gallery__placeholder {
  width: 100%;
  height: 400px;
  background: var(--md-sys-color-surface-container-highest);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--md-sys-color-on-surface-variant);
}

.detail-gallery__thumbs {
  display: flex;
  gap: 8px;
  padding: 12px;
  overflow-x: auto;
}

.detail-gallery__thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: var(--md-sys-shape-corner-extra-small);
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.6;
  transition: border-color 0.15s, opacity 0.15s;
}

.detail-gallery__thumb:hover,
.detail-gallery__thumb--active {
  border-color: var(--md-sys-color-primary);
  opacity: 1;
}

.detail-info__title {
  font: var(--md-sys-typescale-headline-medium);
  margin-bottom: 12px;
}

.detail-info__author {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 16px;
}

.detail-info__author span {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

/* === MD3 Star Rating === */
.star-rating {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.star-rating__btns {
  display: flex;
  gap: 2px;
}

.star-rating__btn {
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: var(--md-sys-color-outline-variant);
  transition: color 0.1s, transform 0.1s;
  padding: 0;
  line-height: 1;
}

.star-rating__btn:hover {
  transform: scale(1.15);
}

.star-rating__btn--filled {
  color: var(--md-sys-color-primary);
}

.star-rating__count {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

/* Download section */
.detail-download {
  margin-bottom: 24px;
}

.detail-download .md3-btn--filled {
  height: 48px;
  font-size: 1rem;
}

.download-count {
  display: block;
  margin-top: 8px;
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

/* === Description Block === */
.detail-description {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 24px;
  margin-bottom: 32px;
  font: var(--md-sys-typescale-body-large);
  line-height: 1.8;
  word-break: break-word;
  box-shadow: var(--md-sys-elevation-1);
}

/* === Comments Section === */
.comments-section {
  margin-top: 16px;
}

.comments-section__title {
  font: var(--md-sys-typescale-title-medium);
  margin-bottom: 24px;
}

.comment-form {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.comment-form__input {
  flex: 1;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-medium);
  resize: vertical;
  min-height: 48px;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
}

.comment-form__input:focus {
  border-color: var(--md-sys-color-primary);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 16px;
  box-shadow: var(--md-sys-elevation-1);
}

.comment__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.comment__user {
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-primary);
}

.comment__time {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
}

.comment__delete {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-error);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  transition: background 0.15s;
}

.comment__delete:hover {
  background: rgba(255, 180, 171, 0.08);
}

.comment__content {
  font: var(--md-sys-typescale-body-medium);
  line-height: 1.7;
}

/* === Admin Layout === */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}

/* MD3 Navigation Drawer */
.admin-nav-drawer {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 8px;
  box-shadow: var(--md-sys-elevation-1);
  position: sticky;
  top: 88px;
}

.admin-nav-drawer__heading {
  padding: 16px 16px 12px;
  font: var(--md-sys-typescale-title-small);
  color: var(--md-sys-color-primary);
  letter-spacing: 0.02em;
}

.admin-nav-drawer__divider {
  height: 1px;
  background: var(--md-sys-color-outline-variant);
  margin: 8px 12px;
}

.admin-nav-drawer a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.admin-nav-drawer a:hover {
  background: rgba(203, 196, 206, 0.08);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.admin-nav-drawer a.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

.admin-nav-drawer__back {
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin-top: 8px;
  padding-top: 8px;
}

/* Admin Content */
.admin-content {
  min-width: 0;
}

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

.admin-content__header h2 {
  font: var(--md-sys-typescale-headline-small);
}

/* MD3 Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 24px;
  text-align: center;
  box-shadow: var(--md-sys-elevation-1);
}

.stat-card__value {
  font: var(--md-sys-typescale-display-small);
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.stat-card__label {
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}

/* === MD3 Data Table === */
.md3-table {
  width: 100%;
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-1);
}

.md3-table__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.md3-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.md3-table th {
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  text-align: left;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container-high);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.md3-table td {
  font: var(--md-sys-typescale-body-medium);
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.md3-table th:last-child,
.md3-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
}

.md3-table th:last-child {
  background: var(--md-sys-color-surface-container-high);
  z-index: 2;
}

.md3-table td:last-child {
  background: var(--md-sys-color-surface-container-low);
}

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

.md3-table tr:hover td {
  background: rgba(203, 196, 206, 0.04);
}

.md3-table tr:hover td:last-child {
  background: var(--md-sys-color-surface-container-low);
}

/* MD3 Chip / Badge */
.md3-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-label-small);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.md3-chip--success {
  background: #1b3821;
  color: #a8df8e;
}

.md3-chip--muted {
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
}

.md3-chip--role {
  border: 1px solid currentColor;
  background: transparent;
}

/* === Permission Checkbox List === */
.permission-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  cursor: pointer;
  transition: border-color 0.15s;
}

.permission-item:hover {
  border-color: var(--md-sys-color-outline);
}

.permission-item input[type="checkbox"] {
  accent-color: var(--md-sys-color-primary);
  width: 18px;
  height: 18px;
}

.permission-item__code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--md-sys-color-primary);
}

/* === Color Input === */
.md3-color-input {
  width: 48px;
  height: 36px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 2px solid var(--md-sys-color-outline);
  cursor: pointer;
  padding: 2px;
  background: none;
}

/* === Image Upload === */
.image-upload-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.image-thumb-wrapper {
  position: relative;
  display: inline-block;
}

.image-thumb {
  width: 128px;
  height: 86px;
  object-fit: cover;
  border-radius: var(--md-sys-shape-corner-small);
  border: 2px solid var(--md-sys-color-outline-variant);
}

.image-thumb-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--md-sys-color-error);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-sys-elevation-1);
  transition: transform 0.1s;
}

.image-thumb-remove:hover {
  transform: scale(1.1);
}

/* === Modal (MD3 Dialog) === */
.md3-dialog-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.md3-dialog-backdrop--open {
  display: flex;
}

.md3-dialog {
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 24px;
  max-width: 440px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--md-sys-elevation-5);
  animation: dialog-in 0.2s ease-out;
}

@keyframes dialog-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.md3-dialog__title {
  font: var(--md-sys-typescale-headline-small);
  margin-bottom: 16px;
}

.md3-dialog__body {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 24px;
  line-height: 1.6;
}

.md3-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-small);
}

/* === Toast / Snackbar === */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-body-small);
  font-weight: 500;
  box-shadow: var(--md-sys-elevation-3);
  animation: toast-in 0.25s ease-out;
}

.toast--error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.toast--success {
  background: #1b3821;
  color: #a8df8e;
}

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--md-sys-color-on-surface-variant);
}

.empty-state__icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state__text {
  font: var(--md-sys-typescale-body-large);
}

/* === Responsive === */
@media (max-width: 768px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-nav-drawer {
    position: static;
  }

  .hero__title {
    font-size: 36px;
  }

  .resource-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .top-app-bar {
    padding: 0 8px;
    gap: 4px;
    overflow: visible;
  }

  .top-app-bar__brand span {
    display: none;
  }

  .top-app-bar__spacer {
    flex: 0 0 auto;
    width: 4px;
  }

  .top-app-bar__nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
    gap: 2px;
  }

  .top-app-bar__nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    padding: 0 10px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .nav-item--icon-only {
    padding: 0;
    width: 36px;
  }

  .theme-toggle,
  .lang-switcher .nav-item {
    padding: 0;
    width: 36px;
  }

  /* Mobile: fixed-position dropdowns to escape overflow clipping */
  .lang-switcher__dropdown {
    position: fixed;
    top: 68px;
    right: 8px;
  }

  .user-menu__dropdown {
    position: fixed;
    top: 68px;
    right: 52px;
  }

  .search-bar {
    flex-direction: column;
    height: auto;
    background: none;
    box-shadow: none;
    border-radius: 0;
  }

  .search-bar:focus-within {
    box-shadow: none;
  }

  .search-bar__input {
    height: 56px;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-full);
    margin-bottom: 8px;
    padding: 0 20px;
    flex: none;
    width: 100%;
  }

  .search-bar__btn {
    width: 100%;
    height: 48px;
    margin-right: 0;
    border-radius: var(--md-sys-shape-corner-full);
  }

  .search-bar__icon {
    display: none;
  }
}

/* === Action Menu (three-dot dropdown) === */
.action-menu {
  position: relative;
  display: inline-block;
}
.action-menu summary { list-style: none; }
.action-menu summary::-webkit-details-marker { display: none; }

.action-menu__trigger {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 50%;
  font-size: 20px;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.action-menu__trigger:hover {
  background: rgba(203, 196, 206, 0.08);
}

.action-menu__dropdown {
  display: block;
  position: fixed;
  visibility: hidden;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-small);
  min-width: 160px;
  box-shadow: var(--md-sys-elevation-3);
  overflow: hidden;
  z-index: 400;
}

.action-menu__dropdown--shown {
  visibility: visible;
}

.action-menu__dropdown a,
.action-menu__dropdown button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  text-decoration: none;
}

.action-menu__dropdown a:hover,
.action-menu__dropdown button:hover {
  background: rgba(203, 196, 206, 0.08);
  text-decoration: none;
}

.action-menu__danger {
  color: var(--md-sys-color-error) !important;
}

/* === Markdown Editor === */
.md-editor {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  overflow: hidden;
  background: var(--md-sys-color-surface-container-highest);
}

.md-editor:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(255, 185, 56, 0.3);
}

.md-editor__tabs {
  display: flex;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.md-editor__tab {
  padding: 10px 20px;
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface-variant);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.md-editor__tab:hover {
  color: var(--md-sys-color-on-surface);
}

.md-editor__tab--active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

.md-editor__toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
  flex-wrap: wrap;
}

.md-editor__toolbar button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  border-radius: var(--md-sys-shape-corner-extra-small);
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.md-editor__toolbar button .material-icons {
  font-size: 20px;
}

.md-editor__toolbar button:hover {
  background: rgba(203, 196, 206, 0.12);
  color: var(--md-sys-color-on-surface);
}

.md-editor__toolbar-sep {
  width: 1px;
  margin: 4px 4px;
  background: var(--md-sys-color-outline-variant);
}

.md-editor__textarea {
  display: block;
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: none;
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}

.md-editor__preview {
  display: none;
  min-height: 300px;
  padding: 16px;
  background: var(--md-sys-color-surface-container-highest);
}

/* === Rendered Markdown Body === */
.markdown-body {
  line-height: 1.7;
  color: var(--md-sys-color-on-surface);
}

.markdown-body h1 { font: var(--md-sys-typescale-headline-large); margin: 24px 0 16px; }
.markdown-body h2 { font: var(--md-sys-typescale-headline-medium); margin: 20px 0 12px; }
.markdown-body h3 { font: var(--md-sys-typescale-headline-small); margin: 16px 0 8px; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font: var(--md-sys-typescale-title-large); margin: 12px 0 8px; }

.markdown-body p { margin: 0 0 12px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px; padding-left: 24px; }
.markdown-body li { margin-bottom: 4px; }

.markdown-body code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--md-sys-color-surface-container-high);
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  font-size: 0.9em;
}

.markdown-body pre {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  padding: 16px;
  overflow-x: auto;
  margin: 0 0 16px;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}

.markdown-body blockquote {
  border-left: 4px solid var(--md-sys-color-primary);
  padding: 8px 16px;
  margin: 0 0 16px;
  background: var(--md-sys-color-surface-container);
  border-radius: 0 var(--md-sys-shape-corner-small) var(--md-sys-shape-corner-small) 0;
  color: var(--md-sys-color-on-surface-variant);
}

.markdown-body a {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--md-sys-shape-corner-small);
  margin: 12px 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  border-radius: var(--md-sys-shape-corner-small);
  overflow: hidden;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  text-align: left;
}

.markdown-body th {
  background: var(--md-sys-color-surface-container-high);
  font: var(--md-sys-typescale-label-large);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin: 24px 0;
}

.markdown-body strong { font-weight: 700; }
.markdown-body em { font-style: italic; }

.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

/* === Browse / All-Resources Page === */
.browse-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
}

.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.browse-header h2 {
  font: var(--md-sys-typescale-headline-small);
}

.browse-header__count {
  display: block;
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}

/* === MD3 Filter Bar === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-1);
}

/* === MD3 Custom Dropdown (replaces native select) === */
.md3-dropdown {
  position: relative;
  flex: 1;
  min-width: 160px;
}

.md3-dropdown__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 56px;
  padding: 0 16px;
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-medium);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.15s;
  text-align: left;
}

.md3-dropdown__trigger:hover {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-outline);
}

.md3-dropdown--open .md3-dropdown__trigger {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(255, 185, 56, 0.25);
  background: var(--md-sys-color-surface-container-high);
}

.md3-dropdown__trigger .material-icons:first-child {
  font-size: 20px;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
}

.md3-dropdown__text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.md3-dropdown__arrow {
  font-size: 20px;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.md3-dropdown--open .md3-dropdown__arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.md3-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-small);
  box-shadow: var(--md-sys-elevation-3);
  overflow: hidden;
  z-index: 300;
  max-height: 320px;
  overflow-y: auto;
  animation: dropdown-in 0.15s ease-out;
}

.md3-dropdown__menu--open {
  display: block;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.md3-dropdown__option {
  display: flex;
  align-items: center;
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: none;
  background: none;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-medium);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.md3-dropdown__option:hover {
  background: rgba(203, 196, 206, 0.08);
}

.md3-dropdown__option--selected {
  color: var(--md-sys-color-primary);
  font-weight: 600;
  background: rgba(255, 185, 56, 0.08);
}

.md3-dropdown__option--selected::after {
  content: 'check';
  font-family: 'Material Icons';
  font-size: 18px;
  margin-left: auto;
}

.filter-bar__reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 16px;
  border: none;
  background: none;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-error);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.filter-bar__reset:hover {
  background: rgba(255, 180, 171, 0.08);
}

.filter-bar__reset .material-icons {
  font-size: 18px;
}

/* Active filter chips */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px 0 12px;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-label-medium);
}

.active-filter-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: rgba(0,0,0,0.15);
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s;
}

.active-filter-chip button:hover {
  background: rgba(0,0,0,0.25);
}

/* === Browse Grid (Responsive Columns) === */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Card category tag */
.md3-card__category {
  display: inline-block;
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-corner-extra-small);
  padding: 2px 8px;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.md3-card__downloads {
  color: var(--md-sys-color-on-surface-variant);
}

/* === Responsive: Tablet (2 columns) === */
@media (max-width: 1023px) {
  .browse-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .md3-dropdown {
    min-width: 140px;
  }
}

/* === Responsive: Mobile (1 column) === */
@media (max-width: 767px) {
  .browse-page {
    padding: 16px 12px;
  }

  .browse-grid {
    grid-template-columns: 1fr;
  }

  .browse-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-bar {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .md3-dropdown {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .md3-dropdown__menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: auto;
    max-height: 50vh;
    border-radius: var(--md-sys-shape-corner-large);
  }

  .filter-bar__reset {
    width: 100%;
    justify-content: center;
  }

  .md3-card__media,
  .md3-card__media-placeholder {
    height: 200px;
  }
}

/* Category tag on detail page */
.detail-info__category {
  margin-bottom: 12px;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-label-medium);
  font-weight: 600;
  letter-spacing: 0.02em;
}
