:root {
  --ground: #F7F3EE;
  --surface: #FFFFFF;
  --ink: #1F1A2B;
  --muted: #5E566B;
  --line: #E6DFD6;
  --line-strong: #DDD4C9;
  --soft: #F1ECE5;
  --brand: #5B2A86;
  --brand-dark: #3F1C5E;
  --brand-tint: #EFE7F7;
  --danger: #B3261E;
  --ok-bg: #EAF3E8;
  --ok-ink: #1F4D1F;
  --note-bg: #FFF6DB;
  --note-ink: #4A3A0C;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid #1D5FA8; outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; font-family: var(--body); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout ------------------------------------------------------------------ */
.shell { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex-grow: 1; min-width: 0; }
.content { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* Brand -------------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 19px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #FFFFFF;
  display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; font-size: 18px;
}

/* Cards and forms --------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
label { font-weight: 700; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.input {
  min-height: 50px; width: 100%; border: 1.5px solid #E3DBD1; border-radius: 14px; padding: 0 14px;
  background: var(--surface); font-size: 17px;
}
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(91, 42, 134, 0.18); }
.input.code { font-size: 26px; letter-spacing: 8px; text-align: center; font-weight: 700; }
.hint { font-size: 14px; color: var(--muted); }
.error { background: #FCE8E6; color: #7A1712; border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.note { background: var(--note-bg); color: var(--note-ink); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.ok { background: var(--ok-bg); color: var(--ok-ink); border-radius: 12px; padding: 12px 14px; font-size: 15px; }

.btn {
  min-height: 50px; border-radius: 25px; border: none; padding: 0 20px; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn-primary { background: var(--brand); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--brand); border: 1.5px solid #D6CBE3; }
.btn-plain { background: var(--soft); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1.5px solid #E8C9C6; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 20px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; padding: 8px 0; color: var(--brand); font-weight: 700; text-decoration: underline; min-height: 44px; }

.segmented { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 24px; background: #EAE3DA; }
.segmented button { min-height: 44px; border: none; border-radius: 20px; background: transparent; color: var(--muted); font-weight: 700; font-size: 15px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(31, 26, 43, 0.12); }

/* Header and sphere ovals ------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; z-index: 5; }
.avatar-btn {
  position: relative; width: 42px; height: 42px; border-radius: 21px; border: none; background: var(--brand-tint); color: var(--brand);
  font-weight: 700; font-size: 14px; padding: 0;
}
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #D12F3A; color: #FFFFFF; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #FFFFFF;
}
.ovals { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 2px; }
.oval-wrap { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; padding: 0; width: 58px; }
.oval {
  width: 58px; height: 40px; border-radius: 20px; color: #FFFFFF; font-weight: 700; font-size: 16px; letter-spacing: 0.02em;
  display: flex; align-items: center; justify-content: center;
}
.oval-wrap[aria-pressed="false"] .oval { filter: grayscale(1); opacity: 0.35; }
.oval-wrap[aria-pressed="true"] .oval { box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4.5px var(--ink); }
.oval-icon { height: 16px; display: flex; align-items: center; color: var(--muted); }
.oval-add { background: var(--soft); color: var(--ink); border: 1.5px dashed #A89E92; filter: none !important; opacity: 1 !important; }

/* Sphere page ------------------------------------------------------------- */
.sphere-head { display: flex; align-items: center; gap: 14px; }
.sphere-head .oval { width: 72px; height: 48px; border-radius: 24px; font-size: 20px; flex-shrink: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 14px; border-bottom: 1px solid #EFE9E1; }
.list-row:last-child { border-bottom: none; }
.face { width: 36px; height: 36px; border-radius: 18px; background: var(--brand-tint); color: var(--brand); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 13px; font-weight: 700; background: var(--soft); color: var(--muted); }
.pill-brand { background: var(--brand-tint); color: var(--brand-dark); }
.pill-wait { background: var(--note-bg); color: var(--note-ink); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.coming { border: 1.5px dashed #CFC4B7; border-radius: 16px; padding: 16px; color: var(--muted); font-size: 15px; background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Color palette ----------------------------------------------------------- */
.palette { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.swatch { height: 44px; border-radius: 22px; border: none; color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4.5px var(--ink); }

/* Sheets (full-screen panels on top) --------------------------------------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--ground); overflow-y: auto; }
.sheet-inner { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.sheet-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; z-index: 1; }
.sheet-head h2 { flex-grow: 1; text-align: center; font-size: 20px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex-shrink: 0; }
.sheet-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); margin-top: auto; }

/* Bottom bar ---------------------------------------------------------------- */
.shell.has-tabs { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); max-width: 560px; margin: 0 auto;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; justify-content: center; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.tab[aria-current="page"] { color: var(--brand); }
.tab-icon { position: relative; display: inline-flex; }
.tab-icon .dot { position: absolute; top: -2px; right: -5px; }
.tab-share { color: var(--ink); }
.share-disc { width: 46px; height: 46px; border-radius: 23px; background: var(--brand); color: #FFFFFF; display: flex; align-items: center; justify-content: center; margin-top: -22px; box-shadow: 0 4px 12px rgba(91, 42, 134, 0.35); border: 3px solid var(--surface); }
.dot { width: 10px; height: 10px; border-radius: 5px; background: #D12F3A; display: inline-block; flex-shrink: 0; }
.oval-menu { background: var(--soft); color: var(--ink); border: 1.5px solid var(--line-strong); filter: none !important; opacity: 1 !important; box-shadow: none !important; }
.oval-icon.small { font-size: 12px; font-weight: 700; white-space: nowrap; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 48px 16px; }
.empty-icon { width: 64px; height: 64px; border-radius: 32px; background: var(--brand-tint); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.small-empty { padding: 32px 16px; }
.center { text-align: center; }

/* Chat list ----------------------------------------------------------------- */
.conv-row {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 10px 14px 10px 12px; text-align: left;
  background: var(--surface); border: none; border-bottom: 1px solid #EFE9E1;
}
.conv-row:last-child { border-bottom: none; }
.conv-row:hover { background: #FBF9F6; }
.conv-bar { width: 6px; align-self: stretch; border-radius: 3px; background: var(--sphere, var(--brand)); flex-shrink: 0; }
.conv-text { display: flex; flex-direction: column; gap: 2px; }
.conv-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-row.unread .conv-preview { color: var(--ink); font-weight: 700; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.sphere-pill { font-size: 12px; font-weight: 700; height: 20px; padding: 0 7px; border-radius: 10px; display: inline-flex; align-items: center; flex-shrink: 0; }
.list-btn { width: 100%; background: var(--surface); border-left: none; border-right: none; border-top: none; text-align: left; }

/* A conversation ------------------------------------------------------------ */
.conv-shell { min-height: 100vh; }
.conv-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px 8px 4px; display: flex; align-items: center; gap: 10px; }
.conv-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { font-weight: 700; }
.live[data-state="live"] { color: #2F6B2F; }
.messages { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px 12px 16px; }
.load-earlier { align-self: center; margin-bottom: 8px; }
.day { align-self: center; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 12px; padding: 3px 10px; margin: 12px 0 6px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; margin-top: 8px; }
.msg.grouped { margin-top: 0; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-name { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 2px 12px; }
.bubble {
  border: none; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px;
  padding: 9px 13px; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; color: var(--ink);
}
.msg.mine .bubble { background: var(--brand); color: #FFFFFF; border-color: var(--brand); border-radius: 18px 18px 6px 18px; }
.bubble.deleted, .msg.mine .bubble.deleted { background: transparent; color: var(--muted); border: 1.5px dashed var(--line-strong); font-style: italic; opacity: 1; }
.msg-time { font-size: 11.5px; color: var(--muted); margin: 2px 8px 0; display: none; }
.msg:last-child .msg-time, .msg:has(+ .msg:not(.grouped)) .msg-time, .msg:has(+ .day) .msg-time { display: block; }
.composer {
  position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.composer-input {
  flex-grow: 1; min-height: 46px; max-height: 160px; resize: none; border: 1.5px solid #E3DBD1; border-radius: 23px; padding: 11px 16px;
  font-size: 17px; line-height: 1.3; background: var(--ground);
}
.composer-input:focus { border-color: var(--brand); outline: none; }
.send-btn { width: 46px; height: 46px; border-radius: 23px; border: none; background: var(--brand); color: #FFFFFF; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.textarea { min-height: 90px; padding: 12px 14px; resize: vertical; }

/* Pop-up actions --------------------------------------------------------------- */
.popup-back { position: fixed; inset: 0; z-index: 40; background: rgba(31, 26, 43, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.popup {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; max-height: 90vh; overflow-y: auto;
}
.popup-quote { background: var(--soft); border-radius: 12px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30vh; overflow-y: auto; }

/* New conversation --------------------------------------------------------------- */
.ovals.picker .oval-wrap { width: 64px; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.person-pick { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 2px; border-radius: 14px; font-size: 14px; font-weight: 700; }
.person-pick .face { width: 52px; height: 52px; border-radius: 26px; font-size: 17px; }
.person-pick[aria-pressed="true"] .face { background: var(--brand); color: #FFFFFF; }
.share-choice { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; opacity: 0.75; }

svg.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.f { fill: currentColor; stroke: none; flex-shrink: 0; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px);
  background: var(--ink); color: #FFFFFF; padding: 12px 18px; border-radius: 14px; font-size: 15px; text-align: center;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Notifications and install ----------------------------------------------------- */
.toggle-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.toggles .toggle-row + .toggle-row { border-top: 1px solid #EFE9E1; padding-top: 10px; }
.switch { width: 52px; height: 32px; border-radius: 16px; border: none; background: #CFC6BB; position: relative; flex-shrink: 0; padding: 0; transition: background 0.15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: left 0.15s; }
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"] .knob { left: 23px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; font-size: 17px; }
.prompt-card { border-color: #D6CBE3; background: #FBF8FE; }
.field input[type="time"] { min-height: 46px; }

/* Plans: calendar ----------------------------------------------------------------- */
.flip svg { transform: rotate(180deg); }
.week, .month { padding: 10px 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.week-days, .mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.day-cell, .mcell {
  border: none; background: transparent; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 7px; min-height: 64px; color: var(--ink);
}
.mcell { min-height: 48px; padding: 5px 0; }
.mcell.out { color: #B4AA9E; }
.dow { font-size: 12px; font-weight: 700; color: var(--muted); }
.dnum { font-weight: 700; font-size: 16px; width: 30px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.today .dnum { background: var(--brand); color: #FFFFFF; }
.day-cell[aria-pressed="true"], .mcell[aria-pressed="true"] { background: var(--brand-tint); }
.dots { display: flex; gap: 3px; height: 7px; }
.cal-dot { width: 7px; height: 7px; border-radius: 4px; }
.mhead span { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.agenda-day { font-size: 15px; color: var(--muted); margin-top: 6px; }
.event-row { align-items: center; }
.ev-time { width: 68px; flex-shrink: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.ev-head { display: flex; gap: 12px; align-items: stretch; }
.ev-head .conv-bar { width: 8px; }
.ev-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-col .field { font-weight: 700; font-size: 15px; }
label.field { font-weight: 700; font-size: 15px; }
select.input { appearance: auto; }

/* "Luxsphera was updated" bar */
#update-bar {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 24px;
  background: var(--ink); color: #FFFFFF; font-weight: 700; font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  max-width: calc(100% - 24px);
}
#update-bar span { white-space: nowrap; }
#update-bar .btn { background: #FFFFFF; color: var(--ink); }

/* Plans: board ---------------------------------------------------------------------- */
.bcard { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--sphere, var(--brand)); border-radius: 16px; padding: 12px 12px 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.bcard-head { display: flex; align-items: flex-start; gap: 10px; }
.bcard-icon { width: 32px; height: 32px; border-radius: 16px; background: var(--soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--ink); }
.bcard-title { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.bcard-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-text { font-size: 17px; }
.bitems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bitems li { display: flex; align-items: center; gap: 10px; min-height: 44px; border-top: 1px solid #F0EAE2; overflow-wrap: anywhere; }
.bitems li.done > .grow { text-decoration: line-through; color: var(--muted); }
.bitems .who { text-decoration: none; display: inline; font-size: 13px; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #B9AFA3; background: var(--surface); display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; color: #FFFFFF; }
.check[aria-checked="true"] { background: var(--brand); border-color: var(--brand); }
.small-x { width: 36px; height: 36px; color: var(--muted); }
.claim { font-weight: 700; font-size: 14px; background: var(--soft); border-radius: 14px; padding: 4px 10px; display: inline-flex; align-items: center; white-space: nowrap; }
.claim.mine { background: var(--brand-tint); color: var(--brand-dark); }
.claim-btn { min-height: 36px; white-space: nowrap; }
.add-row { display: flex; gap: 6px; align-items: center; }
.add-item { min-height: 42px; font-size: 16px; border-radius: 21px; background: var(--ground); }
.add-btn { width: 42px; height: 42px; background: var(--soft); }

/* Albums ------------------------------------------------------------------------------- */
.album-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.album-card { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 0; overflow: hidden; text-align: left; display: flex; flex-direction: column; }
.album-cover { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.album-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; margin: 0 -12px; }
.photo-tile { position: relative; aspect-ratio: 1 / 1; border: none; padding: 0; background: var(--soft); overflow: hidden; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-badge { position: absolute; right: 5px; bottom: 5px; width: 22px; height: 22px; border-radius: 11px; background: rgba(0, 0, 0, 0.55); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); transition: width 0.2s; }
body.no-scroll { overflow: hidden; }

.viewer { position: fixed; inset: 0; z-index: 35; background: #0E0B12; color: #FFFFFF; display: flex; flex-direction: column; }
.viewer .icon-btn { color: #FFFFFF; }
.viewer-top { display: flex; align-items: center; gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; }
.viewer-scroll { flex-grow: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.viewer-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 55vh; max-height: 78vh; }
.viewer-stage img { max-width: 100%; max-height: 78vh; object-fit: contain; display: block; background: #1B1720; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 22px; border: none; background: rgba(0, 0, 0, 0.45); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.nav.prev { left: 8px; }
.nav.next { right: 8px; }
.viewer-panel { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.viewer-panel h3 { font-size: 16px; margin-top: 4px; }
.caption { font-size: 17px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reactions { display: flex; gap: 8px; flex-wrap: wrap; }
.react { min-width: 52px; height: 44px; border-radius: 22px; border: 1.5px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 10px; }
.react[aria-pressed="true"] { background: rgba(255, 255, 255, 0.95); color: var(--ink); border-color: #FFFFFF; }
.react .emoji { font-size: 20px; line-height: 1; }
.react .rcount { font-weight: 700; font-size: 14px; }
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
.viewer .comment-input { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #FFFFFF; }
.viewer .add-btn { background: rgba(255, 255, 255, 0.15); color: #FFFFFF; }
.viewer .small-x { color: rgba(255, 255, 255, 0.7); }

/* All oval and view filters */
.oval-all { position: relative; background: var(--ink); color: #FFFFFF; font-size: 15px; filter: none !important; }
.oval-wrap[aria-pressed="false"] .oval-all { background: var(--soft); color: var(--ink); border: 1.5px solid var(--line-strong); opacity: 1; }
.filter-dot { position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 6px; background: #E0A100; border: 2px solid #FFFFFF; }
.filter-note { display: flex; align-items: center; gap: 8px; background: #FFF6DB; color: var(--note-ink); border-radius: 12px; padding: 6px 12px; font-size: 14px; font-weight: 700; }

/* Terms */
.family-rule { font-weight: 700; background: var(--brand-tint); color: var(--brand-dark); border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.agree { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 15px; cursor: pointer; }
.agree input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); flex-shrink: 0; }

/* Rays: Newest Rays row -------------------------------------------------------------- */
.rays { display: flex; flex-direction: column; gap: 6px; margin: -4px -16px 0; }
.rays-title { font-weight: 700; font-size: 14px; color: var(--muted); padding: 0 16px; }
.rays-row { display: flex; gap: 12px; overflow-x: auto; padding: 4px 16px 6px; scrollbar-width: none; }
.rays-row::-webkit-scrollbar { display: none; }
.ray-bubble { flex-shrink: 0; width: 72px; background: none; border: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ray-ring { width: 68px; height: 68px; border-radius: 34px; padding: 3px; background: #D8D0C6; display: flex; }
.ray-ring.unseen { background: conic-gradient(from 200deg, #FF6F00, #C2185B, #7B35A8, #FFB300, #FF6F00); }
.ray-ring.add { background: var(--brand-tint); }
.ray-face { position: relative; flex-grow: 1; border-radius: 50%; border: 3px solid var(--ground); overflow: hidden; background: var(--brand-tint); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.ray-face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ray-initials { position: absolute; right: 0; bottom: 0; background: rgba(31, 26, 43, 0.75); color: #FFFFFF; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 1px 4px; }
.ray-name { font-size: 13px; font-weight: 700; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-choice.active { opacity: 1; text-align: left; width: 100%; cursor: pointer; }
.share-choice.active:hover { border-color: var(--brand); }
.tile-video { position: absolute; left: 5px; bottom: 5px; background: rgba(0, 0, 0, 0.6); color: #FFFFFF; border-radius: 10px; padding: 1px 6px 1px 4px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.viewer-stage video { max-width: 100%; max-height: 78vh; display: block; background: #000; }

/* Rays: recorder -------------------------------------------------------------------------- */
.recorder, .ray-player { position: fixed; inset: 0; z-index: 36; background: #000; color: #FFFFFF; display: flex; flex-direction: column; }
.recorder .icon-btn, .ray-player .icon-btn { color: #FFFFFF; }
.rec-top, .ray-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
.rec-top { justify-content: space-between; }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.15); }
.rec-time.on { background: #D12F3A; }
.rec-stage { flex-grow: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.rec-stage video { width: 100%; height: 100%; object-fit: cover; }
.rec-stage video.mirror { transform: scaleX(-1); }
.rec-error { max-width: 360px; padding: 24px; text-align: center; font-size: 17px; }
.rec-bottom { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0 calc(18px + env(safe-area-inset-bottom)); }
.rec-btn { position: relative; width: 88px; height: 88px; border: none; background: none; padding: 0; display: flex; align-items: center; justify-content: center; }
.rec-btn svg { position: absolute; inset: 0; }
.rec-ring-fill { transition: stroke-dashoffset 0.2s linear; }
.rec-dot { width: 64px; height: 64px; border-radius: 32px; background: #E53935; transition: all 0.2s; }
.rec-btn.recording .rec-dot { width: 32px; height: 32px; border-radius: 8px; }
.rec-hint { font-size: 14px; opacity: 0.8; }
.rec-share { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; }
.rec-share video.preview { width: 100%; max-height: 46vh; border-radius: 16px; background: #111; object-fit: contain; }
.rec-share .input { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #FFFFFF; }
.rec-share .toggle-row .muted { color: rgba(255, 255, 255, 0.7); }
.rec-share .oval-icon { color: rgba(255, 255, 255, 0.8); }
.rec-share .oval-wrap[aria-pressed="true"] .oval { box-shadow: 0 0 0 2px #000, 0 0 0 4.5px #FFFFFF; }
.rec-share .btn-plain { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }

/* Rays: player ----------------------------------------------------------------------------- */
.segs { display: flex; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 10px 0; }
.seg { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.seg > span { display: block; height: 100%; width: 0; background: #FFFFFF; }
.seg.done > span { width: 100%; }
.ray-top { padding-top: 8px; }
.small-face { width: 34px; height: 34px; font-size: 13px; }
.ray-stage { position: relative; flex-grow: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.ray-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tap-zone { position: absolute; top: 0; bottom: 0; border: none; background: transparent; padding: 0; }
.tap-zone.left { left: 0; width: 28%; }
.tap-zone.middle { left: 28%; width: 44%; }
.tap-zone.right { right: 0; width: 28%; }
.ray-bottom { padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; max-width: 560px; width: 100%; margin: 0 auto; }
.ray-note { opacity: 0.75; }
.ray-player .react { color: #FFFFFF; }
.ray-comments { position: absolute; left: 0; right: 0; bottom: 0; max-height: 65vh; overflow-y: auto; background: #1B1720; border-radius: 20px 20px 0 0; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; z-index: 2; }
.ray-comments .comment-input { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #FFFFFF; }
.ray-comments .add-btn { background: rgba(255, 255, 255, 0.15); color: #FFFFFF; }
.ray-comments .small-x { color: rgba(255, 255, 255, 0.7); }

/* Ray button (warm sunrise) and intro ---------------------------------------------------- */
.share-disc { background: linear-gradient(135deg, #FFB300, #FF6F00 55%, #C2185B); box-shadow: 0 4px 14px rgba(255, 111, 0, 0.4); }
.share-disc.big { width: 96px; height: 96px; border-radius: 48px; margin: 0; border: none; }
.btn-warm { background: linear-gradient(135deg, #FF8F00, #E64A19 60%, #C2185B); }
.btn-warm:hover:not(:disabled) { background: linear-gradient(135deg, #FF8F00, #D84315 60%, #AD1457); }
.ray-intro { align-items: stretch; }
.ray-hero { display: flex; justify-content: center; padding-top: 8px; }
.ray-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ray-points li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.ray-points li svg { color: #E65100; margin-top: 1px; }

/* Hearth */
.hearth-icon { display: inline-flex; color: #E65100; flex-shrink: 0; margin-right: -2px; }
.conv-name .hearth-icon { vertical-align: -2px; margin-right: 4px; }

/* Photos and videos in chat ------------------------------------------------------------------- */
.composer-wrap { position: sticky; bottom: 0; z-index: 4; }
.composer-wrap .composer { position: static; }
.attach-btn { width: 46px; height: 46px; color: var(--brand); flex-shrink: 0; }
.attach-tray { display: flex; gap: 8px; overflow-x: auto; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px 2px; }
.tray-item { position: relative; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--soft); flex-shrink: 0; }
.tray-item img { width: 100%; height: 100%; object-fit: cover; }
.tray-wait { position: absolute; inset: 0; background: linear-gradient(90deg, var(--soft), #E9E2D8, var(--soft)); }
.tray-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.35); color: #FFFFFF; font-weight: 700; font-size: 14px; }
.tray-x { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 12px; border: none; background: rgba(0, 0, 0, 0.6); color: #FFFFFF; display: flex; align-items: center; justify-content: center; padding: 0; }
.msg-media { display: grid; gap: 3px; border-radius: 16px; overflow: hidden; width: min(280px, 70vw); margin-bottom: 3px; }
.msg-media.n1 { grid-template-columns: 1fr; }
.msg-media.n2, .msg-media.n4 { grid-template-columns: 1fr 1fr; }
.msg-media.n3 { grid-template-columns: 1fr 1fr 1fr; }
.media-tile { position: relative; border: none; padding: 0; background: var(--soft); aspect-ratio: 1 / 1; overflow: hidden; }
.msg-media.n1 .media-tile { max-height: 360px; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-opts { min-height: 28px; padding: 0 4px; font-size: 13px; }
.msg-reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: -4px; position: relative; z-index: 1; }
.msg.mine .msg-reacts { justify-content: flex-end; }
.rpill { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 26px; padding: 0 7px; display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 700; color: var(--ink); }
.rpill.mine { border-color: var(--brand); background: var(--brand-tint); }
.popup-reactions { justify-content: space-between; }
.popup-reactions .react { color: var(--ink); background: var(--soft); border-color: transparent; min-width: 54px; height: 54px; border-radius: 27px; }
.popup-reactions .react .emoji { font-size: 26px; }
.popup-reactions .react[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand); }

/* --- Step 12a: birthday, storage, friend invites, album picker --- */
.birthday { display: grid; grid-template-columns: 1.4fr 0.9fr 1fr; gap: 8px; }
.birthday select { padding-left: 10px; padding-right: 6px; }
.invite-only { line-height: 1.45; }

.storage-bar { display: flex; height: 12px; border-radius: 6px; background: var(--soft); overflow: hidden; }
.storage-bar .seg { height: 100%; min-width: 0; }
.seg.st-albums, .dot.st-albums { background: var(--brand); }
.seg.st-chat, .dot.st-chat { background: #2E8B8B; }
.seg.st-rays, .dot.st-rays { background: #E8912D; }
.storage-bar.high { box-shadow: inset 0 0 0 1px #E0B64A; }
.storage-bar.full { box-shadow: inset 0 0 0 2px var(--danger); }
.storage-parts { display: grid; gap: 6px; font-size: 15px; }
.storage-part { display: flex; align-items: center; gap: 10px; }
.storage-part .dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; }
.storage-option { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.friend-left { font-size: 15px; }

.album-picker { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; }
.ap-group { display: flex; flex-direction: column; gap: 4px; }
.ap-sphere { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.mini-oval { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 22px; border-radius: 11px; color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.ap-album { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.ap-album:hover { border-color: var(--brand); }
.ap-album:disabled { opacity: 0.6; }
.ap-add { color: var(--brand); font-weight: 700; font-size: 14px; }
.ap-new { border: 1px solid var(--line); border-radius: 12px; padding: 12px; gap: 10px; }
.ap-spheres { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-sphere-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px 0 6px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.ap-sphere-chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); font-weight: 700; }
.ray-intro-off { justify-content: center; }

/* --- Step 12b: kids' accounts --- */
.kid-signin-btn { color: var(--muted); }
.kid-pill { margin-left: 6px; background: #E3F1F7; color: #0F4C63; font-size: 12px; vertical-align: middle; }
.kid-note { margin: 0; padding: 8px 16px; background: var(--note-bg); color: var(--note-ink); display: flex; align-items: center; gap: 6px; }
.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); max-height: 32vh; overflow-y: auto; }
.quick-replies.dark { background: transparent; border-top: none; padding: 6px 0 0; }
.quick-reply { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line-strong); background: var(--soft); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; }
.quick-replies.dark .quick-reply { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.25); color: inherit; }
.quick-reply:hover { border-color: var(--brand); }
.quick-reply:disabled { opacity: 0.5; }
.person-pick.locked { opacity: 0.75; }
.person-pick.locked .face { background: var(--soft); color: var(--muted); }
.tiny { font-size: 11px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: flex-start; gap: 12px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.choice[aria-checked="true"] { border-color: var(--brand); background: var(--brand-tint); }
.choice-dot { width: 20px; height: 20px; border-radius: 10px; border: 2px solid var(--line-strong); flex-shrink: 0; margin-top: 2px; }
.choice[aria-checked="true"] .choice-dot { border: 6px solid var(--brand); }
.choice-title { display: block; font-weight: 700; }
.choice-desc { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }
.kid-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--soft); }
.badge.static { position: static; border: none; }
.pin-input { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.child-toggle { font-weight: 700; }
.kid-row { width: 100%; background: none; border: none; border-bottom: 1px solid #EFE9E1; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.kid-row:last-child { border-bottom: none; }
.tile-wait { position: absolute; left: 6px; bottom: 6px; background: rgba(31, 26, 43, 0.78); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 8px; }
