:root {
  --bg: #0a0908;
  --bg-2: #15110d;
  --bg-3: #1d1812;
  --fg: #f5e6d3;
  --fg-dim: #a0907a;
  --fg-muted: #6b6358;
  --flame: #d4a574;
  --flame-bright: #f0c478;
  --rust: #8b1a0b;
  --brass: #a06a3a;
  --border: #2a2218;
  --border-bright: #3d3020;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background:
    radial-gradient(ellipse 800px 600px at 50% 30%, rgba(212,165,116,0.05) 0%, transparent 70%),
    radial-gradient(ellipse 500px 400px at 80% 100%, rgba(139,26,11,0.04) 0%, transparent 60%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 2px,
      rgba(245,230,211,0.008) 2px,
      rgba(245,230,211,0.008) 3px
    );
  pointer-events: none;
  z-index: 1;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 2;
}
.container { position: relative; z-index: 3; }
/* TOP BAR */
.topbar {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: rgba(10,9,8,0.6);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar a { color: var(--fg-muted); text-decoration: none; transition: color 0.2s; }
.topbar a:hover { color: var(--flame); }
.topbar .left { display: flex; gap: 1.5rem; align-items: center; }
.topbar .right { display: flex; gap: 1.5rem; align-items: center; }
.dot {
  width: 7px; height: 7px;
  background: #6eba70;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
  animation: pulse 3s ease-in-out infinite;
  box-shadow: 0 0 6px #6eba70;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
/* HERO */
.hero {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  position: relative;
}
.lantern-wrap {
  position: relative;
  width: 360px;
  max-width: 70vw;
  margin-bottom: 2rem;
}
.lantern-wrap img,
.lantern-wrap object {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 60px rgba(212,165,116,0.15));
  animation: lanternBreathe 6s ease-in-out infinite;
}
@keyframes lanternBreathe {
  0%, 100% { filter: drop-shadow(0 0 60px rgba(212,165,116,0.15)); }
  50% { filter: drop-shadow(0 0 80px rgba(212,165,116,0.25)); }
}
.wordmark {
  font-family: 'Cinzel', 'Cormorant Garamond', serif;
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #f5e6d3 0%, #d4a574 40%, #8b1a0b 70%, #5a1206 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 24px rgba(139,26,11,0.4);
  margin-bottom: 0.2rem;
  line-height: 1;
}
.wordmark-sub {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  letter-spacing: 0.5em;
  color: var(--flame);
  margin-bottom: 3rem;
  text-indent: 0.5em;
  text-transform: uppercase;
}
.tagline {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  color: var(--fg);
  text-align: center;
  max-width: 540px;
  margin: 0 auto 2.5rem;
  line-height: 1.6;
}
.tagline em {
  color: var(--flame-bright);
  font-style: italic;
  font-weight: 500;
}
.cta-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 4rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem 2.4rem;
  border: 1px solid var(--flame);
  background: transparent;
  color: var(--flame);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(212,165,116,0.18) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.btn:hover::before { transform: translateX(100%); }
.btn:hover {
  background: var(--flame);
  color: var(--bg);
  box-shadow: 0 0 32px rgba(212, 165, 116, 0.4);
}
.btn-primary {
  background: var(--flame);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--flame-bright);
  box-shadow: 0 0 40px rgba(240, 196, 120, 0.5);
}
.btn-secondary {
  border-color: var(--brass);
  color: var(--brass);
}
.btn-secondary:hover {
  background: var(--brass);
  color: var(--bg);
}
/* SECTIONS */
section {
  padding: 5rem 2rem;
  border-top: 1px solid var(--border);
  position: relative;
}
.container-narrow {
  max-width: 720px;
  margin: 0 auto;
}
.section-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--flame);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.section-label::before {
  content: '';
  width: 32px; height: 1px;
  background: var(--flame);
}
.section-h {
  font-family: 'Cinzel', 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0.02em;
  margin-bottom: 2rem;
  color: var(--fg);
}
.section-h em { font-style: italic; color: var(--flame-bright); }
.lede {
  font-size: 1.2rem;
  line-height: 1.85;
  color: var(--fg);
  margin-bottom: 1.6rem;
}
.lede.dim { color: var(--fg-dim); }
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}
.step {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 2rem 1.8rem;
  position: relative;
  transition: all 0.25s;
}
.step:hover {
  border-color: var(--flame);
  transform: translateY(-2px);
}
.step::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--flame);
  opacity: 0;
  transition: opacity 0.25s;
}
.step:hover::before { opacity: 1; }
.step-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--flame);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  margin-bottom: 0.8rem;
  text-transform: uppercase;
}
.step h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
  color: var(--fg);
}
.step p {
  color: var(--fg-dim);
  font-size: 0.95rem;
  line-height: 1.65;
}
.note-box {
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--flame);
  background: var(--bg-2);
  padding: 2rem 2rem 2rem 2.2rem;
  margin: 3rem 0;
  font-family: 'EB Garamond', serif;
}
.note-box .note-h {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--flame);
  margin-bottom: 0.8rem;
}
.note-box p {
  color: var(--fg);
  font-size: 1.02rem;
  line-height: 1.75;
  margin-bottom: 0.8rem;
}
.note-box p:last-child { margin-bottom: 0; }
.note-box code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--flame);
  background: var(--bg-3);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}
/* DROP / CTA SECTION */
.drop-section {
  text-align: center;
  padding: 6rem 2rem;
  background: linear-gradient(180deg, transparent 0%, rgba(139,26,11,0.04) 100%);
}
.drop-section h2 {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
  margin-bottom: 1rem;
  background: linear-gradient(180deg, #f5e6d3 0%, #d4a574 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.drop-section p {
  color: var(--fg-dim);
  font-size: 1.15rem;
  max-width: 540px;
  margin: 0 auto 2.5rem;
  font-style: italic;
}
/* FOOTER */
footer {
  border-top: 1px solid var(--border);
  padding: 3rem 2rem 2rem;
  text-align: center;
  color: var(--fg-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  line-height: 2.2;
}
footer a { color: var(--flame); text-decoration: none; }
footer a:hover { color: var(--flame-bright); }
footer .footer-mark {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  letter-spacing: 0.4em;
  color: var(--flame);
  margin-bottom: 0.8rem;
  text-transform: uppercase;
}
footer .pgp {
  font-size: 0.65rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
  word-break: break-all;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
/* RESPONSIVE */
/* mobile rules moved below */


/* ========================================================================
   BLACK LAMP · Responsive layer
   Breakpoints:
     ≤ 900px → tablet (reduce padding, tighten spacing)
     ≤ 600px → phone (single-column, stacked controls, touch-friendly sizing)
     ≤ 380px → small phone (Eva's REVVL 7 / typical Android)
   ======================================================================== */

/* ---------- TABLET (~iPad portrait, narrow laptops) ---------- */
@media (max-width: 900px) {
  section { padding: 3rem 1.5rem; }
  .container-narrow { padding: 0 1rem; }
  .hero { padding: 3.5rem 1.5rem; }
  .topbar { padding: 0.8rem 1.5rem; }
  .topbar .left, .topbar .right { gap: 1.1rem; }
  h2.section-h, .section-h { font-size: 2rem; line-height: 1.1; }
}

/* ---------- PHONE (most Android/iPhone portrait) ---------- */
@media (max-width: 600px) {

  /* Body base — slightly smaller everywhere */
  body { font-size: 0.95rem; }

  /* Sections shrink padding aggressively */
  section { padding: 2rem 1rem; }
  .container, .container-narrow { padding: 0 0.4rem; }

  /* HERO — vertical and tighter */
  .hero {
    padding: 2.2rem 1rem;
    text-align: center;
  }
  .hero .lantern-wrap { width: 200px; margin: 0 auto 1.5rem; }
  h1, .hero h1 { font-size: 2rem !important; line-height: 1.15; letter-spacing: 0.03em; }
  h2.section-h, .section-h { font-size: 1.5rem !important; letter-spacing: 0.02em; }
  .section-label { font-size: 0.6rem; letter-spacing: 0.18em; }
  .lede, .hero p { font-size: 1rem; line-height: 1.55; }

  /* TOPBAR — wrap to two rows, smaller text */
  .topbar {
    padding: 0.6rem 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
  }
  .topbar .left, .topbar .right {
    flex-wrap: wrap;
    gap: 0.7rem;
    font-size: 0.6rem;
  }
  .topbar .left { width: auto; }
  .topbar .right { justify-content: flex-end; flex: 1; }

  /* Hide some less-critical separator dots in the topbar */
  .topbar .right > .dot { display: none; }

  /* Bell pill — shrink + simplify on mobile */
  .live-bell {
    padding: 4px 9px; font-size: 0.6rem; margin-right: 4px;
    letter-spacing: 0.06em;
  }
  .live-bell .badge { padding: 0 5px; font-size: 0.6rem; }

  /* Bell dropdown becomes nearly full-width */
  .bell-dropdown {
    position: fixed; top: 56px; right: 4px; left: 4px;
    min-width: 0; max-width: none; width: calc(100vw - 8px);
    margin-top: 4px;
  }

  /* Presence pill — compact */
  #presence-pill {
    font-size: 0.55rem !important;
    padding: 3px 7px !important;
    letter-spacing: 0.06em !important;
  }

  /* Burning indicator — compact */
  #burning-link {
    font-size: 0.6rem !important;
    padding: 3px 8px !important;
  }

  /* THREAD ROWS (inbox) — stack metadata under ID with breathing room */
  .thread-row, .inbox-thread, [data-thread-row] {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 0.9rem;
    gap: 0.4rem;
  }
  .thread-row .meta, .inbox-thread .meta {
    font-size: 0.7rem; flex-wrap: wrap;
  }
  .thread-row .meta span, .inbox-thread .meta span {
    margin: 0;
  }

  /* CLAIM BANNER — stack info above buttons, full-width buttons */
  .claim-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.1rem;
    gap: 1rem;
  }
  .claim-actions {
    flex-direction: column;
    gap: 0.6rem;
  }
  .claim-btn, .claim-select {
    width: 100%;
    text-align: center;
    padding: 0.8rem 1rem;
    font-size: 0.75rem;
  }
  .claim-select { background-position: right 0.8rem center; }
  .claim-info .who { font-size: 1rem; }

  /* INTERNAL NOTES SECTION — tighter cards, smaller avatar */
  .notes-section { margin-top: 2rem; padding-top: 1.5rem; }
  .notes-h { font-size: 1.15rem; }
  .note-card { padding: 0.8rem 1rem; gap: 0.8rem; }
  .note-avatar { width: 30px; height: 30px; font-size: 0.85rem; }
  .note-head {
    flex-wrap: wrap;
    font-size: 0.65rem;
    gap: 0.4rem;
  }
  .note-content { font-size: 0.95rem; line-height: 1.5; }
  .note-form textarea {
    font-size: 1rem;            /* iOS won't zoom on 16px+ inputs */
    min-height: 80px;
  }
  .note-form .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .note-form .controls .hint { font-size: 0.6rem; text-align: center; }
  .note-form .controls .claim-btn { width: 100%; }

  /* ENCRYPTED MESSAGE rows — wrap path */
  .message-row, [data-message-row] {
    padding: 0.9rem 1rem;
    word-break: break-all;
  }
  .message-row .path {
    font-size: 0.7rem;
    word-break: break-all;
  }

  /* REPLY TEXTAREA */
  textarea[name="message"], form textarea {
    font-size: 1rem; min-height: 100px;
  }

  /* OPERATORS ADMIN — cards stack */
  .op-card { padding: 1rem 1.1rem; margin-bottom: 1rem; }
  .op-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
  }
  .op-name { font-size: 1.15rem; }
  .op-meta {
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem 1rem;
    font-size: 0.7rem;
  }
  .op-meta-label { font-size: 0.55rem; }
  .op-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  .op-action-btn { width: 100%; text-align: center; padding: 0.7rem 1rem; }

  /* Credential rows (passkey list) — stack vertically */
  .cred-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.8rem 1rem;
  }
  .cred-row > * { width: 100%; }
  .cred-revoke {
    margin-top: 0.4rem;
    padding: 0.6rem 1rem;
    align-self: flex-start;
  }
  .cred-desc { font-size: 0.85rem; }
  .cred-meta { font-size: 0.65rem; }

  /* ENROLLMENT CODES section — code is huge, row stacks vertically */
  .codes-section { padding: 1rem 1.1rem; }
  .codes-header {
    flex-direction: column;
    gap: 0.6rem;
    align-items: stretch;
  }
  .codes-refresh { align-self: flex-end; }
  .codes-title h3 { font-size: 1rem; }
  .codes-help { font-size: 0.85rem; }

  .code-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    text-align: center;
  }
  .code-value {
    font-size: 1.6rem; letter-spacing: 0.3em;
    text-align: center;
    padding: 0.4rem 0;
  }
  .code-user { text-align: center; }
  .code-user .who { font-size: 0.9rem; }
  .code-user .meta { font-size: 0.7rem; }
  .code-age { text-align: center; min-width: 0; font-size: 0.65rem; }
  .code-copy { width: 100%; padding: 0.8rem; font-size: 0.8rem; }

  /* AUDIT FILTER — stack dropdowns */
  .audit-filter-bar {
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.9rem 1rem;
  }
  .filter-group { width: 100%; min-width: 0; }
  .filter-group select {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.7rem 0.8rem;
  }
  .filter-apply {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.8rem;
    height: auto;
  }

  /* Audit rows — table becomes stacked card */
  table { font-size: 0.75rem; }
  table th, table td { padding: 0.4rem 0.5rem; }

  /* PREFERENCES — tighter cards, larger toggles */
  .pref-card { padding: 1.2rem 1.1rem; margin-bottom: 1rem; }
  .pref-card h3 { font-size: 1.05rem; }
  .pref-row {
    padding: 0.7rem 0;
    flex-wrap: nowrap;
    gap: 0.8rem;
  }
  .pref-label {
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
  }
  .pref-label .desc { font-size: 0.78rem; }
  .toggle { width: 50px; height: 26px; }   /* bigger touch target */
  .toggle .knob { width: 22px; height: 22px; top: 2px; left: 2px; }
  .toggle input:checked + .knob { transform: translateX(24px); }

  .quiet-hours {
    flex-direction: column;
    gap: 0.6rem;
    align-items: stretch;
    margin-top: 1rem;
  }
  .quiet-hours label {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.5rem;
  }
  .quiet-hours input[type=time] {
    padding: 0.6rem;
    font-size: 0.95rem;
    flex: 1;
    max-width: 160px;
  }

  .save-bar {
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.9rem;
    text-align: center;
  }
  .save-btn { width: 100%; padding: 0.9rem; font-size: 0.8rem; }
  .save-status { font-size: 0.85rem; }

  /* LEGEND / EXPLAINER cards on operators page */
  .legend-card { padding: 0.9rem 1rem; font-size: 0.9rem; }

  /* WELCOME TOUR — fits phone screen */
  .tour-card {
    max-width: calc(100vw - 24px);
    margin: 0 12px;
    padding: 1.4rem 1.1rem;
  }
  .tour-h { font-size: 1.3rem; }
  .tour-body { font-size: 0.95rem; }
  .tour-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .tour-btn { padding: 0.6rem 0.9rem; font-size: 0.7rem; flex: 1; min-width: 0; }

  /* Form inputs everywhere — prevent iOS zoom on focus */
  input, textarea, select { font-size: 16px !important; }
}

/* ---------- SMALL PHONE (Eva's REVVL 7-class, ≤ 380px) ---------- */
@media (max-width: 380px) {
  section { padding: 1.6rem 0.7rem; }
  .container, .container-narrow { padding: 0 0.2rem; }

  h1, .hero h1 { font-size: 1.7rem !important; }
  h2.section-h, .section-h { font-size: 1.25rem !important; }

  .topbar {
    padding: 0.5rem 0.6rem;
    font-size: 0.55rem;
    letter-spacing: 0.08em;
  }
  .topbar a { font-size: 0.55rem; }

  .live-bell { padding: 3px 7px; font-size: 0.55rem; margin-right: 3px; }

  /* Code value is the hero element — make sure it fits */
  .code-value { font-size: 1.4rem; letter-spacing: 0.25em; }

  /* Stack op-meta to single column on very small screens */
  .op-meta { grid-template-columns: 1fr; gap: 0.5rem; }

  .pref-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .pref-row .toggle { align-self: flex-end; }
}
