:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #6f6a62;
  --border: #e6e1d8;
  --accent: #7a5c3e;
  --accent-text: #ffffff;
  --accent-soft: #f1e9df;
  --danger: #b3261e;
  --warning-bg: #fff4d6;
  --success-bg: #e6f4ea;
  --error-bg: #fde7e7;
  --highlight: rgba(255, 200, 0, 0.45);
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --text: #ece8e1;
    --muted: #a19b91;
    --border: #36322d;
    --accent: #d2ad85;
    --accent-text: #1b1917;
    --accent-soft: #332b22;
    --danger: #ff8a80;
    --warning-bg: #3b3220;
    --success-bg: #1f3325;
    --error-bg: #3d2020;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.error { color: var(--danger); }
.warning { background: var(--warning-bg); padding: 0.25rem 0.5rem; border-radius: 6px; font-size: 0.9rem; margin-top: 0.25rem; }

/* Layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; align-items: center; gap: 1rem; white-space: nowrap; }
.brand { min-width: 0; font-weight: 700; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.narrow { max-width: 640px; margin: 2rem auto; padding: 0 1rem; }
.wide { max-width: 860px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
main.card { padding: 1.5rem; }
.center { text-align: center; }
.lead { font-size: 1.15rem; color: var(--muted); }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row input[type=text] { flex: 1; min-width: 200px; }
.inline { display: inline; }

/* Forms */
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], textarea, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.7rem; width: 100%;
}
input[type=checkbox] { width: auto; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
form p label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
form p:has(input[type=checkbox]) label { display: inline; }
.helptext { display: block; color: var(--muted); font-size: 0.85rem; }
.errorlist { color: var(--danger); padding-left: 1.1rem; margin: 0.25rem 0; }
.upload { display: grid; gap: 0.75rem; }
.upload-cta { margin: 1rem 0 0; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.dropzone { display: grid !important; gap: 0.3rem; justify-items: center; text-align: center; padding: 1.4rem 1rem; border: 2px dashed var(--border); border-radius: 12px; background: var(--bg); cursor: pointer; font-weight: 400 !important; }
.dropzone:hover, #documents.dragover .dropzone { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .dz-text { font-size: 0.98rem; }
#documents.dragover { outline: 2px dashed var(--accent); outline-offset: 4px; }
.dialog.wide { width: min(520px, calc(100vw - 2rem)); }
.upload label { display: grid; gap: 0.25rem; font-weight: 600; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: 8px; padding: 0.55rem 1rem;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.link.danger { color: var(--danger); }

/* Lists */
.list { list-style: none; padding: 0; margin: 0 0 1rem; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li > div { min-width: 0; overflow-wrap: anywhere; }
.list li > a + .muted { margin-left: auto; }
.qa-log { list-style: none; padding: 0; margin: 0; }
.qa-log li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.qa-log summary { cursor: pointer; }
.answer-text { white-space: normal; margin: 0.5rem 0 0 1rem; }

/* Flash messages */
.messages { max-width: 860px; margin: 1rem auto 0; padding: 0 1rem; }
.msg { padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 0.5rem; background: var(--accent-soft); }
.msg.success { background: var(--success-bg); }
.msg.error { background: var(--error-bg); color: inherit; }
.msg.warning { background: var(--warning-bg); }

/* ------------------------------------------------------------------------ */
/* Chat page                                                                 */
/* ------------------------------------------------------------------------ */

body.chat-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.chat-page .messages { position: absolute; top: 3.5rem; left: 0; right: 0; z-index: 5; }
.chat-layout { flex: 1; display: grid; grid-template-columns: minmax(340px, 2fr) 3fr; min-height: 0; }

.chat-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--bg); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.welcome { margin: auto 0; text-align: center; padding: 2rem 1rem; }
.welcome h2 { font-size: 1.3rem; }

.chat-log .msg { max-width: 92%; padding: 0.7rem 0.9rem; border-radius: 14px; margin: 0; }
.msg-user { align-self: flex-end; background: var(--accent); color: var(--accent-text); white-space: pre-wrap; border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-assistant .answer > :first-child { margin-top: 0; }
.msg-assistant .answer > :last-child { margin-bottom: 0; }
.msg-assistant ul, .msg-assistant ol { padding-left: 1.3rem; margin: 0.4rem 0; }

.cite-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.35em; height: 1.35em; padding: 0 0.3em; margin: 0 0.1em;
  font: 600 0.72rem/1 system-ui, sans-serif; vertical-align: 0.15em;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 999px; cursor: pointer;
}
.cite-chip:hover { background: var(--accent); color: var(--accent-text); }
.cite-chip.demo { cursor: default; }

.sources { margin-top: 0.6rem; font-size: 0.88rem; border-top: 1px solid var(--border); padding-top: 0.4rem; }
.sources summary { cursor: pointer; color: var(--muted); }
.sources ol { padding-left: 1.3rem; margin: 0.4rem 0 0; }
.sources li { margin-bottom: 0.35rem; }
.sources q { color: var(--muted); }
.source-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-align: left; }

.typing { display: inline-flex; gap: 4px; padding: 0.3rem 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.ask-form { display: flex; gap: 0.5rem; padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.ask-form textarea { resize: none; max-height: 160px; overflow-y: hidden; }

/* Viewer */
.viewer-pane { display: flex; flex-direction: column; min-height: 0; background: var(--border); }
.viewer-toolbar { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.doc-tabs { display: flex; gap: 0.3rem; overflow-x: auto; flex: 1; }
.doc-tabs.single .doc-tab { pointer-events: none; border-color: transparent; background: none; color: var(--text); font-weight: 600; padding-left: 0.2rem; }
.doc-tab { font: inherit; font-size: 0.9rem; white-space: nowrap; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.doc-tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.close-viewer { display: none; font-weight: 600; white-space: nowrap; }

.pages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.page { position: relative; width: 100%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); flex-shrink: 0; transition: box-shadow 0.3s; }
.page.flash { box-shadow: 0 0 0 3px var(--accent); }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.page-label { position: absolute; top: 45%; width: 100%; text-align: center; color: #999; font-size: 0.9rem; }
.page.rendered .page-label { display: none; }

/* PDF.js text layer (subset of pdfjs-dist/web/pdf_viewer.css v4.10) */
.textLayer {
  position: absolute; inset: 0; overflow: clip; opacity: 1; line-height: 1;
  text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 0;
}
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(0, 100, 255, 0.25); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer span.cite-hl { background: var(--highlight); border-radius: 2px; }

/* Mobile: the document opens as a full-screen sheet */
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-pane { border-right: 0; }
  .viewer-pane {
    position: fixed; inset: 0; z-index: 20; transform: translateY(100%);
    transition: transform 0.25s ease; visibility: hidden;
  }
  .viewer-pane.open { transform: none; visibility: visible; }
  .close-viewer { display: block; }
}
@media (min-width: 901px) {
  #show-doc { display: none; }
}

/* Wedding details: "From binder, p. 3" opens the binder beside the form on a
   wide screen (a sheet on phones, like the chat), with the quote highlighted. */
.qa-page { display: grid; grid-template-columns: minmax(0, 1fr); }
.binder-ref { text-decoration: none; cursor: pointer; }
.binder-ref:hover { background: var(--accent); color: var(--accent-text); }
.close-desktop { display: none; }
@media (min-width: 901px) {
  .qa-page .viewer-pane:not(.open) { display: none; }
  body.viewer-open .qa-page { max-width: 1400px; grid-template-columns: minmax(0, 3fr) minmax(380px, 2fr); gap: 1.5rem; align-items: start; }
  .qa-page .viewer-pane { position: sticky; top: 0.75rem; height: calc(100dvh - 1.5rem); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
  .qa-page .close-viewer { display: block; }
  .qa-page .close-mobile { display: none; }
  .qa-page .close-desktop { display: inline; }
}

.usage { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.usage meter { width: 140px; }

@media (max-width: 600px) {
  h1 { font-size: 1.45rem; }
  .card { padding: 1rem; }
  .list li { flex-wrap: wrap; }
  .list li > a + .muted { margin-left: 0; }
  .row > .btn { flex: 1; text-align: center; }
  .chat-log .msg { max-width: 96%; }
}

/* Space management */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
.stat { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.stat-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-value.small { font-size: 1.1rem; }
.badge { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.processing { font-size: 0.9rem; color: var(--accent); margin-top: 0.25rem; }
.processing::before { content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.4em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -0.1em; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.assistant-form textarea { font-size: 0.95rem; }
.row.between { justify-content: space-between; margin-top: 0.4rem; }
.qa-meta { display: block; font-size: 0.85rem; color: var(--muted); margin-left: 1.1rem; }
.read-mode { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; font-size: 0.9rem; margin-top: 0.3rem; }
.read-mode button.link { font-size: 0.9rem; }

/* Appearance settings */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.6rem; width: 100%; }
.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.preset { display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; font-size: 0.88rem; padding: 0.3rem 0.65rem 0.3rem 0.35rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.preset:hover { border-color: var(--accent); }
.swatch { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; }
.swatch i { width: 0.65rem; height: 0.65rem; border-radius: 50%; }
.color-field { display: flex; gap: 0.5rem; align-items: center; }
.color-field input[type=color] { width: 2.6rem; height: 2.4rem; padding: 0.15rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); flex-shrink: 0; cursor: pointer; }
.theme-preview { border: 1px solid var(--p-border); border-radius: 12px; overflow: hidden; background: var(--p-bg); color: var(--p-text); margin: 0.25rem 0 0.75rem; font-size: 0.9rem; max-width: 420px; }
.tp-bar { padding: 0.5rem 0.8rem; font-family: var(--title-font, Georgia, serif); font-weight: var(--title-weight, 600); font-style: var(--title-style, normal); font-size: calc(1.15rem * var(--title-scale, 1)); background: var(--p-surface); border-bottom: 1px solid var(--p-border); }
.title-font-row { align-items: flex-end; margin: 0.5rem 0; }
.title-font-row p { margin: 0; }
.title-font-row .inline-check { padding-bottom: 0.55rem; }
.map-style-note:empty { display: none; }
.wedding-title { font-family: var(--title-font, Georgia, serif); font-weight: var(--title-weight, 600); font-style: var(--title-style, normal); }
.tp-body { padding: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }
.tp-user { align-self: flex-end; background: var(--p-accent); color: var(--p-accent-text); padding: 0.45rem 0.7rem; border-radius: 12px 12px 4px 12px; }
.tp-bot { align-self: flex-start; background: var(--p-surface); border: 1px solid var(--p-border); padding: 0.45rem 0.7rem; border-radius: 12px 12px 12px 4px; }
.tp-chip { display: inline-block; min-width: 1.3em; margin-left: 0.15em; font-size: 0.72rem; font-weight: 600; text-align: center; color: var(--p-accent); background: var(--p-soft); border: 1px solid var(--p-accent); border-radius: 999px; }
.tp-ask { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.3rem; }
.tp-ask span { flex: 1; padding: 0.4rem 0.6rem; border: 1px solid var(--p-border); border-radius: 8px; opacity: 0.7; }
.tp-ask b { background: var(--p-accent); color: var(--p-accent-text); padding: 0.4rem 0.8rem; border-radius: 8px; }
.usage-card .usage { justify-content: space-between; }
.usage-card .msg { margin: 0.75rem 0 0; }
.usage-card p.muted { margin: 0.4rem 0 0; }
.trial-card h2 { margin-bottom: 0.5rem; }
.trial-form select, .trial-form input, .trial-form textarea { margin-top: 0.2rem; }
.delete-form label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.delete-form .row input { flex: 1; min-width: 180px; }

/* Wedding page */
.card { scroll-margin-top: 1rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
.level-card { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.75rem; background: var(--bg); }
.level-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem; }
.level-card details { margin-top: 0.5rem; }
.level-card summary, .doc-list summary { cursor: pointer; color: var(--accent); font-size: 0.92rem; }

/* Share links: the first card on the wedding page, and the last setting-up step */
.share-card { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.share-card h2 { font-size: 1.35rem; }
.share-link { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem 1rem; align-items: start; padding: 1rem 0; border-top: 1px solid var(--border); text-align: left; }
.share-list > .share-link:first-child { border-top: 0; padding-top: 0.25rem; }
.share-link.off { grid-template-columns: minmax(0, 1fr); color: var(--muted); }
.qr-thumb { grid-row: span 2; padding: 4px; line-height: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.qr-thumb:hover { border-color: var(--accent); }
.qr-thumb img { display: block; width: 72px; height: 72px; }
.share-main { min-width: 0; }
.share-main .level-head { margin-bottom: 0.2rem; }
.share-url { display: block; font-size: 1.05rem; font-weight: 600; color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.share-url:hover { text-decoration: underline; }
.share-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.share-actions .btn { white-space: nowrap; }
.copy-link { display: inline-flex; align-items: center; gap: 0.4rem; }
.copy-link .icon { width: 1.05em; height: 1.05em; }
.level-edit { grid-column: 1 / -1; margin: 0; }
.level-edit summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }
.level-edit summary:hover { color: var(--accent); }
.level-edit form { margin-top: 0.5rem; }
.add-level { margin-top: 1rem; }
.add-level > summary { list-style: none; width: max-content; }
.add-level > summary::-webkit-details-marker { display: none; }
.add-level[open] > summary { margin-bottom: 0.75rem; }
.qr-dialog { text-align: center; }
.qr-dialog img { width: 220px; height: 220px; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.qr-dialog .form-actions { justify-content: center; }
@media (max-width: 600px) {
  .qr-thumb { grid-row: auto; }
  .qr-thumb img { width: 56px; height: 56px; }
  .share-actions { grid-column: 1 / -1; }
  .share-actions .btn { flex: 1; justify-content: center; text-align: center; }
}
.badge.off { background: var(--error-bg); color: var(--danger); }
.add-level .row input[type=text] { flex: 1; min-width: 160px; }
.inline-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.92rem; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.3rem 0; }
.chip { font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.chip.private { background: var(--border); color: var(--muted); }
.doc-list details { margin: 0.3rem 0; }
.doc-list details ul, .levels-field ul { list-style: none; padding: 0; margin: 0.4rem 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.doc-list details label, .levels-field label { display: inline-flex !important; gap: 0.35rem; align-items: center; font-weight: 400 !important; }
.levels-field { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; }
.levels-field legend { font-weight: 600; padding: 0 0.25rem; }
.invite-row { display: grid; gap: 0.4rem; flex: 1; min-width: 0; }
.invite-row .row input { flex: 1; min-width: 0; }
.invite-form label { font-weight: 600; }
.invite-form select { width: auto; }
.chat-page .ask-form { padding-bottom: 0.4rem; }
.site-footer { max-width: 860px; margin: 2rem auto 1.5rem; padding: 0 1rem; font-size: 0.85rem; color: var(--muted); text-align: center; }
.prose h2 { margin-top: 1.5rem; }
.prose li { margin-bottom: 0.4rem; }

/* Documents × links table (also used for reviewing sensitive info) */
.table-scroll { overflow-x: auto; }
.access-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.access-table th, .access-table td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.access-table thead th { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-align: center; min-width: 4.5rem; vertical-align: bottom; }
.access-table td { text-align: center; }
.access-table td input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; cursor: pointer; }
.access-table .doc-col { text-align: left; font-weight: 400; min-width: 12rem; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.access-table thead .doc-col { font-weight: 600; }
.access-table .doc-col > a { font-weight: 600; }
.access-table .doc-col > span { display: block; margin-top: 0.2rem; }
.doc-meta { font-size: 0.82rem; color: var(--muted); }
.doc-actions { display: flex !important; flex-wrap: wrap; gap: 0.2rem 0.8rem; font-size: 0.82rem; }
.doc-actions button.link { font-size: 0.82rem; text-align: left; }
.review-table q { display: block; margin: 0.35rem 0; font-style: italic; }
.review-table .doc-col { min-width: 16rem; }
.save-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.save-bar.sticky { position: sticky; bottom: 0; z-index: 3; padding: 0.75rem 1rem; margin: 1rem -1rem 0; background: var(--surface); border-top: 1px solid var(--border); }
.unsaved { color: var(--accent) !important; font-weight: 600; }
.warn-text { color: var(--accent); }
.chip.warn { background: var(--warning-bg); color: var(--text); }

/* Questionnaire */
.qa-item { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.qa-item:last-child { border-bottom: 0; }
.qa-item.missing .qa-label { color: var(--text); }
.qa-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; }
.qa-label { font-weight: 600; }
.qa-item input[type=text], .qa-item textarea { margin-top: 0.3rem; }
.qa-quote { margin-top: 0.35rem; font-size: 0.88rem; }
.qa-quote summary { cursor: pointer; color: var(--accent); }
.qa-quote q { display: block; margin-top: 0.25rem; color: var(--muted); font-style: italic; }
.qa-levels { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; margin-top: 0.4rem; font-size: 0.88rem; }
.qa-levels label { display: inline-flex; align-items: center; gap: 0.3rem; }

/* Delete: out of the way and deliberate */
.danger-zone { margin: 2rem 0 1rem; }
.danger-zone > details > summary { cursor: pointer; color: var(--muted); font-size: 0.92rem; }
.danger-zone .card { margin-top: 0.75rem; }
.delete-form { display: grid; gap: 0.4rem; max-width: 26rem; }
.delete-form label { font-weight: 400 !important; margin-top: 0.4rem; }
.btn.danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.delete-form .btn.danger-outline { margin-top: 0.6rem; justify-self: start; }
.btn.danger-outline:not(:disabled):hover { background: var(--error-bg); }
.upload label.inline-check { display: flex !important; align-items: flex-start; gap: 0.5rem; white-space: normal; }
.upload label.inline-check input { margin-top: 0.3rem; }
@media (max-width: 600px) {
  .access-table .doc-col { min-width: 9.5rem; }
  .review-table .doc-col { min-width: 11rem; }
}

/* Anything marked hidden stays hidden, whatever other rules say. */
[hidden] { display: none !important; }

/* Upload progress overlay */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(20, 18, 16, 0.55); }
.overlay-card { width: 100%; max-width: 22rem; padding: 1.5rem; border-radius: 14px; background: var(--surface); color: var(--text); text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.overlay-card h2 { margin: 0 0 0.25rem; }
.overlay-card p { margin: 0.5rem 0; overflow-wrap: anywhere; }
.overlay-card progress { width: 100%; height: 0.6rem; margin: 0.5rem 0; accent-color: var(--accent); }
.spinner { width: 2.5rem; height: 2.5rem; margin: 0 auto 0.75rem; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }

/* "Your document is ready" notice when a refresh would lose your typing */
/* A short confirmation at the bottom of the screen ("Link copied") */
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; max-width: calc(100vw - 2rem); padding: 0.55rem 1rem; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 0.9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2); opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.show { opacity: 1; }
.share-dialog .form-actions { flex-direction: column; align-items: stretch; }
.share-dialog .form-actions .btn { text-align: center; }
.share-dialog .form-actions .link { align-self: center; margin-top: 0.25rem; }
.ready-banner { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.6rem 0.6rem 1rem; border-radius: 999px; background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2); white-space: nowrap; }

/* Renaming a document in the table */
.rename-row { display: flex !important; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.2rem; }
.rename-row input { flex: 1; min-width: 8rem; padding: 0.35rem 0.5rem; }
.rename-row[hidden], .doc-title[hidden] { display: none !important; }

/* Sign-in pages */
.auth-card { max-width: 440px; }
.auth-title { margin-bottom: 0.4rem; }
.auth-form { display: grid; gap: 0.45rem; margin-top: 0.5rem; }
.auth-form label { font-weight: 600; }
.auth-form .btn, .google-btn { width: 100%; padding: 0.7rem 1rem; border-radius: 10px; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 1rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.google-btn:hover { border-color: var(--accent); }
.auth-or { display: flex; align-items: center; gap: 0.75rem; margin: 1.1rem 0 0.4rem; color: var(--muted); font-size: 0.85rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-password { margin-top: 1rem; font-size: 0.92rem; }
.auth-password summary { cursor: pointer; color: var(--accent); }
.auth-password form { margin-top: 0.75rem; }
.auth-switch { margin: 1.25rem 0 0; text-align: center; color: var(--muted); }
.auth-card form p { margin: 0.75rem 0; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password] { width: 100%; }
main.auth-card { width: calc(100% - 2rem); margin: 2rem auto; }
.auth-card h1 { margin-bottom: 0.5rem; }

/* Buttons that sit together wrap with even spacing, never overlapping. */
.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 1rem; }
.form-actions:empty { display: none; }
.chip.ok { background: var(--success-bg); color: var(--text); }
.email-rows { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.5rem; }
.email-rows li { display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.email-rows label { display: flex !important; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; margin: 0 !important; font-weight: 400 !important; cursor: pointer; }
.email-address { font-weight: 600; overflow-wrap: anywhere; }
.email-add-title { margin-top: 2rem; font-size: 1.1rem; }
@media (max-width: 420px) {
  .topbar nav { gap: 0.75rem; font-size: 0.95rem; }
}

/* QR codes for share links */

/* Form errors sit right under the box they're about */
.field-error { display: block; color: var(--danger); font-size: 0.88rem; margin-top: 0.3rem; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.level-card, .add-level { scroll-margin-top: 1rem; }

/* Plans */
.tiers { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.6rem 0 0.8rem; }
.tier { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.9rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--bg); }
.tier:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tier strong { margin-left: auto; }
.tier input { margin: 0; }
.plan-form p { margin: 0.4rem 0; }
.plan-more { margin-top: 0.6rem; }
@media (max-width: 600px) { .tiers { flex-direction: column; } .tier { width: 100%; box-sizing: border-box; } }

/* Locations (wedding page) */
.manage-map { height: 260px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 0.75rem; }
/* Leaflet stacks its layers at z-index 400+; kept inside the map so the sticky Save bar and section tabs stay on top. */
.manage-map, .mini-map { isolation: isolate; }
.locations-list li { flex-direction: column; align-items: stretch; }
.loc-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; }
.loc-head > div { display: flex; flex-direction: column; gap: 0.1rem; }
.loc-head .badge { white-space: nowrap; }
button.link.loc-edit { margin-left: 0.45rem; padding: 0.1rem 0.6rem; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; vertical-align: 0.1em; }
button.link.loc-edit:hover { border-color: var(--accent); }
.loc-panel { margin-top: 0.5rem; }
.location-form p { margin: 0.5rem 0; }
.addr-check.ok { color: #2e6b3a; }
.addr-check:empty { display: none; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; }
.pin span { transform: rotate(45deg); color: var(--accent-text); font-size: 0.78rem; font-weight: 700; }
.style-preview { height: 220px; margin-top: 0.5rem; }
#id_map_style { max-width: 320px; }

/* Questionnaire: not-applicable and custom questions */
.qa-na { margin-left: auto; font-size: 0.82rem; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 0.3rem; }
.qa-item.na > :not(.qa-head) { display: none; }
.qa-item.na .qa-label { text-decoration: line-through; color: var(--muted); }
.qa-remove { font-size: 0.82rem; margin-left: 0.5rem; }
.qa-hidden summary { cursor: pointer; font-weight: 600; }
.qa-na-row { display: block; padding: 0.3rem 0; }
.qa-top { margin-bottom: 0.5rem; }
.qa-top p { margin: 0; }
.dialog { border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem 1.5rem; width: min(440px, calc(100vw - 2rem)); box-shadow: 0 12px 40px rgba(0,0,0,0.18); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgba(0,0,0,0.35); }
.dialog h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }
.dialog p { margin: 0 0 0.75rem; }
.dialog label { display: block; margin-bottom: 0.25rem; font-weight: 600; }
.dialog input[type=text] { width: 100%; box-sizing: border-box; }
.page-save { margin-left: 0; margin-right: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.unsaved { color: var(--accent); font-weight: 600; }
.mini-map { height: 150px; margin-top: 0.4rem; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.mini-map .pin span { font-size: 1rem; line-height: 0; }

/* Setting up a wedding: one question per card, big buttons. */
.start { max-width: 560px; margin: 2.5rem auto; padding: 0 1rem; text-align: center; }
.start h1 { font-size: 1.6rem; margin-bottom: 0.75rem; }
.start .step { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.25rem; }
.start p { color: var(--text); }
.choices { display: grid; gap: 0.75rem; margin: 1.25rem 0; }
.choice { display: block; width: 100%; padding: 1rem 1.1rem; font: inherit; font-size: 1.05rem; font-weight: 600; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); cursor: pointer; box-shadow: var(--shadow); }
.choice:hover, .choice:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); outline: none; }
.choice small { display: block; font-weight: 400; color: var(--muted); font-size: 0.88rem; margin-top: 0.15rem; }
.start form.fields { text-align: left; margin-top: 1rem; }
.start form.fields input[type=text], .start form.fields input[type=date] { width: 100%; box-sizing: border-box; }
.start .form-actions { justify-content: center; }
.start.wide { max-width: 760px; text-align: left; }
.start.wide h1, .start.wide .step, .start.wide .lead { text-align: center; }
.start.wide .lead { margin-bottom: 1.25rem; }
.start .save-bar { display: flex; gap: 1.25rem; align-items: center; justify-content: center; }
.start h2 { margin-top: 1.25rem; }
.start .level-card { text-align: left; }
.link-url { word-break: break-all; color: var(--muted); font-size: 0.92rem; margin: 0 0 0.5rem; }
.add-link { margin: 1rem 0 0.5rem; }
.preset.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.voice-sample { margin: -0.4rem 0 0.9rem; font-size: 0.92rem; }
.voice-sample q { font-style: italic; }
.length-choices .label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.length-choices > div > div { display: inline-block; margin: 0 1.1rem 0.25rem 0; }
.length-choices label { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 400; }
.assistant-form details { margin: 0.25rem 0 1rem; }
.assistant-form summary { cursor: pointer; color: var(--accent); font-size: 0.95rem; }
.add-location { margin-top: 0.75rem; }
.add-location summary { display: inline-flex; list-style: none; }
.add-location summary::-webkit-details-marker { display: none; }
.add-location[open] summary { margin-bottom: 0.75rem; }
/* Every setting-up card is one white card on the page. */
.start .card { padding: 1.5rem 1.25rem; margin: 0; }
.start .card h1 { margin-top: 0; }
.start .card .choice { background: var(--bg); box-shadow: none; }
.start .card .choice:hover, .start .card .choice:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.start .card .card { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 1rem 0 0; margin: 1rem 0 0; }
.start .card .save-bar.sticky { margin: 1rem -1.25rem -1.5rem; padding: 0.75rem 1.25rem; border-radius: 0 0 var(--radius) var(--radius); }
#plan-while h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
