:root {
  --paper: #f6efe4;
  --paper-deep: #ede4d4;
  --ink: #2a1f1a;
  --ink-soft: #5a4a3f;
  --ink-fade: #8a7868;
  --rule: #d7c8b3;
  --rule-soft: #e6dac6;
  --terracotta: #b85c3a;
  --terracotta-deep: #8d4129;
  --sage: #6e7d5d;
  --warning-bg: #f5e3d4;
  --warning-border: #c47b4a;
  --shadow: 0 1px 2px rgba(74, 53, 37, 0.06), 0 8px 24px rgba(74, 53, 37, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Lora', Georgia, serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.12  0 0 0 0 0.10  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 32px 96px;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400;
  color: var(--ink);
  margin: 0;
  line-height: 1.15;
  font-variation-settings: "SOFT" 50;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 350;
  letter-spacing: -0.02em;
  margin-bottom: 0.4em;
}

h2 {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0 0 0.3em;
}

h3 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 1.6em 0 0.4em;
  color: var(--ink);
}

h4 {
  font-size: 1rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink-soft);
  margin: 1.2em 0 0.3em;
}

p { margin: 0 0 1em; }

em, .italic { font-style: italic; }

a {
  color: var(--terracotta-deep);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover { color: var(--terracotta); }

/* Cover */
.cover {
  text-align: center;
  padding: 40px 0 56px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 56px;
}

.cover .eyebrow {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terracotta-deep);
  margin-bottom: 1.2em;
  font-weight: 400;
}

.cover h1 {
  margin-bottom: 0.5em;
}

.cover .subtitle {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink-soft);
  font-weight: 300;
  max-width: 520px;
  margin: 0 auto 1.4em;
  line-height: 1.4;
}

.ornament {
  color: var(--terracotta);
  font-size: 1.3rem;
  letter-spacing: 1.2em;
  margin: 1.8em 0;
  text-align: center;
  user-select: none;
}

/* Section dividers */
.chapter {
  margin: 80px 0 0;
  padding-top: 56px;
  border-top: 1px solid var(--rule);
}

.chapter:first-of-type { border-top: 0; padding-top: 0; }

.chapter-num {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terracotta-deep);
  margin-bottom: 0.6em;
  display: block;
}

.lede {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  color: var(--ink-soft);
  font-style: italic;
  font-weight: 300;
  line-height: 1.55;
  margin: 0.8em 0 1.6em;
  max-width: 60ch;
}

/* Privacy banner */
.privacy {
  background: var(--paper-deep);
  border-left: 3px solid var(--sage);
  padding: 18px 22px;
  margin: 28px 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  border-radius: 2px;
}

.privacy strong { color: var(--ink); }

/* Warnings */
.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 4px;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 0.95rem;
  color: var(--terracotta-deep);
}

.warning strong {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--terracotta-deep);
  margin-bottom: 0.3em;
  letter-spacing: 0.02em;
}

/* Form elements */
.field {
  margin: 18px 0;
}

label {
  display: block;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 400;
}

label .hint {
  font-style: normal;
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  color: var(--ink-fade);
  margin-left: 6px;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="tel"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 251, 244, 0.6);
  border: 1px solid var(--rule);
  border-bottom: 1px solid var(--ink-fade);
  border-radius: 2px;
  font-family: 'Lora', serif;
  font-size: 1rem;
  color: var(--ink);
  transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--terracotta);
  background: #fffbf4;
  box-shadow: 0 1px 0 var(--terracotta);
}

textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.55;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-row.three { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 600px) {
  .field-row, .field-row.three { grid-template-columns: 1fr; }
}

/* Repeating items */
.repeater {
  margin: 18px 0 8px;
}

.item-card {
  background: rgba(255, 251, 244, 0.5);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative;
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--rule);
}

.item-num {
  font-family: 'Fraunces', serif;
  font-style: italic;
  color: var(--terracotta-deep);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Buttons */
button, .btn {
  font-family: 'Fraunces', serif;
  font-size: 0.95rem;
  font-weight: 400;
  padding: 8px 16px;
  border: 1px solid var(--ink-soft);
  background: transparent;
  color: var(--ink);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

button:hover, .btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-add {
  border-color: var(--terracotta);
  color: var(--terracotta-deep);
  font-style: italic;
  margin-top: 8px;
}

.btn-add:hover {
  background: var(--terracotta);
  color: var(--paper);
  border-color: var(--terracotta);
}

.btn-remove {
  border: none;
  background: transparent;
  color: var(--ink-fade);
  font-size: 0.85rem;
  padding: 2px 8px;
  font-style: italic;
}

.btn-remove:hover {
  background: transparent;
  color: var(--terracotta-deep);
}

.btn-danger {
  border-color: var(--terracotta-deep);
  color: var(--terracotta-deep);
}

.btn-danger:hover {
  background: var(--terracotta-deep);
  color: var(--paper);
}

/* Checklist */
.checklist {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule-soft);
}

.checklist li:last-child { border-bottom: 0; }

.checklist input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 4px;
  position: relative;
  transition: all 0.2s;
}

.checklist input[type="checkbox"]:checked {
  background: var(--terracotta);
  border-color: var(--terracotta);
}

.checklist input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  top: -2px;
  left: 3px;
}

.checklist label {
  margin: 0;
  font-style: normal;
  font-family: 'Lora', serif;
  color: var(--ink);
  font-size: 0.98rem;
  cursor: pointer;
  flex: 1;
}

.phase-title {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-style: italic;
  color: var(--terracotta-deep);
  margin: 24px 0 4px;
  font-weight: 400;
}

/* Toolbar */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 239, 228, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
}

.toolbar .save-status {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--sage);
  margin-right: auto;
  padding-left: 8px;
}

.toolbar button {
  font-size: 0.85rem;
  padding: 6px 12px;
}

@media (max-width: 600px) {
  .toolbar { padding: 10px 12px; }
  .toolbar .save-status { width: 100%; text-align: center; margin-bottom: 4px; }
}

/* Resource links */
.resource-list {
  list-style: none;
  padding: 0;
  margin: 14px 0;
}

.resource-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--rule-soft);
  font-size: 0.95rem;
}

.resource-list li:last-child { border-bottom: 0; }

.resource-list strong {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  color: var(--ink);
}

/* Footer */
.footer {
  margin-top: 96px;
  padding-top: 40px;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-fade);
  font-style: italic;
  font-family: 'Fraunces', serif;
}

.footer p { margin: 0.4em 0; }

/* Print styles */
@media print {
  @page { margin: 18mm 16mm; size: A4; }

  body { background: white; color: black; font-size: 10pt; }
  body::before { display: none; }

  .page { max-width: 100%; padding: 0; margin: 0; }

  .toolbar, .btn, button, .no-print { display: none !important; }

  .chapter {
    page-break-before: always;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
  }

  .chapter:first-of-type { page-break-before: auto; }

  .cover {
    page-break-after: always;
    border-bottom: none;
    padding: 100px 0;
  }

  h1, h2, h3 { page-break-after: avoid; }

  .item-card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .privacy, .warning {
    border: 1px solid #999;
    background: #f5f5f5 !important;
    color: #333 !important;
  }

  input, textarea, select {
    border: none;
    border-bottom: 1px solid #999;
    background: transparent !important;
    box-shadow: none;
    padding: 4px 0;
  }

  textarea {
    min-height: 40px;
    border: 1px solid #999;
  }

  a { color: #333; text-decoration: none; }
  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  .checklist input[type="checkbox"] {
    border: 1px solid #333;
  }

  .footer { margin-top: 40px; }
}

/* Small accents */
.small-print {
  font-size: 0.85rem;
  color: var(--ink-fade);
  font-style: italic;
}

.pull-quote {
  font-family: 'Fraunces', serif;
  font-size: 1.4rem;
  font-style: italic;
  font-weight: 300;
  color: var(--ink);
  border-left: 2px solid var(--terracotta);
  padding-left: 24px;
  margin: 32px 0;
  line-height: 1.4;
  font-variation-settings: "SOFT" 100;
}

/* Toolbar accent for paid feature */
.toolbar .btn-accent {
  border-color: var(--terracotta);
  color: var(--terracotta-deep);
}
.toolbar .btn-accent:hover {
  background: var(--terracotta);
  color: var(--paper);
  border-color: var(--terracotta);
}
.sparkle { font-size: 0.8em; color: var(--terracotta); margin-left: 2px; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42, 31, 26, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  padding: 32px 16px;
  overflow-y: auto;
}
.modal-backdrop.open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.modal {
  background: var(--paper);
  border-radius: 4px;
  max-width: 540px;
  width: 100%;
  padding: 36px 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  position: relative;
  margin: auto;
}
.modal::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.12  0 0 0 0 0.10  0 0 0 0.04 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
  border-radius: 4px;
}
.modal > * { position: relative; z-index: 1; }
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--ink-fade);
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1;
  z-index: 2;
}
.modal-close:hover { background: transparent; color: var(--ink); }
.modal h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.7rem;
  font-weight: 400;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.modal .modal-eyebrow {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terracotta-deep);
  margin-bottom: 4px;
  font-weight: 400;
}
.modal p { font-size: 0.96rem; }

.price-block {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 22px 0 8px;
}
.price {
  font-family: 'Fraunces', serif;
  font-size: 2.6rem;
  font-weight: 350;
  color: var(--terracotta-deep);
  line-height: 1;
}
.price-note {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-fade);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 22px;
}
.feature-list li {
  padding: 8px 0 8px 24px;
  position: relative;
  font-size: 0.95rem;
  color: var(--ink);
  border-bottom: 1px dashed var(--rule-soft);
}
.feature-list li:last-child { border-bottom: 0; }
.feature-list li::before {
  content: "✦";
  position: absolute;
  left: 0;
  top: 8px;
  color: var(--terracotta);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}
.btn-primary {
  background: var(--terracotta);
  color: var(--paper);
  border-color: var(--terracotta);
  font-size: 1rem;
  padding: 10px 22px;
}
.btn-primary:hover {
  background: var(--terracotta-deep);
  color: var(--paper);
  border-color: var(--terracotta-deep);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-link {
  background: none;
  border: none;
  color: var(--terracotta-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-style: italic;
  padding: 4px 8px;
}
.btn-link:hover {
  background: none;
  color: var(--terracotta);
}

.passphrase-strength {
  height: 5px;
  background: var(--rule-soft);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
.passphrase-strength-bar {
  height: 100%;
  width: 0;
  background: var(--terracotta);
  transition: width 0.3s, background 0.3s;
}
.passphrase-strength-bar.weak { width: 25%; background: #b03828; }
.passphrase-strength-bar.fair { width: 50%; background: #c47b4a; }
.passphrase-strength-bar.good { width: 75%; background: #8b9a5b; }
.passphrase-strength-bar.strong { width: 100%; background: var(--sage); }
.strength-label {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-fade);
  margin-top: 4px;
  display: block;
  min-height: 1em;
}

.checkbox-warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 3px;
  margin: 18px 0;
  font-size: 0.9rem;
  color: var(--terracotta-deep);
  line-height: 1.5;
}
.checkbox-warning input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--terracotta-deep);
  border-radius: 2px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  background: transparent;
  position: relative;
}
.checkbox-warning input[type="checkbox"]:checked {
  background: var(--terracotta-deep);
}
.checkbox-warning input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  color: var(--paper);
  font-size: 13px;
  top: -3px;
  left: 3px;
  font-weight: 700;
}
.checkbox-warning label {
  margin: 0;
  font-style: normal;
  font-family: 'Lora', serif;
  color: var(--terracotta-deep);
  font-size: 0.9rem;
  cursor: pointer;
  flex: 1;
}

.status-line {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.92rem;
  margin: 10px 0 4px;
  min-height: 1.2em;
}

.modal-divider {
  border: 0;
  border-top: 1px dashed var(--rule);
  margin: 22px 0;
}

.small-muted {
  font-size: 0.85rem;
  color: var(--ink-fade);
  font-style: italic;
  line-height: 1.5;
}

.license-badge {
  display: inline-block;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.78rem;
  padding: 2px 10px;
  background: var(--paper-deep);
  color: var(--sage);
  border-radius: 10px;
  border: 1px solid var(--rule);
  letter-spacing: 0.04em;
}

/* License status bar (below toolbar) */
.license-status-bar {
  text-align: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-fade);
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule-soft);
  background: rgba(237, 228, 212, 0.4);
  position: relative;
  z-index: 5;
}
.license-status-bar a {
  color: var(--terracotta-deep);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 4px;
}
.license-status-bar a:hover { color: var(--terracotta); }
.license-status-bar .activated-mark { color: var(--sage); font-style: normal; }
.license-status-bar .sep {
  color: var(--ink-fade);
  margin: 0 8px;
  opacity: 0.5;
}

/* License info rows in manage modal */
.license-info {
  margin: 18px 0;
  background: var(--paper-deep);
  border-radius: 3px;
  padding: 14px 18px;
}
.license-info-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  padding: 6px 0;
  font-size: 0.92rem;
  border-bottom: 1px dashed var(--rule);
}
.license-info-row:last-child { border-bottom: 0; }
.license-info-row .lbl {
  font-style: italic;
  color: var(--ink-soft);
}
.license-info-row .val {
  font-family: 'Fraunces', serif;
  color: var(--ink);
  word-break: break-all;
}

/* Side table of contents */
.toc {
  position: fixed;
  top: 96px;
  left: 24px;
  width: 200px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 18px 0 18px 16px;
  border-left: 1px solid var(--rule);
  font-size: 0.84rem;
  line-height: 1.5;
  z-index: 5;
}
.toc-title {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-fade);
  margin-bottom: 10px;
}
.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc li { margin: 4px 0; }
.toc a {
  display: block;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 2px 0 2px 10px;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.toc a:hover { color: var(--terracotta-deep); }
.toc a.active {
  color: var(--terracotta-deep);
  border-left-color: var(--terracotta);
}
.toc .toc-num {
  font-family: 'Fraunces', serif;
  font-style: italic;
  color: var(--ink-fade);
  margin-right: 6px;
  font-size: 0.78rem;
}
@media (max-width: 1200px) {
  .toc { display: none; }
}
@media print {
  .toc { display: none; }
}

/* Language picker — flag dropdown */
.lang-picker {
  position: relative;
}
.lang-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--ink-soft);
  font-family: 'Fraunces', serif;
}
.lang-picker-btn:hover { border-color: var(--ink-soft); }
.lang-picker-btn:focus { outline: none; border-color: var(--terracotta); }
.flag {
  display: inline-block;
  width: 22px;
  height: 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 1px;
  vertical-align: middle;
  flex-shrink: 0;
}
.lang-picker-btn .caret {
  font-size: 0.65rem;
  color: var(--ink-fade);
  transition: transform 0.15s;
}
.lang-picker.open .lang-picker-btn .caret { transform: rotate(180deg); }
.lang-picker-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow);
  z-index: 20;
  min-width: 140px;
  padding: 4px 0;
}
.lang-picker.open .lang-picker-menu { display: block; }
.lang-picker-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-size: 0.92rem;
  color: var(--ink);
  line-height: 1.2;
}
.lang-picker-menu button:hover { background: var(--paper-deep); }
.lang-picker-menu button.active { color: var(--terracotta-deep); }

/* Attachments in the encrypt modal */
.attach-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  font-size: 0.9rem;
}
.attach-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 251, 244, 0.5);
  border: 1px solid var(--rule-soft);
  border-radius: 3px;
  margin-bottom: 4px;
}
.attach-list .attach-name { flex: 1; word-break: break-all; }
.attach-list .attach-size {
  color: var(--ink-fade);
  font-style: italic;
  font-size: 0.85rem;
}
.attach-list .attach-remove {
  background: none;
  border: none;
  color: var(--terracotta-deep);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 6px;
}
.attach-total { font-style: italic; color: var(--ink-fade); }
.attach-total.warn { color: var(--terracotta-deep); }

/* Reusable dialog (replaces native confirm/alert) */
.dialog-modal { z-index: 110; }
.dialog-modal .modal { max-width: 460px; }
.dialog-message {
  font-family: 'Lora', serif;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 12px 0 22px;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

/* Per-chapter attachments */
.chapter-attach { margin-top: 8px; }
.chapter-attach .attach-list { margin: 0 0 8px; }
.chapter-attach-btn.locked {
  background: transparent;
  color: var(--terracotta-deep);
  border-style: dashed;
  border-color: var(--terracotta);
}
.chapter-attach-btn.locked:hover {
  background: var(--paper-deep);
  color: var(--terracotta-deep);
}
.chapter-attach-locked-hint {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--ink-fade);
  font-style: italic;
  margin-left: 10px;
}
