/* ==========================================================================
   Northstar Journal — "a naturalist field journal, set in type"
   --------------------------------------------------------------------------
   Art direction: a small literary press for writing from the field.
   Open typographic layout on near-white paper. No card boxes, no shadows
   (except the two genuinely floating surfaces: account menu, auth dialog).
   Signature: the masthead — a folio dateline strip between hairlines,
   circled press mark, Newsreader wordmark, then the Oxford double rule
   (2px over 1px) opening a small-caps section ribbon that carries the
   reader's session at its right end. The double rule is echoed once, at
   the footer, and nowhere else.

   Type   Newsreader (display + article body, optical sizes, italic deks)
          Source Sans 3 (UI chrome, forms, metadata)
   Ochre appears at most twice per page: the selected topic-tab underline
   and the article drop cap.
   ========================================================================== */

:root {
  /* -- color ------------------------------------------------------------- */
  --paper: #FBFAF7;        /* page ground (near-white, not cream)           */
  --paper-deep: #F3F1E8;   /* quiet tinted wells (lock, demo row)           */
  --ink: #1C1E1B;          /* iron ink — 16.1:1 on paper                    */
  --ink-soft: #40453D;     /* deks, article prose accents — 9.4:1           */
  --muted: #5B5F56;        /* metadata, captions — 6.3:1                    */
  --green: #3D5A33;        /* botanical green: links, active, primary — 7.4 */
  --green-deep: #314A28;   /* green hover/pressed — 9.4:1                   */
  --green-wash: #EDF1E9;   /* signed-in tint                                */
  --ochre: #C88A2E;        /* decorative rule only (selected tab underline) */
  --ochre-deep: #96660F;   /* drop cap — 4.79:1 on paper                    */
  --rule: #E5E2D8;         /* hairlines                                     */
  --field: #8F8C7D;        /* form-control borders — >=3:1 on paper/white   */

  /* -- type -------------------------------------------------------------- */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Source Sans Pro", -apple-system, "Segoe UI", sans-serif;
  --caps-ls: 0.14em;       /* small-caps tracking                           */

  /* -- layout ------------------------------------------------------------ */
  --content: 1140px;
  --gutter: clamp(18px, 4vw, 40px);
  --section-gap: clamp(44px, 6vw, 68px);

  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-optical-sizing: auto;
}

/* == base ================================================================= */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

/* anchored sections keep a breath of paper above them after nav jumps */
#home, #latest, #topics, #studio, #articleView { scroll-margin-top: 28px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}

::selection { background: var(--green); color: var(--paper); }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* == shared utilities ===================================================== */

/* section eyebrows — quiet small caps, never numbered */
.overline {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
  color: var(--muted);
}

.status-text {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* -- buttons: quiet rectangles, green primary ----------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 20px;
  border: 1px solid var(--field);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.button:hover { border-color: var(--ink); }

.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
}

.button.primary:hover {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

.button.wide { width: 100%; }

/* text links & text buttons — the only animated thing on the page:
   an underline that grows from the left */
.text-button,
.site-nav a,
.account-trigger,
.story-card > .button {
  border: 0;
  background-color: transparent;
  padding: 2px 1px;
  color: var(--green);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 240ms ease;
}

.text-button:hover,
.text-button:focus-visible,
.site-nav a:hover,
.site-nav a:focus-visible,
.account-trigger:hover,
.account-trigger:focus-visible,
.story-card > .button:hover,
.story-card > .button:focus-visible {
  background-size: 100% 1px;
}

.text-button { min-height: 0; }

/* == masthead ============================================================= */

.site-header {
  padding: 10px var(--gutter) 0;
  background: var(--paper);
}

/* folio strip: the paper's top furniture — dateline left, edition right,
   held between hairlines like a broadsheet teaser bar */
.masthead-folio {
  max-width: var(--content);
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 18px;
  flex-wrap: wrap;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 8px 2px 9px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
}

/* the wordmark block */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  margin: 24px auto 22px;
}

/* press device: circled italic serif N above the wordmark */
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1;
  padding-right: 2px; /* optical centering of the italic N */
  margin-bottom: 12px;
}

.brand-copy strong {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 4.5vw, 2.65rem);
  line-height: 1.05;
  letter-spacing: 0.005em;
}

.brand-copy small {
  display: block;
  margin-top: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* balances the trailing letter-space */
  color: var(--muted);
}

/* section ribbon under the Oxford double rule (2px over 1px):
   sections dead-center, the reader's session quietly at the right end */
.section-ribbon {
  position: relative;
  max-width: var(--content);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 12px 8px 13px;
}

.section-ribbon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ink);
}

.site-nav {
  grid-column: 2;
  display: flex;
  justify-content: center;
  gap: clamp(24px, 5vw, 52px);
}

.site-nav a {
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a:focus-visible { color: var(--green); }

/* the session slot: reader label, a printer's column rule, the trigger */
.ribbon-session {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.session-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  max-width: 200px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ribbon-session .account-control {
  border-left: 1px solid var(--rule);
  padding-left: 12px;
}

.account-trigger {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
  white-space: nowrap;
}

/* -- account menu (floating surface) -------------------------------------- */

.account-control { position: relative; }

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: min(300px, calc(100vw - 32px));
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: 0 14px 40px rgba(28, 30, 27, 0.16);
  padding: 18px;
  text-align: left;
}

.account-menu-inner { display: grid; gap: 14px; }

.account-menu strong,
.account-menu span { display: block; }

.account-menu strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.25;
  margin-top: 2px;
  word-break: break-word;
}

.account-menu span {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.account-menu-inner > div:first-child > span:first-child {
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
  font-size: 0.65rem;
  font-weight: 600;
}

.account-role {
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}

.account-menu-actions { display: grid; gap: 10px; }
.account-menu .button,
.account-menu .text-button { width: 100%; justify-content: center; }
.account-menu .text-button { background-position: 50% 100%; }

/* == main scaffold ======================================================== */

main {
  max-width: calc(var(--content) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-heading h2 {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 6px;
}

/* == front page: hero + lead story ======================================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: clamp(28px, 4vw, 52px);
  padding: clamp(36px, 5.5vw, 60px) 0 clamp(40px, 6vw, 64px);
}

.hero-copy {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 20px;
}

.hero h1 {
  font-size: clamp(2.05rem, 4vw, 2.9rem);
  font-weight: 500;
  line-height: 1.14;
  max-width: 18em;
}

/* standfirst — italic Newsreader dek */
.hero-intro {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 34em;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

/* the lead story: open column behind a single vertical hairline,
   larger headline set with a hanging indent */
.featured-story {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 16px;
  border-left: 1px solid var(--rule);
  padding-left: clamp(28px, 4vw, 52px);
  min-width: 0;
}

.featured-story h2 {
  font-size: clamp(1.55rem, 2.7vw, 2.15rem);
  font-weight: 600;
  line-height: 1.16;
  padding-left: 1.1em;
  text-indent: -1.1em; /* hanging indent on wrapped lines */
}

/* child combinator: injected empty/error states keep their own quiet sans */
.featured-story > p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 56ch;
}

/* == story metadata: small caps line ====================================== */

.story-meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
}

.status-chip { color: var(--green); }

/* == topics: small-caps tab rail ========================================== */

.topic-section { margin-bottom: var(--section-gap); }

.topic-rail {
  display: flex;
  gap: clamp(18px, 3vw, 30px);
  overflow-x: auto;
  border-bottom: 1px solid var(--rule);
  scrollbar-width: none; /* the rail scrolls, but never grows a scrollbar strip */
}

.topic-rail::-webkit-scrollbar { display: none; }

.topic-button {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  padding: 6px 2px 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
  white-space: nowrap;
}

.topic-button:hover { color: var(--green); }

/* each lane carries its shelf count as a serif folio numeral */
.topic-count {
  margin-left: 7px;
  font-family: var(--serif);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  font-variant-numeric: oldstyle-nums;
}

/* ochre use no. 1: the selected tab underline */
.topic-button.active {
  color: var(--green);
  border-bottom-color: var(--ochre);
}

.topic-button.active .topic-count { color: var(--green); }

/* == reading room: rail + feed ============================================ */

.content-grid {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: clamp(36px, 5vw, 64px);
  align-items: start;
  margin-bottom: var(--section-gap);
}

.left-rail {
  position: sticky;
  top: 28px;
  display: grid;
  gap: 40px;
}

.rail-panel { min-width: 0; }

.rail-panel h2 {
  font-size: 1.2rem;
  line-height: 1.25;
  margin-top: 10px;
}

.rail-panel p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-top: 8px;
}

.rail-panel .button { margin-top: 14px; }

/* almanac index: label left, serif figure right, hairline rows */
.publication-stats {
  display: grid;
  margin-top: 12px;
  border-top: 1px solid var(--rule);
}

.stat-box {
  display: flex;
  flex-direction: row-reverse; /* DOM is value-then-label; read label first */
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.stat-box strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1;
}

.stat-box span {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
}

/* membership note */
.onboarding-panel {
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-deep);
  padding: 20px;
}

.onboarding-panel.signed-in {
  background: var(--green-wash);
  border-color: rgba(61, 90, 51, 0.35);
}

/* the feed: open hairline rows, no boxes */
.story-column { min-width: 0; }

.story-feed { display: grid; }

.story-card {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 24px 0 26px;
  border-top: 1px solid var(--rule);
  min-width: 0;
}

.story-card > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.story-card h3 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.22;
}

.story-card p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 62ch;
}

.story-card > .button {
  min-height: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* == loading / empty / error states ======================================= */

.skeleton {
  display: block;
  border-radius: 2px;
  background: var(--rule);
  animation: pulse 1.4s ease-in-out infinite alternate;
}

.skeleton.line { height: 13px; width: 88%; }
.skeleton.short { height: 10px; width: 34%; }
.skeleton.title { height: 34px; width: 72%; }

.loading-card { gap: 14px; }

@keyframes pulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.empty-state,
.error-state {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  padding: 44px 24px;
  width: 100%;
}

/* a quiet press separator instead of a dashed box */
.empty-state::before,
.error-state::before {
  content: "· · ·";
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: var(--green);
}

.error-state::before { color: var(--muted); }

.empty-state h3,
.error-state h3 {
  font-size: 1.3rem;
  line-height: 1.25;
}

.empty-state p,
.error-state p {
  color: var(--muted);
  max-width: 46ch;
  line-height: 1.6;
}

.empty-state .button,
.error-state .button { margin-top: 8px; }

.empty-state.compact { padding: 28px 16px; }

/* feed rows lend their top hairline to states rendered inside them */
#storyFeed > .empty-state,
#storyFeed > .error-state { border-top: 1px solid var(--rule); }

/* == article view: the reading experience ================================= */

.article-view { display: none; }

.article-view.active {
  display: block;
  border-top: 1px solid var(--rule);
  padding-top: clamp(36px, 5vw, 56px);
  margin-bottom: var(--section-gap);
}

.article-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(36px, 5vw, 64px);
  align-items: start;
}

.article-main { min-width: 0; }

.article-main h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  font-weight: 500;
  line-height: 1.12;
  max-width: 24em;
  margin-top: 14px;
}

.article-body {
  margin-top: 26px;
  max-width: 66ch;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-line; /* honor paragraph breaks in stored prose */
  overflow-wrap: anywhere;
}

/* ochre use no. 2: the drop cap, article body only */
.article-body::first-letter {
  float: left;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 3.35em;
  line-height: 0.8;
  padding: 0.07em 0.12em 0 0;
  color: var(--ochre-deep);
}

.article-edit { margin-top: 30px; }

/* -- reader notes --------------------------------------------------------- */

.comment-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.comment-panel h3 {
  font-size: 1.3rem;
  margin-top: 6px;
}

.comment-list { display: grid; }

.comment {
  border-top: 1px solid var(--rule);
  padding: 12px 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.comment-list > .status-text {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}

.comment-form { display: grid; gap: 14px; }
.comment-form textarea { min-height: 120px; }

/* comment sign-in invitation sits flush left in the panel */
.comment-panel .empty-state {
  justify-items: start;
  text-align: left;
  padding: 20px 0 8px;
  border-top: 1px solid var(--rule);
}

/* == author studio ======================================================== */

.studio-section {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(36px, 5vw, 64px);
  align-items: start;
  border-top: 1px solid var(--rule);
  padding-top: clamp(36px, 5vw, 56px);
  margin-bottom: var(--section-gap);
}

.studio-intro h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.7rem);
  font-weight: 500;
  line-height: 1.25;
  margin-top: 10px;
  max-width: 20em;
}

.studio-intro p {
  color: var(--muted);
  line-height: 1.6;
  margin-top: 14px;
  max-width: 44ch;
}

.studio-lock {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-deep);
  padding: clamp(40px, 6vw, 64px) 24px;
}

.studio-lock h3 { font-size: 1.35rem; }

.studio-lock p {
  color: var(--muted);
  line-height: 1.55;
  max-width: 38ch;
}

.studio-lock .button { margin-top: 8px; }

.studio-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: clamp(28px, 4vw, 48px);
  min-width: 0;
}

.writer-card {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.form-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}

.form-topline label { min-width: 150px; }
.editor-actions { display: grid; gap: 12px; justify-items: start; }
.editor-actions .button.wide { justify-self: stretch; }

.studio-queue { min-width: 0; }
.studio-queue h3 { font-size: 1.2rem; }

.studio-queue > p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-top: 8px;
}

.queue-list { display: grid; margin-top: 16px; }

.queue-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--rule);
  padding: 12px 0;
  min-width: 0;
}

.queue-item > div { min-width: 0; }

.queue-item strong {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.queue-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
}

.queue-item .text-button { flex: 0 0 auto; font-size: 0.8rem; }

/* == forms: quiet sans, generous label spacing ============================ */

label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
}

input, textarea, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--field);
  border-radius: 2px;
  background: #FFFFFF;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
}

input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 1; }

input:focus, textarea:focus, select:focus { border-color: var(--green); }

textarea { resize: vertical; line-height: 1.6; }

/* the writing canvas is set in the same face the essay will publish in */
#postContent {
  min-height: 280px;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.65;
}

#commentBody { font-family: var(--serif); font-size: 1rem; }

/* == auth dialog ========================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 30, 27, 0.5);
}

.auth-dialog {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(28, 30, 27, 0.28);
  padding: clamp(22px, 4vw, 30px);
  display: grid;
  gap: 12px;
}

.auth-dialog h2 {
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.15;
}

.auth-dialog > p { color: var(--muted); line-height: 1.55; font-size: 0.92rem; }

.close-button {
  justify-self: end;
  border: 0;
  background: transparent;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.close-button:hover { color: var(--ink); }

.auth-tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--rule);
  margin-top: 4px;
}

.auth-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  padding: 6px 2px 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--caps-ls);
}

.auth-tabs button:hover { color: var(--green); }

.auth-tabs button.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

.auth-form { display: grid; gap: 16px; margin-top: 4px; }

.demo-login {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-deep);
  padding: 12px 14px;
  margin-top: 4px;
}

.demo-login div { display: grid; gap: 3px; min-width: 0; }

.demo-login strong { font-size: 0.8rem; }

.demo-login code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.demo-login .button { min-height: 34px; padding: 5px 14px; font-size: 0.8rem; }

/* == footer: the double rule returns ====================================== */

.site-footer {
  position: relative;
  /* keep the rule flush with the main content column at every width */
  margin: 0 max(var(--gutter), calc((100% - var(--content)) / 2));
  padding: 26px 0 56px;
  border-top: 2px solid var(--ink);
  text-align: center;
}

.site-footer::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ink);
}

.footer-wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
}

.footer-tagline {
  margin-top: 6px;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--muted);
}

/* == responsive =========================================================== */

@media (max-width: 1080px) {
  .content-grid { grid-template-columns: minmax(0, 1fr); }

  /* stories first on small screens; the index and membership note follow */
  .left-rail {
    position: static;
    order: 2;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 36px;
    border-top: 1px solid var(--rule);
    padding-top: 28px;
  }

  .article-shell { grid-template-columns: minmax(0, 1fr); }

  .comment-panel {
    border-top: 1px solid var(--rule);
    padding-top: 24px;
  }

  .studio-section,
  .studio-workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }

  .featured-story {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--rule);
    padding-top: 28px;
  }
}

@media (max-width: 640px) {
  html { scroll-behavior: auto; }

  .site-header { padding-top: 8px; }
  .brand { margin: 20px auto 18px; }
  .session-label { max-width: 150px; }

  /* the ribbon breaks into two decks: sections, then the session slot */
  .section-ribbon { grid-template-columns: 1fr; padding-bottom: 0; }
  .site-nav { grid-column: 1; }

  .ribbon-session {
    grid-column: 1;
    justify-self: stretch;
    justify-content: flex-end;
    border-top: 1px solid var(--rule);
    margin-top: 12px;
    padding: 8px 0 9px;
  }

  .hero { padding-top: 28px; }
  .hero-intro { font-size: 1.08rem; }

  .story-card { padding: 20px 0 22px; }
  .story-card h3 { font-size: 1.25rem; }

  .article-body { font-size: 1.0625rem; }
  .form-topline label { min-width: 100%; }
}

/* == reduced motion ======================================================= */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
