/* Deck OS: the page family outside the house sees (chat, family tree, photos). No inline styles anywhere: the
   outside page runs under a strict Content-Security-Policy. */
:root { --bg: #0b0e13; --panel: #141922; --panel-2: #1b2230; --line: #263042; --text: #e8edf5; --muted: #93a0b4;
  --accent: #6f9bff; --accent-text: #fff; --good: #4fd18b; --bad: #ff6b6b; --warn: #f2c14e; }
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f6fa; --panel: #fff; --panel-2: #eef1f6; --line: #d9dfe8; --text: #141a24; --muted: #5b6678;
    --accent: #2f5fe0; --good: #168a4a; --bad: #c62828; --warn: #9a6a00; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); padding: 10px 16px; min-height: 44px; }
button.go { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 650; }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: default; }
input, textarea, select { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); min-height: 44px; }
label { display: block; margin: 12px 0 4px; font-weight: 600; }
label input, label select { margin-top: 6px; font-weight: 400; }
label.row { display: flex; gap: 10px; align-items: center; font-weight: 400; }
label.row input { width: auto; min-height: 0; margin: 0; }
.muted { color: var(--muted); font-size: 15px; }
.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 15px; color: var(--bad); }
.msg.good { color: var(--good); }
.hidden { display: none !important; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.narrow { max-width: 460px; margin: 28px auto; }
main.card.narrow { margin: 28px 16px; }
@media (min-width: 500px) { main.card.narrow { margin: 40px auto; } }

/* the top bar + tabs */
#top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
#top .bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 820px; margin: 0 auto; }
#top h1 { font-size: 18px; margin: 0; flex: 1; }
#tabs { display: flex; gap: 6px; padding: 0 12px 10px; max-width: 820px; margin: 0 auto; overflow-x: auto; }
#tabs button { flex: 1 0 auto; border-radius: 999px; padding: 8px 14px; min-height: 40px; }
#tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 650; }
.page { max-width: 820px; margin: 0 auto; padding: 14px 16px 120px; }
#offline { background: var(--warn); color: #1a1300; padding: 10px 16px; text-align: center; font-weight: 600; }

/* avatars */
.av { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--panel-2); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.av.big { width: 64px; height: 64px; font-size: 24px; }

/* chat */
#chat-list { display: flex; flex-direction: column; gap: 10px; }
.cm { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.cm.mine { align-self: flex-end; flex-direction: row-reverse; }
.cm .who { font-size: 13px; color: var(--muted); margin: 0 4px 2px; }
.cm .bub { background: var(--panel-2); border: 1px solid var(--line); border-radius: 18px; padding: 9px 13px; white-space: pre-wrap; word-break: break-word; }
.cm.mine .bub { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.cm.sys { align-self: center; max-width: 100%; }
.cm.sys .bub { background: transparent; border-style: dashed; color: var(--muted); font-size: 15px; }
.cm .when { font-size: 12px; color: var(--muted); margin: 2px 6px 0; }
.cm .reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.cm .reacts span { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 14px; }
.cm .reacts span.mine { border-color: var(--accent); }
.cm .tools { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.cm .tools button { min-height: 32px; padding: 2px 10px; font-size: 14px; border-radius: 999px; }
.cm .photos { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.cm .photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 12px; }
.cm .poll li { list-style: none; margin: 4px 0; }
.cm .poll ul { padding: 0; margin: 6px 0 0; }
.cm .poll button { width: 100%; text-align: left; }
.cm .poll button.mine { border-color: var(--accent); }
#chat-form { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px; }
#chat-form .in { display: flex; gap: 8px; max-width: 820px; margin: 0 auto; align-items: flex-end; }
#chat-form textarea { resize: none; min-height: 48px; max-height: 160px; }
#chat-reply { max-width: 820px; margin: 0 auto 6px; font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
#chat-reply button { min-height: 28px; padding: 0 10px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.swatches button { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 50%; }

/* bubble colours (the same names the home screen uses) */
.cm .bub.b-rose { background: #e0466b; border-color: #e0466b; color: #fff; }
.cm .bub.b-coral { background: #ff7a5c; border-color: #ff7a5c; color: #1a0b06; }
.cm .bub.b-tangerine { background: #ff9a1f; border-color: #ff9a1f; color: #1a0f00; }
.cm .bub.b-lemon { background: #ffe14d; border-color: #ffe14d; color: #1d1a00; }
.cm .bub.b-mint { background: #5be0a8; border-color: #5be0a8; color: #04170f; }
.cm .bub.b-teal { background: #17b3a6; border-color: #17b3a6; color: #fff; }
.cm .bub.b-sky { background: #6cc7ff; border-color: #6cc7ff; color: #04131d; }
.cm .bub.b-blue { background: #3d6dff; border-color: #3d6dff; color: #fff; }
.cm .bub.b-grape { background: #8a5cf6; border-color: #8a5cf6; color: #fff; }
.cm .bub.b-pink { background: #ff7ad9; border-color: #ff7ad9; color: #2a0620; }
.cm .bub.b-slate { background: #5b6678; border-color: #5b6678; color: #fff; }
.cm .bub.b-midnight { background: #141a3a; border-color: #2a3570; color: #e8edff; }
.cm .bub.b-snow { background: #ffffff; border-color: #d9dfe8; color: #141a24; }
.cm .bub.b-sunset { background: linear-gradient(135deg, #ff7a5c, #e0466b); border-color: #e0466b; color: #fff; }
.cm .bub.b-ocean { background: linear-gradient(135deg, #17b3a6, #3d6dff); border-color: #3d6dff; color: #fff; }
.cm .bub.b-aurora { background: linear-gradient(135deg, #5be0a8, #8a5cf6); border-color: #8a5cf6; color: #fff; }
.cm .bub.b-candy { background: linear-gradient(135deg, #ff7ad9, #6cc7ff); border-color: #ff7ad9; color: #1d0718; }
.cm .bub.b-gold { background: linear-gradient(135deg, #ffe14d, #ff9a1f); border-color: #ff9a1f; color: #1a0f00; }
.cm .bub.b-galaxy { background: linear-gradient(135deg, #141a3a, #8a5cf6); border-color: #8a5cf6; color: #fff; }
.cm .bub.b-fire { background: linear-gradient(135deg, #ff9a1f, #d62828); border-color: #d62828; color: #fff; }
.cm .bub.b-forest { background: linear-gradient(135deg, #1f7a4a, #5be0a8); border-color: #1f7a4a; color: #fff; }
.cm .bub.b-cotton { background: linear-gradient(135deg, #ffd1ec, #cfe8ff); border-color: #ffd1ec; color: #1d1424; }
.swatches .s-rose { background: #e0466b; } .swatches .s-coral { background: #ff7a5c; } .swatches .s-tangerine { background: #ff9a1f; }
.swatches .s-lemon { background: #ffe14d; } .swatches .s-mint { background: #5be0a8; } .swatches .s-teal { background: #17b3a6; }
.swatches .s-sky { background: #6cc7ff; } .swatches .s-blue { background: #3d6dff; } .swatches .s-grape { background: #8a5cf6; }
.swatches .s-pink { background: #ff7ad9; } .swatches .s-slate { background: #5b6678; } .swatches .s-midnight { background: #141a3a; }
.swatches .s-snow { background: #fff; } .swatches .s-sunset { background: linear-gradient(135deg, #ff7a5c, #e0466b); }
.swatches .s-ocean { background: linear-gradient(135deg, #17b3a6, #3d6dff); } .swatches .s-aurora { background: linear-gradient(135deg, #5be0a8, #8a5cf6); }
.swatches .s-candy { background: linear-gradient(135deg, #ff7ad9, #6cc7ff); } .swatches .s-gold { background: linear-gradient(135deg, #ffe14d, #ff9a1f); }
.swatches .s-galaxy { background: linear-gradient(135deg, #141a3a, #8a5cf6); } .swatches .s-fire { background: linear-gradient(135deg, #ff9a1f, #d62828); }
.swatches .s-forest { background: linear-gradient(135deg, #1f7a4a, #5be0a8); } .swatches .s-cotton { background: linear-gradient(135deg, #ffd1ec, #cfe8ff); }
.swatches .s-none { background: var(--panel-2); }

/* family tree */
.gen { margin: 0 0 16px; }
.gen h3 { font-size: 14px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.gen .people { display: flex; gap: 10px; flex-wrap: wrap; }
.person { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; min-width: 150px; }
.person.me { border-color: var(--accent); }
.person b { display: block; }
.person small { color: var(--muted); }

/* photos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.grid button { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; min-height: 0; background: var(--panel-2); }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.years { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.years button { border-radius: 999px; min-height: 36px; padding: 4px 12px; }
.years button.on { border-color: var(--accent); }
#viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
#viewer img { max-width: 100%; max-height: 74vh; border-radius: 10px; }
#viewer p { color: #fff; text-align: center; }
#viewer .row { display: flex; gap: 10px; }
.addbox { margin: 0 0 14px; }

/* sections + forms */
.section { margin: 0 0 18px; }
.section h2 { font-size: 19px; margin: 0 0 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.me-head { display: flex; gap: 14px; align-items: center; }
.mem { margin: 0 0 14px; }
.mem .photos { display: flex; gap: 6px; flex-wrap: wrap; }
.mem .photos img { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; }
