/* Night Almanac. The only live theme.
   html[data-theme="almanac"] is set in the markup.
   Midnight Herbarium and Apothecary live in design/themes-archive/.
   The page is always bone paper and charcoal ink. prefers-color-scheme is
   not consulted. A force-dark pass that adds .is-force-dark is inverted
   at the end so the rendered page stays light. */

:root {
  color-scheme: only light;
}

html[data-theme="almanac"] {
  --sanctum: #1a1916;
  --sanctum-2: #242320;
  --sanctum-3: #2e2c28;
  --linen: #f6f1e6;
  --linen-2: #efe8d6;
  --linen-3: #e4dcc8;
  --surface: #f6f1e6;
  --ink: #1c1a16;
  --ink-2: #3a362e;
  --ink-3: #4a453c;
  --ink-4: #5c564c;
  --linen-ink: #1c1a16;
  --linen-dim: #4a453c;
  --copper: #1c1a16;
  --copper-deep: #1c1a16;
  --rust: #1c1a16;
  --auburn: #3a362e;
  --gold-spare: #1c1a16;
  --line: #8a8172;
  --line-2: #6e675c;
  --line-dark: #1c1a16;
  --accent-soft: #efe8d6;
  --accent-softer: #f6f1e6;
  --field: #fffaf1;
  --field-hover: #efe8d6;
  --sheet-line: #1c1a16;
  --danger: #7a2e1c;
  --focus: #1c1a16;
  --mast: #1a1916;
  --mast-ink: #f6f1e6;
  --mast-dim: #d4cbb8;
  --bg-deep: #f6f1e6;
  --bg-mid: #f6f1e6;
  --bg-card: #f6f1e6;
  --bg-card-solid: #f6f1e6;
  --font-display: "EB Garamond", Georgia, serif;
  --font-sans: "EB Garamond", Georgia, serif;
  --font-serif: "EB Garamond", Georgia, serif;
  --fiber: none;
  --plate-radius: 16px;
  color-scheme: only light;
  background: #1a1916 !important;
  color: #f6f1e6;
}
html[data-theme="almanac"] body {
  background: #f6f1e6 !important;
  background-image: none !important;
  color: #1c1a16 !important;
}
html[data-theme="almanac"] img,
html[data-theme="almanac"] svg,
html[data-theme="almanac"] video,
html[data-theme="almanac"] canvas {
  color-scheme: only light;
}

html[data-theme] :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
html[data-theme="almanac"] :focus-visible {
  outline: 2px solid #f6f1e6;
  box-shadow: 0 0 0 4px #1c1a16;
}

/* ---- type ---- */
html[data-theme] .hero-wordmark,
html[data-theme] .folio-title,
html[data-theme] .folio-name,
html[data-theme] .folio-card .offer-title,
html[data-theme] .site-word,
html[data-theme] .legal h1,
html[data-theme] .order-page h1,
html[data-theme] .sheet h1,
html[data-theme] .miss-card h1 {
  font-family: var(--font-display) !important;
}
html[data-theme] .hero-tagline,
html[data-theme] .mast-tag,
html[data-theme] .folio-lead,
html[data-theme] .folio-frame .offerings-lead,
html[data-theme] .folio-blurb,
html[data-theme] .folio-card .offer-desc {
  font-family: var(--font-serif) !important;
}

/* ---- frontispiece masthead ---- */
.site-mast {
  position: static;
  display: flex;
  flex-direction: column;
  align-items: center;
  --mast-gutter: 1.5rem;
  padding: calc(0.95rem + env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px) 0.35rem env(safe-area-inset-left, 0px);
  max-width: none;
}
.mast-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: center;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  padding: 0 var(--mast-gutter, 1.5rem);
}
.mast-heading {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: normal;
  text-transform: none;
}
.mast-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  text-align: center;
}
.mast-mark {
  display: block;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--mark-on-dark, #d4bc84);
}
.mast-titles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  min-width: 0;
  max-width: 36rem;
}
.site-word {
  margin: 0;
  display: block;
  padding-left: 0.32em;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: clamp(0.92rem, 0.78rem + 0.7vw, 1.05rem);
  font-weight: 500;
  line-height: 1.2;
}
.mast-tag {
  display: block;
  font-style: italic;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.4;
  opacity: 0.78;
}
.mast-rule {
  display: block;
  width: 7.5rem;
  height: 0;
  margin: 0.45rem 0 0.05rem;
  border: 0;
  border-top: 1px solid currentColor;
  opacity: 0.45;
  pointer-events: none;
}
.mast-band {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0.7rem 0 0.2rem;
  overflow: hidden;
  line-height: 0;
  align-self: stretch;
  color: var(--mark-on-dark, #d4bc84);
  pointer-events: none;
}
.mast-band .mark-engraving {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 960 / 124;
}
.skip-link {
  position: fixed;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 80;
  transform: translateY(-200%);
  background: #1a1916;
  color: #f6f1e6;
  padding: 0.65rem 1rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  border: 2px solid #f6f1e6;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
}
.mast-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-width: 0;
}
.ctrl-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a1916;
}
h2.card-title {
  margin-top: 0;
  font-size: 0.82rem;
  font-weight: 400;
}
.chart-figure { margin: 0; }
.chart-summary {
  margin: 12px 0 0;
  font-family: var(--font-serif, "EB Garamond", Georgia, serif);
  font-size: 1rem;
  line-height: 1.5;
  color: #1a1916;
}
.syn-hint {
  margin: 0.75rem 0 0.35rem;
  font-size: 1rem;
  line-height: 1.45;
  color: #1a1916;
}
html[data-theme="almanac"] .footer-legal a {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 24px;
  padding: 2px 0;
}
.mast-nav,
.site-links {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.mast-nav::-webkit-scrollbar,
.site-links::-webkit-scrollbar { display: none; }
.site-links a,
.site-mast .nav-btn {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.6rem;
  text-decoration: none;
  letter-spacing: 0.16em;
  font-variant-caps: all-small-caps;
  text-transform: none;
  font-size: 0.92rem;
  line-height: 1.2;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.site-links a[aria-current="page"],
.site-mast .nav-btn.active {
  box-shadow: inset 0 -2px 0 currentColor;
}

html[data-theme] .mast-heading {
  margin: 0 !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  line-height: inherit !important;
}
html[data-theme] .site-mast .nav-btn {
  font-family: var(--font-serif) !important;
  color: inherit !important;
  background: transparent !important;
  border: 0 !important;
  min-height: 48px !important;
  min-width: 48px !important;
  padding: 0 0.55rem !important;
  letter-spacing: 0.16em !important;
  font-variant-caps: all-small-caps !important;
  text-transform: none !important;
  font-size: 0.92rem !important;
  box-shadow: none !important;
}
html[data-theme] .site-mast .nav-btn.active {
  color: inherit !important;
  background: transparent !important;
  box-shadow: inset 0 -2px 0 currentColor !important;
}
html[data-theme] .site-mast .nav-btn.active::after,
html[data-theme] .site-mast .nav-btn::after {
  content: none !important;
  display: none !important;
}
html[data-theme="almanac"] .site-mast {
  background: #1a1916;
  color: #f6f1e6;
  border-bottom: 1px solid rgba(246, 241, 230, 0.22);
}
html[data-theme="almanac"] .site-word,
html[data-theme="almanac"] .site-links a,
html[data-theme="almanac"] .site-mast .nav-btn { color: #f6f1e6; }
html[data-theme="almanac"] .site-links a:hover,
html[data-theme="almanac"] .site-mast .nav-btn:hover { color: #d4cbb8 !important; }

html[data-theme="almanac"] .hero-word::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 0.7rem;
  margin: 0.45rem auto 0;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 12'%3E%3Cpath d='M36 1.2l1.1 3.2h3.4l-2.7 2 1 3.2L36 7.6l-2.8 2 1-3.2-2.7-2h3.4z' fill='none' stroke='%23d4cbb8' stroke-width='0.8'/%3E%3Cpath d='M8 6h16M48 6h16' stroke='%23d4cbb8' stroke-width='0.6'/%3E%3C/svg%3E");
}

@media (max-width: 1040px) {
.site-mast {
    --mast-gutter: 0.85rem;
    align-items: stretch;
    padding: calc(0.8rem + env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px) 0.25rem env(safe-area-inset-left, 0px);
  }
  .mast-band { margin: 0.45rem 0 0.1rem; }
  .mast-identity { align-self: center; }
  .mast-titles { max-width: none; }
  .site-word { letter-spacing: 0.22em; padding-left: 0.22em; }
  .mast-tag {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mast-nav,
  .site-links {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Legal pages pad the body for the notebook sheet. The frontispiece
   spans the viewport, so that padding stays off when the mast is present. */
body.legal-body:has(.site-mast) {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}
html[data-theme="almanac"] .hero,
html[data-theme="almanac"] .hero-word {
  --parchment-night: #1a1916;
  --ink-night: #f6f1e6;
  --ink-muted-night: #d4cbb8;
  background: #1a1916 !important;
  color: #f6f1e6 !important;
}
html[data-theme] .hero-wordmark { color: var(--ink-night) !important; }
html[data-theme] .hero-tagline { color: var(--ink-muted-night) !important; }
html[data-theme="almanac"] .nav {
  background: #1a1916 !important;
  border-bottom-color: rgba(246, 241, 230, 0.35) !important;
}
html[data-theme="almanac"] .nav-btn { color: #d4cbb8 !important; }
html[data-theme="almanac"] .nav-btn:hover,
html[data-theme="almanac"] .nav-btn.active { color: #f6f1e6 !important; }
html[data-theme="almanac"] .nav-btn.active::after { background: #f6f1e6 !important; }
html[data-theme="almanac"] .controls {
  background: #f6f1e6 !important;
  color: #1a1916 !important;
  border-bottom: 1px solid #1a1916 !important;
}
html[data-theme="almanac"] .moon-phase-indicator,
html[data-theme="almanac"] .zoom-level { color: #1a1916 !important; }

html[data-theme] .header { background: transparent !important; }

/* ---- cards, folio, legal, fields ---- */
html[data-theme] .card {
  border-color: var(--sheet-line) !important;
  box-shadow: inset 5px 0 0 var(--copper-deep), 0 10px 28px rgba(8, 10, 8, 0.28) !important;
}
html[data-theme="almanac"] .card {
  border: 1px solid #1c1a16 !important;
  box-shadow: none !important;
  background-image: none !important;
}
html[data-theme] .legal,
html[data-theme] .miss-card,
html[data-theme] .sheet {
  border-color: var(--sheet-line) !important;
}
html[data-theme="almanac"] .legal,
html[data-theme="almanac"] .miss-card,
html[data-theme="almanac"] .sheet {
  border: 1px solid #1c1a16 !important;
  box-shadow: none !important;
  background-image: none !important;
}
html[data-theme="almanac"] .folio-frame {
  --folio-parchment: #f6f1e6;
  --folio-linen: #1c1a16;
  --folio-ink: #1c1a16;
  --folio-ink-muted: #4a453c;
  --folio-cinnabar: #1c1a16;
  --folio-ember: #3a362e;
  --folio-hairline: rgba(28, 26, 22, 0.55);
  background-image: none;
  box-shadow: none;
}
html[data-theme="almanac"] .folio-card,
html[data-theme="almanac"] .folio-frame .offer-card {
  background: #efe8d6;
  box-shadow: none !important;
}
html[data-theme="almanac"] .folio-card.is-live { background: #f6f1e6; }
html[data-theme="almanac"] .folio-card.is-soon { background: #e7e0d0; }

html[data-theme] .order-page .err { color: var(--danger) !important; }
html[data-theme] .brand-seal img,
html[data-theme] .miss-earth img { box-shadow: 0 0 0 1px var(--sheet-line); }
html[data-theme="almanac"] .reading-page .brand-seal,
html[data-theme="almanac"] .order-page .brand-seal,
html[data-theme] .legal .brand-seal,
html[data-theme] .miss-card .brand-seal {
  color: var(--mark-on-light);
}

body.legal-body { padding-top: 0; }
.legal { margin-top: 1.25rem; }

.sheet {
  width: min(52rem, calc(100% - 2rem));
  margin: 1.25rem auto 2rem;
  padding: 1.4rem 1.25rem 1.7rem;
  background: var(--surface);
  background-image: var(--fiber);
  color: var(--ink);
  border: 1px solid var(--sheet-line);
  box-shadow: inset 5px 0 0 var(--copper-deep);
  overflow: auto;
}
.sheet .kicker {
  font-family: var(--font-serif);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-3);
  margin: 0 0 0.6rem;
}
.sheet h1 {
  font-weight: 500;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.03em;
  margin: 0 0 0.9rem;
  color: var(--ink);
}
.sheet p, .sheet li {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 0.85rem;
}
.sheet a { color: var(--copper-deep); text-underline-offset: 0.15em; }
.sheet h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--ink);
  margin: 1.2rem 0 0.4rem;
}

.plate {
  margin: 0;
  padding: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--copper-deep);
  border-radius: var(--plate-radius);
  overflow: hidden;
}
html[data-theme="almanac"] .plate {
  border: 1px solid #1c1a16;
  box-shadow: none;
  background: #f6f1e6;
}
.plate img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--plate-radius);
  image-rendering: auto;
  image-rendering: high-quality;
}
.plate figcaption {
  margin-top: 0.45rem;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--ink-3);
}
.sheet .plate {
  float: right;
  width: min(16rem, 42%);
  margin: 0 0 1rem 1.25rem;
}
.reports-plate {
  width: min(16rem, 100%);
  margin: 1.6rem auto 0;
}
.miss-plate {
  width: min(9rem, 70%);
  margin: 0.85rem auto 0;
}

@media (max-width: 700px) {
.sheet .plate {
    float: none;
    width: min(18rem, 100%);
    margin: 0 auto 1.15rem;
  }
}

.reading-plate {
  width: min(16rem, 100%);
  margin: 1.4rem auto 0;
}

/* Plates stay fully opaque and in normal flow. The hero frame is a
   mounted specimen, not a background wash. */
html[data-theme] .hero {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  overflow: visible !important;
  padding: 0.85rem clamp(0.75rem, 2.4vw, 1.8rem) 1rem;
}
html[data-theme] .hero-word {
  flex: 1 1 16rem;
  min-width: 0;
}
html[data-theme] .hero-tagline {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
.hero-plate {
  flex: 0 1 18rem;
  width: min(18rem, 100%);
  margin: 0;
  padding: 0.45rem;
  background: #f4ecd9;
  opacity: 1;
}
.hero-plate img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 26rem;
  object-fit: contain;
  object-position: center center;
  opacity: 1;
}
html[data-theme="almanac"] .hero-plate {
  border: 1px solid #1c1a16;
  background: #f6f1e6;
  box-shadow: none;
}
.folio-accent {
  width: min(8.5rem, 100%);
  margin: 0 auto 0.85rem;
  padding: 0.35rem;
  opacity: 1;
  color: var(--mark-on-light);
}
.folio-accent .herb-mark {
  display: block;
  width: 100%;
  height: 15rem;
  max-height: 15rem;
  object-fit: contain;
  object-position: center center;
  shape-rendering: geometricPrecision;
}
.reading-hero-plate {
  width: min(12rem, 70%);
  margin: 0.15rem auto 1.1rem;
  padding: 0.4rem;
  opacity: 1;
}
.reading-hero-plate img {
  display: block;
  width: 100%;
  height: 16rem;
  object-fit: contain;
  object-position: center center;
  opacity: 1;
}
.plate-ink {
  display: block;
  position: relative;
  color-scheme: only light;
}
/* Engraving ink is masked block text in charcoal, so the line stays
   dark on bone paper. color-scheme: only light asks the browser not to
   recolor the mask. */
@supports ((-webkit-mask-image: none) or (mask-image: none)) {
  .plate-ink::before {
    content: "████████████████████████████████████████████████";
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    color: #1c1a16;
    font: 900 7rem/0.7 sans-serif;
    letter-spacing: -0.15em;
    word-break: break-all;
    pointer-events: none;
    -webkit-mask-image: var(--engraving);
    mask-image: var(--engraving);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center center;
    mask-position: center center;
    -webkit-mask-size: contain;
    mask-size: contain;
    mask-mode: alpha;
  }
  .plate-ink img {
    visibility: hidden;
  }
}

@media (max-width: 720px) {
html[data-theme] .hero { justify-content: center; }
  .hero-plate { flex-basis: min(16rem, 86%); }
  .reading-hero-plate { width: min(11rem, 78%); }
}
html[data-theme="almanac"] {
  --mark-on-dark: #f6f1e6;
  --mark-on-light: #1c1a16;
}
html[data-theme="almanac"] .wp { background: #1a1916 !important; }
html[data-theme] .wp-ink { color: var(--mark-on-dark); }
html[data-theme="almanac"] .kit-band {
  color: var(--mark-on-light);
}
html[data-theme="almanac"] .footer-mark,
html[data-theme="almanac"] .footer-earth {
  color: var(--mark-on-light);
}
html[data-theme] .folio-flourish,
html[data-theme] svg.ornament {
  color: var(--mark-on-light);
}
html[data-theme] svg.ornament {
  box-shadow: none;
  background: transparent;
  border-radius: 0;
}

html[data-theme] .reading-page .site-nav,
html[data-theme] .reading-body p,
html[data-theme] .reading-body li,
html[data-theme] .reading-lead,
html[data-theme] .reading-date,
html[data-theme] .reading-note,
html[data-theme] .reading-group-lead,
html[data-theme] .reading-card p,
html[data-theme] .reading-related a,
html[data-theme] .reports-page .reports-nav {
  font-family: var(--font-serif) !important;
}
html[data-theme] .reading-sheet h1,
html[data-theme] .reading-body h2,
html[data-theme] .reading-group h2,
html[data-theme] .reading-card h2,
html[data-theme] .reading-card h3 {
  font-family: var(--font-display) !important;
}
html[data-theme] .reading-sheet,
html[data-theme] .reading-card,
html[data-theme] .reading-cta,
html[data-theme] .reading-related {
  border-color: var(--sheet-line) !important;
}
html[data-theme] .reading-card,
html[data-theme] .reading-cta {
  background: var(--surface) !important;
}
html[data-theme] .reading-cta-link {
  color: var(--linen) !important;
}
html[data-theme="almanac"] .reading-sheet,
html[data-theme="almanac"] .reading-card,
html[data-theme="almanac"] .reading-cta {
  border: 1px solid #1c1a16 !important;
  box-shadow: none !important;
  background-image: none !important;
}
html[data-theme="almanac"] .reading-page .site-nav a,
html[data-theme="almanac"] .reports-page .reports-nav a {
  color: #4a453c !important;
}
html[data-theme="almanac"] .reading-page .site-nav a[aria-current="page"],
html[data-theme="almanac"] .reports-page .reports-nav a[aria-current="page"],
html[data-theme="almanac"] .reading-page .site-nav a:hover,
html[data-theme="almanac"] .reports-page .reports-nav a:hover {
  color: #1c1a16 !important;
}

html[data-theme="almanac"] .reading-sheet h1,
html[data-theme="almanac"] .legal h1,
html[data-theme="almanac"] .order-page h1 {
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem);
}

/* Tables scroll inside their own frame. The page itself does not. */
#aspectGridWrap,
.eph-table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.eph-table,
.aspect-grid-table {
  width: max-content;
  min-width: 100%;
}
.aspect-grid-table { min-width: 36rem; }
.dashboard-grid,
.card,
.content,
.view-panel { min-width: 0; max-width: 100%; }

.mast-burger,
.mast-cta,
.order-dock { display: none; }
.mast-burger {
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 48px;
  min-height: 48px;
  padding: 0 0.75rem;
  border: 1px solid rgba(246, 241, 230, 0.4);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.mast-burger-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 18px;
}
.mast-burger-bars span {
  display: block;
  height: 1.5px;
  background: currentColor;
}
.mast-cta,
.order-dock {
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  padding: 0.75rem 1rem;
  text-decoration: none;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  background: #f6f1e6;
  color: #1a1916;
  border: 1px solid #f6f1e6;
}
span.mast-cta,
span.order-dock {
  cursor: default;
  pointer-events: none;
}
body.mast-lock { overflow: hidden; }

@media (max-width: 860px), (max-device-width: 860px) {
  .site-mast { position: relative; }
  .mast-identity {
    padding-left: 5.5rem;
    padding-right: 5.5rem;
  }
  .site-word {
    font-size: clamp(0.72rem, 2.8vw, 0.98rem);
    letter-spacing: 0.12em;
    padding-left: 0.12em;
  }
  .mast-burger {
    display: inline-flex;
    position: absolute;
    top: calc(0.45rem + env(safe-area-inset-top, 0px));
    right: calc(0.4rem + env(safe-area-inset-right, 0px));
    z-index: 3;
  }
  .site-mast .mast-nav { display: none; }
  .site-mast.mast-open .mast-nav,
  .site-mast:has(.mast-burger[aria-expanded="true"]) .mast-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    overflow: visible;
    padding: 0.15rem 0 0.75rem;
  }
  .site-mast.mast-open .mast-tabs,
  .site-mast:has(.mast-burger[aria-expanded="true"]) .mast-tabs {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .site-mast.mast-open .site-links a,
  .site-mast:has(.mast-burger[aria-expanded="true"]) .site-links a,
  .site-mast.mast-open .site-mast .nav-btn,
  .site-mast:has(.mast-burger[aria-expanded="true"]) .site-mast .nav-btn,
  html[data-theme] .site-mast.mast-open .nav-btn,
  html[data-theme] .site-mast:has(.mast-burger[aria-expanded="true"]) .nav-btn {
    justify-content: flex-start;
    width: 100%;
    padding-left: 1.1rem !important;
    padding-right: 1.1rem !important;
    letter-spacing: 0.08em !important;
  }
  .site-mast.mast-open .mast-cta,
  .site-mast:has(.mast-burger[aria-expanded="true"]) .mast-cta {
    display: inline-flex;
    margin: 0.45rem 1rem 0.35rem;
    width: calc(100% - 2rem);
  }
  .content {
    padding: 16px max(12px, env(safe-area-inset-right, 0px)) 28px max(12px, env(safe-area-inset-left, 0px));
  }
  .controls {
    padding: 10px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px)) !important;
  }
  .ctrl-btn,
  .ctrl-input,
  .eph-btn,
  .folio-cta,
  .offer-cta,
  .zoom-controls,
  .depth-tab,
  .rpt-tab,
  .fmt-tab {
    min-height: 48px !important;
    min-width: 48px !important;
    font-size: 16px !important;
  }
  .order-page #checkout-submit {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: 100%;
    max-width: none;
    margin: 0;
    min-height: 48px;
    border-radius: 0;
    padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
  }
  body.order-page:has(#checkout-submit),
  body.reports-page:has(.order-dock) {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  }
  .order-dock {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: 100%;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Layout viewport stayed desktop-wide on a handset (Samsung sometimes
   ignores the viewport meta). These sit outside max-width so they still match. */
html[data-narrow] .site-mast { position: relative; }
html[data-narrow] .mast-identity {
  padding-left: 5.5rem;
  padding-right: 5.5rem;
}
html[data-narrow] .mast-burger {
  display: inline-flex;
  position: absolute;
  top: calc(0.45rem + env(safe-area-inset-top, 0px));
  right: calc(0.4rem + env(safe-area-inset-right, 0px));
  z-index: 3;
}
html[data-narrow] .site-mast .mast-nav { display: none; }
html[data-narrow] .site-mast.mast-open .mast-nav,
html[data-narrow] .site-mast:has(.mast-burger[aria-expanded="true"]) .mast-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  overflow: visible;
  padding: 0.15rem 0 0.75rem;
}
html[data-narrow] .site-mast.mast-open .mast-tabs,
html[data-narrow] .site-mast:has(.mast-burger[aria-expanded="true"]) .mast-tabs {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}
html[data-narrow] .site-mast.mast-open .site-links a,
html[data-narrow] .site-mast:has(.mast-burger[aria-expanded="true"]) .site-links a,
html[data-narrow] .site-mast.mast-open .nav-btn,
html[data-narrow] .site-mast:has(.mast-burger[aria-expanded="true"]) .nav-btn {
  justify-content: flex-start;
  width: 100%;
  padding-left: 1.1rem !important;
  padding-right: 1.1rem !important;
  letter-spacing: 0.08em !important;
}
html[data-narrow] .site-mast.mast-open .mast-cta,
html[data-narrow] .site-mast:has(.mast-burger[aria-expanded="true"]) .mast-cta {
  display: inline-flex;
  margin: 0.45rem 1rem 0.35rem;
  width: calc(100% - 2rem);
}
html[data-narrow] .folio-grid,
html[data-narrow] .offer-grid,
html[data-narrow] .dashboard-grid {
  grid-template-columns: 1fr !important;
}
html[data-narrow] body.reports-page:has(.order-dock),
html[data-narrow] body.order-page:has(#checkout-submit) {
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
}
html[data-narrow] .order-dock {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: 100%;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 380px) {
  .site-word {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    padding-left: 0.08em;
  }
  .mast-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .newsletter-star,
  .newsletter-star * {
    animation: none !important;
  }
}


/* Form controls stay on the light Almanac. Native checkboxes and fields
   follow color-scheme, so an OS dark setting must not restyle them.
   The synastry age box is charcoal on bone, same as the other 18+ boxes. */
html[data-theme="almanac"] input,
html[data-theme="almanac"] textarea,
html[data-theme="almanac"] select,
html[data-theme="almanac"] button {
  color-scheme: only light;
}
html[data-theme="almanac"] input[type="checkbox"],
html[data-theme="almanac"] input[type="radio"],
html[data-theme="almanac"] #view-synastry .syn-age input[type="checkbox"] {
  color-scheme: only light;
  accent-color: #1c1a16;
}
html[data-theme="almanac"] #view-synastry .syn-age {
  color: #3a362e;
}

/* Chrome's forced-dark pass can still darken pixels after color-scheme:
   only light. The head probe adds is-force-dark when light-dark() is
   rewritten. Inverting that pass restores a light page (bone-range paper,
   dark ink). It does not run for prefers-color-scheme alone, and it never
   paints a charcoal page. getComputedStyle still reports the authored
   colors under that pass, so this filter is the countermeasure. */
html.is-force-dark {
  filter: invert(1) hue-rotate(180deg);
}
/* The transit wheel is a white disc drawn in SVG. Force-dark leaves that
   paint alone, so the page invert would turn the disc dark. Inverting
   the wheel again puts the light disc back. */
html.is-force-dark #wheelContainer,
html.is-force-dark .wheel-overlay {
  filter: invert(1) hue-rotate(180deg);
}
html.is-force-dark[data-theme="almanac"] input,
html.is-force-dark[data-theme="almanac"] textarea,
html.is-force-dark[data-theme="almanac"] select,
html.is-force-dark[data-theme="almanac"] button,
html.is-force-dark[data-theme="almanac"] #view-synastry .syn-age input[type="checkbox"] {
  color-scheme: only light;
  accent-color: #1c1a16;
}
html.is-force-dark[data-theme="almanac"] #view-synastry .syn-age {
  color: #3a362e;
}
