/**
 * Final Peace - Styles
 *
 * Color Palette:
 * - Primary (Sage Green): #6b9080
 * - Background (Cream): #f6fff8
 * - Text (Near Black): #1a202c
 * - Accent (Light Sage): #a4c3b2
 * - Gray (Slate): #4a5568
 * - Error (Red): #B33A3A
 */

:root {
  /* ===== Heirloom token system =====
     Primitives (c-*) → semantic tokens → back-compat aliases. The old variable
     names (--brass, --cream, --gray, …) are kept as aliases pointing at the new
     semantic tokens, so every existing rule re-themes automatically — including
     dark mode — without being rewritten. */

  /* Primitives */
  --c-paper:#f4ecda;   --c-paper2:#efe5cf;
  --c-vellum:#fbf6ea;  --c-vellum2:#f6efdd;
  --c-ink:#24281f;     --c-ink-soft:#5d5a4b;  --c-ink-faint:#8a8472;
  --c-sage:#3f5a4e;    --c-sage-bright:#5d8071;
  --c-metal:#a8814b;   --c-metal-soft:#c2a674;
  --c-danger:#9a3b32;
  --rule-c:63,90,78;   --shadow-c:58,45,20;

  /* Semantic (light) */
  --bg:var(--c-paper);        --bg-2:var(--c-paper2);
  --surface:var(--c-vellum);  --surface-2:var(--c-vellum2);
  --text:var(--c-ink);        --text-muted:var(--c-ink-soft);  --text-faint:var(--c-ink-faint);
  --accent:var(--c-sage);     --accent-2:var(--c-metal);       --accent-on:#fbf6ea;
  --rule:rgba(var(--rule-c),0.20);   --rule-strong:rgba(var(--rule-c),0.42);
  --overlay:rgba(36,28,14,0.55);
  --shadow-sm:0 1px 2px rgba(var(--shadow-c),.07), 0 2px 6px rgba(var(--shadow-c),.06);
  --shadow-md:0 2px 5px rgba(var(--shadow-c),.08), 0 18px 38px -16px rgba(var(--shadow-c),.26);

  /* Fonts — system stacks only (offline-safe); serif display for the heirloom
     character, humanist sans body, mono for ledgers/figures. */
  --font-display:'Iowan Old Style','Palatino Linotype','Book Antiqua',Palatino,'Hoefler Text',Georgia,'Times New Roman',serif;
  --font-body:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
  --font-ledger:ui-monospace,'SF Mono','Cascadia Code',Consolas,'Roboto Mono',monospace;

  /* Size scale (default = large; senior-first) */
  --scale:1.34;

  /* ===== Back-compat aliases (old names → new semantic tokens) ===== */
  --black:var(--text);
  --brass:var(--accent);
  --green:var(--accent);
  --cream:var(--bg);
  --gold:var(--accent-2);
  --gray:var(--text-muted);
  --white:var(--surface);
  --error:var(--c-danger);
  --success:var(--accent);
}

/* ===== Dark theme — warm, candle-lit (not cold) ===== */
html[data-theme="dark"] {
  --c-paper:#17150f;   --c-paper2:#120f0a;
  --c-vellum:#211d15;  --c-vellum2:#2a251a;
  --c-ink:#ece2c9;     --c-ink-soft:#b6ac92;  --c-ink-faint:#837a64;
  --c-sage:#7fa593;    --c-metal:#cda968;
  --accent-on:#17150f;
  --rule:rgba(200,168,106,0.16);  --rule-strong:rgba(200,168,106,0.32);
  --overlay:rgba(0,0,0,0.66);
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow-md:0 2px 6px rgba(0,0,0,.45), 0 22px 44px -18px rgba(0,0,0,.7);
}

/* ===== Size / low-vision steps ===== */
html[data-size="comfortable"] { --scale:1; }
html[data-size="large"]       { --scale:1.34; }
html[data-size="xlarge"]      { --scale:1.66; }
html { font-size: calc(18px * var(--scale)); }

/* Large + X-large also raise contrast for low-vision users (glaucoma,
   cataracts, diabetic retinopathy): darker text / lighter ground in light,
   brighter text / darker ground in dark, stronger rules. Token overrides. */
html:is([data-size="large"],[data-size="xlarge"]) {
  /* High contrast for low vision, but keep the warm vellum — darken the INK,
     don't bleach the paper. */
  --c-paper:#efe3c8;  --c-paper2:#e7d9ba;
  --c-vellum:#fbf3df; --c-vellum2:#f3e9d2;
  --c-ink:#15130a;    --c-ink-soft:#332f1d;  --c-ink-faint:#4f4936;
  --c-sage:#2f463b;   --c-metal:#7a5a24;
  --rule:rgba(var(--rule-c),0.34);  --rule-strong:rgba(var(--rule-c),0.56);
}
html[data-theme="dark"]:is([data-size="large"],[data-size="xlarge"]) {
  --c-paper:#0d0b07;  --c-paper2:#060503;
  --c-vellum:#1d1a12; --c-vellum2:#272318;
  --c-ink:#fef7e4;    --c-ink-soft:#e0d5b6;  --c-ink-faint:#b4a988;
  --c-sage:#93baa6;   --c-metal:#e0bd76;
  --rule:rgba(200,168,106,0.30);  --rule-strong:rgba(200,168,106,0.52);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--cream);
  color: var(--black);
  min-height: 100vh;
  line-height: 1.6;
}

/* Layout */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.screen {
  display: none;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
header {
  text-align: center;
  padding: 30px 20px 20px 20px;
  margin-bottom: 20px;
}

.header-logo {
  max-width: 240px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
}

/* Partner co-branding (white-label) */
.partner-logo {
  max-width: 320px;
  max-height: 90px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
}

.header-logo--co {
  max-width: 90px;
  margin-top: 4px;
  opacity: 0.85;
}

.powered-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 6px auto 0;
  font-size: 0.7rem;
  color: var(--gray, #708090);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.powered-by-logo {
  height: 22px;
  width: auto;
  border-radius: 4px;
  opacity: 0.9;
}

.partner-contact-card {
  max-width: 520px;
  margin: 0 auto 24px;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 2px solid var(--brass, #6b9080);
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(107, 144, 128, 0.15);
}

.partner-contact-label {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gray, #708090);
  margin-bottom: 8px;
}

.partner-contact-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--black, #1a202c);
  margin-bottom: 4px;
}

.partner-contact-firm {
  font-size: 0.95rem;
  color: var(--gray, #4a5568);
  margin-bottom: 10px;
}

.partner-contact-phone {
  display: inline-block;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--brass, #6b9080);
  text-decoration: none;
  margin: 4px 0;
}

.partner-contact-phone:hover {
  text-decoration: underline;
}

.partner-contact-email {
  display: block;
  font-size: 0.95rem;
  color: var(--brass, #6b9080);
  text-decoration: none;
  margin-top: 4px;
}

.partner-contact-email:hover {
  text-decoration: underline;
}

.logo {
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--brass);
  letter-spacing: 2px;
}

.logo span {
  font-weight: 600;
}

.tagline {
  color: var(--gray);
  font-size: 0.95rem;
  margin-top: 8px;
  font-style: italic;
  letter-spacing: 0.5px;
}

/* Welcome Screen */
.welcome-screen {
  text-align: center;
  padding: 60px 20px;
}

.welcome-screen h1 {
  font-size: 1.8rem;
  font-weight: 400;
  margin-bottom: 20px;
  color: var(--black);
}

.welcome-screen p {
  color: var(--gray);
  margin-bottom: 40px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.choice-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.choice-btn {
  background: transparent;
  border: 2px solid var(--brass);
  color: var(--brass);
  padding: 20px 40px;
  font-size: 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 200px;
}

.choice-btn:hover {
  background: var(--brass);
  color: var(--black);
}

.choice-btn.primary {
  background: var(--brass);
  color: var(--black);
}

.choice-btn.primary:hover {
  background: var(--gold);
}

/* Buttons */
.btn {
  background: var(--brass);
  color: var(--black);
  border: none;
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  margin-right: 8px;
  margin-bottom: 8px;
}

.btn:hover {
  background: var(--gold);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--gray);
  color: var(--gray);
}

.btn-secondary:hover {
  border-color: var(--brass);
  color: var(--brass);
  background: rgba(107, 144, 128, 0.05);
}


.btn-success {
  background: var(--green);
  color: white;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.btn-icon:hover {
  opacity: 1;
}

.btn-show-hide {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  font-size: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--black);
  font-weight: 500;
}

label input[type="checkbox"] {
  margin-right: 8px;
  width: auto;
}

input, textarea, select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--black);
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(107, 144, 128, 0.1);
}

input::placeholder, textarea::placeholder {
  color: var(--gray);
  opacity: 0.6;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

select {
  cursor: pointer;
}

select option {
  background: var(--surface);
  color: var(--black);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card h3 {
  color: var(--brass);
  margin-bottom: 15px;
  font-weight: 500;
}

/* Key display label */
.qr-label {
  color: var(--black);
  font-weight: 600;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* Alerts */
.alert {
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid var(--error);
  color: var(--error);
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid var(--green);
  color: var(--success);
}

.alert-warning {
  background: rgba(193, 154, 107, 0.2);
  border: 1px solid var(--brass);
  color: var(--brass);
}

/* Navigation */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--gray);
  margin-bottom: 20px;
  gap: 2px 0;
}

.nav-tab {
  padding: 12px 16px;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 0.9rem;
  min-height: 44px;
}

.nav-tab:hover {
  color: var(--brass);
}

.nav-tab.active {
  color: var(--brass);
  border-bottom-color: var(--brass);
}

.tab-check {
  display: none;
  margin-right: 2px;
  font-size: 0.75rem;
}

.tab-check.done {
  display: inline;
  color: #28A745;
}

/* Sections */
.section {
  padding: 10px 0;
}

.section h4 {
  color: var(--black);
  font-weight: 500;
  margin-bottom: 15px;
  margin-top: 10px;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 30px 0;
}

/* List Items */
.item-list {
  margin-bottom: 15px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin-bottom: 10px;
}

.list-item-content {
  flex: 1;
}

.list-item-content strong {
  color: var(--black);
}

.list-item-actions {
  display: flex;
  gap: 5px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.modal h2, .modal h3 {
  color: var(--brass);
  margin-bottom: 20px;
  font-weight: 500;
}

/* Action Bar */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

/* Heir View */
.heir-section {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 15px 20px;
  margin-bottom: 15px;
}

.heir-section p {
  margin-bottom: 8px;
}

.heir-section p:last-child {
  margin-bottom: 0;
}

/* Helpers */
.text-center { text-align: center; }
.text-muted { color: var(--gray); }
.text-brass { color: var(--brass); }
.text-green { color: var(--green); }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 15px;
  }
  
  header {
    padding: 30px 15px;
  }
  
  .logo {
    font-size: 2rem;
  }
  
  .choice-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .choice-btn {
    width: 100%;
    max-width: 300px;
  }
  
  .nav-tab {
    padding: 10px 12px;
    font-size: 0.8rem;
  }
  
  .card {
    padding: 16px;
  }
  
  .modal {
    padding: 20px;
  }
  
  .action-bar {
    flex-direction: column;
  }
  
  .action-bar .btn {
    width: 100%;
    margin-right: 0;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
  }

  /* Hide everything by default when printing */
  .no-print, header, .header-logo, .action-bar, .nav-tabs, .btn,
  .tagline, #progress-summary,
  details, .btn-show-hide, .btn-secondary, .btn-status,
  #storage-status, #load-from-usb, .choice-buttons,
  .forgot-pin-link, .welcome-screen, .form-group {
    display: none !important;
  }

  /* Hide all screens */
  .screen {
    display: none !important;
  }

  /* Only show the active screen */
  .screen.active {
    display: block !important;
  }

  .card {
    border: none;
    box-shadow: none;
    background: white;
  }

  #screen-qr-setup .card,
  #screen-heir-view .card {
    page-break-inside: avoid;
  }

  /* On the QR setup screen, show the print button's target content but hide buttons */
  #screen-qr-setup .btn,
  #screen-qr-setup .alert {
    display: none !important;
  }

  #screen-qr-setup .text-center,
  #screen-qr-setup h3,
  #screen-qr-setup h4,
  #screen-qr-setup .qr-container,
  #screen-qr-setup .text-muted {
    display: block !important;
  }

  .heir-section {
    border: 1px solid #ddd;
    background: #f9f9f9;
  }
}

/* Word grid for heir login.
   Generous targets and spacing: stressed heirs and shaky hands must not
   misclick the word next door. */
.word-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.word-grid .word-btn {
  background: #f0f7f4;
  border: 2px solid #d0ddd6;
  border-radius: 8px;
  padding: 16px 10px;
  min-height: 52px;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  letter-spacing: 1px;
}

.word-grid .word-btn:hover {
  border-color: #6b9080;
  background: #e4f0ea;
}

.word-grid .word-btn.selected {
  background: #6b9080;
  border-color: #6b9080;
  color: white;
}

.word-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
  min-height: 36px;
}

.word-selected .word-chip {
  background: #6b9080;
  color: white;
  border-radius: 16px;
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.word-selected .word-chip:hover {
  background: #5a7d6e;
}

.word-selected .word-num {
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

@media (max-width: 480px) {
  .word-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--green);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  font-weight: 500;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Icon buttons */
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Password toggle — styled as a pill button inside the field.
   Sized for older users: large enough to spot and to hit with a tremor. */
.btn-show-hide {
  position: absolute;
  right: 8px;
  top: 34px;
  background: var(--surface-2);
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  padding: 8px 14px;
  min-width: 64px;
  min-height: 42px;
  color: var(--black);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
}

.btn-show-hide:hover {
  background: #e0e0e0;
  color: var(--brass);
  border-color: var(--brass);
}

/* Keep typed text clear of the Show/Hide button */
.form-group:has(.btn-show-hide) input {
  padding-right: 88px;
}

/* Heir view details */
.heir-table {
  width: 100%;
  border-collapse: collapse;
}

.heir-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.heir-table td:first-child {
  color: var(--gray);
  width: 40%;
}

.heir-table code {
  background: rgba(193, 154, 107, 0.2);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  color: var(--brass);
}

.heir-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.heir-item:last-child {
  border-bottom: none;
}

.heir-item strong {
  color: var(--black);
}

.heir-item em {
  color: var(--gray);
  font-style: italic;
}

.heir-message-card {
  background: rgba(45, 90, 61, 0.15);
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
}

.heir-message-card h5 {
  color: var(--green);
  margin-bottom: 12px;
  font-weight: 500;
}

/* Modal actions */
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
  background: var(--gray);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brass);
}

/* Recovery Setup */
.recovery-setup {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.recovery-method {
  margin: 30px 0;
  padding: 20px;
  border: 2px solid var(--rule);
  border-radius: 8px;
  background: #f9f9f9;
}

.recovery-method h3 {
  margin-top: 0;
  color: var(--brass);
}

.recovery-method img {
  display: block;
  margin: 20px auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 8px;
}

.recovery-method button {
  margin: 5px;
}

.recovery-warning {
  margin: 20px 0;
  padding: 15px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  color: #856404;
}

.recovery-instructions {
  margin: 15px 0;
  padding: 15px;
  background: rgba(107, 144, 128, 0.1);
  border-radius: 6px;
}

.recovery-instructions ol {
  margin: 10px 0 0 20px;
  color: var(--gray);
}

.recovery-instructions li {
  margin: 8px 0;
}

/* Recovery Grid */
.recovery-grid-screen {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin: 30px 0;
}

.grid-item {
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s;
  position: relative;
}

.grid-item:hover {
  border-color: var(--brass);
  transform: scale(1.05);
}

.grid-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.recovery-attempts {
  margin: 15px 0;
  padding: 10px;
  background: #fff3cd;
  border-radius: 6px;
  color: #856404;
  font-size: 0.9rem;
}

/* PIN Reset Screen */
.pin-reset-screen {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

.pin-reset-screen h2 {
  color: var(--green);
  text-align: center;
  margin-bottom: 20px;
}

.recovery-success {
  background: #f0fdf4;
  border: 1px solid var(--green);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
  color: var(--green);
}

/* Forgot PIN Link */
.forgot-pin-link {
  display: block;
  text-align: center;
  margin: 15px 0;
  color: var(--brass);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.forgot-pin-link:hover {
  color: var(--gold);
  text-decoration: underline;
}

/* Recovery Options */
.recovery-options {
  display: flex;
  gap: 15px;
  margin: 20px 0;
  justify-content: center;
}

.recovery-option-btn {
  flex: 1;
  padding: 30px 20px;
  background: var(--surface);
  border: 2px solid var(--brass);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.recovery-option-btn:hover {
  background: rgba(107, 144, 128, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.recovery-option-btn h3 {
  margin: 10px 0 5px;
  color: var(--brass);
}

.recovery-option-btn p {
  color: var(--gray);
  font-size: 0.9rem;
}

.recovery-option-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

/* Responsive recovery screens */
@media (max-width: 600px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .grid-item img {
    height: 150px;
  }

  .recovery-method {
    padding: 15px;
  }

  .recovery-options {
    flex-direction: column;
  }

  .recovery-option-btn {
    padding: 20px;
  }

}

/* ===== Welcome Screen Metadata ===== */

.welcome-meta {
  background: rgba(107, 144, 128, 0.1);
  border: 1px solid rgba(107, 144, 128, 0.2);
  border-radius: 10px;
  padding: 18px 24px;
  margin-bottom: 25px;
  text-align: center;
}

.welcome-meta .meta-owner {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--brass);
  margin-bottom: 4px;
}

.welcome-meta .meta-date {
  font-size: 0.85rem;
  color: var(--gray);
}

/* ===== Storage Status Bar ===== */

.storage-status {
  margin-top: 30px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.03);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0 0 8px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--gray);
}

.storage-status .status-connected {
  color: var(--success);
}

.storage-status .status-connected::before {
  content: '\25CF ';
  color: var(--success);
}

.storage-status .status-local::before {
  content: '\25CF ';
  color: #D4AF37;
}

.storage-status .status-empty::before {
  content: '\25CB ';
}

.btn-status {
  background: transparent;
  border: 1px solid var(--brass);
  color: var(--brass);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-status:hover {
  background: var(--brass);
  color: white;
}

/* ===== Access Log ===== */

.access-log-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
}

.log-entry {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.log-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.log-badge.log-owner {
  background: rgba(107, 144, 128, 0.15);
  color: var(--brass);
}

.log-badge.log-heir {
  background: rgba(212, 175, 55, 0.15);
  color: #b8860b;
}

.log-date {
  font-size: 0.8rem;
  color: var(--gray);
}

.log-detail {
  font-size: 0.85rem;
  color: var(--gray);
}

/* ===== Remind Me Checkboxes ===== */

.remind-me-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.remind-me-wrap label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: #4a6b5a;
  cursor: pointer;
  user-select: none;
  margin: 0;
  font-weight: 500;
  white-space: nowrap;
}

.remind-me-wrap input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  accent-color: #d4a017;
}

.remind-me-wrap label:hover {
  color: #d4a017;
}

.remind-me-wrap input[type="checkbox"]:checked + span {
  color: #d4a017;
  font-weight: 500;
}

/* "Don't have one" — a calmer slate than the gold "need to find", since it's a
   settled fact (N/A), not an outstanding to-do. */
.not-present-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.not-present-wrap label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: #64748b;
  cursor: pointer;
  user-select: none;
  margin: 0;
  font-weight: 500;
  white-space: nowrap;
}

.not-present-wrap input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  accent-color: #64748b;
}

.not-present-wrap label:hover {
  color: #475569;
}

.not-present-wrap input[type="checkbox"]:checked + span {
  color: #475569;
  font-weight: 600;
}

/* List-item Edit/Remove buttons — these had NO styling at all, so the "×"
   rendered as a ~20px default browser button: far too small a target for
   older hands. 40px+ tap targets, and the remove button only turns red on
   hover so the list doesn't read as a wall of warnings. */
.btn-small {
  min-width: 44px;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 1.05rem;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  background: #f7fafc;
  color: #4a5568;
  cursor: pointer;
}

.btn-small:hover {
  background: #fff5f5;
  border-color: #e53e3e;
  color: #c53030;
}

/* Reminder Summary Modal */
.reminder-summary-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.reminder-summary {
  background: var(--surface);
  border-radius: 12px;
  padding: 30px;
  max-width: 550px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.reminder-summary h3 {
  color: #d4a017;
  margin-bottom: 6px;
  font-weight: 600;
}

.reminder-summary .reminder-subtitle {
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.reminder-summary .reminder-section {
  margin-bottom: 16px;
}

.reminder-summary .reminder-section h4 {
  color: var(--brass);
  font-size: 0.95rem;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}

.reminder-summary .reminder-item {
  padding: 4px 0 4px 12px;
  font-size: 0.9rem;
  color: var(--black);
  line-height: 1.5;
}

.reminder-summary .reminder-item::before {
  content: '\25A1 ';
  color: #d4a017;
}

.reminder-summary .reminder-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

/* Print styles for reminder summary */
@media print {
  .reminder-summary-overlay {
    position: static;
    background: none;
  }

  .reminder-summary {
    max-width: 100%;
    max-height: none;
    box-shadow: none;
    padding: 20px 0;
  }

  .reminder-summary .reminder-actions {
    display: none !important;
  }

  .reminder-summary .reminder-item::before {
    content: '\25A1 ';
    color: black;
  }

  .reminder-summary h3 {
    color: black;
  }

  .reminder-summary .reminder-section h4 {
    color: #333;
  }
}

/* ===== N/A Toggles ===== */

.na-toggle { margin-bottom: 16px; }
.na-toggle label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: #4a6b5a; cursor: pointer; }
.na-toggle input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.na-collapsed { display: none !important; }

/* ===== Modal Button Sizing ===== */

.modal .btn, .modal .btn-secondary {
  min-height: 44px;
  font-size: 1rem;
}

/* ===== Mobile Navigation ===== */

.mobile-nav-select {
  display: none;
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 2px solid var(--brass);
  border-radius: 8px;
  background: white;
  color: var(--black);
  margin-bottom: 16px;
}

@media (max-width: 700px) {
  .nav-tabs { display: none !important; }
  .mobile-nav-select { display: block; }
}

/* ============================================================
   HEIRLOOM SKIN  —  layered over the components above.
   Later rules win by cascade, so this re-skins without rewriting
   the structural CSS. Everything reads from the token system, so
   it follows light/dark and the three size/contrast steps.
   ============================================================ */

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image: radial-gradient(120% 80% at 50% -8%, rgba(168,129,75,.08), transparent 58%);
  background-attachment: fixed;
}

/* Serif display for the heirloom character */
h1, h2, h3, h4,
.logo, .tagline, .welcome-screen h1, .card h3,
.modal h2, .modal h3 {
  font-family: var(--font-display);
  letter-spacing: 0.005em;
}
.logo { font-weight: 600; }
.tagline { font-style: italic; }

/* Primary buttons — solid accent with cream ink */
.btn, .btn-success {
  background: var(--accent);
  color: var(--accent-on);
  border-radius: 8px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.btn:hover, .btn-success:hover { background: var(--accent-2); color: var(--accent-on); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--text-muted);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--rule-c), .06); }

/* Welcome choices */
.choice-btn { border: 2px solid var(--accent); color: var(--accent); }
.choice-btn:hover, .choice-btn.primary { background: var(--accent); color: var(--accent-on); }
.choice-btn.primary:hover { background: var(--accent-2); }

/* Cards & surfaces with warm depth and hairlines */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card h3 { color: var(--text); font-weight: 600; }

/* List items — document rows with a brass-able accent edge */
.list-item {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.list-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-left-color: var(--accent-2);
}
.list-item-content strong, .list-item strong { color: var(--text); }

/* Inputs */
input, textarea, select {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--rule-c), .16);
}
label { color: var(--text); }

/* Navigation */
.nav-tabs { border-bottom: 1px solid var(--rule-strong); }
.nav-tab { color: var(--text-muted); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.nav-tab:hover { color: var(--text); }
.mobile-nav-select { background: var(--surface); color: var(--text); border-color: var(--accent); }

/* Modals */
.modal {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.modal h2, .modal h3 { color: var(--text); }

/* ===== Composition & rhythm — make it feel like the prototype ===== */

/* The dashboard "chapter" heading */
.card > h3:first-child, #owner-dashboard .card h3 {
  font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em;
}

/* Section sub-headings become refined chapter heads with a hairline rule */
.section h4 {
  font-family: var(--font-display);
  font-size: 1.34rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  margin: 6px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule-strong);
}
.section h4 ~ h4 { margin-top: 34px; }
.section h5 {
  font-family: var(--font-display);
  color: var(--accent);
  font-weight: 600;
  font-size: 1.05rem;
  margin-top: 22px;
}

/* Softer dividers, more air between blocks */
.section-divider, hr.section-divider {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 32px 0;
}
.form-group { margin-bottom: 22px; }
.section > p.text-muted, .section-intro {
  font-size: 1.04rem; line-height: 1.6; margin-bottom: 20px; max-width: 70ch;
}
.card { padding: 30px; margin-bottom: 26px; }
.item-list { margin-bottom: 18px; }
.list-item { padding: 16px 18px; }

/* Roomier nav */
.nav-tabs { gap: 4px 6px; padding-bottom: 4px; margin-bottom: 28px; }
.nav-tab { padding: 12px 18px; font-size: 1rem; }

/* The "+ Add" buttons read as quiet, not heavy */
.section .btn-secondary { margin-top: 4px; }

/* Net Worth Snapshot moved to the BOTTOM of the Financial tab via flex order */
#section-financial.active { display: flex; flex-direction: column; }
.nw-block { order: 99; border-top: 1px solid var(--rule-strong); margin-top: 36px; padding-top: 24px; }

/* ===== Masthead (replaces the emoji + awkward wrap) ===== */
.fp-masthead { line-height: 1.05; }
.fp-eyebrow {
  display: block; font-family: var(--font-body);
  font-size: 0.68rem; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--accent-2); font-weight: 700; margin-bottom: 5px;
}
.fp-wordmark {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.85rem !important; letter-spacing: 0.005em; line-height: 1.05;
  color: var(--text); margin: 0 !important; white-space: nowrap;
}

/* ===== Line-icon navigation (replaces emoji) ===== */
.nav-tab { display: inline-flex; align-items: center; }
.tab-ico {
  width: 17px; height: 17px; flex-shrink: 0; margin-right: 9px;
  stroke: currentColor; opacity: 0.72; transition: opacity .16s ease;
}
.nav-tab.active .tab-ico, .nav-tab:hover .tab-ico { opacity: 1; }
.tab-check { color: var(--accent); font-weight: 700; margin-right: 5px; display: inline-flex; align-items: center; }
.tab-check:empty { display: none; }

/* ===== The control cluster (Theme / Text / Mode) in the header ===== */
.fp-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.fp-seg {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-radius: 999px; padding: 4px; box-shadow: var(--shadow-sm);
}
.fp-seg .fp-seg-label {
  font-size: 0.62rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint); padding-left: 8px; font-weight: 700;
}
.fp-seg button {
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; border: none; background: transparent; color: var(--text-muted);
  padding: 6px 11px; border-radius: 999px; cursor: pointer; transition: all .16s ease; min-height: 0;
}
.fp-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-on); }
.seg-ico { width: 15px; height: 15px; display: block; stroke: currentColor; }
.fp-seg button:hover { color: var(--text); }
.fp-seg button[aria-pressed="true"]:hover { color: var(--accent-on); }

/* ===== Beginner / Expert ===== */
.fp-expert-only { display: none; }
html[data-mode="expert"] .fp-beginner-only { display: none; }
html[data-mode="expert"] .fp-expert-only { display: revert; }
/* Expert collapses the hand-holding: tagged hints, the verbose .tip callouts,
   the Start-Here guide, and section intro blurbs. Field labels, examples in
   placeholders, and the data itself always stay. */
html[data-mode="expert"] .fp-help,
html[data-mode="expert"] .tip,
html[data-mode="expert"] .section-intro,
html[data-mode="expert"] .start-here-card,
html[data-mode="expert"] .suggestion { display: none; }
/* Expert also tightens vertical rhythm a touch */
html[data-mode="expert"] .form-group { margin-bottom: 14px; }

/* ===== Co-location reference cards ("life-adjacent = UI-adjacent") ===== */
.related-ref { margin: 4px 0 20px; }
.related-ref-card {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-2);
  border-radius: 10px;
  padding: 12px 16px;
}
.related-ref-label {
  font-size: 0.72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; margin-bottom: 5px;
}
.related-ref-body { color: var(--text); font-size: 0.92rem; margin: 2px 0; }
.related-ref-body a { color: var(--accent); font-weight: 600; }
.related-ref-card .btn-link {
  background: none; border: none; color: var(--accent); font-weight: 600;
  cursor: pointer; padding: 7px 0 0; font-size: 0.85rem; font-family: var(--font-body);
}
.related-ref-card .btn-link:hover { color: var(--accent-2); text-decoration: underline; }
.related-ref-empty { border-left-color: var(--rule-strong); }
