/* =========================================================================
   Lodge Helios — Book of Declarations
   Formal masonic aesthetic: deep navy + antique gold + parchment cream.
   Fonts mirror the generated PDF for total brand consistency:
     - Pirata One (blackletter) — the book's title
     - Cinzel (small caps)             — lodge name, section labels
     - EB Garamond                     — body copy, declaration text
   ========================================================================= */

@font-face {
  font-family: 'PirataOne';
  src: url('./assets/fonts/PirataOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('./assets/fonts/Cinzel-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('./assets/fonts/Cinzel-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('./assets/fonts/EBGaramond-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('./assets/fonts/EBGaramond-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('./assets/fonts/EBGaramond-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root,
[data-theme='light'] {
  --color-bg: #f5f0e4;
  --color-surface: #faf7ee;
  --color-surface-2: #fdfbf5;
  --color-surface-offset: #efe8d6;
  --color-surface-offset-2: #e6dcc2;
  --color-surface-dynamic: #ddd0ab;
  --color-divider: #d8cca8;
  --color-border: #c9b985;

  --color-text: #221d3d;
  --color-text-muted: #5a5474;
  --color-text-faint: #9691a8;
  --color-text-inverse: #faf7ee;

  --color-primary: #1f1b4d;
  --color-primary-hover: #14113a;
  --color-primary-active: #0d0b28;
  --color-primary-highlight: #d6d2e6;

  --color-gold: #96741f;
  --color-gold-hover: #7a5c15;
  --color-gold-active: #5f470f;
  --color-gold-highlight: #ecdfb8;

  --color-error: #8c2a3a;
  --color-error-hover: #6f202d;
  --color-error-active: #521721;
  --color-error-highlight: #e5cdd1;

  --color-success: #3c6b2f;
  --color-success-hover: #2c5122;
  --color-success-active: #1e3818;
  --color-success-highlight: #d5e0cd;

  --radius-sm: 0.3rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.9rem;
  --radius-xl: 1.4rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px rgba(30, 24, 60, 0.08);
  --shadow-md: 0 6px 20px rgba(30, 24, 60, 0.14);
  --shadow-lg: 0 18px 48px rgba(30, 24, 60, 0.22);

  --content-narrow: 640px;
  --content-default: 900px;
  --content-wide: 1200px;

  --font-display: 'Cinzel', Georgia, serif;
  --font-blackletter: 'PirataOne', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
}

[data-theme='dark'] {
  --color-bg: #12102a;
  --color-surface: #181533;
  --color-surface-2: #1c1938;
  --color-surface-offset: #201d3d;
  --color-surface-offset-2: #262242;
  --color-surface-dynamic: #2c2850;
  --color-divider: #322d54;
  --color-border: #3c3660;

  --color-text: #ece8f7;
  --color-text-muted: #a9a3c4;
  --color-text-faint: #726c94;
  --color-text-inverse: #14113a;

  --color-primary: #ece8f7;
  --color-primary-hover: #cfc8ea;
  --color-primary-active: #b3aadb;
  --color-primary-highlight: #322d54;

  --color-gold: #d8b45a;
  --color-gold-hover: #e6c778;
  --color-gold-active: #f0d494;
  --color-gold-highlight: #3d3320;

  --color-error: #de8794;
  --color-error-hover: #e8a4ae;
  --color-error-active: #f0bcc4;
  --color-error-highlight: #422730;

  --color-success: #8fc47c;
  --color-success-hover: #a6d494;
  --color-success-active: #bde2ae;
  --color-success-highlight: #263a20;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #12102a;
    --color-surface: #181533;
    --color-surface-2: #1c1938;
    --color-surface-offset: #201d3d;
    --color-surface-offset-2: #262242;
    --color-surface-dynamic: #2c2850;
    --color-divider: #322d54;
    --color-border: #3c3660;
    --color-text: #ece8f7;
    --color-text-muted: #a9a3c4;
    --color-text-faint: #726c94;
    --color-text-inverse: #14113a;
    --color-primary: #ece8f7;
    --color-gold: #d8b45a;
  }
}

:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.25rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
}

/* ---------------------------------------------------------------------- */
/* Chrome: header, theme toggle, layout shell                              */
/* ---------------------------------------------------------------------- */

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
}
.site-header__brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.site-header__brand-text {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-gold);
  text-transform: uppercase;
  line-height: 1.2;
}
.site-header__brand-text span {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-xs);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}
.theme-toggle:hover {
  color: var(--color-gold);
  border-color: var(--color-gold);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge--gold { background: var(--color-gold-highlight); color: var(--color-gold-active, var(--color-gold)); }
.badge--success { background: var(--color-success-highlight); color: var(--color-success); }
.badge--pending { background: var(--color-surface-offset-2); color: var(--color-text-muted); }

main {
  flex: 1;
}

.container {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* ---------------------------------------------------------------------- */
/* Buttons & form controls                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}
.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--gold {
  background: var(--color-gold);
  color: #fbf6e6;
}
.btn--gold:hover { background: var(--color-gold-hover); }
.btn--outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn--outline:hover { border-color: var(--color-gold); color: var(--color-gold); }
.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn--ghost:hover { color: var(--color-text); }
.btn--danger {
  background: transparent;
  border-color: var(--color-error);
  color: var(--color-error);
}
.btn--danger:hover { background: var(--color-error-highlight); }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.field label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.field input,
.field select,
.field textarea {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-base);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px var(--color-gold-highlight);
}
.field textarea { resize: vertical; min-height: 5rem; font-family: var(--font-body); }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 640px) { .field-row-2 { grid-template-columns: 1fr; } }
.field-row-3 { display: grid; grid-template-columns: 1fr 1.4fr 1.4fr; gap: var(--space-4); }
@media (max-width: 640px) { .field-row-3 { grid-template-columns: 1fr; } }
.field-group { margin-bottom: var(--space-4); }
.field-group-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.address-preview {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: normal;
  margin: calc(var(--space-2) * -1) 0 var(--space-4);
}
.address-preview strong { color: var(--color-text); font-weight: 600; font-style: normal; }
.doc-address-fields .field label,
.doc-address-fields .field-group-label { color: var(--color-text-muted); }
.doc-address-fields .field input,
.doc-address-fields .field select {
  font-family: var(--font-body);
  border: none;
  border-bottom: 1px solid var(--color-divider);
  background: transparent;
  border-radius: 0;
  padding: 4px 0;
}
.doc-address-fields .field { margin-bottom: var(--space-3); }
.doc-address-fields .address-preview { color: var(--color-text-muted); }

.form-error {
  background: var(--color-error-highlight);
  color: var(--color-error);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}
.form-note {
  background: var(--color-success-highlight);
  color: var(--color-success);
  border: 1px solid var(--color-success);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

/* ---------------------------------------------------------------------- */
/* Cards, panels, tables (admin)                                           */
/* ---------------------------------------------------------------------- */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.panel-header h1, .panel-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: 0.02em;
  color: var(--color-text);
}

.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}
.tab.is-active { color: var(--color-gold); border-color: var(--color-gold); }
.tab:hover { color: var(--color-text); }

.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th, .data-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}
.data-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.data-table tbody tr:hover { background: var(--color-surface-offset); }
.row-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.candidate-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: 70vh;
  overflow-y: auto;
  padding-right: var(--space-1);
}
.candidate-card {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}
.candidate-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}
.candidate-card-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  letter-spacing: 0.01em;
  color: var(--color-text);
}
.candidate-card-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
}
@media (max-width: 640px) {
  .candidate-card-body { grid-template-columns: 1fr; }
}
.candidate-detail-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.candidate-detail-value {
  font-size: var(--text-sm);
  color: var(--color-text);
  word-break: break-word;
}
.candidate-card-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-muted);
}
.empty-state h3 { font-family: var(--font-display); color: var(--color-text); margin-bottom: var(--space-2); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 24, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin-bottom: var(--space-6);
  color: var(--color-text);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.link-copy {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
}
.link-copy input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: var(--text-sm);
  min-width: 0;
}
.link-copy input:focus { outline: none; }

/* ---------------------------------------------------------------------- */
/* Admin login page                                                        */
/* ---------------------------------------------------------------------- */

.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(circle at 20% 15%, var(--color-surface-offset), transparent 60%),
    var(--color-bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-card img { width: 72px; height: 72px; object-fit: contain; margin-inline: auto; margin-bottom: var(--space-4); }
.login-card h1 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: 0.03em;
  color: var(--color-gold);
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}
.login-card p.subtitle { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: var(--space-6); }
.login-card form { text-align: left; }

/* ---------------------------------------------------------------------- */
/* Landing / home page                                                     */
/* ---------------------------------------------------------------------- */

.landing {
  min-height: 100dvh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background: linear-gradient(180deg, var(--color-bg), var(--color-surface-offset));
}
.landing-card {
  max-width: 640px;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-xl);
  padding: var(--space-16) var(--space-10);
  box-shadow: var(--shadow-lg);
}
.landing-card img.crest { width: 110px; height: 110px; object-fit: contain; margin-inline: auto; margin-bottom: var(--space-6); }
.landing-card h1 {
  font-family: var(--font-blackletter);
  font-size: var(--text-2xl);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.landing-card .lodge-line {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  color: var(--color-gold);
  text-transform: uppercase;
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}
.landing-card p { color: var(--color-text-muted); margin-bottom: var(--space-8); }
.landing-card .divider { margin-block: var(--space-6); }

/* ---------------------------------------------------------------------- */
/* The Declaration document (signing page) — mirrors the PDF layout        */
/* ---------------------------------------------------------------------- */

.doc-shell {
  /* Always render this document as light parchment with dark ink,
     regardless of the viewer's OS/browser dark-mode preference or an
     admin dark-mode toggle elsewhere on the site. Without this, a
     visitor whose system is set to dark mode inherits the dark-theme
     text colors (near-white) on top of the always-light parchment
     card background below, making the declaration unreadable. */
  color-scheme: light;
  --color-bg: #f5f0e4;
  --color-surface: #faf7ee;
  --color-surface-2: #fdfbf5;
  --color-surface-offset: #efe8d6;
  --color-surface-offset-2: #e6dcc2;
  --color-surface-dynamic: #ddd0ab;
  --color-divider: #d8cca8;
  --color-border: #c9b985;
  --color-text: #221d3d;
  --color-text-muted: #5a5474;
  --color-text-faint: #9691a8;
  --color-text-inverse: #faf7ee;
  --color-primary: #1f1b4d;
  --color-primary-hover: #14113a;
  --color-primary-active: #0d0b28;
  --color-primary-highlight: #d6d2e6;
  --color-gold: #96741f;
  --color-gold-hover: #7a5c15;
  --color-gold-active: #5f470f;
  --color-gold-highlight: #ecdfb8;
  --color-error: #8c2a3a;
  --color-error-hover: #6f202d;
  --color-error-active: #521721;
  --color-error-highlight: #e5cdd1;
  --color-success: #3c6b2f;
  --color-success-hover: #2c5122;
  --color-success-active: #1e3818;
  --color-success-highlight: #d5e0cd;
  --shadow-sm: 0 1px 2px rgba(30, 24, 60, 0.08);
  --shadow-md: 0 6px 20px rgba(30, 24, 60, 0.14);
  --shadow-lg: 0 18px 48px rgba(30, 24, 60, 0.22);

  min-height: 100dvh;
  position: relative;
  padding: var(--space-6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.doc-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('./assets/poster.jpg');
  background-size: cover;
  background-position: center;
  z-index: -1;
}
.doc-shell::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 40, 0.12);
  z-index: -1;
}

.parchment {
  width: 100%;
  max-width: 720px;
  margin-block: var(--space-8);
  background: rgba(250, 247, 238, 0.94);
  border: 1.5px solid var(--color-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-8);
  position: relative;
}
.parchment::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid var(--color-gold);
  border-radius: calc(var(--radius-lg) - 4px);
  pointer-events: none;
  opacity: 0.7;
}

.doc-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 1;
}
.doc-corner::before,
.doc-corner::after {
  content: '';
  position: absolute;
  background: var(--color-gold);
  opacity: 0.75;
}
.doc-corner::before { top: 0; left: 0; width: 100%; height: 1.5px; }
.doc-corner::after { top: 0; left: 0; width: 1.5px; height: 100%; }
.doc-corner--tl { top: 18px; left: 18px; }
.doc-corner--tr { top: 18px; right: 18px; transform: scaleX(-1); }
.doc-corner--bl { bottom: 18px; left: 18px; transform: scaleY(-1); }
.doc-corner--br { bottom: 18px; right: 18px; transform: scale(-1, -1); }

.doc-crest { width: 84px; height: 84px; object-fit: contain; margin-inline: auto; margin-bottom: var(--space-4); }
.doc-title {
  font-family: var(--font-blackletter);
  font-size: var(--text-2xl);
  text-align: center;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.doc-lodge-name {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  color: var(--color-gold);
  font-size: var(--text-base);
}
.doc-constitution {
  font-family: var(--font-body);
  font-style: italic;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.doc-register-row { display: flex; justify-content: center; margin-bottom: var(--space-4); }
.doc-register-badge {
  display: inline-block;
  padding: 3px 14px;
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-gold);
}

.doc-preface {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--color-text-muted);
  text-align: center;
  max-width: 560px;
  margin: 0 auto var(--space-5);
}

.doc-section-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold);
  margin-bottom: var(--space-3);
}

.doc-charge {
  border: 1px solid var(--color-divider);
  border-left: 3px solid var(--color-gold);
  border-radius: var(--radius-sm);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  background: rgba(150, 116, 31, 0.05);
}
.doc-charge-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-sm);
  line-height: 1.75;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.doc-charge-attribution {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: right;
}

.doc-attestation {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-4);
  margin-top: var(--space-1);
  margin-bottom: var(--space-5);
}

.doc-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-gold);
  margin-block: var(--space-5);
}
.doc-divider .line { flex: 1; height: 1px; background: var(--color-gold); opacity: 0.6; }

.doc-salutation {
  text-align: center;
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-base);
  margin-bottom: var(--space-2);
}
.doc-salutation-lodge {
  text-align: center;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-primary);
  font-size: var(--text-lg);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: var(--space-2);
}
.doc-order-line {
  text-align: center;
  font-family: var(--font-body);
  font-style: italic;
  margin-bottom: var(--space-6);
}

.doc-declaration {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  max-width: none;
}
.doc-declaration strong { color: var(--color-primary); }
.doc-declaration::first-letter {
  font-family: var(--font-blackletter);
  font-size: 3.4em;
  float: left;
  line-height: 0.68;
  padding-right: 0.1em;
  padding-top: 0.06em;
  color: var(--color-gold);
}

.doc-witness-line {
  font-family: var(--font-body);
  font-style: italic;
  margin-bottom: var(--space-6);
}

.doc-fields { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-6); }
.doc-field { display: flex; flex-direction: column; gap: var(--space-1); }
.doc-field-label {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.doc-field-value {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-primary);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-divider);
  min-height: 1.6em;
}
.doc-field-readonly { color: var(--color-text); font-weight: 700; }

.signature-pad-wrap {
  border: 1px dashed var(--color-gold);
  border-radius: var(--radius-md);
  background: #fff;
  padding: var(--space-2);
}
.signature-pad-wrap canvas {
  width: 100%;
  height: 160px;
  touch-action: none;
  cursor: crosshair;
  border-radius: var(--radius-sm);
  background: #fff;
}
.signature-actions { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-2); gap: var(--space-3); }
.signature-hint { font-size: var(--text-xs); color: var(--color-text-muted); }

.doc-footnote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.doc-submit-row { display: flex; justify-content: center; margin-top: var(--space-8); }

.doc-confirmation {
  text-align: center;
  padding: var(--space-10) var(--space-4);
}
.doc-confirmation h2 {
  font-family: var(--font-blackletter);
  font-size: var(--text-2xl);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}
.doc-confirmation p { color: var(--color-text); margin-bottom: var(--space-6); }

@media (max-width: 640px) {
  .parchment { padding: var(--space-6) var(--space-5); }
  .doc-title { font-size: var(--text-xl); }
  .doc-corner { width: 16px; height: 16px; }
  .doc-corner--tl, .doc-corner--tr { top: 12px; }
  .doc-corner--bl, .doc-corner--br { bottom: 12px; }
  .doc-corner--tl, .doc-corner--bl { left: 12px; }
  .doc-corner--tr, .doc-corner--br { right: 12px; }
  .doc-declaration::first-letter { font-size: 2.6em; }
  .doc-charge { padding: var(--space-4); }
}

/* ---------------------------------------------------------------------- */
/* Utility                                                                  */
/* ---------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; }
.row-between { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; }
.text-muted { color: var(--color-text-muted); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.loading-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-gold);
  animation: spin 0.8s linear infinite;
  margin-inline: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-loading { display: flex; align-items: center; justify-content: center; min-height: 60vh; }

/* ---------------------------------------------------------------------- */
/* Public Book of Declarations (general access flip-book)                  */
/* ---------------------------------------------------------------------- */

.book-page-shell { padding-top: var(--space-8); padding-bottom: var(--space-16); }

.book-intro { max-width: 640px; margin: 0 auto var(--space-8); text-align: center; }
.book-intro h1 { font-family: var(--font-blackletter); font-size: var(--text-2xl); color: var(--color-text); margin-bottom: var(--space-3); }
.book-intro p { color: var(--color-text-muted); }

.book-loading-label { color: var(--color-text-muted); font-size: var(--text-sm); }

.book-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}
.book-toolbar__counter {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  color: var(--color-gold);
  font-size: var(--text-sm);
  min-width: 9rem;
  text-align: center;
}

.book-stage {
  display: flex;
  justify-content: center;
  padding: 0 var(--space-4);
}

.pd-book {
  width: 100%;
  max-width: 960px;
}

.pd-book .page {
  background: #faf7ee;
  overflow: hidden;
}
.pd-book .page.pd-cover {
  background: linear-gradient(160deg, #1f1b4d, #14113a);
}

.pd-page__inner { width: 100%; height: 100%; background: #faf7ee; display: flex; align-items: center; justify-content: center; }
.pd-page__inner img { width: 100%; height: 100%; object-fit: contain; display: block; background: #faf7ee; }

.pd-cover {
  background: linear-gradient(160deg, #1f1b4d, #14113a);
  color: #f5f0e4;
}
.pd-cover__inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-10);
  border: 1px solid rgba(214, 178, 90, 0.5);
  margin: var(--space-3);
}
.pd-cover__crest { width: 84px; height: 84px; object-fit: contain; margin-bottom: var(--space-5); border-radius: 50%; background: #f5f0e4; padding: var(--space-2); }
.pd-cover h2 { font-family: var(--font-blackletter); font-size: var(--text-xl); color: #f5f0e4; margin-bottom: var(--space-2); }
.pd-cover__lodge { font-family: var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: #d8b45a; font-size: var(--text-sm); margin-bottom: var(--space-5); }
.pd-cover__sub { color: #cfc8ea; font-size: var(--text-sm); }
.pd-cover--back p { color: #cfc8ea; max-width: 26rem; margin-top: var(--space-3); }

@media (max-width: 640px) {
  .book-intro h1 { font-size: var(--text-xl); }
  .book-toolbar__counter { min-width: 100%; order: -1; margin-bottom: var(--space-2); }
}

/* ---------------------------------------------------------------------- */
/* Zoom overlay for the public Book of Declarations                       */
/* ---------------------------------------------------------------------- */

.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.zoom-overlay[hidden] { display: none; }

.zoom-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 12, 30, 0.82);
}

.zoom-overlay__panel {
  position: relative;
  z-index: 1;
  max-width: min(1400px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6) var(--space-6);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.zoom-overlay__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zoom-overlay__close:hover { background: var(--color-surface-hover, var(--color-border)); }

.zoom-overlay__body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.zoom-page {
  max-width: min(660px, 90vw);
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #faf7ee;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}

.zoom-loading {
  width: min(480px, 80vw);
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-cover {
  width: min(480px, 80vw);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-10);
  border-radius: 4px;
  background: linear-gradient(160deg, #1f1b4d, #14113a);
  color: #f5f0e4;
}
.zoom-cover .pd-cover__crest { width: 96px; height: 96px; object-fit: contain; margin-bottom: var(--space-5); border-radius: 50%; background: #f5f0e4; padding: var(--space-2); }
.zoom-cover h2 { font-family: var(--font-blackletter); font-size: var(--text-xl); color: #f5f0e4; margin-bottom: var(--space-2); }
.zoom-cover .pd-cover__lodge { font-family: var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: #d8b45a; font-size: var(--text-sm); margin-bottom: var(--space-5); }
.zoom-cover .pd-cover__sub { color: #cfc8ea; font-size: var(--text-sm); }
.zoom-cover--back p { color: #cfc8ea; max-width: 26rem; margin-top: var(--space-3); }

@media (max-width: 640px) {
  .zoom-overlay { padding: var(--space-3); }
  .zoom-overlay__panel { padding: var(--space-8) var(--space-3) var(--space-3); }
  .zoom-page { max-width: 92vw; max-height: 74vh; }
}
