:root {
  --bg: #f4f1ea;
  --ink: #2b2b2b;
  --shadow: rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a1a;
    --ink: #e8e5df;
    --shadow: rgba(255, 255, 255, 0.2);
  }
}

:root[data-theme="dark"] {
  --bg: #1a1a1a;
  --ink: #e8e5df;
  --shadow: rgba(255, 255, 255, 0.2);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  align-items: safe center;
  justify-content: center;
  padding: 6rem 0 3rem;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
}

body.viewer {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#app {
  max-width: 1000px;
  width: 90%;
  text-align: center;
}

body.viewer #app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#content {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  row-gap: 1.25rem;
  justify-items: center;
  width: 100%;
  max-height: 100%;
}

#frame-wrap {
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#frame {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 4px;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#frame.loaded {
  opacity: 1;
  border: 10px solid var(--ink);
  box-shadow: 0 2px 8px var(--shadow);
}

#caption {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
}

#caption p {
  margin: 0;
}

a {
  color: var(--ink);
}

.noscript-message {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
}

.error-message {
  font-style: italic;
  opacity: 0.75;
}

.site-nav {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
}

.site-nav a {
  display: inline-block;
  padding: 0.85rem;
  font-size: 0.95rem;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.theme-toggle {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  background: none;
  border: none;
  padding: 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid currentColor;
}

.back-link {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  padding: 0.85rem;
  font-size: 0.95rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.back-link.hidden {
  opacity: 0;
  pointer-events: none;
}

#app.page {
  text-align: left;
}

#app.page h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

#app.page p {
  font-size: 1.05rem;
  line-height: 1.6;
}
