:root {
  color-scheme: dark;
  --bg: #11100f;
  --panel: #1b1916;
  --panel-raised: #24211d;
  --border: #554a3d;
  --gold: #d6b36a;
  --gold-bright: #f0d08a;
  --text: #eee8dc;
  --muted: #aaa094;
  --shadow: 0 18px 50px rgb(0 0 0 / 35%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgb(112 73 42 / 28%), transparent 34rem),
    linear-gradient(180deg, #181410 0, var(--bg) 24rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.masthead {
  border-bottom: 1px solid rgb(214 179 106 / 24%);
  background: linear-gradient(90deg, rgb(29 22 16 / 82%), rgb(16 15 14 / 50%));
}

.masthead__inner,
main,
footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.masthead__inner {
  padding: 52px 0 46px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.lede {
  max-width: 680px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.6;
}

main {
  padding: 32px 0 56px;
}

.search-panel {
  position: sticky;
  z-index: 2;
  top: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgb(27 25 22 / 94%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.search-panel > label {
  display: block;
  margin-bottom: 9px;
  color: var(--gold-bright);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 12px;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #66594a;
  border-radius: 9px;
  color: var(--text);
  background: #12110f;
  font: inherit;
}

input {
  padding: 0 15px;
}

select {
  padding: 0 40px 0 13px;
}

input:focus,
select:focus {
  border-color: var(--gold);
  outline: 3px solid rgb(214 179 106 / 17%);
}

.search-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

a {
  color: var(--gold-bright);
}

.results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.result {
  min-width: 0;
  border: 1px solid #3f3932;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--panel-raised), #1a1815);
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    background 120ms ease;
}

.result:hover {
  border-color: #846f50;
  background: linear-gradient(145deg, #2b2721, #1d1a17);
  transform: translateY(-1px);
}

.result a {
  display: block;
  min-height: 100%;
  padding: 17px 18px;
  color: inherit;
  text-decoration: none;
}

.result__title {
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.35;
}

.result__path {
  overflow: hidden;
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result__category {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-note {
  margin: 24px 0 0;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

footer {
  padding: 0 0 44px;
  color: #81786e;
  font-size: 0.8rem;
}

body.viewer-open {
  overflow: hidden;
}

.viewer[hidden] {
  display: none;
}

.viewer {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(7 6 5 / 82%);
  backdrop-filter: blur(8px);
}

.viewer__panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1500px, 100%);
  height: min(94vh, 1050px);
  overflow: hidden;
  border: 1px solid #756348;
  border-radius: 14px;
  background: #171512;
  box-shadow: 0 26px 90px rgb(0 0 0 / 65%);
}

.viewer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 15px 13px 18px;
  border-bottom: 1px solid var(--border);
  background: #211e1a;
}

.viewer__heading {
  min-width: 0;
}

.viewer__heading > span {
  color: var(--gold);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.viewer__heading h2 {
  overflow: hidden;
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.viewer__actions a,
.viewer__actions button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #685b4a;
  border-radius: 8px;
  color: var(--text);
  background: #161411;
  font: inherit;
  font-size: 0.8rem;
  line-height: 36px;
  text-decoration: none;
  cursor: pointer;
}

.viewer__actions button {
  color: #18130d;
  background: var(--gold-bright);
  font-weight: 750;
  line-height: normal;
}

#viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 700px) {
  .masthead__inner {
    padding: 38px 0 34px;
  }

  main {
    padding-top: 20px;
  }

  .search-panel {
    top: 8px;
    padding: 15px;
  }

  .controls,
  .results {
    grid-template-columns: 1fr;
  }

  .results {
    gap: 9px;
  }

  .viewer {
    padding: 0;
  }

  .viewer__panel {
    width: 100%;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .viewer__header {
    align-items: flex-start;
    padding: 11px 10px 11px 13px;
  }

  .viewer__actions a {
    display: none;
  }
}
