:root {
  --ink: #14110e;
  --ink-soft: #2a241c;
  --paper: #f4efe6;
  --paper-2: #fbf7f0;
  --cream: #f7f1e6;
  --brass: #b08948;
  --brass-deep: #8c6830;
  --moss: #24362f;
  --muted: #5e564c;
  --line: #e3d6c4;
  --danger: #8a3d32;
  --serif: "Fraunces", "Palatino Linotype", Palatino, Georgia, serif;
  --reader: "Newsreader", "Iowan Old Style", Palatino, Georgia, serif;
  --shadow: 0 30px 70px rgba(20, 17, 14, 0.28);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 700px at 10% -10%, #2a241c 0%, transparent 55%),
    var(--ink);
  color: var(--ink);
  font-family: var(--serif);
}

button, input, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 0;
  background: var(--ink);
  color: var(--cream);
  border-radius: 999px;
  padding: 12px 18px;
}

button.quiet {
  background: transparent;
  color: var(--brass);
  padding: 8px 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brass-deep);
  font-family: var(--reader);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede, .status, .preamble, .notice {
  color: var(--muted);
  font-family: var(--reader);
  font-size: 16px;
  line-height: 1.5;
}

.error { color: var(--danger); min-height: 1.2em; font-family: var(--reader); }

.seal {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(176, 137, 72, 0.45);
}

.seal-small { width: 72px; height: 72px; }

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.gate-card {
  width: 100%;
  max-width: 440px;
  background: var(--paper-2);
  border-radius: 28px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  display: grid;
  justify-items: start;
  gap: 8px;
}

.gate-card h1, .sheet h1, .passage h2, .shelf-head h2 {
  margin: 0;
  font-weight: 560;
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.gate-card label {
  margin-top: 14px;
  font-family: var(--reader);
  font-size: 14px;
  color: var(--muted);
}

.gate-card input, #shelf-query, textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 0 12px;
  outline: none;
}

.gate-card input:focus, #shelf-query:focus, textarea:focus {
  border-bottom-color: var(--brass);
}

.room {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) minmax(280px, 380px);
}

.rail {
  padding: 28px 22px;
  color: #f6f1e8;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.brand {
  margin: 0;
  font-size: 28px;
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.brand-sub {
  margin: 8px 0 0;
  color: var(--brass);
  font-family: var(--reader);
  font-size: 14px;
}

.rail button { background: #f6f1e8; color: var(--ink); }
.rail button.quiet { background: transparent; color: var(--brass); margin-top: auto; }

.sheet, .passage {
  background: var(--paper);
  margin: 18px 18px 18px 0;
  border-radius: 28px;
  padding: 36px 40px 28px;
}

.passage {
  background: var(--paper-2);
  margin-left: 0;
  overflow: auto;
}

.sheet h1 { max-width: 12ch; margin-bottom: 22px; }

textarea {
  font-family: var(--reader);
  font-size: 22px;
  line-height: 1.45;
  resize: vertical;
  min-height: 92px;
}

.ask-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.status { margin: 0; }

.overview {
  margin-top: 28px;
  max-width: 68ch;
}

.overview p {
  font-family: var(--reader);
  font-size: 21px;
  line-height: 1.55;
  margin: 0 0 16px;
}

.preamble { max-width: 68ch; }

.cites {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 8px 0 18px;
}

.cites button {
  background: transparent;
  color: var(--brass-deep);
  border-radius: 0;
  padding: 0;
  text-align: left;
  font-family: var(--reader);
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.notice {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 14px;
  max-width: 70ch;
}

.passage h2 {
  font-size: 32px;
  margin-bottom: 8px;
}

#passage-page {
  width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 12px 0;
  background: white;
}

.passage-text {
  font-family: var(--reader);
  font-size: 17px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.shelf {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 14, 0.46);
  display: grid;
  place-items: center;
  padding: 24px;
}

.shelf-card {
  width: min(720px, 100%);
  max-height: min(80vh, 760px);
  overflow: auto;
  background: var(--paper-2);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.shelf-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.shelf-head h2 { font-size: 42px; }

#shelf-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

#shelf-list li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-family: var(--reader);
}

#shelf-list strong { font-family: var(--serif); font-weight: 560; display: block; }
#shelf-list span { color: var(--muted); font-size: 14px; }

@media (max-width: 640px) {
  .gate { padding: 24px 16px; }
  .gate-card { padding: 28px 22px 24px; }
  .gate-card h1 { font-size: 34px; }
}

@media (max-width: 960px) {
  .room {
    grid-template-columns: 1fr;
    padding-bottom: 24px;
  }
  .rail {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 16px;
  }
  .brand { font-size: 22px; }
  .rail button.quiet { margin-top: 0; }
  .sheet, .passage {
    margin: 0 12px 12px;
    padding: 24px 18px;
    border-radius: 22px;
  }
  .overview p { font-size: 19px; }
}
