:root {
  --ink: #12251e;
  --forest: #10291f;
  --forest-soft: #17392c;
  --green: #087255;
  --mint: #b6dfcc;
  --gold: #c9a76a;
  --paper: #f5f1e9;
  --white: #fff;
  --line: rgba(18, 37, 30, 0.13);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  padding: 0.75rem 1rem;
  color: var(--ink);
  background: var(--white);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.library-header {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem clamp(1.25rem, 5vw, 5rem);
  color: var(--white);
  background: var(--forest);
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.brand img {
  display: block;
  width: 180px;
  height: auto;
}

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-home:hover,
.back-home:focus-visible {
  color: var(--mint);
}

.library-hero {
  display: flex;
  min-height: 290px;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: 4.5rem clamp(1.25rem, 7vw, 7.5rem) 3.5rem;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(5, 24, 17, 0.96), rgba(5, 24, 17, 0.48)),
    url("/assets/montanas.jpg") center 49% / cover;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.library-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 6vw, 6rem);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.library-hero > div > p:last-child {
  max-width: 590px;
  margin: 1.25rem 0 0;
  color: rgba(255, 255, 255, 0.72);
}

.demo-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.demo-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(201, 167, 106, 0.18);
}

.library-shell {
  display: grid;
  width: min(1450px, calc(100% - 3rem));
  min-height: 680px;
  margin: clamp(2.5rem, 5vw, 5rem) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 24px 70px rgba(18, 37, 30, 0.09);
  grid-template-columns: 310px 1fr;
}

.collections-panel {
  display: flex;
  padding: 2rem 1.25rem 1.5rem;
  color: var(--white);
  background: var(--forest);
  flex-direction: column;
}

.panel-heading {
  display: flex;
  margin: 0 0 1rem;
  padding: 0 0.75rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.panel-heading p,
.panel-heading span {
  margin: 0;
}

.panel-heading p {
  font-family: var(--serif);
  font-size: 1.35rem;
}

.panel-heading span {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#collection-nav {
  display: grid;
  gap: 0.35rem;
}

.collection-button {
  display: grid;
  width: 100%;
  padding: 0.85rem 0.75rem;
  border: 0;
  color: rgba(255, 255, 255, 0.68);
  background: transparent;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.collection-button:hover,
.collection-button:focus-visible {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  outline: 0;
}

.collection-button.is-active {
  color: var(--white);
  background: rgba(182, 223, 204, 0.12);
}

.collection-button img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.collection-button__title {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.2;
}

.collection-button__count {
  color: var(--gold);
  font-size: 0.64rem;
}

.sync-note {
  display: flex;
  margin-top: auto;
  padding: 1.25rem 0.75rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  gap: 0.8rem;
}

.sync-note__icon {
  color: var(--gold);
  font-size: 1.3rem;
}

.sync-note strong {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.sync-note p {
  margin: 0.35rem 0 0;
  color: rgba(255, 255, 255, 0.47);
  font-size: 0.7rem;
  line-height: 1.45;
}

.explorer-panel {
  min-width: 0;
  padding: clamp(1.5rem, 4vw, 3.5rem);
}

.explorer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.collection-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 1.15rem;
}

.collection-title img {
  width: 65px;
  height: 65px;
  flex: 0 0 auto;
  object-fit: contain;
}

.collection-title p {
  margin: 0 0 0.2rem;
  color: var(--green);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.collection-title h2 {
  margin: 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
  text-overflow: ellipsis;
}

.search-box {
  position: relative;
  width: min(300px, 35%);
  flex: 0 0 auto;
}

.search-box svg {
  position: absolute;
  top: 50%;
  left: 1rem;
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  min-height: 46px;
  padding: 0.7rem 1rem 0.7rem 2.8rem;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #faf9f6;
  outline: 0;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 114, 85, 0.09);
}

.toolbar {
  display: flex;
  min-height: 74px;
  margin-top: 2rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

#breadcrumbs {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.78rem;
}

.breadcrumb-button {
  padding: 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.breadcrumb-current {
  overflow: hidden;
  color: rgba(18, 37, 30, 0.58);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#item-count {
  flex: 0 0 auto;
  margin: 0;
  color: rgba(18, 37, 30, 0.52);
  font-size: 0.7rem;
}

.file-table__header,
.file-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 90px 90px 120px;
  gap: 1rem;
  align-items: center;
}

.file-table__header {
  padding: 1rem 1.15rem;
  color: rgba(18, 37, 30, 0.45);
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.file-row {
  width: 100%;
  min-height: 72px;
  padding: 0.85rem 1.15rem;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease;
}

.file-row:hover,
.file-row:focus-visible {
  background: rgba(8, 114, 85, 0.055);
  outline: 0;
}

.youtube-row {
  text-decoration: none;
}

.youtube-thumb {
  width: 72px;
  height: 42px;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--forest-deep);
}

.file-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.9rem;
}

.file-name__text {
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 3px;
  color: var(--green);
  background: rgba(8, 114, 85, 0.1);
  place-items: center;
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.file-icon--folder {
  color: #7b5d27;
  background: rgba(201, 167, 106, 0.24);
}

.file-icon--folder::before {
  position: absolute;
  top: -4px;
  left: 4px;
  width: 15px;
  height: 6px;
  border-radius: 3px 3px 0 0;
  background: #d5b675;
  content: "";
}

.file-meta {
  color: rgba(18, 37, 30, 0.56);
  font-size: 0.72rem;
}

.folder-count {
  color: rgba(18, 37, 30, 0.48);
  font-size: 0.68rem;
}

.empty-state {
  padding: 5rem 2rem;
  color: rgba(18, 37, 30, 0.6);
  text-align: center;
}

.empty-state > span {
  display: block;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 4rem;
}

.empty-state h3 {
  margin: 0.5rem 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 400;
}

.empty-state p {
  margin: 0;
  font-size: 0.85rem;
}

dialog {
  width: min(520px, calc(100% - 2rem));
  padding: 2.5rem;
  border: 0;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(4, 20, 15, 0.3);
}

dialog::backdrop {
  background: rgba(4, 20, 15, 0.78);
  backdrop-filter: blur(3px);
}

.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1.6rem;
  cursor: pointer;
}

.file-preview-icon {
  display: grid;
  width: 62px;
  height: 72px;
  margin-bottom: 1.5rem;
  color: var(--white);
  background: var(--green);
  place-items: center;
  font-size: 0.7rem;
  font-weight: 900;
}

dialog h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.1;
}

dialog dl {
  display: grid;
  margin: 2rem 0;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(3, 1fr);
}

dialog dl div {
  padding: 1rem 0.75rem 0 0;
}

dialog dt {
  color: rgba(18, 37, 30, 0.48);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dialog dd {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
}

.dialog-note {
  color: rgba(18, 37, 30, 0.65);
  font-size: 0.82rem;
}

.dialog-action {
  display: flex;
  width: 100%;
  min-height: 48px;
  margin-top: 1rem;
  border: 0;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(18, 37, 30, 0.55);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

footer {
  display: flex;
  padding: 2rem clamp(1.25rem, 5vw, 5rem);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.48);
  background: #06140f;
  font-size: 0.67rem;
  letter-spacing: 0.06em;
}

footer a {
  color: var(--mint);
  text-decoration: none;
}

@media (max-width: 980px) {
  .library-shell {
    grid-template-columns: 250px 1fr;
  }

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

  .search-box {
    width: 100%;
  }

  .file-table__header,
  .file-row {
    grid-template-columns: minmax(190px, 1fr) 70px 90px;
  }

  .file-table__header span:last-child,
  .file-row > span:last-child {
    display: none;
  }
}

@media (max-width: 720px) {
  .library-header {
    min-height: 72px;
  }

  .brand img {
    width: 145px;
  }

  .back-home {
    font-size: 0;
  }

  .back-home span {
    font-size: 1.4rem;
  }

  .library-hero {
    min-height: 330px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: end;
  }

  .library-shell {
    width: calc(100% - 1.5rem);
    grid-template-columns: 1fr;
  }

  .collections-panel {
    padding: 1rem;
  }

  .panel-heading,
  .sync-note {
    display: none;
  }

  #collection-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }

  .collection-button {
    min-width: 190px;
    grid-template-columns: 38px 1fr;
  }

  .collection-button__count {
    display: none;
  }

  .explorer-panel {
    padding: 1.25rem;
  }

  .collection-title img {
    width: 52px;
    height: 52px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }

  .file-table__header {
    display: none;
  }

  .file-row {
    min-height: 72px;
    padding: 0.9rem 0;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .file-row > span:nth-child(3),
  .file-row > span:nth-child(4) {
    display: none;
  }

  .file-meta {
    padding-right: 0.25rem;
  }

  dialog {
    padding: 2rem 1.5rem;
  }

  dialog dl {
    grid-template-columns: 1fr;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
