:root {
  --kw1:  #D3777D;
  --kw2:  #E1A365;
  --kw3:  #E1D089;
  --kw4:  #99BF95;
  --kw5:  #7FB9B3;
  --kw6:  #7DA5B9;
  --kw7:  #8999DA;
  --kw8:  #A17FBF;
  --kw9:  #B87DAE;
  --kw10: #DA88AF;
  --kw11: #AEB7C1;
  --kw12: #95899D;
}

/* GLOBAL SIZING */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* BASE */
body {
  margin: 0;
  padding: 0;
  font-family: 'Nunito', sans-serif;
  background: #4876bb59;
  color: #1f2937;
}

/* HEADER */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(72, 118, 187, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* BRAND */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.logo {
  height: 52px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-weight: 800;
  font-size: 28px;
  color: #ffffff;
  line-height: 1.1;
}

.tagline {
  font-size: 16px;
  font-style: italic;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  margin-top: 2px;
}

/* HAMBURGER */
.menu-toggle {
  display: none !important;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.18);
  color: white;
  font-size: 22px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* NAV */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-bar a {
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-bar a:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.nav-bar a.active {
  background: rgba(255, 255, 255, 0.28);
}

.nav-bar a .menu-icon {
  margin-right: 8px;
  font-size: 18px;
}

/* PAGE */
.page-wrap {
  width: 100%;
  padding: 16px;
}

/* CONTROLS */
.controls {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto 16px auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-row {
  width: 100%;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.control-row > * {
  min-width: 0;
}

#search,
#searchMode,
#emailAddress,
#emailFavoritesBtn,
.secondary-btn {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d8deea;
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
}

#search {
  flex: 1 1 0;
  min-width: 0;
}

#searchMode,
#resetSearchBtn {
  flex: 0 0 auto;
}

.filter-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d8deea;
  font-size: 14px;
  font-weight: 700;
}

.toggle-filter input {
  margin: 0;
}

.filter-toggle-btn {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-weight: 700;
  color: #1f2937;
  cursor: pointer;
}

.filter-toggle-arrow {
  font-size: 16px;
  line-height: 1;
  transition: transform 0.18s ease;
}

.filter-toggle-btn[aria-expanded="true"] .filter-toggle-arrow {
  transform: rotate(180deg);
}

.more-filters-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.email-tools {
  width: 100%;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.email-tools > * {
  min-width: 0;
}

#emailAddress {
  flex: 1 1 260px;
}

#emailFavoritesBtn,
.secondary-btn {
  flex: 0 0 auto;
}

.secondary-btn,
#emailFavoritesBtn {
  cursor: pointer;
}

.secondary-btn {
  background: #fff;
}

.secondary-btn:hover {
  background: #ffe4e6;
}

.secondary-btn:disabled,
#emailFavoritesBtn:disabled {
  opacity: 0.6;
}

.favorites-note {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.6);
  padding: 8px 10px;
  border-radius: 10px;
}

/* LIST */
#list {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.load-error {
  padding: 16px;
  background: #ffffff;
  border-radius: 12px;
}

/* CARD */
.card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px 14px 24px;
  background: #fff;
  border-radius: 16px;
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: linear-gradient(
    to bottom,
    #ff6b6b,
    #feca57,
    #48dbfb,
    #1dd1a1,
    #5f27cd
  );
  border-radius: 16px 0 0 16px;
}

/* CARD ID */
.card-id {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 11px;
  color: #6b7280;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 7px;
  border-radius: 6px;
  border: none;
  z-index: 2;
}

/* COLUMNS */
.top {
  flex: 1.2;
  min-width: 0;
  padding-right: 70px;
}

.keywords {
  flex: 2.2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.links {
  flex: 1.1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding-top: 26px;
}

/* LEFT */
.top-main {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.text-block {
  min-width: 0;
}

.title {
  font-weight: 700;
  word-break: break-word;
  padding-right: 10px;
  font-size: 1.15em;
}

.meta {
  margin-top: 2px;
}

.creator {
  font-size: 12px;
  color: #6b7280;
  word-break: break-word;
}

.creator-search {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.creator-search:hover {
  opacity: 0.85;
}

.creator-search:disabled {
  cursor: default;
  opacity: 1;
}

.active-creator {
  background: rgba(72, 118, 187, 0.14);
  color: #2f5f9d;
  padding: 2px 6px;
}

/* GROUPED KEYWORDS */
.keyword-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.keyword-group-label {
  font-size: 11px;
  font-weight: 800;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.keyword-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* PILLS */
.pill {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  color: #111111;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.15s ease,
    opacity 0.18s ease;
}

.pill:hover {
  transform: translateY(-1px);
}

.pill:active {
  transform: translateY(0);
}

.pill:not(.active-pill) {
  opacity: 0.96;
}

.active-pill {
  color: #111111 !important;
  box-shadow: 0 0 0 2px rgba(31, 41, 55, 0.08);
  border-color: rgba(0, 0, 0, 0.12) !important;
}

/* CATEGORY COLORS */
.early-literacy-pill {
  background: rgba(211, 119, 125, 0.22);
  border-color: rgba(211, 119, 125, 0.4);
}
.early-literacy-pill.active-pill {
  background: var(--kw1);
}

.physical-pill {
  background: rgba(225, 163, 101, 0.22);
  border-color: rgba(225, 163, 101, 0.4);
}
.physical-pill.active-pill {
  background: var(--kw2);
}

.cognitive-pill {
  background: rgba(225, 208, 137, 0.24);
  border-color: rgba(225, 208, 137, 0.42);
}
.cognitive-pill.active-pill {
  background: var(--kw3);
}

.social-skill-pill {
  background: rgba(153, 191, 149, 0.22);
  border-color: rgba(153, 191, 149, 0.4);
}
.social-skill-pill.active-pill {
  background: var(--kw4);
}

.concept-pill {
  background: rgba(127, 185, 179, 0.22);
  border-color: rgba(127, 185, 179, 0.4);
}
.concept-pill.active-pill {
  background: var(--kw5);
}

.theme-pill {
  background: rgba(125, 165, 185, 0.22);
  border-color: rgba(125, 165, 185, 0.4);
}
.theme-pill.active-pill {
  background: var(--kw6);
}

.tune-pill {
  background: rgba(137, 153, 218, 0.22);
  border-color: rgba(137, 153, 218, 0.4);
}
.tune-pill.active-pill {
  background: var(--kw7);
}

.language-pill {
  background: rgba(161, 127, 191, 0.22);
  border-color: rgba(161, 127, 191, 0.4);
}
.language-pill.active-pill {
  background: var(--kw8);
}

.prop-pill {
  background: rgba(184, 125, 174, 0.22);
  border-color: rgba(184, 125, 174, 0.4);
}
.prop-pill.active-pill {
  background: var(--kw9);
}

.music-genre-pill {
  background: rgba(218, 136, 175, 0.22);
  border-color: rgba(218, 136, 175, 0.4);
}
.music-genre-pill.active-pill {
  background: var(--kw10);
}

.format-pill {
  background: rgba(174, 183, 193, 0.24);
  border-color: rgba(174, 183, 193, 0.42);
}
.format-pill.active-pill {
  background: var(--kw11);
}

.music-source-pill {
  background: rgba(149, 137, 157, 0.22);
  border-color: rgba(149, 137, 157, 0.4);
}
.music-source-pill.active-pill {
  background: var(--kw12);
}

/* STAR */
.star {
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.star.fav {
  color: #fbbf24;
}

/* LINKS */
.icon-link {
  padding: 8px 12px;
  border-radius: 10px;
  background: #f8fafc;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  white-space: nowrap;
}

.icon-link:hover {
  background: #eef2f7;
}

.link-icon {
  font-size: 15px;
  line-height: 1;
}

.video-link {
  font-size: 1rem;
  padding: 10px 14px;
}

.extra-link {
  font-size: 0.83rem;
  padding: 7px 11px;
}

/* STATUS FLAGS */
.status-flags {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-top: 2px;
}

.status-flag {
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #d8deea;
  background: rgba(255, 255, 255, 0.9);
  color: #4b5563;
  font-family: inherit;
  text-align: right;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.flag-icon {
  line-height: 1;
}

.ai-flag {
  border-color: rgba(174, 183, 193, 0.42);
  background: rgba(174, 183, 193, 0.18);
  color: #4f5a65;
}

.warning-flag {
  border-color: rgba(215, 88, 88, 0.45);
  background: rgba(255, 228, 228, 0.95);
  color: #8a1f1f;
}

.active-flag {
  box-shadow: 0 0 0 2px rgba(31, 41, 55, 0.08);
  border-width: 2px;
}

/* INFO PAGES */
.info-page {
  max-width: 1400px;
  margin: 0 auto;
}

.info-card {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  padding: 28px 30px 28px 38px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.info-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: linear-gradient(
    to bottom,
    #ff6b6b,
    #feca57,
    #48dbfb,
    #1dd1a1,
    #5f27cd
  );
  border-radius: 16px 0 0 16px;
}

.info-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.info-title {
  margin: 0;
  font-size: 30px;
  color: #4876bb;
}

.info-subtitle {
  margin-top: 20px;
  margin-bottom: 8px;
  font-size: 20px;
  color: #4876bb;
}

.info-card p {
  margin: 0;
  line-height: 1.6;
}

.info-card p + p {
  margin-top: 8px;
}

.back-link {
  font-size: 14px;
  text-decoration: none;
  background: #f8fafc;
  color: #4876bb;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d8deea;
  display: inline-block;
}

.back-link:hover {
  background: #e0f2fe;
}

.plain-page::before,
.plain-page::after,
.plain-page .page-wrap::before,
.plain-page .page-wrap::after,
.plain-page main::before,
.plain-page main::after,
.plain-page .back-link::before,
.plain-page .back-link::after {
  content: none !important;
  display: none !important;
}

/* DESKTOP FILTER LAYOUT */
@media (min-width: 769px) {
  .filter-stack {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .filter-row-excludes,
  .filter-row-recents,
  .filter-row-favorites {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .more-filters-panel {
    display: contents !important;
  }

  .filter-toggle-btn {
    display: none !important;
  }

  .more-filters-panel[hidden] {
    display: contents !important;
  }

  .email-tools-collapsible {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
}

/* MOBILE */
@media (max-width: 768px) {
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 10px;
  }

  .brand {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    flex: none;
  }

  .brand-text {
    min-width: 0;
  }

  .logo {
    height: 38px;
  }

  .brand-title {
    font-size: 22px;
    line-height: 1.1;
    margin: 0;
  }

  .tagline {
    display: block;
    font-size: 13px;
    margin-top: 2px;
  }

  .menu-toggle {
    display: block !important;
    margin-left: 0;
    justify-self: end;
    align-self: start;
  }

  .nav-bar {
    display: none;
    width: 100%;
    grid-column: 1 / -1;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
    margin-left: 0;
  }

  .nav-bar.open {
    display: flex;
  }

  .nav-bar a {
    width: 100%;
    text-align: center;
  }

  .page-wrap {
    padding: 12px;
  }

  .control-row {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .filter-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .filter-toggle-btn {
    display: flex;
  }

  .more-filters-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .more-filters-panel[hidden] {
    display: none !important;
  }

  /* excludes stacked */
  .filter-row-excludes {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* recents same row */
  .filter-row-recents {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* favorites same row */
  .filter-row-favorites {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .filter-row-recents .toggle-filter,
  .filter-row-favorites .toggle-filter,
  .filter-row-excludes .toggle-filter {
    width: 100%;
    justify-content: flex-start;
  }

  /* email layout */
  .email-tools-collapsible {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  #search,
  #searchMode,
  #emailAddress {
    width: 100%;
    max-width: 100%;
    display: block;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.2;
  }

  #emailAddress {
    grid-column: 1 / -1;
  }

  #emailFavoritesBtn,
  .secondary-btn {
    width: 100%;
    max-width: 100%;
    display: block;
    min-height: 38px;
    height: 38px;
    font-size: 14px;
  }

  #emailFavoritesBtn {
    grid-column: 1 / -1;
  }

  #copyFavoritesBtn,
  #clearFavoritesBtn {
    width: 100%;
  }

  .card {
    flex-direction: column;
    gap: 16px;
  }

  .top {
    padding-right: 82px;
  }

  .links {
    justify-content: flex-start;
    align-items: flex-start;
    padding-top: 0;
  }

  .status-flags {
    align-items: flex-start;
  }

  .info-card {
    padding: 22px 18px 22px 24px;
  }

  .info-card::before {
    width: 8px;
  }

  .info-title {
    font-size: 26px;
  }

  .info-subtitle {
    font-size: 18px;
  }
}