@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Lora:ital,wght@0,400;0,500;1,400&family=Inter:wght@300;400;500&display=swap');

:root {
  --ink: #181410;
  --ink-soft: #2b241d;
  --ivory: #F6F1E7;
  --ivory-warm: #FBF7EF;
  --bone: #EAE1CD;
  --plaster: #EDE4D2;
  --gold: #A8823F;
  --gold-bright: #D9B96E;
  --gold-deep: #7A5D28;
  --plum: #3F2530;
  --sage: #6E7A65;
  --ash: #7C7268;
  --ash-light: #B4AB9E;
  --line: #D6CBBA;
  --line-soft: #E5DBCA;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-soft: 0 1px 2px rgba(24,20,16,0.05), 0 4px 12px rgba(24,20,16,0.05);
  --shadow-page: 0 2px 8px rgba(24,20,16,0.07), 0 20px 48px rgba(24,20,16,0.09);
  --rail-width: 260px;
  --rail-width-mobile: 100%;
  --tap-min: 44px;
}

/* ---------- Fluid typography ---------- */
html {
  font-size: clamp(15px, 1.5vw + 12px, 18px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0; padding: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  letter-spacing: 0.005em;
  min-height: 100%;
  overflow-x: hidden;
  width: 100%;
}

body {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(217, 185, 110, 0.08), transparent 45%),
    radial-gradient(circle at 85% 92%, rgba(110, 122, 101, 0.06), transparent 45%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 0 0.06 0 0 0 0.035 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
}

/* Prevent iOS zoom on input focus */
input, select, textarea {
  font-size: 16px;
}

/* ---------- Fluid headings ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

h1 { font-size: clamp(1.9rem, 5vw + 0.5rem, 3rem); line-height: 1.12; letter-spacing: -0.022em; }
h2 { font-size: clamp(1.5rem, 3vw + 0.5rem, 2rem); line-height: 1.2; }
h3 { font-size: clamp(1.15rem, 1.5vw + 0.5rem, 1.35rem); line-height: 1.3; }
h4 { font-size: 1.05rem; line-height: 1.4; }

p { overflow-wrap: break-word; word-wrap: break-word; }

a { color: var(--ink-soft); text-decoration: none; transition: color 200ms; }
a:hover { color: var(--gold-deep); }

img, video, svg { max-width: 100%; height: auto; display: block; }

button, .btn {
  min-height: var(--tap-min);
  touch-action: manipulation;
}

.muted { color: var(--ash); font-style: italic; }

.small-caps {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ash);
}

.ornament {
  text-align: center;
  color: var(--gold);
  font-size: 1.1rem;
  letter-spacing: 0.5em;
  margin: clamp(1.5rem, 4vw, 2.75rem) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 2vw, 1.5rem);
}
.ornament::before, .ornament::after {
  content: '';
  height: 1px;
  width: clamp(40px, 12vw, 90px);
  background: linear-gradient(to right, transparent, var(--gold-bright), transparent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.75rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--ivory);
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  transition: all 400ms cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}
.btn:hover {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
  color: var(--ivory-warm);
}
.btn--quiet { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn--quiet:hover { border-color: var(--gold); color: var(--gold-deep); background: transparent; }

.link-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--ash);
  font-family: var(--font-ui); font-size: 0.7rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  padding: 0.5rem 0;
}
.link-btn:hover { color: var(--gold-deep); }

/* ============================================================
   NAVIGATION RAIL — desktop fixed, mobile drawer
   ============================================================ */

.rail-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--ivory-warm);
  border-radius: 2px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  transition: all 240ms;
}
.rail-toggle:hover { border-color: var(--gold); }
.rail-toggle__lines {
  display: flex; flex-direction: column; gap: 4px;
}
.rail-toggle__lines span {
  display: block; width: 20px; height: 1.5px; background: var(--ink-soft);
  transition: all 240ms;
}
.rail-toggle.is-open .rail-toggle__lines span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.rail-toggle.is-open .rail-toggle__lines span:nth-child(2) { opacity: 0; }
.rail-toggle.is-open .rail-toggle__lines span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.rail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 16, 0.45);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms;
}
.rail-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.nav-rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-width);
  background: linear-gradient(180deg, #FBF7EF 0%, #F4EEDF 100%);
  border-right: 1px solid var(--line);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 1px 0 20px rgba(24,20,16,0.04);
  transition: transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-rail__mark {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; text-decoration: none; padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.nav-rail__monogram {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 500;
  color: var(--gold-deep);
  line-height: 1;
  border: 1px solid var(--gold);
  border-radius: 50%;
  width: 3.5rem; height: 3.5rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--ivory-warm);
  box-shadow: inset 0 0 0 3px var(--ivory-warm), inset 0 0 0 4px var(--gold-bright);
}
.nav-rail__name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.nav-rail__groups { display: flex; flex-direction: column; gap: 2rem; margin-top: 2rem; }
.nav-rail__group { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-rail__label {
  color: var(--gold-deep);
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}
.nav-rail__link {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.85rem 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink-soft);
  border-radius: 3px;
  transition: all 240ms cubic-bezier(0.22, 1, 0.36, 1);
  min-height: var(--tap-min);
}
.nav-rail__link .glyph {
  color: var(--gold);
  font-size: 0.9rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}
.nav-rail__link:hover { background: rgba(217,185,110,0.14); color: var(--ink); }
.nav-rail__link.is-active {
  background: var(--ivory-warm);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--gold);
}
.nav-rail__link.is-active .glyph { color: var(--gold-deep); }

.nav-rail__footer {
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 0.6rem;
  margin-top: 2rem;
}
.nav-rail__identity { display: flex; flex-direction: column; gap: 0.2rem; }
.nav-rail__name-small { font-family: var(--font-display); font-size: 1rem; color: var(--ink-soft); }
.nav-rail__role { color: var(--gold-deep); font-size: 0.62rem; }
.nav-rail__house {
  color: var(--gold-deep);
  font-size: 0.6rem;
  letter-spacing: 0.26em;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line-soft);
}
.nav-rail__logout { margin-top: 0.5rem; }

/* ---------- Page shell ---------- */
.page-shell {
  max-width: 1440px;
  margin: 0 auto;
  transition: margin-left 400ms cubic-bezier(0.22, 1, 0.36, 1);
  width: 100%;
}
.page-shell.with-rail { margin-left: var(--rail-width); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: clamp(1rem, 4vw, 2rem); }
.login__panel {
  width: 100%; max-width: 440px; text-align: center;
  background: var(--ivory-warm);
  padding: clamp(2rem, 6vw, 4rem) clamp(1.5rem, 5vw, 3.25rem);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  box-shadow: var(--shadow-page);
}
.login__title { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 300; margin: 1.5rem 0 0.4rem; letter-spacing: -0.02em; }
.login__subtitle { font-family: var(--font-display); font-style: italic; color: var(--ash); margin-bottom: 2rem; font-size: 1.05rem; }
.login__imprint {
  color: var(--gold-deep);
  margin-top: 0.75rem;
  letter-spacing: 0.28em;
  font-size: 0.62rem;
}
.login__question-label { color: var(--gold-deep); margin-bottom: 0.5rem; }
.login__question { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink-soft); font-style: italic; margin: 0 0 2rem; }
.login__form { display: flex; flex-direction: column; gap: 1.25rem; text-align: left; }
.login__label { display: flex; flex-direction: column; gap: 0.5rem; }
.login__label input,
.login__label select {
  padding: 0.9rem 1.1rem;
  background: var(--ivory);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  transition: border-color 240ms;
  width: 100%;
  min-height: var(--tap-min);
}
.login__label input:focus,
.login__label select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,185,110,0.18); }
.login__error { color: var(--plum); font-size: 0.9rem; text-align: center; margin: 0; font-style: italic; }

/* ---------- Threshold ---------- */
.threshold { max-width: 820px; margin: 0 auto; padding: clamp(3rem, 8vw, 6rem) clamp(1.25rem, 5vw, 3rem) clamp(4rem, 8vw, 7rem); }
.threshold__greeting { text-align: center; margin-bottom: clamp(2.5rem, 6vw, 5rem); }
.threshold__salutation {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 6vw, 3.1rem);
  font-weight: 300;
  margin: 1.5rem 0 1rem;
  letter-spacing: -0.02em;
}
.threshold__ceremonial {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  color: var(--gold-deep);
  margin: 0.75rem 0 0.5rem;
  letter-spacing: 0.03em;
  line-height: 1.5;
}
.threshold__time { font-family: var(--font-display); font-style: italic; font-size: 1.1rem; color: var(--ash); }
.threshold__primary { text-align: center; margin: clamp(2.5rem, 6vw, 5rem) 0; }
.primary-action {
  display: inline-flex; align-items: center; gap: 1.25rem;
  padding: clamp(1.1rem, 3vw, 1.5rem) clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--gold);
  background: var(--ivory-warm);
  color: var(--ink);
  text-decoration: none;
  border-radius: 2px;
  transition: all 500ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: var(--shadow-soft);
  min-height: var(--tap-min);
}
.primary-action:hover {
  background: var(--ink); color: var(--ivory);
  border-color: var(--ink);
  box-shadow: var(--shadow-page);
  transform: translateY(-1px);
}
.primary-action__arrow { color: var(--gold); transition: all 500ms cubic-bezier(0.22, 1, 0.36, 1); }
.primary-action:hover .primary-action__arrow { color: var(--gold-bright); transform: translateX(6px); }
.threshold__secondary { margin-top: 1.5rem; font-size: 0.9rem; color: var(--ash); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.5rem; }
.threshold__secondary a { color: var(--ink-soft); border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.threshold__secondary a:hover { border-bottom-color: var(--gold); color: var(--ink); }
.threshold__sep { color: var(--line); }
.threshold__chronicles { margin-top: clamp(3rem, 8vw, 6rem); padding-top: clamp(1.5rem, 4vw, 3rem); border-top: 1px solid var(--line-soft); }
.threshold__section-title { text-align: center; margin-bottom: 2rem; color: var(--ash); }

.thread {
  display: flex; gap: 1.25rem;
  align-items: flex-start;
  padding: 1.25rem 0.75rem;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  transition: background 240ms;
}
.thread:hover { background: var(--ivory-warm); }
.thread__marker { color: var(--gold); font-size: 1.1rem; line-height: 1.6; width: 1.5rem; flex-shrink: 0; }
.thread__body { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 0; }
.thread__title { font-family: var(--font-display); font-size: clamp(1.1rem, 2vw, 1.35rem); }
.thread__meta { font-family: var(--font-ui); font-size: 0.82rem; color: var(--ash); }
.thread__drafting { color: var(--plum); }

/* ---------- Shape ---------- */
.shape { max-width: 820px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 5vw, 3rem); }
.shape__header { text-align: center; margin-bottom: 2rem; }
.shape__title { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.shape__chronicles {
  display: flex; justify-content: center; gap: 1.5rem;
  margin-bottom: clamp(2.5rem, 6vw, 5rem);
  flex-wrap: wrap;
}
.shape__chronicles a {
  font-family: var(--font-ui); font-size: 0.75rem; letter-spacing: 0.22em;
  color: var(--ash); padding: 0.65rem 0.25rem;
  border-bottom: 1px solid transparent; transition: all 240ms;
  min-height: var(--tap-min);
  display: inline-flex; align-items: center;
}
.shape__chronicles a:hover { color: var(--ink-soft); }
.shape__chronicles a.is-active { color: var(--ink); border-bottom-color: var(--gold); }
.shape__part { margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.shape__part-title {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 500;
  color: var(--ink-soft); margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.75rem;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--line-soft);
}
.shape__marker { color: var(--gold); font-size: 0.75rem; }
.shape__chapters { list-style: none; padding: 0; margin: 0; }
.shape__chapter {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 1rem 0.5rem;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  transition: background 240ms;
  flex-wrap: wrap;
}
.shape__chapter:hover { background: var(--ivory-warm); }
.shape__status { font-size: 1rem; width: 1rem; flex-shrink: 0; color: var(--ash-light); }
.shape__status--drafting { color: var(--plum); }
.shape__status--review { color: var(--gold); }
.shape__status--approved { color: var(--sage); }
.shape__chapter-title { font-family: var(--font-display); font-size: clamp(1rem, 2vw, 1.2rem); flex: 1; min-width: 0; }
.shape__revisions { color: var(--gold-deep); font-size: 0.65rem; margin-right: 0.5rem; }
.shape__chapter-state { color: var(--ash); font-size: 0.66rem; }

/* ---------- Desk ---------- */
.desk { max-width: 820px; margin: 0 auto; padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 4vw, 3rem) clamp(3rem, 6vw, 6rem); }
.desk__breadcrumb {
  font-family: var(--font-ui); font-size: 0.8rem; color: var(--ash);
  margin-bottom: clamp(1.5rem, 4vw, 3rem);
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.desk__breadcrumb a { color: var(--ink-soft); }
.desk__sep { color: var(--line); }
.desk__header { text-align: center; margin-bottom: clamp(2rem, 5vw, 3rem); }
.desk__title { font-size: clamp(1.6rem, 5vw, 2.6rem); margin: 0.75rem 0 1.5rem; }
.desk__brief {
  max-width: 540px; margin: 1.5rem auto 0;
  padding: 1.25rem 1.5rem;
  background: var(--ivory-warm);
  border-left: 2px solid var(--gold);
  text-align: left;
}
.desk__brief p { font-style: italic; color: var(--ink-soft); margin: 0.5rem 0 0; }
.desk__revision-badge { color: var(--gold-deep); margin-top: 1.25rem; letter-spacing: 0.22em; }
.desk__page {
  background: var(--ivory-warm);
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1.25rem, 5vw, 4.5rem);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  box-shadow: var(--shadow-page);
  min-height: 55vh;
  position: relative;
}
.desk__textarea {
  width: 100%; border: none; outline: none;
  background: transparent; resize: none;
  font-family: var(--font-body);
  font-size: clamp(1rem, 2vw, 1.08rem);
  line-height: 1.88; color: var(--ink);
  min-height: 50vh;
}
.desk__footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: clamp(2rem, 4vw, 3rem); padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
  gap: 1rem; flex-wrap: wrap;
}
.desk__stats { display: flex; gap: 1.25rem; font-family: var(--font-ui); font-size: 0.78rem; color: var(--ash); flex-wrap: wrap; }
#save-status { color: var(--sage); }
.seal-btn {
  padding: 0.85rem 1.5rem;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: all 400ms cubic-bezier(0.22, 1, 0.36, 1);
  min-height: var(--tap-min);
}
.seal-btn:hover { background: var(--gold); color: var(--ivory); }
.seal-btn.is-sealed { background: var(--sage); border-color: var(--sage); color: var(--ivory); }

/* ---------- Gallery ---------- */
.gallery { margin-top: 2.5rem; padding: clamp(1rem, 3vw, 2rem); background: var(--plaster); border-radius: 2px; }
.gallery__title { color: var(--gold-deep); margin-bottom: 1rem; }
.gallery__strip {
  display: flex; gap: 1rem; overflow-x: auto;
  padding-bottom: 0.75rem;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.gallery__strip::-webkit-scrollbar { height: 6px; }
.gallery__strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.gallery__thumb {
  position: relative; flex-shrink: 0;
  width: clamp(90px, 20vw, 110px);
  height: clamp(120px, 27vw, 148px);
  overflow: hidden; border: 1px solid var(--line);
  border-radius: 2px; background: var(--ivory-warm);
  transition: all 300ms;
  scroll-snap-align: start;
}
.gallery__thumb:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery__num {
  position: absolute; bottom: 5px; right: 5px;
  background: rgba(24,20,16,0.75); color: var(--ivory);
  font-family: var(--font-ui); font-size: 0.66rem;
  padding: 2px 7px; border-radius: 2px;
}
.gallery__thumb--audio {
  display: flex; align-items: center; justify-content: center;
  background: var(--bone);
  padding: 0.5rem;
}
.gallery__thumb--audio audio {
  width: 100%; max-width: 240px;
}

/* ---------- Versions ---------- */
.versions { margin-top: 2.5rem; padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 4vw, 2rem); background: var(--ivory-warm); border: 1px solid var(--line-soft); border-radius: 2px; }
.versions__title { color: var(--gold-deep); margin-bottom: 1rem; }
.versions__list { list-style: none; padding: 0; margin: 0; }
.versions__item {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 1rem; align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-ui); font-size: 0.82rem; color: var(--ash);
}
.versions__item:last-child { border-bottom: none; }
.versions__layer { color: var(--gold-deep); letter-spacing: 0.22em; }
.versions__item--original .versions__layer { color: var(--plum); }
.versions__item--derived .versions__layer { color: var(--sage); }
.versions__item--approved .versions__layer { color: var(--ink); }

/* ---------- Assign & Comments ---------- */
.desk__assign { margin-top: 2.5rem; padding-top: 1.75rem; border-top: 1px solid var(--line-soft); }
.inline-form { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.inline-form select {
  flex: 1; min-width: 200px;
  padding: 0.75rem 1rem;
  background: var(--ivory-warm); border: 1px solid var(--line);
  border-radius: 2px; font-family: var(--font-body); font-size: 1rem;
  min-height: var(--tap-min);
}
.desk__comments { margin-top: 2.5rem; padding-top: 1.75rem; border-top: 1px solid var(--line-soft); }
.comments { list-style: none; padding: 0; margin: 1rem 0 1.5rem; }
.comment { padding: 1rem 0; border-bottom: 1px solid var(--line-soft); }
.comment__meta { display: flex; gap: 1rem; font-family: var(--font-ui); font-size: 0.76rem; color: var(--ash); margin-bottom: 0.5rem; flex-wrap: wrap; }
.comment__author { color: var(--ink-soft); font-weight: 500; letter-spacing: 0.05em; }
.comment__body { font-family: var(--font-body); font-size: 0.98rem; color: var(--ink-soft); }
.comment-form { display: flex; flex-direction: column; gap: 0.75rem; }
.comment-form textarea {
  width: 100%; padding: 0.85rem 1.1rem;
  background: var(--ivory-warm); border: 1px solid var(--line);
  border-radius: 2px; font-family: var(--font-body); font-size: 1rem;
  color: var(--ink); resize: vertical;
  min-height: 80px;
}
.comment-form button { align-self: flex-end; }

/* ---------- Console ---------- */
.console { max-width: 1100px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem); }
.console__header { margin-bottom: 2.5rem; }
.console__header h1 { margin-top: 0.5rem; }
.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 2.5rem;
}
.pipeline__tab {
  padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1rem, 3vw, 1.5rem);
  background: var(--ivory-warm);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  display: flex; flex-direction: column; gap: 0.85rem;
  color: var(--ink); transition: all 300ms;
}
.pipeline__tab:hover { border-color: var(--gold); box-shadow: var(--shadow-soft); }
.pipeline__count { font-family: var(--font-display); font-size: clamp(1.75rem, 4vw, 2.25rem); color: var(--gold-deep); line-height: 1; }
.console__quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin-bottom: 3rem;
}
.quick-action {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--plaster);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink); transition: all 300ms;
  min-height: var(--tap-min);
}
.quick-action:hover { background: var(--ivory-warm); border-color: var(--gold); }
.quick-action__glyph { color: var(--gold-deep); font-size: 1.1rem; }
.captures { list-style: none; padding: 0; margin-top: 1rem; }
.captures li {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1.5rem; padding: 1rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-ui); font-size: 0.85rem; color: var(--ash);
}

/* ---------- Vault ---------- */
.vault { max-width: 1100px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem); }
.vault__header { margin-bottom: 2.5rem; }
.vault__list { list-style: none; padding: 0; margin-top: 2rem; }
.vault__item {
  display: grid; grid-template-columns: 1.5fr 1fr 1fr;
  gap: 1.5rem; padding: 1.25rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-ui); font-size: 0.85rem; color: var(--ash);
}
.vault__date { color: var(--ink-soft); }

/* ---------- Invite ---------- */
.invite { max-width: 840px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem); }
.invite__header { margin-bottom: 2.5rem; }
.invite__sent { padding: 1.25rem 1.5rem; background: var(--bone); border-left: 2px solid var(--sage); border-radius: 2px; margin-bottom: 2rem; }
.invite__form { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 3.5rem; }
.invite__form label { display: flex; flex-direction: column; gap: 0.5rem; }
.invite__form input, .invite__form select {
  padding: 0.85rem 1rem;
  background: var(--ivory-warm); border: 1px solid var(--line);
  border-radius: 2px; font-family: var(--font-body); font-size: 1rem;
  min-height: var(--tap-min); width: 100%;
}
.invite__form button { align-self: flex-start; }
.invite__pending { margin-bottom: 2.5rem; }
.invite__list { list-style: none; padding: 0; margin-top: 1rem; }
.invite__item {
  display: grid; grid-template-columns: 1.4fr auto 2fr auto;
  gap: 1rem; padding: 0.9rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-ui); font-size: 0.82rem; color: var(--ash);
  align-items: center;
}
.invite__email { color: var(--ink-soft); overflow-wrap: break-word; word-break: break-word; }
.invite__link code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.76rem; color: var(--gold-deep);
  word-break: break-all;
}

/* ---------- Writer Setup ---------- */
.writer-setup { max-width: 780px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem); }
.writer-setup__header { margin-bottom: 2.5rem; }
.writer-setup__form { display: flex; flex-direction: column; gap: 1.4rem; }
.writer-setup__form button { align-self: flex-start; margin-top: 1rem; }
.writer-setup__created {
  background: var(--ivory-warm);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--gold);
  border-radius: 2px;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-page);
}
.writer-setup__details { list-style: none; padding: 0; margin: 1rem 0 2rem; }
.writer-setup__details li {
  display: flex; gap: 1rem; padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-ui); font-size: 0.85rem;
  flex-wrap: wrap;
}
.writer-setup__link {
  background: var(--plaster); padding: 1rem 1.25rem;
  border-radius: 2px; margin: 0.75rem 0 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.writer-setup__link code {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem; color: var(--gold-deep);
  word-break: break-all;
}

/* ---------- Invitation acceptance ---------- */
.invitation { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: clamp(1rem, 4vw, 2rem); }
.invitation__panel {
  width: 100%; max-width: 520px; text-align: center;
  background: var(--ivory-warm);
  padding: clamp(2rem, 6vw, 4rem) clamp(1.5rem, 5vw, 3.25rem);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  box-shadow: var(--shadow-page);
}
.invitation__title { font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 300; margin: 1rem 0; }
.invitation__intro { color: var(--ash); margin-bottom: 2rem; }
.invitation__form { display: flex; flex-direction: column; gap: 1.25rem; text-align: left; }
.invitation__form button { margin-top: 1rem; }
.invitation__validation { padding: 1.5rem 0; border-top: 1px solid var(--line-soft); margin-top: 1rem; }
.invitation__question { font-family: var(--font-display); font-style: italic; font-size: 1.1rem; color: var(--ink-soft); margin: 0.5rem 0 1.25rem; }

/* ---------- Contributor section ---------- */
.contributor-section { max-width: 760px; margin: 0 auto; padding: clamp(2rem, 5vw, 4rem) clamp(1.25rem, 4vw, 3rem) clamp(3rem, 6vw, 6rem); }
.reading-page {
  background: var(--ivory-warm);
  padding: clamp(1.5rem, 5vw, 3.5rem);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  box-shadow: var(--shadow-page);
}
.reading-page p { margin: 0 0 1.25em; text-align: justify; hyphens: auto; }

/* ---------- Guide ---------- */
.guide { max-width: 800px; margin: 0 auto; padding: clamp(3rem, 8vw, 6rem) clamp(1.25rem, 4vw, 3rem); }
.guide__header { text-align: center; margin-bottom: 3rem; }
.guide__subtitle { font-family: var(--font-display); font-style: italic; color: var(--ash); font-size: 1.1rem; }
.guide__body { line-height: 1.88; }
.guide__section { margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.guide__section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.guide__section ul { padding-left: 1.25rem; }
.guide__section li { margin-bottom: 0.75rem; }
.guide__section p { text-align: justify; }
kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  background: var(--bone); padding: 2px 7px;
  border-radius: 3px; border: 1px solid var(--line);
}
.guide__close { text-align: center; font-family: var(--font-display); font-style: italic; font-size: clamp(1.1rem, 2.5vw, 1.3rem); color: var(--ash); margin-top: 2.5rem; }
.guide__colophon { text-align: center; color: var(--gold-deep); margin-top: 2rem; letter-spacing: 0.24em; font-size: 0.66rem; }

/* ---------- Misc ---------- */
.centered-page { max-width: 640px; margin: 0 auto; padding: clamp(3rem, 8vw, 6rem) clamp(1.25rem, 4vw, 3rem); text-align: center; }
.capture { max-width: 640px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem); text-align: center; }
.capture__intro { font-style: italic; color: var(--ash); margin-bottom: 2.5rem; }
.capture input[type="file"] { display: block; margin: 0 auto 2rem; font-family: var(--font-ui); font-size: 0.9rem; max-width: 100%; }
.capture button { margin-top: 1rem; }

/* ---------- Voice recorder ---------- */
.recorder {
  margin-top: 3rem;
  padding: 1.75rem 2rem;
  background: var(--plaster);
  border-radius: 2px;
  border: 1px solid var(--line);
}
.recorder__header { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.25rem; }
.recorder__hint { font-size: 0.9rem; }
.recorder__controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.recorder__timer { color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.recorder__upload { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.recorder__upload input[type="file"] {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  max-width: 100%;
}
.recorder__status { margin-top: 1rem; min-height: 1.2rem; }

@media (max-width: 560px) {
  .recorder { padding: 1.25rem 1rem; }
  .recorder__controls { flex-direction: column; align-items: stretch; }
  .recorder__controls .btn { width: 100%; }
}

/* ============================================================
   RESPONSIVE — mobile, tablet, landscape
   ============================================================ */

/* Tablet — reduce rail to compact form */
@media (max-width: 1080px) and (min-width: 861px) {
  :root { --rail-width: 220px; }
  .nav-rail { padding: 1.75rem 1.25rem; }
  .nav-rail__link { font-size: 0.95rem; padding: 0.75rem 0.6rem; }
}

/* Below 860px — rail becomes a drawer */
@media (max-width: 860px) {
  .rail-toggle { display: flex; }
  .rail-backdrop { display: block; }

  .nav-rail {
    transform: translateX(-100%);
    width: min(320px, 85vw);
    box-shadow: 4px 0 32px rgba(24,20,16,0.15);
  }
  .nav-rail.is-open { transform: translateX(0); }

  .page-shell.with-rail { margin-left: 0; }

  /* Push content down so the toggle doesn't overlap */
  .page-shell { padding-top: 4.5rem; }

  /* Touch-friendly links */
  .nav-rail__link { padding: 0.9rem 0.75rem; font-size: 1.05rem; }
  .nav-rail__groups { gap: 1.5rem; }
  .nav-rail__footer { margin-top: 1.5rem; }

  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .console__quick { grid-template-columns: 1fr; }
  .captures li { grid-template-columns: 1fr; gap: 0.35rem; padding: 0.85rem 0; }
  .vault__item { grid-template-columns: 1fr; gap: 0.35rem; }
  .invite__item { grid-template-columns: 1fr; gap: 0.5rem; }
  .versions__item { grid-template-columns: 1fr auto auto; gap: 0.75rem; }

  .desk__page { padding: 1.5rem 1.25rem; }
  .reading-page { padding: 1.5rem 1.25rem; }

  /* Slightly reduce letter spacing on small screens for tighter headlines */
  h1 { letter-spacing: -0.015em; }
}

/* Phone portrait — tighter */
@media (max-width: 560px) {
  .login__panel,
  .invitation__panel {
    padding: 2rem 1.5rem;
  }

  .threshold { padding-left: 1rem; padding-right: 1rem; }
  .shape { padding-left: 1rem; padding-right: 1rem; }
  .desk { padding-left: 0.75rem; padding-right: 0.75rem; }
  .console,
  .vault,
  .invite,
  .writer-setup,
  .guide,
  .contributor-section { padding-left: 1rem; padding-right: 1rem; }

  .threshold__salutation { font-size: 1.65rem; }

  .primary-action {
    padding: 1rem 1.5rem;
    width: 100%;
    justify-content: center;
  }

  .desk__footer {
    flex-direction: column;
    align-items: stretch;
  }
  .desk__footer .seal-btn { width: 100%; }

  .pipeline { grid-template-columns: 1fr; }

  .shape__chronicles { gap: 1rem; }
  .shape__chapter { padding: 0.85rem 0.4rem; }

  .comment-form button { align-self: stretch; }
  .inline-form button { flex: 1; }

  .btn { width: 100%; }

  .captures li { font-size: 0.8rem; }
  .vault__item { font-size: 0.8rem; }
}

/* Small phone (SE-class) */
@media (max-width: 380px) {
  .nav-rail { width: 90vw; }
  .threshold__salutation { font-size: 1.5rem; }
  .login__title { font-size: 1.75rem; }
  .ornament::before,
  .ornament::after { width: 40px; }
}

/* Landscape phone — reduce vertical padding, ensure rail toggle visible */
@media (max-height: 500px) and (orientation: landscape) {
  .nav-rail { padding: 1rem 1.25rem; }
  .nav-rail__mark { padding-bottom: 0.75rem; }
  .nav-rail__monogram { width: 2.5rem; height: 2.5rem; font-size: 1.75rem; }
  .nav-rail__groups { margin-top: 1rem; gap: 1rem; }
  .threshold { padding-top: 2rem; padding-bottom: 2rem; }
  .threshold__greeting { margin-bottom: 2rem; }
  .threshold__primary { margin: 2rem 0; }
  .login { padding: 1rem; }
  .login__panel { padding: 1.5rem; }
  .page-shell { padding-top: 4rem; }
}

/* Very large screens — keep typography readable */
@media (min-width: 1600px) {
  :root { --rail-width: 300px; }
  .nav-rail { padding: 3rem 2.25rem; }
  .page-shell { max-width: 1600px; }
}

/* Landscape tablet/desktop — full rail stays fixed */
@media (min-width: 861px) and (orientation: landscape) {
  .nav-rail { transform: translateX(0); }
}

/* Reduce motion preference */
@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;
  }
}

/* Dark mode — optional, honours system preference */
@media (prefers-color-scheme: dark) {
  :root {
    --ivory: #1C1A16;
    --ivory-warm: #221E1A;
    --bone: #2A251F;
    --plaster: #2F2922;
    --ink: #F2EBDE;
    --ink-soft: #D8CFBC;
    --ash: #9A9084;
    --ash-light: #6E6459;
    --line: #3A332B;
    --line-soft: #2F2A23;
    --gold: #D0A860;
    --gold-bright: #E5C583;
    --gold-deep: #E0B978;
  }
  body {
    background-image:
      radial-gradient(circle at 15% 8%, rgba(208, 168, 96, 0.06), transparent 45%),
      radial-gradient(circle at 85% 92%, rgba(110, 122, 101, 0.04), transparent 45%);
  }
  .nav-rail {
    background: linear-gradient(180deg, #221E1A 0%, #1C1A16 100%);
  }
  .nav-rail__monogram {
    box-shadow: inset 0 0 0 3px var(--ivory-warm), inset 0 0 0 4px var(--gold-bright);
  }
}