:root {
    --deep: #061a2e;
    --ocean: #0a3a5c;
    --mid: #0e5a82;
    --foam: #a8dff0;
    --gold: #c9a84c;
    --serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
    --sans: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--sans);
    font-weight: 300;
    background: var(--deep);
    color: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: var(--foam);
}

a:hover {
    color: var(--gold);
    text-decoration: underline;
}

/* Navigation bar */
.navbar {
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    padding: 0 15px 0 25px;
    background: var(--ocean);
    border-bottom: 1px solid rgba(168, 223, 240, 0.15);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Brand and logo text */
.nav-brand-container {
    display: flex;
    align-items: center;
    padding: 14px 0;
}

.nav-brand {
    color: var(--foam);
    font-family: var(--serif);
    font-size: 1.15rem;
    letter-spacing: 0.05em;
}

.nav-brand a {
    color: inherit;
    text-decoration: none;
}

.nav-brand strong {
    color: var(--gold);
    font-weight: 400;
}

/* Navigation links */
.nav-links {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.nav-links a {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: color 0.2s, background-color 0.2s;
}

.nav-links a:hover {
    color: var(--gold);
}

/* Hide the checkbox and hamburger on desktop */
#nav-toggle,
.nav-toggle-label {
    display: none;
}

/* Responsive mobile navigation */
@media (max-width: 960px) {
    .nav-toggle-label {
        display: block;
        align-self: center;
        cursor: pointer;
        color: var(--foam);
        font-size: 1.6rem;
        line-height: 1;
        padding: 14px 12px;
        margin-right: -12px;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .navbar {
        padding: 0 25px;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--ocean);
        flex-direction: column;
        border-bottom: 1px solid rgba(168, 223, 240, 0.15);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
        z-index: 1001;
    }

    .nav-links a {
        display: block;
        width: 100%;
        padding: 1rem 2rem;
        border-bottom: 1px solid rgba(168, 223, 240, 0.15);
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .nav-links a:hover,
    .nav-links a:active {
        color: var(--gold);
        background: rgba(168, 223, 240, 0.08);
    }

    /* Show the menu when the hamburger is checked */
    #nav-toggle:checked ~ .nav-links {
        display: flex;
    }
}

/* --- Main Layout & Sidebar --- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

aside {
  padding: 2rem 1.8rem;
  border-right: 1px solid rgba(168,223,240,0.12);
}

.filters-toggle { display: none; }
.filters-body { display: block; }
.filters-backdrop { display: none; }
.filters-drawer-header,
.filters-drawer-footer { display: none; }

.search-box {
  position: relative;
  margin-bottom: 2rem;
}
.search-box input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 300;
  border: 1px solid rgba(168,223,240,0.25);
  border-radius: 3px;
  background: rgba(255,255,255,0.03);
  color: #fff;
}
.search-box input::placeholder { color: rgba(255,255,255,0.35); }
.search-box input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.12);
}

.facet-group { margin-bottom: 2.2rem; }
.facet-group h2 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.05rem;
  color: var(--gold);
  margin-bottom: 0.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(201,168,76,0.2);
}
.facet-list {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.facet-list::-webkit-scrollbar { width: 6px; }
.facet-list::-webkit-scrollbar-thumb { background: rgba(168,223,240,0.2); border-radius: 3px; }

.facet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.32rem 0;
  font-size: 0.85rem;
}
.facet-item label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  color: rgba(255,255,255,0.85);
}
.facet-item span.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.facet-item input[type=checkbox] {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.facet-item .count {
  font-size: 0.74rem;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

.clear-btn {
  background: none;
  border: 1px solid rgba(201,168,76,0.35);
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.45em 1em;
  border-radius: 2em;
  font-family: var(--sans);
  transition: background 0.2s;
}
.clear-btn:hover { background: rgba(201,168,76,0.1); }

/* --- Results Feed --- */
main {
  padding: 2.2rem 2.4rem 3.5rem;
  min-width: 0;
}

.results-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.3rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(168,223,240,0.15);
}
.results-bar .count {
  font-size: 0.86rem;
  color: rgba(255,255,255,0.55);
}
.results-bar .count strong { color: var(--foam); font-weight: 400; }

select#sortSelect {
  font-family: var(--sans);
  font-size: 0.8rem;
  border: 1px solid rgba(168,223,240,0.25);
  border-radius: 3px;
  padding: 0.4rem 0.6rem;
  background: var(--ocean);
  color: #fff;
}

.active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.2rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(168,223,240,0.06);
  border: 1px solid rgba(168,223,240,0.2);
  border-radius: 20px;
  padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  font-size: 0.78rem;
  color: var(--foam);
}
.chip button {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 0.15rem;
}

.entries { display: flex; flex-direction: column; }

.entry {
  padding: 1.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.entry h3 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.2rem;
  line-height: 1.4;
  color: #fff;
  margin-bottom: 0.4rem;
}
.entry .meta {
  font-size: 0.82rem;
  color: var(--foam);
  margin-bottom: 0.35rem;
}
.entry .meta .sep { color: rgba(168,223,240,0.35); margin: 0 0.45rem; }
.entry .authors {
  font-size: 0.87rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.55;
}
.entry .doi {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--gold);
  text-decoration: none;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.entry .doi:hover { text-decoration: underline; }

mark {
  background: rgba(201,168,76,0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 1px;
}

.empty-state {
  padding: 3.5rem 1rem;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 0.95rem;
}

/* --- Footer --- */
footer {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.4);
  padding: 2rem 0;
  border-top: 1px solid rgba(168,223,240,0.1);
  margin-top: auto;
  background: var(--ocean);
}

/* --- Media Queries --- */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }

  aside {
    border-right: none;
    border-bottom: none;
    padding: 1.4rem 1.2rem 0.6rem;
  }

  .filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(168,223,240,0.25);
    border-radius: 3px;
    color: var(--foam);
    font-family: var(--sans);
    font-size: 0.9rem;
    padding: 0.7rem 0.9rem;
    cursor: pointer;
  }
  .filters-toggle .badge {
    background: var(--gold);
    color: var(--deep);
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.05rem 0.5rem;
    margin-left: 0.5rem;
  }
  .filters-toggle .chevron { color: var(--gold); }

  /* Backdrop behind the drawer */
  .filters-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2,10,20,0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1100;
  }
  .filters-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* The drawer itself: slides up from the bottom, overlays content, never pushes it */
  .filters-body {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: var(--ocean);
    border-top: 1px solid rgba(168,223,240,0.2);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
    transform: translateY(100%);
    transition: transform 0.28s ease;
    z-index: 1200;
    margin-top: 0;
    padding: 0;
  }
  .filters-body.open { transform: translateY(0); }

  .filters-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(168,223,240,0.15);
    flex-shrink: 0;
  }
  .filters-drawer-header h2 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--foam);
  }
  .drawer-result-count {
    font-size: 0.78rem;
    color: var(--gold);
    margin-top: 0.15rem;
  }
  .filters-drawer-header button {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
  }

  .filters-drawer-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.2rem;
    flex: 1;
  }

  .filters-drawer-footer {
    display: block;
    flex-shrink: 0;
    padding: 0.9rem 1.2rem calc(0.9rem + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(168,223,240,0.15);
    background: var(--ocean);
  }
  .filters-drawer-footer .show-results-btn {
    display: block;
    width: 100%;
    background: var(--gold);
    color: var(--deep);
    border: none;
    border-radius: 4px;
    padding: 0.8em 1em;
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    margin-bottom: 0.6rem;
  }
  .filters-drawer-footer .show-results-btn:active { opacity: 0.85; }
  .filters-drawer-footer .show-results-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  .filters-drawer-footer .clear-btn {
    width: 100%;
    padding: 0.6em 1em;
    border-color: rgba(201,168,76,0.25);
  }

  .search-box { margin-bottom: 1.4rem; }

  /* Prevent iOS Safari from auto-zooming when a text input is focused */
  .search-box input, select#sortSelect { font-size: 16px; }

  .facet-list { -webkit-overflow-scrolling: touch; }

  .facet-item { padding: 0.5rem 0; }
  .facet-item input[type=checkbox] { width: 18px; height: 18px; }

  main { padding: 1.4rem 1.2rem 2.5rem; }

  .results-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }
  select#sortSelect { width: 100%; padding: 0.6rem; }

  .entry h3 { font-size: 1.08rem; }
  .entry .authors { font-size: 0.85rem; }
}

@media (max-width: 420px) {
  .navbar { padding: 0 16px; }
  .nav-brand { font-size: 1rem; }
  main { padding: 1.1rem 0.9rem 2rem; }
  aside { padding: 1.1rem 0.9rem 0.5rem; }
  .entry { padding: 1.05rem 0; }
  .entry h3 { font-size: 1rem; }
  .entry .meta { font-size: 0.78rem; }
  .entry .authors { font-size: 0.82rem; }
}