/* ============================================================
   Brandi Family Archive — app.css
   Warm archival layer over shared-ui adult (dark) tokens.
   ============================================================ */

:root {
  --fa-paper: #14161d;
  --fa-sepia: #c9a86a;
  --fa-sepia-soft: #8a7856;
  --fa-serif: var(--sui-font-display, Georgia, serif);
  --fa-maxw: 1080px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--sui-font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sui-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--sui-text-muted); }
.hint { color: var(--sui-text-muted); font-size: .85rem; margin: 4px 0; }
code { font-family: var(--sui-font-mono); font-size: .85em; background: var(--sui-bg-elevated); padding: 1px 5px; border-radius: 4px; }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15,17,23,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--sui-border);
}
.topbar-inner {
  max-width: var(--fa-maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--sui-text); text-decoration: none; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--fa-sepia); font-size: 1.3rem; }
.brand-name { font-family: var(--fa-serif); font-size: 1.15rem; letter-spacing: .2px; }
.navsearch { flex: 1; min-width: 0; }
.navsearch input {
  width: 100%; max-width: 340px;
  background: var(--sui-bg-card); border: 1px solid var(--sui-border);
  color: var(--sui-text); border-radius: 999px; padding: 7px 14px; font-size: .9rem;
}
.mainnav { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.mainnav a { color: var(--sui-text-muted); font-size: .92rem; padding: 4px 2px; }
.mainnav a:hover { color: var(--sui-text); text-decoration: none; }
.mainnav a.active { color: var(--fa-sepia); }
.whoami { color: var(--sui-text-muted); font-size: .8rem; border-left: 1px solid var(--sui-border); padding-left: 12px; }
.logout { font-size: .82rem; }
.navtoggle { display: none; background: none; border: none; color: var(--sui-text); font-size: 1.4rem; cursor: pointer; }

/* ── Page shell ──────────────────────────────────────────── */
.page { max-width: var(--fa-maxw); margin: 0 auto; padding: 22px 18px 80px; }
.col-narrow { max-width: 720px; margin: 0 auto; }
.col-wide { max-width: var(--fa-maxw); margin: 0 auto; }

.page-title { font-family: var(--fa-serif); font-size: 1.9rem; font-weight: 400; margin: 0 0 4px; line-height: 1.15; }
.section-h { font-family: var(--fa-serif); font-size: 1.15rem; font-weight: 400; color: var(--fa-sepia); margin: 22px 0 10px; }

.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }

.filterbar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.filterbar label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--sui-text-muted); }
.filterbar select { width: auto; min-width: 150px; }
.filterbar-count { margin-left: auto; color: var(--sui-text-muted); font-size: .85rem; align-self: center; }

/* Q&A "Answer a question" panel + prompt-sourced fact rendering */
.qa-panel { border-left: 3px solid var(--fa-sepia); margin-bottom: 16px; }
.qa-eyebrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qa-cat { width: auto; min-width: 0; font-size: .8rem; padding: 4px 8px; }
.qa-question { font-family: var(--fa-serif); font-size: 1.15rem; margin: 8px 0 10px; line-height: 1.3; }
.qa-shuffle { font-size: .82rem; white-space: nowrap; }
.fact-question { display: block; font-style: italic; color: var(--sui-text-muted); font-size: .82rem; margin-bottom: 2px; }
.fact-attrib { color: var(--sui-text-muted); font-size: .74rem; }

.sui-card { background: var(--sui-bg-card); border: 1px solid var(--sui-border); border-radius: 14px; padding: 18px; }
.block { margin-top: 16px; }

/* ── Flashes ─────────────────────────────────────────────── */
.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.35); color: #7ee2bd; }
.flash-error { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.35); color: #fca5a5; }

/* ── Buttons (extend shared-ui) ──────────────────────────── */
.sui-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-size: .92rem; font-weight: 500; cursor: pointer; font-family: inherit; transition: filter .15s, background .15s; }
.sui-btn-sm { padding: 6px 12px; font-size: .84rem; }
.sui-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--sui-text-muted); }
.stack label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--sui-text); }
input[type=text], input[type=password], input[type=search], input[type=file], textarea, select {
  background: var(--sui-bg); border: 1px solid var(--sui-border); color: var(--sui-text);
  border-radius: 9px; padding: 9px 11px; font-size: .95rem; font-family: inherit; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--sui-accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.adder { margin-top: 12px; }
.adder > summary { display: inline-flex; list-style: none; cursor: pointer; }
.adder > summary::-webkit-details-marker { display: none; }
.adder-form { margin-top: 12px; }
.inline-adder { display: inline-block; }

/* ── Auth ────────────────────────────────────────────────── */
.auth-wrap { min-height: 82vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; text-align: center; padding: 34px 28px; }
.auth-mark { font-size: 2.2rem; color: var(--fa-sepia); }
.auth-title { font-family: var(--fa-serif); font-weight: 400; font-size: 1.6rem; margin: 8px 0 2px; }
.auth-sub { color: var(--sui-text-muted); font-size: .9rem; margin: 0 0 20px; }
.auth-card .stack label { text-align: left; }
.auth-card .sui-btn { justify-content: center; margin-top: 6px; }

/* ── Inbox capture ───────────────────────────────────────── */
.capture { padding: 22px; }
.capture-title { font-family: var(--fa-serif); font-weight: 400; font-size: 1.5rem; margin: 0 0 14px; }
.capture-box { min-height: 200px; font-size: 1.05rem; line-height: 1.6; }
.capture-row { display: flex; gap: 12px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.capture-title-in { flex: 1; min-width: 180px; }
.privtoggle { display: inline-flex; align-items: center; gap: 6px; color: var(--sui-text-muted); font-size: .88rem; white-space: nowrap; cursor: pointer; }
.capture-save { width: 100%; justify-content: center; font-size: 1rem; padding: 12px; }
.capture-attach { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--sui-text-muted); }
.capture-personpick { background: var(--sui-bg-elevated); border: 1px solid var(--fa-sepia-soft); border-radius: 10px; padding: 10px 12px; }
.capture-personpick label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; color: var(--fa-sepia); }

.promptcard { border-left: 3px solid var(--fa-sepia); }
.promptcard-eyebrow { color: var(--fa-sepia); font-size: .74rem; text-transform: uppercase; letter-spacing: 1.2px; }
.promptcard-q { font-family: var(--fa-serif); font-size: 1.2rem; margin: 6px 0 10px; line-height: 1.3; }

/* ── Story list rows ─────────────────────────────────────── */
.storylist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.storyrow { display: flex; align-items: center; gap: 8px; }
.storyrow-main { flex: 1; display: flex; flex-direction: column; gap: 3px; background: var(--sui-bg-card); border: 1px solid var(--sui-border); border-radius: 10px; padding: 11px 14px; color: var(--sui-text); }
.storyrow-main:hover { text-decoration: none; border-color: var(--sui-accent); }
.storyrow-title { font-weight: 500; }
.storyrow-meta { font-size: .8rem; color: var(--sui-text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.statuspill { font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--sui-border); }
.status-inbox { color: #9ca3af; }
.status-tagged { color: #7aa2ff; border-color: rgba(122,162,255,.4); }
.status-polished { color: var(--fa-sepia); border-color: rgba(201,168,106,.4); }
.status-final { color: #7ee2bd; border-color: rgba(52,211,153,.4); }
.status-answered { color: #7ee2bd; }
.status-sent { color: #7aa2ff; }
.status-skipped { color: var(--sui-text-muted); }
.privpill, .rolepill { font-size: .7rem; }
.rolepill { background: var(--sui-bg-elevated); color: var(--sui-text-muted); padding: 2px 8px; border-radius: 999px; }

/* ── People grid ─────────────────────────────────────────── */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.personcard { display: flex; gap: 14px; align-items: center; color: var(--sui-text); }
.personcard:hover { text-decoration: none; border-color: var(--sui-accent); }
.personcard-photo { width: 62px; height: 62px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: var(--sui-bg-elevated); display: flex; align-items: center; justify-content: center; }
.personcard-photo img { width: 100%; height: 100%; object-fit: cover; }
.personcard-initial { font-family: var(--fa-serif); font-size: 1.6rem; color: var(--fa-sepia); }
.personcard-initial.big { font-size: 3rem; }
.personcard-name { font-family: var(--fa-serif); font-size: 1.15rem; }
.personcard-nick { color: var(--sui-text-muted); font-size: .85rem; font-style: italic; }
.personcard-bio { font-size: .82rem; color: var(--sui-text-muted); margin-top: 3px; }
.personcard-meta { font-size: .76rem; color: var(--sui-text-muted); margin-top: 5px; }
.memoriam { color: var(--fa-sepia-soft); font-style: italic; }

/* ── Person page ─────────────────────────────────────────── */
.personhead { display: flex; gap: 20px; align-items: flex-start; }
.personhead-photo { width: 110px; height: 110px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--sui-bg-elevated); display: flex; align-items: center; justify-content: center; }
.personhead-photo img { width: 100%; height: 100%; object-fit: cover; }
.personhead-body { flex: 1; min-width: 0; }
.personhead-nick { font-family: var(--fa-serif); font-size: 1.1rem; color: var(--sui-text-muted); font-style: italic; }
.personhead-dates { color: var(--sui-text-muted); font-size: .9rem; margin: 2px 0; }
.personhead-bio { font-style: italic; margin: 8px 0; }
.personhead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--sui-border); margin: 22px 0 16px; overflow-x: auto; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--sui-text-muted); padding: 10px 14px; cursor: pointer; font-family: inherit; font-size: .95rem; white-space: nowrap; }
.tab:hover { color: var(--sui-text); }
.tab.active { color: var(--fa-sepia); border-bottom-color: var(--fa-sepia); }
.tabpanel { display: none; }
.tabpanel.active { display: block; }

.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }

.factgroup { margin-bottom: 14px; }
.factgroup-cat { text-transform: uppercase; font-size: .72rem; letter-spacing: 1px; color: var(--fa-sepia-soft); margin-bottom: 4px; }
.factlist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.factlist li { display: flex; align-items: baseline; gap: 6px; font-size: .95rem; }
.fact-era { color: var(--fa-sepia); font-size: .8rem; font-weight: 500; }
.verbatim-badge { color: var(--fa-sepia); }

.sayings { background: var(--sui-bg-elevated); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; border-left: 3px solid var(--fa-sepia); }
.sayings-label { text-transform: uppercase; font-size: .7rem; letter-spacing: 1.2px; color: var(--fa-sepia); margin-bottom: 8px; }
.saying { font-family: var(--fa-serif); font-size: 1.15rem; font-style: italic; margin: 0 0 8px; line-height: 1.4; display: flex; justify-content: space-between; gap: 8px; }
.saying:last-child { margin-bottom: 0; }

.rellist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rellist li { font-size: .95rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.rel-notes { flex-basis: 100%; font-size: .84rem; color: var(--sui-text-muted); font-style: italic; }

.del-inline { display: inline; }
.del-inline button { background: none; border: none; color: var(--sui-text-muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px; }
.del-inline button:hover { color: var(--sui-error); }

/* ── Story page ──────────────────────────────────────────── */
.storyhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.storyhead-meta { font-size: .82rem; color: var(--sui-text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.viewtoggle { display: inline-flex; background: var(--sui-bg-elevated); border-radius: 10px; padding: 3px; gap: 3px; }
.vt { background: none; border: none; color: var(--sui-text-muted); padding: 6px 16px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: .88rem; }
.vt.active { background: var(--sui-bg-card); color: var(--fa-sepia); }
.vt:disabled { opacity: .4; cursor: not-allowed; }
.storybody { margin: 12px 0; }
.storytext { display: none; white-space: pre-wrap; line-height: 1.7; font-size: 1.05rem; }
.storytext.active { display: block; }
.storyactions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.aitoast { margin: 10px 0; padding: 10px 14px; border-radius: 10px; font-size: .9rem; background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.35); color: #fca5a5; }
.aitoast.busy { background: rgba(122,162,255,.12); border-color: rgba(122,162,255,.35); color: #a9c1ff; }

.extractbox { margin: 14px 0; }
.extract-section { margin-bottom: 14px; }
.extract-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--sui-border); }
.extract-row label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; flex: 1; font-size: .92rem; }
.extract-row .newbadge { color: var(--fa-sepia); font-size: .72rem; border: 1px solid var(--fa-sepia-soft); border-radius: 999px; padding: 1px 7px; }

.taglist { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.taglist li { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.tagform { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tagform select { width: auto; flex: 1; min-width: 130px; }
.linklike { color: var(--sui-accent); cursor: pointer; font-size: .88rem; background: none; border: none; }
.danger-link { color: var(--fa-sepia-soft); }

/* ── Galleries ───────────────────────────────────────────── */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.gallery-item { position: relative; margin: 0; padding: 0; overflow: hidden; border-radius: 10px; }
.gallery-item img { width: 100%; height: 150px; object-fit: cover; display: block; }
.gallery-item figcaption { font-size: .78rem; color: var(--sui-text-muted); padding: 6px 8px; }
.recipe-gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.filechip { display: block; padding: 20px 12px; text-align: center; background: var(--sui-bg-elevated); border-radius: 10px; }
.del-corner { position: absolute; top: 6px; right: 6px; }
.del-corner button { background: rgba(0,0,0,.55); color: #fff; border: none; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; }
.del-corner button:hover { background: var(--sui-error); }

.preserved { white-space: pre-wrap; line-height: 1.6; }
.recipe-notes { font-style: italic; color: var(--sui-text-muted); }
.recipecard { display: block; color: var(--sui-text); }
.recipecard:hover { text-decoration: none; border-color: var(--sui-accent); }
.recipecard-title { font-family: var(--fa-serif); font-size: 1.2rem; }
.recipecard-meta { font-size: .82rem; color: var(--sui-text-muted); margin-top: 3px; }
.recipecard-notes { font-size: .82rem; font-style: italic; color: var(--sui-text-muted); margin-top: 6px; }

/* ── Prompts ─────────────────────────────────────────────── */
.statsrow { display: flex; gap: 16px; color: var(--sui-text-muted); font-size: .85rem; margin-bottom: 6px; flex-wrap: wrap; }
.promptbank { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.promptbank-item { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: var(--sui-bg-card); border: 1px solid var(--sui-border); border-radius: 10px; padding: 10px 14px; }
.promptbank-item.status-answered { opacity: .72; }
.promptbank-item.status-skipped { opacity: .5; }
.promptbank-q { flex: 1; font-size: .95rem; }
.promptbank-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.iconbtn { background: none; border: 1px solid var(--sui-border); color: var(--sui-text-muted); border-radius: 7px; padding: 3px 8px; cursor: pointer; font-size: .78rem; font-family: inherit; }
.iconbtn:hover { color: var(--sui-text); border-color: var(--sui-accent); }
.iconbtn.danger:hover { color: var(--sui-error); border-color: var(--sui-error); }

/* ── Settings ────────────────────────────────────────────── */
.backup-note { border-left: 3px solid var(--sui-warning); }
.backup-note ul { margin: 8px 0; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 14px; text-align: center; }
.statgrid > div { display: flex; flex-direction: column; }
.statnum { font-family: var(--fa-serif); font-size: 1.6rem; color: var(--fa-sepia); }
.statlbl { font-size: .74rem; color: var(--sui-text-muted); text-transform: uppercase; letter-spacing: .5px; }
.statuslist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; }
.ok { color: var(--sui-success); }
.bad { color: var(--sui-error); }
.usertable { width: 100%; margin-bottom: 12px; }
.usertable-actions { display: flex; gap: 8px; align-items: center; }
.inlineform { display: flex; gap: 6px; margin-top: 6px; }

.errorpage { text-align: center; padding-top: 60px; }
.errcode { font-family: var(--fa-serif); font-size: 4rem; color: var(--fa-sepia); }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 760px) {
  .mainnav { display: none; position: absolute; top: 54px; right: 12px; flex-direction: column; align-items: flex-start; background: var(--sui-bg-card); border: 1px solid var(--sui-border); border-radius: 12px; padding: 14px 18px; gap: 12px; box-shadow: var(--sui-shadow-lg); }
  .mainnav.open { display: flex; }
  .whoami { border-left: none; padding-left: 0; }
  .navtoggle { display: block; }
  .navsearch input { max-width: none; }
  .twocol { grid-template-columns: 1fr; gap: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .personhead { flex-direction: column; }
  .page-title { font-size: 1.6rem; }
}

/* ── passkey auth + admin/people (FSA-PUB-M1) ─────────────────────────────── */
.logoutform { display: inline; margin: 0; }
button.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
button.linkbtn:hover { text-decoration: underline; }
.linkbox input[readonly] { width: 100%; font-family: monospace; margin: .4rem 0; }
.personrow { padding: 12px 0; border-top: 1px solid var(--sui-border); }
.personrow:first-of-type { border-top: 0; }
.personhead { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.keyrow { margin: 4px 0 0 4px; font-size: .9rem; }
.rowactions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.statuspill { font-size: .72rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--sui-border); }
.status-active { color: #6fcf97; } .status-invited { color: #f2c94c; } .status-revoked { color: #eb5757; }
.small { font-size: .8rem; }

/* ── viewer role: hide the write controls (the server refuses the writes regardless) ── */
body.readonly .capture,
body.readonly details.adder,
body.readonly .adder-form,
body.readonly form[method="post"]:not(.logoutform):not(.feedbackform) { display: none !important; }
.viewer-note { margin-bottom: 16px; }

/* ── beta feedback widget ─────────────────────────────────────────────────── */
.fbwidget { position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: calc(100vw - 32px); }
.fbwidget summary { list-style: none; cursor: pointer; padding: 8px 14px; border-radius: 99px; font-size: .85rem;
  background: var(--sui-bg-elevated); border: 1px solid var(--sui-border); box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.fbwidget summary::-webkit-details-marker { display: none; }
.fbwidget[open] summary { margin-bottom: 8px; }
.fbwidget .feedbackform { width: 320px; max-width: 100%; padding: 14px; border-radius: 12px;
  background: var(--sui-bg-elevated); border: 1px solid var(--sui-border); box-shadow: 0 6px 24px rgba(0,0,0,.45); }
.fbwidget textarea { width: 100%; }
.fbcount { background: #eb5757; color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 6px; }
.fbrow { padding: 12px 0; border-top: 1px solid var(--sui-border); }
.fbrow.seen { opacity: .55; }
.fbmsg { white-space: pre-wrap; margin: .35rem 0; }
