:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --panel: #ffffff;
  --ink: #1f2623;
  --muted: #65706a;
  --line: #d9ded7;
  --green: #247b55;
  --green-soft: #e4f2eb;
  --blue: #315f8f;
  --coral: #b94c43;
  --shadow: 0 14px 36px rgba(38, 49, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf6;
}

.topbar__kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  white-space: nowrap;
}

.topbar__kicker #totalCount::before {
  content: "/";
  margin-right: 12px;
  color: var(--line);
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.08;
}

#totalCount {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
}

a {
  color: var(--blue);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 28px;
}

.filters {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filters__header,
.results__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.filters__header h2 {
  margin: 0;
  font-size: 18px;
}

.filters__summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filters__result-count {
  display: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

.filters__header button,
.load-more,
.card button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.filters__header button {
  padding: 8px 10px;
  color: var(--coral);
}

.filters__toggle {
  display: none;
  color: var(--ink);
}

.filters__footer {
  display: none;
}

.filters__footer button {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.search {
  display: grid;
  gap: 7px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input,
.sort select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.search input {
  padding: 11px 12px;
}

.status-filter {
  display: grid;
  gap: 2px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.status-filter h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.duration-filter {
  display: grid;
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.duration-filter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.duration-filter h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.duration-filter__header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.duration-range {
  position: relative;
  height: 32px;
  --range-start: 0%;
  --range-end: 100%;
}

.duration-range::before,
.duration-range::after {
  content: "";
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 999px;
}

.duration-range::before {
  background: #e4e8e1;
}

.duration-range::after {
  left: var(--range-start);
  right: calc(100% - var(--range-end));
  background: var(--green);
}

.duration-range input[type="range"] {
  position: absolute;
  top: 5px;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 24px;
  margin: 0;
  appearance: none;
  background: transparent;
  pointer-events: none;
}

.duration-range input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.duration-range input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 2px solid var(--green);
  border-radius: 999px;
  appearance: none;
  background: #fff;
  box-shadow: 0 2px 7px rgba(38, 49, 44, 0.22);
  cursor: pointer;
  pointer-events: auto;
}

.duration-range input[type="range"]::-moz-range-track {
  height: 4px;
  background: transparent;
}

.duration-range input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid var(--green);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(38, 49, 44, 0.22);
  cursor: pointer;
  pointer-events: auto;
}

.filter-group {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.filter-group__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.filter-group__title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-group__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.filter-group--collapsed .filter-group__chevron {
  transform: rotate(-45deg);
}

.filter-group__options {
  padding-top: 8px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.filter-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.filter-option span:last-child {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.results {
  min-width: 0;
}

.results__toolbar {
  margin-bottom: 18px;
}

#resultCount {
  display: block;
  margin-bottom: 2px;
  font-size: 18px;
}

#activeFilters {
  color: var(--muted);
  font-size: 13px;
}

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

.view-toggle {
  display: none;
}

.view-toggle button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.view-toggle button:first-child {
  border-radius: 8px 0 0 8px;
}

.view-toggle button:last-child {
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

.view-toggle button.is-active {
  background: var(--green);
  color: #fff;
}

.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.sort select {
  min-width: 210px;
  padding: 9px 10px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px;
}

.card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(38, 49, 44, 0.06);
}

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

.card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #e3e8e3;
}

.card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(20, 23, 22, 0.86);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.card__body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.card__title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.28;
}

.card__status-actions {
  display: inline-flex;
  gap: 5px;
}

.status-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.status-button.is-active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.card__meta,
.card__description {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.card__description {
  min-height: 56px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #24513f;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag--level {
  background: #e8edf6;
  color: #2f5278;
}

.tag--type {
  background: #f4e7e4;
  color: #7b3d37;
}

.card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.card button,
.card__actions a,
.primary-link,
.load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
}

.card__actions a,
.primary-link {
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.card .status-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

.load-more {
  width: 100%;
  margin-top: 22px;
  background: #fff;
}

.load-more[hidden] {
  display: none;
}

.details {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.details::backdrop {
  background: rgba(22, 27, 25, 0.62);
}

.details__frame {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.details__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

#detailsThumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #e3e8e3;
}

.details__body {
  padding: 22px;
}

.details__body h2 {
  margin-bottom: 12px;
  font-size: 24px;
  line-height: 1.2;
}

#detailsDescription {
  margin: 18px 0;
  color: #303934;
  line-height: 1.58;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    padding: 16px 14px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .filters {
    position: static;
    max-height: none;
    padding: 14px;
  }

  .filters__header {
    align-items: center;
  }

  .filters__toggle {
    display: inline-flex;
  }

  .filters__result-count {
    display: inline-flex;
  }

  .filters__panel {
    display: none;
  }

  .filters-open .filters__panel {
    display: block;
  }

  .filters-open .filters__footer {
    display: block;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }

  .results__toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .results__count {
    display: none;
  }

  .toolbar-controls {
    justify-content: space-between;
    width: 100%;
  }

  .view-toggle {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .sort {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    flex: 1 1 auto;
    width: auto;
  }

  .sort select {
    min-width: 0;
    width: min(100%, 230px);
  }

  .cards--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card--compact {
    grid-template-rows: auto 1fr;
  }

  .card--compact .card__body {
    padding: 9px;
  }

  .card--compact h3 {
    display: -webkit-box;
    min-height: 42px;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .card--compact .duration {
    right: 6px;
    bottom: 6px;
    padding: 3px 5px;
    font-size: 11px;
  }
}
