:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --border: #d1d9e0;
  --text: #1a1f2e;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --error: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #1a1f2e;
    --border: #2d3748;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: #1e3a5f;
    --error: #f87171;
    --success: #4ade80;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
  flex-shrink: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Center the Clerk sign-in card within the container */
#sign-in-wall {
  display: flex;
  justify-content: center;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 32px;
}

.logo, a.logo {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.logo span { color: var(--text); }
a.logo { text-decoration: none; display: inline-block; }

.tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Note title + date header */
#note-meta {
  text-align: center;
  margin-bottom: 24px;
}

.note-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.note-date {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.note-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.note-inline-input {
  font-size: inherit;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 8px;
  width: 100%;
  max-width: 480px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* API Key */
.key-row {
  display: flex;
  gap: 8px;
}

input[type="password"], input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus { border-color: var(--accent); }

.btn-icon {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover { background: var(--accent-light); color: var(--accent); }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone .upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone p { color: var(--text-muted); font-size: 0.9rem; }
.upload-zone strong { color: var(--accent); }

/* Input buttons row */
.input-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* Thumbnails */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.thumb {
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Primary button */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* Loading */
.loading {
  display: none;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error-msg {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 8px;
  min-height: 20px;
}

/* Results page */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.back-btn:hover { text-decoration: underline; }

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}
.result-text h2 { font-size: 1rem; font-weight: 700; margin: 14px 0 4px; }
.result-text h3 { font-size: 0.9rem; font-weight: 600; margin: 10px 0 4px; }
.result-text p  { margin-bottom: 10px; }
.result-text ul, .result-text ol { padding-left: 20px; margin-bottom: 10px; }
.result-text li { margin-bottom: 3px; }
.result-text strong { font-weight: 600; }
.result-text p:last-child, .result-text li:last-child { margin-bottom: 0; }
.result-text h2:first-child, .result-text h3:first-child { margin-top: 0; }

/* Share button */
.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: transparent;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-share:hover { background: var(--accent); color: #fff; }

/* Edit button */
.btn-edit {
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-edit:hover { border-color: var(--accent); color: var(--accent); }

/* Editable textarea */
.result-textarea {
  width: 100%;
  min-height: 160px;
  padding: 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

.copied-msg {
  font-size: 0.8rem;
  color: var(--success);
  margin-top: 6px;
  min-height: 18px;
}

/* Test harness */
.test-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.test-item:last-child { border-bottom: none; }
.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.badge.pass { background: #dcfce7; color: #15803d; }
.badge.fail { background: #fee2e2; color: #b91c1c; }
.badge.pending { background: #f3f4f6; color: #6b7280; }

@media (max-width: 480px) {
  .thumb-grid { grid-template-columns: repeat(3, 1fr); }
  .btn-share { justify-content: center; }
}

/* ── Image strip (results page) ── */

#images-section {
  margin-bottom: 16px;
}

.images-toggle {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  list-style: none;
}

.images-toggle::marker,
.images-toggle::-webkit-details-marker { display: none; }

.images-toggle::before {
  content: '▶ ';
  font-size: 0.7em;
  transition: transform 0.15s;
  display: inline-block;
}

details[open] .images-toggle::before {
  transform: rotate(90deg);
}

.image-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.image-strip .thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.image-strip .thumb:hover { opacity: 0.8; }

#add-images-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-add-images {
  display: inline-block;
  padding: 5px 12px;
  font-size: 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-add-images:hover { border-color: var(--accent); color: var(--accent); }

.add-images-status {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.image-strip .pdf-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: default;
  background: var(--surface);
  overflow: hidden;
}

.pdf-icon { font-size: 1.5rem; line-height: 1; }

.pdf-name {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
  max-width: 72px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Lightbox ── */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lightbox img {
  max-width: 86vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 6px;
  cursor: zoom-out;
}

.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background 0.15s;
  z-index: 10;
}

.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,0.25); }

.lb-close { top: 16px; right: 16px; font-size: 1rem; }
.lb-prev  { left: 16px; }
.lb-next  { right: 16px; }

/* ── Share options checkboxes ── */

.share-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 8px 0 16px;
}

.share-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* ── Auth user row ── */

.user-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.btn-signout {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.btn-signout:hover { border-color: var(--accent); color: var(--accent); }

/* ── Instructions card ── */

.instructions-card { margin-top: 0; }

.instructions-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.optional-tag {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
}

.instructions-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 0;
}

/* ── Additional notes in summary card ── */

.notes-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.section-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* ── My Notes button (scan page) ── */

.btn-mynotes {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.btn-mynotes:hover { background: var(--accent); color: #fff; }

/* ── Note actions row (results page) ── */

.note-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.note-actions .btn-primary {
  width: auto;
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 20px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid #dc2626;
  border-radius: 20px;
  background: transparent;
  color: #dc2626;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-save:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-save:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── My Notes page ── */

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.notes-search {
  width: 100%;
  padding: 14px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}
.notes-search:focus { border-color: var(--accent); }

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-row {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.05s;
}

.note-row:hover { border-color: var(--accent); }
.note-row:active { transform: scale(0.995); }

.note-row-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 2px;
}

.note-row-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.note-row-snippet {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-empty {
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ── EXIF info under thumbnails ── */

.thumb-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}

.thumb-figure:has(details[open]) { z-index: 50; }

.pub-exclude-btn {
  margin-top: 4px;
  padding: 2px 7px;
  font-size: 0.68rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.pub-exclude-btn:hover { border-color: var(--text-muted); color: var(--text); }

.thumb-delete-btn {
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 0.75rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.4;
}
.thumb-delete-btn:hover { border-color: #f87171; color: #b91c1c; }
@media (prefers-color-scheme: dark) {
  .thumb-delete-btn:hover { border-color: #b91c1c; color: #fca5a5; }
}

.pub-exclude-btn.excluded {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  .pub-exclude-btn.excluded {
    background: #450a0a;
    border-color: #b91c1c;
    color: #fca5a5;
  }
}

.exif-details {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.exif-details summary {
  cursor: pointer;
  user-select: none;
  color: var(--accent);
  font-size: 0.7rem;
  list-style: none;
  white-space: nowrap;
}

.exif-details summary::-webkit-details-marker { display: none; }

.exif-dl {
  position: absolute;
  top: 90px;
  left: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 100;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 3px;
  margin: 0;
}

.exif-dl dt {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.75rem;
}

.exif-dl dd {
  margin: 0;
  color: var(--text);
  font-size: 0.75rem;
  word-break: break-word;
}

.exif-dl a { color: var(--accent); }

/* ── Share link row ── */

#share-link-row {
  margin: 12px 0 0;
}

.share-link-display {
  display: block;
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: underline;
  word-break: break-all;
  margin: 4px 0;
}

.share-link-display:hover { opacity: 0.75; }

/* ── Publish card ── */

.pub-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 4px 0 16px;
}

.pub-opt-group { display: flex; flex-direction: column; gap: 6px; }

.pub-opt-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.pub-opt-checks, .pub-opt-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.pub-opt-checks label, .pub-opt-radios label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.template-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tpl-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.tpl-opt input { display: none; }

.tpl-swatch {
  width: 52px;
  height: 40px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  border: 2px solid var(--border);
  transition: border-color 0.15s;
}

.tpl-opt input:checked + .tpl-swatch { border-color: var(--accent); }

.tpl-minimal { background: #fff; color: #111; font-family: Georgia, serif; font-weight: 300; }
.tpl-bold    { background: #000; color: #fff; font-family: system-ui, sans-serif; font-weight: 900; }
.tpl-magazine { background: #111; color: #fff; font-family: system-ui, sans-serif; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }

.tpl-name {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pub-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.pub-options-locked input[type="checkbox"],
.pub-options-locked input[type="radio"] {
  opacity: 0.45;
  pointer-events: none;
}

.pub-options-locked label {
  opacity: 0.6;
  pointer-events: none;
}

.pub-options-locked select {
  opacity: 0.45;
  pointer-events: none;
}

.pub-visibility-select {
  font-size: 0.85rem;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  width: 100%;
  max-width: 320px;
}

.pub-slug-input {
  font-size: 0.85rem;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  max-width: 320px;
  font-family: monospace;
}
.pub-slug-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  word-break: break-all;
}
.pub-options-locked .pub-slug-input {
  opacity: 0.45;
  pointer-events: none;
}

.share-link-unpublished {
  opacity: 0.45;
}

.share-unpublished-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* ── Settings page ── */

.settings-card { display: flex; flex-direction: column; gap: 20px; }

.setting-row { display: flex; flex-direction: column; gap: 6px; }

.setting-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.setting-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.setting-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.setting-input:focus { border-color: var(--accent); }

.setting-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.settings-status {
  font-size: 0.85rem;
  color: var(--accent);
  min-height: 20px;
}

/* ── Top nav row (My Notes + Settings) ── */

.top-nav-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s;
}
.btn-settings:hover { background: var(--border); }

/* ── Published list page ── */

.pub-body {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 16px;
}

.sp-home-link {
  display: inline-block;
  font-size: 0.85rem;
  color: currentColor;
  text-decoration: underline;
  opacity: 0.6;
  margin-bottom: 12px;
}
.sp-home-link:hover { opacity: 1; }

.sp-nav-link {
  display: inline-block;
  font-size: 1rem;
  color: currentColor;
  text-decoration: none;
  opacity: 0.5;
  padding: 0 0.6em;
  line-height: 1;
}
.sp-nav-link:hover { opacity: 1; }

.sp-corner-btns {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
}
.sp-edit-btn,
.sp-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.07);
  color: #555;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.sp-edit-btn {
  text-decoration: none;
}
.sp-edit-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.14);
}
.sp-share-btn {
  cursor: pointer;
  border: none;
  padding: 0;
}
.sp-share-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.14);
}

/* ── My Notes — thumbnails and published badge ── */

.note-row-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-row-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.note-row-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.note-row-body {
  flex: 1;
  min-width: 0;
}

.note-pub-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: none;
  padding: 1px 0 1px 16px;
  transition: opacity 0.15s;
}

.note-pub-badge:hover { opacity: 0.75; text-decoration: underline; }

/* ── Published list: card grid ── */
/* Visibility filter bar (owner-only) */
.pub-vis-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.pub-vis-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pub-vis-btn:hover { border-color: var(--accent); color: var(--accent); }
.pub-vis-btn.pub-vis-active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

/* Card title row with visibility icon */
.pub-card-title-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 3px;
}
.pub-card-title-row .pub-card-title { margin-bottom: 0; flex: 1; }
.pub-card-vis {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 2px;
}

.pub-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 4px;
}

.pub-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.15s, transform 0.1s;
}
.pub-card:hover { border-color: var(--accent); }
.pub-card:active { transform: scale(0.995); }

.pub-card-hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.pub-card-body {
  padding: 12px 14px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pub-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.3;
}

.pub-card-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.pub-card-snippet {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 4.5em;
  overflow: hidden;
  flex: 1;
}
.pub-card-snippet p,
.pub-card-snippet h2,
.pub-card-snippet h3,
.pub-card-snippet ul,
.pub-card-snippet ol { margin: 0; padding: 0; }
.pub-card-snippet ul,
.pub-card-snippet ol { padding-left: 1.1em; }

.pub-card-thumbs {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pub-card-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
}

/* ════════════════════════════════════════════
   Share / Published page
   ════════════════════════════════════════════ */

#share-view {
  min-height: 100vh;
}

.sp-loading, .sp-error, .sp-auth-wall {
  text-align: center;
  padding: 80px 24px;
  color: #888;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1rem;
}

.sp-auth-prompt {
  margin-bottom: 24px;
  font-size: 1rem;
  color: #555;
}

/* base image gallery (shared across templates) */
.sp-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sp-image {
  height: 220px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sp-image:hover { opacity: 0.88; }

.sp-image-hero {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: opacity 0.15s;
}
.sp-image-hero:hover { opacity: 0.88; }

.sp-image-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sp-image-thumb {
  height: 80px;
  width: auto;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.sp-image-thumb:hover { opacity: 0.88; }

/* shared text element styles (mirrors result-text) */
.sp-text h2 { font-size: 1.1rem; font-weight: 700; margin: 16px 0 6px; }
.sp-text h3 { font-size: 1rem; font-weight: 600; margin: 12px 0 4px; }
.sp-text p  { margin-bottom: 12px; }
.sp-text ul, .sp-text ol { padding-left: 20px; margin-bottom: 12px; }
.sp-text li { margin-bottom: 4px; }
.sp-text strong { font-weight: 700; }
.sp-text p:last-child { margin-bottom: 0; }

/* ── Template: minimal ── */

body[data-template="minimal"] {
  background: #ffffff;
  color: #111111;
  font-family: Georgia, 'Times New Roman', serif;
}

body[data-template="minimal"] #share-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

body[data-template="minimal"] .sp-logo {
  text-align: center;
  padding-bottom: 32px;
}

body[data-template="minimal"] .sp-logo-link {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #111;
  text-decoration: none;
  letter-spacing: -0.5px;
}

body[data-template="minimal"] .sp-logo-link span { color: #888; }

body[data-template="minimal"] .sp-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid #e0e0e0;
}

body[data-template="minimal"] .sp-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 300;
  letter-spacing: -0.5px;
  line-height: 1.25;
  color: #111;
  margin-bottom: 12px;
}

body[data-template="minimal"] .sp-date {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.78rem;
  color: #999;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 4px;
}

body[data-template="minimal"] .sp-section-title {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #aaa;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ececec;
  margin-top: 36px;
}

body[data-template="minimal"] section:first-of-type .sp-section-title { margin-top: 0; }

body[data-template="minimal"] .sp-text {
  font-size: 1rem;
  line-height: 1.8;
  color: #222;
}

body[data-template="minimal"] .sp-images {
  margin-bottom: 28px;
  border-radius: 6px;
  overflow: hidden;
}

body[data-template="minimal"] .sp-footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #ececec;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.75rem;
  color: #ccc;
}

/* ── Template: bold ── */

body[data-template="bold"] {
  background: #ffffff;
  color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
}

body[data-template="bold"] #share-content {
  max-width: 800px;
  margin: 0 auto;
}

body[data-template="bold"] .sp-logo {
  background: #000;
  padding: 14px 32px;
}

body[data-template="bold"] .sp-logo-link {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.5px;
}

body[data-template="bold"] .sp-logo-link span { color: #666; }

body[data-template="bold"] .sp-header {
  background: #000;
  color: #fff;
  padding: 48px 32px 40px;
}

body[data-template="bold"] .sp-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.05;
  color: #fff;
  margin-bottom: 14px;
}

body[data-template="bold"] .sp-date {
  font-size: 0.78rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

body[data-template="bold"] .sp-body {
  padding: 32px 32px 60px;
}

body[data-template="bold"] .sp-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #000;
  border-left: 4px solid #000;
  padding-left: 12px;
  margin-bottom: 14px;
  margin-top: 44px;
}

body[data-template="bold"] section:first-of-type .sp-section-title { margin-top: 0; }

body[data-template="bold"] .sp-text {
  font-size: 1rem;
  line-height: 1.7;
  color: #111;
}

body[data-template="bold"] .sp-images { margin-bottom: 24px; }

body[data-template="bold"] .sp-footer {
  text-align: center;
  padding: 20px 32px;
  background: #f4f4f4;
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 40px;
}

/* ── Template: magazine ── */

body[data-template="magazine"] {
  background: #f8f8f8;
  color: #111;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body[data-template="magazine"] #share-content {
  max-width: 840px;
  margin: 0 auto;
}

body[data-template="magazine"] .sp-logo {
  padding: 16px 40px;
  border-bottom: 2px solid #111;
  background: #fff;
}

body[data-template="magazine"] .sp-logo-link {
  font-size: 0.9rem;
  font-weight: 700;
  color: #111;
  text-decoration: none;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

body[data-template="magazine"] .sp-logo-link span { color: #999; }

body[data-template="magazine"] .sp-header {
  background: #111;
  padding: 52px 40px 44px;
}

body[data-template="magazine"] .sp-title {
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1.5px;
  color: #fff;
  text-transform: uppercase;
  margin-bottom: 16px;
}

body[data-template="magazine"] .sp-date {
  font-size: 0.72rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border-top: 1px solid #333;
  padding-top: 14px;
  margin-top: 4px;
}

body[data-template="magazine"] .sp-body {
  padding: 40px 40px 64px;
  background: #fff;
}

body[data-template="magazine"] .sp-section-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #999;
  margin-bottom: 14px;
  margin-top: 52px;
  padding-top: 18px;
  border-top: 2px solid #111;
}

body[data-template="magazine"] section:first-of-type .sp-section-title {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

body[data-template="magazine"] .sp-text {
  font-size: 1rem;
  line-height: 1.75;
  color: #111;
}

body[data-template="magazine"] .sp-images { margin: 20px 0; }

body[data-template="magazine"] .sp-footer {
  background: #fff;
  text-align: center;
  padding: 28px 0;
  border-top: 1px solid #ddd;
  font-size: 0.7rem;
  color: #bbb;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* force white background on share page regardless of OS dark mode */
@media (prefers-color-scheme: dark) {
  body[data-template] {
    background: #ffffff;
    color: #111111;
  }
}

/* ── EasyMDE editor overrides (results page) ── */
.EasyMDEContainer {
  border: 1px solid var(--accent);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: none;
}
.EasyMDEContainer .editor-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: none;
  border-left: none;
  border-right: none;
  padding: 4px 6px;
  opacity: 1;
}
.EasyMDEContainer .editor-toolbar a,
.EasyMDEContainer .editor-toolbar button {
  color: var(--text-muted) !important;
  border-radius: 4px;
}
.EasyMDEContainer .editor-toolbar a:hover,
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar a.active,
.EasyMDEContainer .editor-toolbar button.active {
  color: var(--accent) !important;
  background: transparent !important;
  border-color: var(--border);
}
.EasyMDEContainer .editor-toolbar i.separator {
  border-color: var(--border);
}
.EasyMDEContainer .CodeMirror {
  background: var(--bg);
  color: var(--text);
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 8px;
  min-height: 140px;
  box-shadow: none;
}
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--text); }
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
  border-left: 1px solid var(--border);
}

/* ── App header (three-zone: hamburger | logo | home) ── */

.app-header {
  position: relative;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  min-height: 48px;
}

/* ── Hamburger nav ── */

#site-nav {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.15s;
}
.hamburger-btn:hover { background: var(--surface); }

.nav-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 168px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav-menu-item {
  padding: 11px 16px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}
.nav-menu-item:hover { background: var(--accent-light); color: var(--accent); }

.nav-signout {
  border-top: 1px solid var(--border);
  color: var(--error);
}
.nav-signout:hover { background: #fff1f1; color: var(--error); }
.nav-menu-divider { height: 1px; background: var(--border); margin: 2px 0; }
@media (prefers-color-scheme: dark) {
  .nav-signout:hover { background: #3d1515; }
}

/* ── Home button (inside .app-header) ── */

.home-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.home-btn:hover { color: var(--accent); background: var(--accent-light); }

/* ── Home button on share/published pages (fixed corner) ── */

.sp-home-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: color 0.15s, background 0.15s;
}
.sp-home-btn:hover { color: var(--accent); background: var(--accent-light); }

/* ── Header-right icon group (My Notes, Published list, Home) ── */

.header-right {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
}

.hdr-icon-btn {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.hdr-icon-btn:hover { color: var(--accent); background: var(--accent-light); }

/* ── Note card action strip ── */

.note-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.note-card-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.note-card-action:hover { color: var(--accent); }
.note-card-action-pub { margin-left: auto; }

/* ── Published page nav cluster (home + my notes) ── */

.pub-nav-btns {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-corner-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.07);
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.sp-corner-btn:hover { opacity: 1; background: rgba(0,0,0,0.12); }
@media (prefers-color-scheme: dark) {
  .sp-corner-btn { background: rgba(255,255,255,0.12); color: #ccc; }
  .sp-corner-btn:hover { background: rgba(255,255,255,0.2); }
}

/* ── Visibility status icon (owner-only, inside .sp-corner-btns) ── */

.sp-vis-status {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.07);
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  cursor: default;
  flex-shrink: 0;
}
@media (prefers-color-scheme: dark) {
  .sp-vis-status { background: rgba(255,255,255,0.12); color: #ccc; }
}

/* ── Notebook filter (notes.html) ── */

.notes-notebook-filter {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 10px;
  cursor: pointer;
}
.notes-notebook-filter:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Notebooks page ── */

.notebooks-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.notebooks-page-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}
.new-notebook-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.new-notebook-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.new-notebook-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.notebooks-list { display: flex; flex-direction: column; gap: 8px; }
.notebooks-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 20px;
  text-align: center;
}
.nb-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.nb-card:hover { border-color: var(--accent); }
.nb-card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.nb-card-info {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.nb-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nb-card-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.nb-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.nb-card-system { opacity: 0.8; border-style: dashed; }
.nb-card-system .nb-card-info { cursor: pointer; }
.nb-controls-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.nb-search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}
.nb-sort-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.nb-btn-active { border-color: var(--accent) !important; color: var(--accent) !important; background: var(--accent-light) !important; }
.nb-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  flex-wrap: wrap;
}
.nb-inline-input {
  flex: 1;
  min-width: 120px;
}
.nb-globe-active { border-color: var(--accent) !important; color: var(--accent) !important; }
.nb-slug-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 10px;
  flex-wrap: nowrap;
  min-width: 0;
}
.nb-slug-row:empty { display: none; }
.nb-slug-link {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.nb-slug-link:hover { color: var(--accent); text-decoration: underline; }
.nb-slug-input {
  flex: 1;
  min-width: 60px;
  font-size: 0.78rem;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
}
.nb-notes-panel {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nb-notes-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  box-sizing: border-box;
}
.nb-notes-search:focus { outline: none; border-color: var(--accent); }
.nb-notes-checklist {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 500;
  white-space: nowrap;
}
.btn-icon-sm {
  padding: 5px 8px;
}

/* ── Notebooks picker (results.html) ── */

.notebooks-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.nb-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.nb-picker-item:hover { background: var(--hover, rgba(0,0,0,0.04)); }
.nb-picker-item input[type="checkbox"] { cursor: pointer; width: 15px; height: 15px; }
.nb-manage-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
}
.nb-manage-link:hover { text-decoration: underline; }
.notebooks-empty-msg {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.notebooks-empty-msg a { color: var(--accent); }

/* ── Help page ── */
.help-intro {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0 0 20px;
}
.help-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}
.help-p {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 8px;
}
.help-p:last-child { margin-bottom: 0; }
.help-list {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  margin: 4px 0 0;
  padding-left: 20px;
}
.help-list li { margin-bottom: 4px; }
.icon-legend { display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.icon-legend-row { display: flex; align-items: center; gap: 12px; }
.icon-legend-icon { flex-shrink: 0; color: var(--text-muted); display: flex; align-items: center; width: 24px; }
.icon-legend-name { font-size: 0.875rem; font-weight: 600; min-width: 90px; color: var(--text); }
.icon-legend-desc { font-size: 0.875rem; color: var(--text-muted); }

/* Reduce top padding for published list page (pub-body) vs share page */
body[data-template="bold"] .pub-body { padding-top: 16px; }
body[data-template="magazine"] .pub-body { padding-top: 20px; }

/* ── Pre-scan thumbnail preview ── */
.pre-scan-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}
.pre-scan-thumb {
  position: relative;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.pre-scan-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}
.pre-scan-pdf {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.pre-scan-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  word-break: break-all;
  max-width: 72px;
}
.pre-scan-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--text-muted);
  color: var(--bg);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.85;
}
.pre-scan-remove:hover { opacity: 1; background: var(--error); }

/* ── Infinite scroll sentinel ── */
.load-sentinel {
  height: 1px;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
}
