:root {
  --paper: #eee6d5;
  --paper-fallback: #eee6d5;
  --ink: rgba(31, 30, 28, 0.82);
  --ink-soft: #847c75;

  --font-display: "Playfair", serif;
  --font-ui: "Zalando Sans SemiExpanded", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;

  --tile-size: 320px;
  --print-filter: url(#printOffsetFilter);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --app-vw: 100vw;
  --app-vh: 100vh;

  --sources-page-width: 780px;

  --top-ui-top: calc(22px + var(--safe-top));
  --top-ui-side: calc(22px + var(--safe-left));
  --top-ui-side-right: calc(22px + var(--safe-right));

  --bottom-ui-bottom: calc(24px + var(--safe-bottom));
  --bottom-ui-side-left: calc(22px + var(--safe-left));
  --bottom-ui-side-right: calc(22px + var(--safe-right));

  --scroll-top-clearance: calc(118px + var(--safe-top));
  --scroll-bottom-clearance: calc(88px + var(--safe-bottom));
}

#global-print-filter-svg {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  overflow: hidden;
}

html {
  -webkit-text-size-adjust: 100%;
}

html.app-is-loading body {
  overflow: hidden;
}

html.app-is-loading #app {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

html.app-is-ready #app {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--paper-fallback);
  color: var(--ink);
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
}

button,
a {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
}

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

i,
em {
  font-style: italic;
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: var(--app-vw);
  min-width: 100vw;
  height: 100vh;
  height: var(--app-vh);
  overflow: hidden;
  background: var(--paper-fallback);
  filter: sepia(0.12) saturate(1.04) hue-rotate(-4deg) brightness(1.005);
}

#app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--paper-fallback);
}

#top-ui,
#top-ui *,
#bottom-ui,
#bottom-ui *,
.sources-shell,
.sources-shell * {
  filter: var(--print-filter);
}

#top-ui {
  position: absolute;
  top: var(--top-ui-top);
  left: var(--top-ui-side);
  right: var(--top-ui-side-right);
  z-index: 140;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: start;
  gap: 16px;
  pointer-events: none;
}

#reloadProject {
  pointer-events: auto;
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 1.7vw, 1.9rem);
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  justify-self: start;
  min-width: 0;
  max-width: 100%;
}

#otherProjectsLink {
  pointer-events: auto;
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  justify-self: end;
  min-width: 0;
  max-width: 220px;
}

#reloadProject:hover,
#otherProjectsLink:hover {
  opacity: 0.6;
}

#sourcesScroll {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#sourcesWorld {
  position: relative;
  min-height: 100%;
  padding-top: var(--scroll-top-clearance);
  padding-right: calc(22px + var(--safe-right));
  padding-bottom: var(--scroll-bottom-clearance);
  padding-left: calc(22px + var(--safe-left));
  isolation: isolate;
  overflow: hidden;
}

#paper-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.035), rgba(0,0,0,0.018)),
    linear-gradient(45deg, rgba(255,255,255,0.04), rgba(0,0,0,0.02)),
    url("assets/background/paper-texture2.jpg");
  background-repeat: repeat, repeat, repeat;
  background-size:
    100% 100%,
    100% 100%,
    var(--tile-size) var(--tile-size);
  background-position:
    center center,
    center center,
    0 0;
  opacity: 0.98;
}

#paper-background::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background:
    radial-gradient(circle at 20% 25%, rgba(255,255,255,0.22) 0 1px, transparent 2px),
    radial-gradient(circle at 68% 58%, rgba(0,0,0,0.05) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 78%, rgba(255,255,255,0.12) 0 1px, transparent 2px);
  background-size: 180px 180px, 240px 240px, 160px 160px;
  mix-blend-mode: multiply;
}

.sources-shell {
  position: relative;
  z-index: 1;
  width: min(var(--sources-page-width), 100%);
  margin: 0 auto;
}

.sources-eyebrow {
  margin: 0 0 18px 0;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: clamp(0.82rem, 0.95vw, 0.98rem);
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.sources-title {
  margin: 0 0 34px 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 0.95;
  font-size: clamp(2.8rem, 4.6vw, 5.2rem);
  text-shadow:
    0.015em 0 rgba(95, 89, 84, 0.18),
    -0.015em 0 rgba(95, 89, 84, 0.1),
    0 0.02em rgba(95, 89, 84, 0.08);
}

.sources-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sources-list li {
  margin: 0 0 18px 0;
  padding: 0 0 18px 0;
  border-bottom: 1px solid rgba(31, 30, 28, 0.12);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.62;
  color: var(--ink);
}

.sources-list li:last-child {
  margin-bottom: 0;
}

.sources-list a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
  word-break: break-word;
}

#bottom-ui {
  position: absolute;
  left: var(--bottom-ui-side-left);
  right: var(--bottom-ui-side-right);
  bottom: var(--bottom-ui-bottom);
  z-index: 145;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 20px;
  pointer-events: none;
}

.side-link {
  pointer-events: auto;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--ink);
  transition: opacity 0.2s ease;
  min-width: 0;
}

.side-link:hover {
  opacity: 0.6;
}

.side-link-left {
  justify-self: start;
}

.side-link-right {
  justify-self: end;
}

.side-link.is-active {
  opacity: 0.62;
  pointer-events: none;
}

.bottom-center-spacer {
  width: min(840px, 62vw);
  height: 1px;
  justify-self: center;
  background: transparent;
}

@media (max-width: 1100px) {
  .sources-shell {
    width: min(760px, 100%);
  }

  .bottom-center-spacer {
    width: min(680px, 58vw);
  }
}

@media (max-width: 820px) {
  :root {
    --scroll-top-clearance: calc(102px + var(--safe-top));
    --scroll-bottom-clearance: calc(78px + var(--safe-bottom));
  }

  #sourcesWorld {
    padding-right: calc(14px + var(--safe-right));
    padding-left: calc(14px + var(--safe-left));
  }

  .sources-title {
    margin-bottom: 24px;
    font-size: clamp(2.2rem, 8vw, 3.8rem);
  }

  .sources-list li {
    font-size: 0.94rem;
    line-height: 1.56;
    padding-bottom: 14px;
    margin-bottom: 14px;
  }

  .side-link {
    font-size: 0.82rem;
  }
}

@media (max-width: 820px) and (orientation: portrait) {
  :root {
    --top-ui-top: calc(14px + var(--safe-top));
    --top-ui-side: calc(14px + var(--safe-left));
    --top-ui-side-right: calc(14px + var(--safe-right));

    --bottom-ui-bottom: calc(14px + var(--safe-bottom));
    --bottom-ui-side-left: calc(14px + var(--safe-left));
    --bottom-ui-side-right: calc(14px + var(--safe-right));

    --scroll-top-clearance: calc(98px + var(--safe-top));
    --scroll-bottom-clearance: calc(70px + var(--safe-bottom));
  }

  #top-ui {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 98px);
  }

  #reloadProject {
    font-size: clamp(1.3rem, 1.7vw, 1.9rem);
    line-height: 1;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
  }

  #otherProjectsLink {
    font-size: 0.86rem;
    line-height: 1.05;
    max-width: 98px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: right;
    min-width: 0;
  }

  #bottom-ui {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "left right";
    gap: 10px 12px;
  }

  .side-link-left {
    grid-area: left;
    justify-self: start;
  }

  .side-link-right {
    grid-area: right;
    justify-self: end;
  }

  .bottom-center-spacer {
    display: none;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  :root {
    --top-ui-top: calc(8px + var(--safe-top));
    --top-ui-side: calc(10px + var(--safe-left));
    --top-ui-side-right: calc(10px + var(--safe-right));

    --bottom-ui-bottom: calc(8px + var(--safe-bottom));
    --bottom-ui-side-left: calc(10px + var(--safe-left));
    --bottom-ui-side-right: calc(10px + var(--safe-right));

    --scroll-top-clearance: calc(82px + var(--safe-top));
    --scroll-bottom-clearance: calc(54px + var(--safe-bottom));
  }

  #sourcesWorld {
    padding-right: calc(18px + var(--safe-right));
    padding-left: calc(18px + var(--safe-left));
  }

  #top-ui {
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 150px);
  }

  #reloadProject {
    font-size: clamp(1.3rem, 1.7vw, 1.9rem);
    line-height: 1;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
  }

  #otherProjectsLink {
    display: block;
    font-size: 0.8rem;
    line-height: 1.05;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 150px;
    min-width: 0;
  }

  #bottom-ui {
    gap: 12px;
  }

  .bottom-center-spacer {
    width: min(560px, 56vw);
  }

  .side-link {
    font-size: 0.68rem;
  }

  .sources-title {
    font-size: clamp(2rem, 5vw, 3rem);
  }

  .sources-list li {
    font-size: 0.88rem;
    line-height: 1.48;
  }
}

@media (max-width: 560px) {
  #sourcesWorld {
    padding-right: calc(12px + var(--safe-right));
    padding-left: calc(12px + var(--safe-left));
  }

  .sources-title {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .sources-eyebrow {
    font-size: 0.74rem;
  }

  .sources-list li {
    font-size: 0.9rem;
  }
}

@media (pointer: coarse) {
  .side-link:hover,
  #reloadProject:hover,
  #otherProjectsLink:hover {
    opacity: 1;
  }
}