/* Veylo design system. No inline styles are used anywhere (strict CSP), everything is class based. */
:root {
  --bg: #f6f3ff; --surface: #ffffff; --surface-2: #efeaff; --text: #1b1640; --muted: #6b6790; --border: #e3dcff;
  --primary: #7c5cff; --primary-hover: #6a47f5; --primary-ink: #ffffff; --lavender: #c4b5fd;
  --ok: #1f9d6b; --warn: #b7791f; --danger: #d9363e; --info: #3b6fd8;
  --ok-bg: #e4f6ee; --warn-bg: #fdf1dc; --danger-bg: #fde8e9; --info-bg: #e6eefc;
  --radius: 18px; --radius-sm: 12px; --shadow: 0 8px 28px rgba(60, 40, 140, .10);
  --sidebar-w: 248px; --right-w: 300px; --bottom-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #120f2b; --surface: #1b1640; --surface-2: #261f55; --text: #f1edff; --muted: #a39fc9; --border: #2f2860;
    --primary: #9b82ff; --primary-hover: #b09cff; --primary-ink: #120f2b; --lavender: #5b4aa8;
    --ok-bg: #12382b; --warn-bg: #3a2c10; --danger-bg: #3d1a1d; --info-bg: #17284d; --shadow: 0 8px 28px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #120f2b; --surface: #1b1640; --surface-2: #261f55; --text: #f1edff; --muted: #a39fc9; --border: #2f2860;
  --primary: #9b82ff; --primary-hover: #b09cff; --primary-ink: #120f2b; --lavender: #5b4aa8;
  --ok-bg: #12382b; --warn-bg: #3a2c10; --danger-bg: #3d1a1d; --info-bg: #17284d; --shadow: 0 8px 28px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: .1em .4em; border-radius: 6px; }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link:focus { position: fixed; top: .5rem; left: .5rem; z-index: 100; background: var(--surface); padding: .6rem 1rem; border-radius: var(--radius-sm); }
:focus-visible { outline: 3px solid var(--lavender); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; } .icon-xl { width: 48px; height: 48px; color: var(--primary); margin: 0 auto 1rem; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; color: var(--text); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 600; color: var(--muted); font-size: .7em; }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), #c4b5fd 70%); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg); opacity: .85; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .6rem 1.2rem; border: 1px solid transparent; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 650; cursor: pointer; transition: transform .12s, background .15s, box-shadow .15s; text-decoration: none; }
.btn:hover { background: var(--primary-hover); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; } .btn-danger:hover { background: #b92a31; }
.btn-block { width: 100%; } .btn-lg { min-height: 52px; padding: .8rem 1.8rem; font-size: 1.05rem; } .btn-sm { min-height: 34px; padding: .3rem .9rem; font-size: .88rem; }
.btn-row, .hero-actions, .inline-form, .share-row, .filter-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.inline-form { display: inline-flex; margin: 0; }
.link-btn { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); } .icon-btn.danger { color: var(--danger); }
.page-back { margin-bottom: .4rem; }
.badge-option-list { display: grid; gap: .45rem; max-height: 16rem; overflow: auto; margin: .4rem 0; }
.badge-options { min-width: 0; border: 0; margin: 0; padding: 0; }
.ghost-btn { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .65rem .9rem; border: 0; background: none; color: var(--muted); font: inherit; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; }
.ghost-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.input { width: 100%; min-height: 46px; padding: .6rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
textarea.input { resize: vertical; min-height: 96px; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }
.input-code { letter-spacing: .3em; text-align: center; font-size: 1.3rem; }
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; font-weight: 600; font-size: .95rem; }
.field em { font-weight: 400; color: var(--muted); font-style: normal; }
.hint { color: var(--muted); font-weight: 400; } .field-error { color: var(--danger); font-weight: 500; font-size: .88rem; margin: 0; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.check { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .25rem; width: 18px; height: 18px; accent-color: var(--primary); }
.consents { border: 0; padding: 0; margin: 0; display: grid; gap: .7rem; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); margin: 0; }
.switch-row:last-child { border-bottom: 0; }
.switch-row strong { display: block; } .switch-row small { color: var(--muted); display: block; }
.switch { appearance: none; flex: none; width: 48px; height: 28px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch:checked { background: var(--primary); } .switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .6; cursor: not-allowed; }
.divider { display: flex; align-items: center; gap: .8rem; color: var(--muted); margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Cards, banners, chips */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-title { margin-bottom: .75rem; } .card-title small { color: var(--muted); font-weight: 500; }
.card-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.card-highlight { border-color: var(--primary); }
.muted-card { background: var(--surface-2); box-shadow: none; }
.banner { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); margin: 0 0 1rem; background: var(--info-bg); color: var(--text); }
.banner .icon { margin-top: .1rem; }
.banner-warn { background: var(--warn-bg); } .banner-error { background: var(--danger-bg); } .banner-ok { background: var(--ok-bg); } .banner-info { background: var(--info-bg); }
.banner form { margin-left: auto; }
.chips, .badges { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0 0 1rem; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .8rem; border-radius: 999px; background: var(--surface-2); font-size: .9rem; }
.chip-tag { color: var(--primary); } .chip-primary { background: var(--primary); color: var(--primary-ink); position: absolute; top: 6px; left: 6px; font-size: .75rem; padding: .1rem .55rem; }
.chip-x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; display: inline-grid; }
.chip-x .icon { width: 14px; height: 14px; }
.chip-badge { --badge: var(--primary); display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 650; color: var(--badge); background: color-mix(in srgb, var(--badge) 16%, transparent); border: 1px solid color-mix(in srgb, var(--badge) 40%, transparent); }
.chip-badge .icon { width: 14px; height: 14px; }
.pill { display: inline-block; padding: .1rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 650; background: var(--surface-2); }
.pill-active { background: var(--ok-bg); color: var(--ok); } .pill-frozen, .pill-pending_deletion { background: var(--warn-bg); color: var(--warn); }
.pill-suspended, .pill-banned { background: var(--danger-bg); color: var(--danger); }
.badge-count { background: var(--danger); color: #fff; font-size: .7rem; min-width: 18px; height: 18px; line-height: 18px; border-radius: 999px; text-align: center; padding: 0 5px; margin-left: auto; }

/* Layout */
.guest-top { display: flex; justify-content: space-between; align-items: center; padding: calc(1rem + var(--safe-t)) 1.25rem 1rem; max-width: 1100px; margin: 0 auto; }
.guest-main { max-width: 520px; margin: 0 auto; padding: 0 1rem 2rem; }
.guest-foot { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; padding: 1rem 1rem 3rem; font-size: .85rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 1.75rem; box-shadow: var(--shadow); }
.auth-card-wide { max-width: 560px; margin: 0 auto; }
.guest-main:has(.auth-card-wide) { max-width: 600px; } .guest-main:has(.hero) { max-width: 760px; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--primary); margin: 0; line-height: 1; }
.hero { padding: 2rem 0; } .hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: -.03em; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 700; color: var(--primary); }
.lead { font-size: 1.15rem; color: var(--muted); }
.hero-actions { margin: 1.5rem 0; }
.feature-list { list-style: none; padding: 0; display: grid; gap: .8rem; margin: 1.5rem 0; }
.feature-list li { display: flex; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; }
.feature-list .icon { color: var(--primary); }

.sidebar { display: none; }
.shell { min-height: 100vh; padding-bottom: calc(var(--bottom-h) + var(--safe-b) + 1rem); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: calc(.6rem + var(--safe-t)) 1rem .6rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.content { padding: 1rem; max-width: 760px; margin: 0 auto; }
.content-wide { max-width: 1100px; }
.rightbar { display: none; }
.side-panel-links { display: grid; gap: .25rem; padding: 0; margin: 0; list-style: none; }
.side-panel-links a { display: flex; align-items: center; gap: .6rem; padding: .5rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.side-panel-links a:hover, .side-panel-links a:focus-visible { background: var(--surface-2); }
.side-panel-links .icon { flex: none; }
.side-panel-count { margin-inline-start: auto; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
#discovery { scroll-margin-top: calc(4.5rem + var(--safe-t)); }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: calc(var(--bottom-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--border); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; color: var(--muted); text-decoration: none; }
.bottomnav a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.bn-icon { position: relative; display: inline-grid; } .bn-icon .badge-count { position: absolute; top: -6px; right: -10px; margin: 0; }
.admin-tabs { display: flex; gap: .4rem; overflow-x: auto; padding: .6rem 1rem; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.admin-tabs a { white-space: nowrap; padding: .4rem .9rem; border-radius: 999px; color: var(--muted); font-size: .9rem; }
.admin-tabs a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.admin .bottomnav { display: none; } .admin .shell { padding-bottom: 2rem; }

@media not all and (min-width: 1024px) {
  body.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; overflow: hidden; }
  .app > .shell { grid-row: 1; min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior-y: none; padding-bottom: 0; }
  .app > .bottomnav { grid-row: 3; position: static; min-width: 0; }
}

@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) {
  .sidebar { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); padding: 1.25rem .9rem; border-right: 1px solid var(--border); background: var(--surface); }
  .side-nav { display: grid; gap: .25rem; margin: 1.5rem 0; }
  .side-nav a { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; text-decoration: none; }
  .side-nav a:hover { background: var(--surface-2); color: var(--text); }
  .side-nav a[aria-current="page"] { background: var(--surface-2); color: var(--primary); }
  .side-foot { margin-top: auto; display: grid; gap: .25rem; }
  .admin .sidebar > .brand, .admin .side-foot { flex-shrink: 0; }
  .admin .side-nav { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
  .admin .side-foot .ghost-btn { width: 100%; }
  .shell { margin-left: var(--sidebar-w); display: grid; grid-template-columns: minmax(0, 1fr) var(--right-w); padding-bottom: 2rem; }
  .shell > .topbar, .shell > .admin-tabs { grid-column: 1 / -1; display: none; }
  .shell > .content { grid-column: 1; width: 100%; padding: 2rem 1.5rem; }
  .rightbar { display: block; padding: 2rem 1.5rem 2rem 0; position: sticky; top: 0; align-self: start; }
  .admin-rightbar { display: none; }
  .shell-admin { grid-template-columns: minmax(0, 1fr); }
  .bottomnav { display: none; }
}
@media (min-width: 1440px) {
  .shell-admin.has-team-panel { grid-template-columns: minmax(0, 1fr) var(--right-w); }
  .admin-rightbar { display: block; }
}

/* Page pieces */
.page-head { margin-bottom: 1rem; } .page-head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1rem; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 999px; color: var(--muted); white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
.tabs a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.tabs .icon { width: 16px; height: 16px; }
.quick-grid { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.quick { display: flex; flex-direction: column; gap: .4rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface-2); }
.quick:hover { text-decoration: none; border-color: var(--primary); } .quick .icon { color: var(--primary); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.checklist li { display: flex; align-items: center; gap: .6rem; }
.check-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.check-dot .icon { width: 13px; height: 13px; } .is-done .check-dot, .health .is-ok .check-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.health .is-bad .check-dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.notif-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.notif { display: flex; gap: .8rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; }
.notif.is-unread { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.notif-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); color: var(--primary); flex: none; }
.notif-body { flex: 1; min-width: 0; } .notif-body p { margin: .1rem 0; color: var(--muted); } .notif-body time { font-size: .8rem; color: var(--muted); }
.prose p { line-height: 1.7; }
.code-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: 0; } .secret { font-size: 1.1rem; word-break: break-all; }
.session-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.session-list li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.session-list div { flex: 1; min-width: 0; } .session-list small { display: block; color: var(--muted); }
.upload-row { margin: .75rem 0; } .file-pick { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.1rem; border: 1.5px dashed var(--primary); border-radius: 999px; color: var(--primary); cursor: pointer; font-weight: 650; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick:focus-within { outline: 3px solid var(--lavender); }
.photo-manage, .photo-grid { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.photo-manage li { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.photo-manage img, .photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.photo-actions { display: flex; justify-content: center; gap: .1rem; padding: .2rem; } .photo-actions form { margin: 0; }
.cover-preview { width: 100%; aspect-ratio: 3 / 1; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: .5rem; }

/* Profile */
.profile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); padding-bottom: 1.25rem; }
.profile-cover { aspect-ratio: 3 / 1; background: linear-gradient(120deg, var(--primary), var(--lavender)); } .profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; padding: 0 1.25rem; margin-top: -48px; }
.profile-id { flex: 1; min-width: 180px; padding-top: 52px; } .profile-id h1 { margin: 0; } .handle { color: var(--muted); margin: 0 0 .4rem; }
.profile-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.profile > :not(.profile-cover):not(.profile-head):not(dialog) { margin-left: 1.25rem; margin-right: 1.25rem; }
.avatar { position: relative; display: inline-grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); color: var(--primary); font-weight: 800; border: 4px solid var(--surface); overflow: hidden; }
.avatar-xl { width: 104px; height: 104px; font-size: 2.4rem; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.is-online::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--ok); border: 3px solid var(--surface); }
.avatar.is-online { overflow: visible; }
.meta-row { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; list-style: none; padding: 0; margin-top: 1rem; margin-bottom: 1rem; color: var(--muted); font-size: .92rem; }
.meta-online { color: var(--ok); font-weight: 650; } .bio { white-space: normal; } .section-title { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.25rem 1.25rem .5rem; }

/* Tables, stats */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; } .table th, .table td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); } .table tr:last-child td { border-bottom: 0; }
.stat-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 1rem; }
.stat { display: flex; align-items: center; gap: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.stat .icon { color: var(--primary); width: 26px; height: 26px; } .stat strong { display: block; font-size: 1.4rem; line-height: 1.1; } .stat span { font-size: .82rem; color: var(--muted); }
.chart { width: 100%; height: 180px; fill: var(--primary); } .chart-axis { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0 0 1rem; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.health { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; } .health li { display: flex; align-items: center; gap: .7rem; } .health small { color: var(--muted); margin-left: auto; text-align: right; }
.filter-row { margin-bottom: 1rem; } .filter-row .input { flex: 1; min-width: 160px; width: auto; }

/* Toasts, sheet, network banner */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-h) + var(--safe-b) + 12px); display: grid; gap: .5rem; width: min(92vw, 440px); pointer-events: none; }
.admin .toasts, .guest .toasts { bottom: 20px; }
@media (min-width: 1024px) { .toasts { bottom: 20px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .6rem; justify-content: space-between; padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); box-shadow: var(--shadow); animation: toast-in .25s ease; }
.toast-success { background: var(--ok); color: #fff; } .toast-error { background: var(--danger); color: #fff; } .toast-warning { background: var(--warn); color: #fff; }
.toast-close { background: none; border: 0; color: inherit; cursor: pointer; display: grid; } .toast-close .icon { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.net-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 95; text-align: center; padding: calc(.5rem + var(--safe-t)) 1rem .5rem; background: var(--text); color: var(--bg); font-size: .9rem; }
.has-pull-refresh { overscroll-behavior-y: none; }
.pull-refresh { position: fixed; z-index: 94; top: calc(var(--safe-t) + .75rem); left: 50%; transform: translateX(-50%); pointer-events: none; padding: .35rem .85rem; border-radius: 999px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); font-size: .85rem; }
.pull-refresh.is-ready { background: var(--primary); color: var(--primary-ink); }
.sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 8, 30, .55); animation: fade .2s; }
.sheet-panel { position: relative; width: min(100%, 480px); max-height: 85vh; overflow: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: .6rem 1.25rem calc(1.25rem + var(--safe-b)); animation: sheet-up .25s ease; }
.sheet-handle { width: 42px; height: 5px; border-radius: 999px; background: var(--border); margin: 0 auto .8rem; }
.sheet-item { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: .85rem .5rem; border: 0; background: none; color: var(--text); font: inherit; border-bottom: 1px solid var(--border); cursor: pointer; text-align: left; }
.sheet-item.is-active { color: var(--primary); font-weight: 700; }
.sheet-theme { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0 0; gap: 1rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; } .seg button { border: 0; background: none; color: var(--text); padding: .45rem .9rem; font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
@media (min-width: 640px) { .sheet { align-items: center; } .sheet-panel { border-radius: 24px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } } @keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Skeletons and motion preferences */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); min-height: 1rem; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Phase 2: discovery, social, messaging ---------- */
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.topbar-actions { display: inline-flex; gap: .1rem; }
@media (max-width: 360px) {
  .app .topbar { padding-inline: .55rem; }
  .app .topbar .brand { gap: .4rem; }
  .app .topbar-actions { gap: 0; }
}
.section { margin-bottom: 1.5rem; } .section-h { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .6rem; }
.card-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; }
.user-card-main { display: flex; gap: .9rem; align-items: center; color: var(--text); text-decoration: none; }
.user-card-main:hover { text-decoration: none; }
.user-card-text { display: grid; gap: .1rem; min-width: 0; } .user-card-text small { color: var(--muted); }
.user-card-meta { display: flex; flex-wrap: wrap; gap: .2rem .8rem; color: var(--muted); font-size: .85rem; }
.user-card-bio { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .badges { margin: .5rem 0 0; }
.card-action { margin: -.3rem 0 .3rem; text-align: right; }
.avatar-anon { --badge: var(--primary); background: color-mix(in srgb, var(--badge) 22%, var(--surface)); font-size: 1.6rem; border-color: color-mix(in srgb, var(--badge) 45%, var(--surface)); }
.profile-stats { display: flex; gap: 1.2rem; flex-wrap: wrap; margin: 0 0 1rem; padding: 0; list-style: none; }
.profile-stats a, .profile-stats span { color: var(--text); } .profile-stats strong { font-size: 1.1rem; }
.profile-actions form { margin: 0; }
.relation-note { color: var(--muted); font-size: .88rem; }

.convo-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.convo { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.msg-story { display: flex; align-items: center; gap: .55rem; margin-bottom: .35rem; padding: .4rem .55rem; border-inline-start: 2px solid currentColor; border-radius: .55rem; background: color-mix(in srgb, currentColor 9%, transparent); color: inherit; text-decoration: none; }
.msg-story > .msg-story-thumb { width: 32px; height: 42px; flex: none; border-radius: .3rem; object-fit: cover; }
.msg-story-copy { display: grid; min-width: 0; gap: .1rem; font-size: .78rem; }
.msg-story-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.msg-verified-profile { display: inline-flex; align-items: center; gap: .35rem; margin-top: .3rem; padding: .18rem .4rem; border: 1px solid currentColor; border-radius: .45rem; color: inherit; font-size: .75rem; text-decoration: none; }
.msg-verified-profile:hover { text-decoration: underline; }
.convo:hover { text-decoration: none; border-color: var(--primary); } .convo.is-unread { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.convo-text { flex: 1; min-width: 0; display: grid; } .convo-preview { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-name { display: flex; align-items: center; gap: .3rem .45rem; flex-wrap: wrap; }
.convo-name > strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-anonymous, .convo-origin { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.convo-origin { flex: none; padding: .12rem .45rem; border-radius: 999px; background: var(--surface-2); }
.convo-origin-mine { color: var(--primary); }
.convo-meta { display: grid; justify-items: end; gap: .2rem; font-size: .75rem; color: var(--muted); }
.convo-meta .badge-count { margin: 0; }

.app--thread .shell > .content { padding-block: 0; }
.app--thread > .consent-bar { display: none; }
.thread { display: flex; flex-direction: column; }
.thread-timeline { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.thread-bottom { position: fixed; right: calc(var(--right-w) + 1rem); bottom: 5rem; z-index: 20; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.thread-bottom-count { position: absolute; top: -.35rem; right: -.35rem; min-width: 18px; padding: 0 .25rem; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .68rem; }
.thread-head { position: sticky; top: 0; z-index: 27; display: flex; align-items: center; gap: .5rem; margin: 0 -1rem .5rem; padding: calc(.25rem + var(--safe-t)) 1rem .25rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.thread-who { flex: 1; display: flex; align-items: center; gap: .85rem; min-width: 0; }
.thread-who > span:last-child { min-width: 0; }
.thread-who strong, .thread-who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .thread-who small { color: var(--muted); }
.thread-who .avatar { width: 38px; height: 38px; flex: none; font-size: 1.1rem; border-width: 2px; }
.thread-who .avatar.is-online::after { right: -11px; bottom: 3px; width: 7px; height: 7px; border: 0; }
.thread-search { margin-bottom: .6rem; } .thread-older { align-self: center; margin-bottom: .6rem; }
.msg-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .35rem; flex: 1; align-content: end; }
.msg { position: relative; display: flex; flex-direction: column; min-width: 0; max-width: 90%; }
.msg.mine { justify-self: end; align-items: flex-end; } .msg.theirs { justify-self: start; align-items: flex-start; }
.bubble { padding: .4rem .65rem; border-radius: 15px; background: var(--surface); border: 1px solid var(--border); max-width: 100%; }
.msg.mine .bubble { background: var(--primary); color: var(--primary-ink); border-color: transparent; border-bottom-right-radius: 6px; }
.msg.theirs .bubble { border-bottom-left-radius: 6px; }
.bubble .body { margin: 0; font-size: .94rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.is-deleted .body { font-style: italic; opacity: .7; } .msg.is-sending { opacity: .6; } .msg.is-failed .bubble { background: var(--danger-bg); color: var(--text); border-color: var(--danger); }
.msg-meta { display: flex; gap: .5rem; font-size: .72rem; opacity: .75; margin-top: .15rem; align-items: center; -webkit-user-select: none; user-select: none; }
.msg.mine .link-btn { color: inherit; }
.quote { border-left: 3px solid color-mix(in srgb, currentColor 50%, transparent); padding-left: .5rem; font-size: .85rem; opacity: .8; margin-bottom: .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reactions { display: flex; gap: .25rem; margin-top: .2rem; flex-wrap: wrap; }
.reaction { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .05rem .5rem; font: inherit; font-size: .8rem; }
.reaction.mine { border-color: var(--primary); }
.msg-more { margin-inline-start: auto; min-width: 1.75rem; min-height: 1.6rem; padding: 0 .2rem; border: 0; border-radius: 6px; background: none; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.msg-more:hover, .msg-more[aria-expanded="true"] { background: color-mix(in srgb, currentColor 12%, transparent); }
.msg-actions { display: grid; width: max-content; max-width: 100%; gap: .1rem; margin-top: .25rem; padding: .2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); scroll-margin-block: 4rem 5rem; }
.msg-action { min-height: 34px; padding: .25rem .55rem; border: 0; border-radius: 6px; background: transparent; color: var(--text); text-align: start; font: inherit; font-size: .82rem; cursor: pointer; }
.msg-action:hover, .msg-action:focus-visible { background: var(--surface-2); }
.msg-action.danger { color: var(--danger); }
.msg-reaction-picker { position: absolute; z-index: 6; bottom: calc(100% + .25rem); inset-inline-start: 0; display: flex; gap: .1rem; padding: .25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); }
.msg.mine .msg-reaction-picker { inset-inline: auto 0; }
.msg-reaction-picker.is-below { top: calc(100% + .25rem); bottom: auto; }
.msg-reaction-picker .emoji { width: clamp(32px, 11vw, 42px); min-height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 1.25rem; cursor: pointer; }
.msg-reaction-picker .emoji:hover, .msg-reaction-picker .emoji:focus-visible { background: var(--surface-2); }
.msg-reaction-hint { padding: .15rem .35rem; font-size: .72rem; color: var(--muted); }
@media (hover: none) {
  .msg[data-id] .bubble { -webkit-touch-callout: none; user-select: none; touch-action: pan-y pinch-zoom; }
}
.msg[data-id] .bubble { transform: translateX(var(--reply-drag, 0px)); }
.btn.danger { color: var(--danger); }
.msg-empty { text-align: center; color: var(--muted); padding: 2rem 0; }
.composer { position: sticky; bottom: 0; z-index: 25; margin-inline: -1rem; background: var(--surface); border-top: 1px solid var(--border); padding: .35rem 1rem calc(.35rem + var(--safe-b)); }
.composer-row { display: flex; gap: .5rem; align-items: flex-end; max-width: 760px; margin: 0 auto; } .composer-row textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 140px; font-size: 16px; resize: none; }
.composer-tools { display: flex; align-items: center; gap: .1rem; }
.composer-context { display: flex; justify-content: space-between; align-items: center; max-width: 760px; margin: 0 auto .4rem; font-size: .88rem; color: var(--muted); padding-left: .6rem; border-left: 3px solid var(--primary); }
#composer-context-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-context .icon-btn { flex: none; }
.composer-send { width: 46px; padding: 0; flex: none; }
@media not all and (min-width: 1024px) {
  body.app--thread { position: fixed; inset-inline: 0; top: var(--dm-viewport-top, 0px); height: var(--dm-viewport-height, 100vh); height: var(--dm-viewport-height, 100dvh); }
  .app--thread > .shell { overflow: hidden; }
  .app--thread .shell > .content { height: 100%; padding: 0; }
  .app--thread .thread { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .app--thread .thread-head { position: static; margin: 0; }
  .app--thread .thread-timeline { min-height: 0; overflow-y: auto; overscroll-behavior-y: none; padding: .4rem .55rem 0; }
  .app--thread .thread-timeline, .app--thread .thread-bottom { grid-area: 2 / 1; }
  .app--thread .thread-bottom { position: relative; inset: auto; justify-self: end; align-self: end; margin: 0 .8rem .65rem 0; }
  .app--thread .composer { grid-row: 3; }
  .app--thread .msg-list { flex: 1 0 auto; }
  .app--thread .composer { position: static; margin: 0; padding: 0 .6rem var(--safe-b); }
  .app--thread.dm-keyboard-open .composer { padding-bottom: 0; }
  .app--thread .composer-row { gap: .3rem; align-items: flex-end; }
  .app--thread .composer-row textarea { max-height: 94px; padding: .65rem .5rem; border: 0; border-radius: 0; box-shadow: none; background: transparent; line-height: 1.35; }
  .app--thread .composer-row textarea:focus { outline: none; }
  .app--thread .composer-row textarea:focus-visible { box-shadow: inset 0 -2px var(--primary); }
  .app--thread .composer-tools .icon-btn { width: 40px; height: 44px; }
  .app--thread .composer-send { min-height: 34px; width: 34px; margin: 5px 0 5px .2rem; }
  .dm-keyboard-open .thread-head { padding-block: var(--safe-t) 0; }
  .dm-keyboard-open .thread-head > .icon-btn { height: 38px; }
  .dm-keyboard-open .thread-who .avatar { width: 30px; height: 30px; }
  .dm-keyboard-open .thread-who small { display: none; }
  .dm-keyboard-open .thread-timeline { padding-top: 0; }
  .dm-keyboard-open .composer-row textarea { max-height: 72px; }
  .dm-keyboard-open .composer-context { margin-bottom: .15rem; }
  .dm-keyboard-open .composer-context .icon-btn { height: 32px; }
  .app--thread > .toasts { bottom: calc(4rem + var(--safe-b)); }
}
@media (min-width: 1024px) {
  .composer, .thread-head { margin-inline: -1.5rem; padding-inline: 1.5rem; }
  .thread { min-height: 100vh; }
  .app--thread .shell { padding-bottom: 0; }
}
.sheet-label { display: inline-flex; align-items: center; gap: .7rem; } .sheet-item.danger { color: var(--danger); }
.sheet-form { padding: .8rem .5rem; border-bottom: 1px solid var(--border); display: grid; gap: .5rem; }
.sheet a.sheet-item { text-decoration: none; }
.banner form { margin: 0; } .banner .sheet-item { width: auto; border: 0; padding: .2rem .5rem; font-weight: 650; color: var(--primary); }
.banner { flex-wrap: wrap; align-items: center; }

/* ---------- Phase 3: stories, media, mentions ---------- */
.is-hidden { display: none !important; }
.mention, .hashtag { color: var(--primary); font-weight: 600; }
.msg.mine .bubble .mention, .msg.mine .bubble .hashtag { color: inherit; text-decoration: underline; }
.mention-list { position: absolute; z-index: 120; list-style: none; margin: 0; padding: .25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.mention-list li { display: grid; padding: .4rem .6rem; border-radius: 8px; cursor: pointer; } .mention-list li small { color: var(--muted); }
.mention-list li.is-active, .mention-list li:hover { background: var(--surface-2); }
.mention-list li.mention-with-avatar { display: flex; align-items: center; gap: .55rem; }
.mention-with-avatar .avatar { width: 34px; height: 34px; border-width: 1px; }
.mention-with-avatar small { display: block; }
.profile-admin-action > summary { cursor: pointer; }
.profile-admin-action > .form { padding: .5rem .85rem 1rem; }
.hashtag-suggestions li { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .6rem; }
.hashtag-suggestions strong { overflow-wrap: anywhere; }
.hashtag-suggestions small { white-space: nowrap; }

.bg-violet { background: linear-gradient(160deg, #7c5cff, #c4b5fd); color: #fff; } .bg-navy { background: linear-gradient(160deg, #1b1640, #3b3a8f); color: #fff; }
.bg-pink { background: linear-gradient(160deg, #ec4899, #f9a8d4); color: #fff; } .bg-teal { background: linear-gradient(160deg, #0d9488, #5eead4); color: #05302c; }
.bg-orange { background: linear-gradient(160deg, #f97316, #fdba74); color: #3b1a02; } .bg-sunset { background: linear-gradient(160deg, #ef4444, #f59e0b, #a855f7); color: #fff; }
.bg-forest { background: linear-gradient(160deg, #14532d, #4ade80); color: #fff; } .bg-mono { background: #0b0a1a; color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; } .swatch { width: 38px; height: 38px; border-radius: 50%; position: relative; cursor: pointer; border: 3px solid transparent; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; } .swatch:has(input:checked) { border-color: var(--text); } .swatch:focus-within { outline: 3px solid var(--lavender); }
.seg-wide { display: flex; } .seg-wide label { flex: 1; text-align: center; cursor: pointer; position: relative; }
.seg-wide label span { display: block; padding: .5rem .4rem; } .seg-wide input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-wide label:has(input:checked) { background: var(--primary); color: var(--primary-ink); } .seg-wide label.is-disabled { opacity: .45; }
.story-studio { position: fixed; inset: var(--studio-top, 0px) 0 auto; width: min(100%, 580px); height: var(--studio-height, 100vh); height: var(--studio-height, 100dvh); margin: 0 auto; padding: var(--safe-t) .75rem calc(.5rem + var(--safe-b)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: .55rem; background: #171322; color: #fff; }
.story-studio-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .35rem; }
.story-studio-top h1 { margin: 0; font-size: clamp(.88rem, 3.9vw, 1.15rem); }
.story-studio-top > a { color: inherit; }
.story-studio-top > .btn { justify-self: end; padding-inline: .65rem; }
.story-studio-top > .btn .icon { width: 14px; height: 14px; }
.story-editor-canvas { display: grid; place-items: center; min-height: 0; min-width: 0; container-type: size; }
.story-preview { position: relative; width: min(100%, 56.25cqh, 400px); aspect-ratio: 9 / 16; container-type: inline-size; border-radius: 18px; overflow: hidden; display: grid; place-items: center; cursor: text; }
.story-preview img, .story-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.story-preview.story-fill img, .story-preview.story-fill video, .sv-slide.story-fill .sv-media { object-fit: cover; }
.story-canvas-prompt { z-index: 1; padding: .5rem .85rem; margin: .6rem; text-align: center; font-size: .85rem; font-weight: 650; color: #fff; background: #0e0a1a91; border-radius: 999px; pointer-events: none; }
.story-studio-toolbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .32rem; padding: .3rem; border: 1px solid #ffffff24; border-radius: 16px; background: #ffffff0b; }
.story-studio-toolbar button { display: grid; place-items: center; gap: .15rem; min-height: 45px; padding: .2rem .1rem; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; font-size: .72rem; cursor: pointer; }
.story-studio-toolbar strong { font-size: 1.1rem; line-height: 1.15; }
.story-studio-toolbar button:hover, .story-studio-toolbar button:focus-visible { background: #ffffff1c; }
.story-studio-panel { position: fixed; inset: auto 0 calc(var(--studio-keyboard, 0px) + .5rem); margin: 0 auto; width: min(440px, calc(100% - 1rem)); max-height: min(32rem, calc(var(--studio-height, 100vh) - 1.5rem)); padding: .85rem 1rem calc(.85rem + var(--safe-b)); overflow: auto; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.story-studio-panel[open] { display: grid; gap: .75rem; }
.story-studio-panel::backdrop { background: #09071170; }
.story-studio-panel-head { display: flex; justify-content: space-between; align-items: center; }
.story-studio-panel-head h2, .story-studio-panel p { margin: 0; }
.story-studio-panel-head h2 { font-size: 1.05rem; }
.story-studio-panel textarea { min-height: 64px; resize: vertical; font-size: 16px; }
.story-studio-panel input[type="range"] { width: 100%; accent-color: var(--primary); }
.story-studio-error { color: var(--danger); }
.story-text-layer { position: absolute; z-index: 5; transform: translate(calc(var(--story-x, 50) * -1%), calc(var(--story-y, 50) * -1%)); width: max-content; max-width: 94%; margin: 0; padding: .12em .26em; border: 0; border-radius: .26em; background: #171022a0; color: #fff; font: 700 1rem/1.16 var(--font); font-size: calc(var(--story-size, 7) * 1cqw); text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; pointer-events: none; }
button.story-text-layer { pointer-events: auto; touch-action: none; cursor: grab; }
.story-text-layer a { pointer-events: auto; color: inherit; text-decoration: underline; }
.sticker-bar { display: flex; flex-wrap: wrap; gap: .3rem; } .emoji { border: 0; background: none; font-size: 1.5rem; cursor: pointer; border-radius: 10px; padding: .1rem .3rem; } .emoji.is-mine { background: var(--surface-2); }
#story-stickers { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.sv-sticker { position: absolute; transform: translate(-50%, -50%); font-size: 2.6rem; line-height: 1; border: 0; background: none; padding: 0; pointer-events: auto; cursor: pointer; z-index: 3; }
#story-stickers .sv-sticker { touch-action: none; cursor: grab; padding: .18rem; border-radius: 10px; outline: 2px solid transparent; }
#story-stickers .sv-sticker[aria-pressed="true"] { outline-color: #fff; background: #0004; }
.story-rail { display: flex; gap: .9rem; list-style: none; padding: 0; margin: 0 0 1rem; overflow-x: auto; scrollbar-width: none; }
.story-item { display: grid; justify-items: center; gap: .25rem; width: 72px; color: var(--text); text-decoration: none; } .story-item:hover { text-decoration: none; }
.story-item small { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
.story-ring { display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%; border: 2px solid var(--border); }
.story-ring.is-new { border-color: transparent; background: linear-gradient(135deg, var(--primary), #f472b6) border-box; padding: 0; } .story-ring.is-new .avatar { border-color: var(--bg); }
.story-ring .avatar { width: 56px; height: 56px; border-width: 3px; } .story-add .avatar { color: var(--primary); }
.archive-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.archive-thumb { aspect-ratio: 9 / 16; border-radius: var(--radius-sm); overflow: hidden; display: grid; place-items: center; padding: .5rem; text-align: center; font-weight: 600; } .archive-thumb img { width: 100%; height: 100%; object-fit: cover; margin: -.5rem; max-width: none; }
.archive-meta { display: grid; gap: .25rem; padding-top: .4rem; } .archive-meta small { color: var(--muted); }
.story-discover-grid { grid-template-columns: repeat(auto-fill, minmax(min(135px, 42vw), 1fr)); gap: .65rem; }
.story-discover-card { display: grid; gap: .45rem; color: var(--text); text-decoration: none; }
.story-discover-card:hover { text-decoration: none; }
.story-discover-card .archive-thumb { position: relative; overflow-wrap: anywhere; }
.story-discover-card .archive-thumb img { position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; }
.story-discover-name { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.story-discover-name > span:last-child { display: grid; min-width: 0; }
.story-discover-name strong, .story-discover-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-discover-name small { color: var(--muted); }
.story-discover-name .avatar { width: 29px; height: 29px; flex: none; border-width: 2px; }
.story-discover-name.is-new .avatar { border-color: var(--primary); }

body.viewer { background: #0e0c15; overflow: hidden; }
.sv { position: fixed; inset: var(--sv-top, 0px) 0 auto; width: min(100%, 480px); height: var(--sv-height, 100vh); height: var(--sv-height, 100dvh); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; margin: 0 auto; background: #171322; color: #fff; overflow: hidden; }
.sv-progress { display: flex; gap: 4px; padding: calc(.6rem + var(--safe-t)) .6rem .3rem; position: absolute; top: 0; left: 0; right: 0; z-index: 6; }
.sv-bar { flex: 1; height: 3px; background: rgba(255, 255, 255, .35); border-radius: 2px; overflow: hidden; } .sv-bar i { display: block; height: 100%; width: 0; background: #fff; }
.sv-head { grid-row: 1; display: flex; justify-content: space-between; align-items: center; padding: calc(1.3rem + var(--safe-t)) .8rem .6rem; position: relative; z-index: 6; background: linear-gradient(#000a, transparent); }
.sv-user { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; } .sv-user small { display: block; opacity: .75; } .sv-user .avatar { width: 40px; height: 40px; border-width: 2px; }
.sv-actions .icon-btn { color: #fff; }
.sv-stage { grid-row: 2; position: relative; min-height: 0; display: grid; touch-action: pan-y pinch-zoom; overflow: hidden; background: #0e0c15; container-type: size; }
.sv-slide { position: absolute; inset: 0; margin: auto; width: min(100%, 56.25cqh); height: min(100%, 177.777cqw); display: grid; place-items: center; overflow: hidden; border-radius: 12px; container-type: inline-size; }
.sv-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.sv-text { position: relative; font-size: 1.9rem; font-weight: 700; text-align: center; padding: 1.5rem; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; z-index: 2; }
.sv-caption { position: absolute; bottom: .7rem; left: .6rem; right: .6rem; margin: 0; padding: .5rem .65rem; text-align: center; border-radius: 8px; background: rgba(0, 0, 0, .58); z-index: 2; overflow-wrap: anywhere; color: #fff; }
.sv-text a, .sv-caption a { color: inherit; text-decoration: underline; }
.sv-nav { position: absolute; top: 0; bottom: 0; width: 32%; border: 0; background: transparent; z-index: 4; cursor: pointer; } .sv-prev { left: 0; } .sv-next { right: 0; }
.sv-foot { grid-row: 3; position: relative; z-index: 7; padding: .6rem .8rem calc(.8rem + var(--safe-b)); background: linear-gradient(transparent, #000b); display: grid; gap: .5rem; }
.sv-reactions { display: flex; justify-content: center; gap: .2rem; } .sv-reactions .emoji { font-size: 1.7rem; } .sv-reactions .emoji.is-mine { background: rgba(255, 255, 255, .25); }
.sv-reply { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; } .sv-reply .input { flex: 1; min-width: 0; background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .35); }
.sv-stats { color: #fff; border-color: rgba(255, 255, 255, .4); } .sv-del { color: #fff; border-color: rgba(255, 255, 255, .4); }
.sv .sheet-panel { background: var(--surface); color: var(--text); }
.sv-foot:has(.sv-stats) { grid-template-columns: 1fr auto; }
.sv-foot:has(.sv-report) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.sv-foot .sv-reply, .sv-chat-hint { grid-column: 1 / -1; }
.sv-chat-hint { color: #d3cadf; }
.sv-reactions { justify-content: flex-start; }
.sv-reactions .emoji { min-width: 0; font-size: clamp(1.05rem, 5vw, 1.45rem); }
.sv-details-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.sv-details-head h2 { margin: 0; }
.sv-details-tabs { margin: .75rem 0; }
.sv-details-content { min-height: 5rem; }
.sv-viewer-reaction { font-size: 1.3rem; }
.viewer .toasts { bottom: calc(3rem + var(--safe-b)); }

.attach { margin-bottom: .3rem; } .attach-img { border-radius: 12px; max-width: 100%; height: auto; display: block; }
.attach-photo { display: block; max-width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.photo-viewer { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: calc(.5rem + var(--safe-t)) .75rem calc(.5rem + var(--safe-b)); border: 0; color: #fff; background: #0b0910; }
.photo-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); justify-items: center; align-items: center; }
.photo-viewer::backdrop { background: #0b0910; }
.photo-viewer-close { justify-self: end; color: inherit; border-color: #fff6; }
.photo-viewer-close:hover { background: #fff2; }
.photo-viewer-image { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-grid .attach-photo { width: 100%; }
.profile-photo-viewer { width: min(390px, calc(100% - 2rem)); height: fit-content; max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); margin: auto; padding: .7rem; border: 1px solid var(--border); border-radius: 22px; color: var(--text); background: var(--surface); box-shadow: 0 24px 64px #0006; }
.profile-photo-viewer[open] { grid-template-rows: auto minmax(0, 1fr) auto; gap: .55rem; touch-action: pan-y pinch-zoom; }
.profile-photo-viewer::backdrop { background: #100b21a8; backdrop-filter: blur(4px); }
.photo-viewer-header { width: 100%; padding-inline-start: .4rem; display: flex; justify-content: space-between; align-items: center; }
.photo-viewer-header h2 { margin: 0; font-size: .95rem; }
.profile-photo-viewer .photo-viewer-close { background: var(--surface-2); }
.profile-photo-viewer .photo-viewer-image { display: block; width: 100%; height: min(48vh, 340px); height: min(48dvh, 340px); object-fit: scale-down; border-radius: 13px; background: var(--bg); }
.photo-viewer-nav { display: flex; align-items: center; gap: .75rem; }
.photo-viewer-nav .icon-btn { color: inherit; background: var(--surface-2); }
.photo-viewer-nav span { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; min-width: 3rem; text-align: center; }
.attach-video { border-radius: 12px; max-width: 100%; max-height: 320px; background: #000; } .attach-audio { max-width: 100%; width: 240px; }
.once-btn { background: var(--surface-2); color: var(--text); } .msg.mine .once-btn { background: rgba(255, 255, 255, .2); color: inherit; }
.once-state { font-size: .9rem; opacity: .85; }
.once-viewer { position: fixed; inset: 0; z-index: 200; background: #000e; display: grid; place-items: center; padding: 1rem; grid-template-rows: auto 1fr auto; }
.once-media { max-width: 100%; max-height: 80vh; margin: auto; object-fit: contain; border-radius: 12px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.once-close { justify-self: end; } .once-note { color: #fff; opacity: .7; font-size: .8rem; text-align: center; margin: .5rem 0 0; }
.attach-btn { cursor: pointer; position: relative; }
.attach-preview { width: min(94vw, 600px); max-height: 90dvh; padding: 1rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.attach-preview::backdrop { background: #000b; }
.attach-preview form { display: grid; gap: .5rem; }
.attach-preview-close { justify-self: end; }
.attach-preview img, .attach-preview video { grid-column: 1 / -1; width: 100%; max-height: 62dvh; object-fit: contain; }
.attach-preview-status, .attach-preview-actions { grid-column: 1 / -1; }
.attach-preview-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.attach-mode { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .65rem; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.attach-mode[aria-pressed="true"] { color: var(--primary); }
.attach-mode-icon { font-size: 1.1rem; line-height: 1; }
.attach-preview-send { width: 44px; padding: 0; flex: none; }
.toast a { color: inherit; }
.push-summary { display: flex; align-items: center; gap: .65rem; width: 100%; }
.push-summary strong { display: block; }
.push-summary .avatar { width: 34px; height: 34px; }
#mic-btn.is-recording { background: var(--danger); color: #fff; animation: pulse 1s infinite; } @keyframes pulse { 50% { opacity: .6; } }
.composer-row .icon-btn { flex: none; }
.msg.is-queued .bubble { opacity: .7; border-style: dashed; }

/* ---- Phase 6: Plus, ads, consent ---- */
.plan-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; } @media (min-width: 640px) { .plan-grid { grid-template-columns: 1fr 1fr; } }
.plan-card { display: block; border: 2px solid var(--border); border-radius: 16px; padding: 1rem; cursor: pointer; background: var(--surface); }
.plan-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.plan-card input { position: absolute; opacity: 0; pointer-events: none; } .plan-card:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.plan-body { display: grid; gap: .35rem; } .plan-price { font-size: 1.5rem; font-weight: 700; } .plan-price small { font-size: .85rem; font-weight: 400; color: var(--muted); }
.plan-body ul { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; gap: .3rem; } .plan-body li { display: flex; gap: .4rem; align-items: center; }
.ad-card { position: relative; display: grid; gap: .4rem; padding: 1rem; margin: 1rem 0; border-radius: 16px; border: 1px dashed var(--border); background: var(--surface-2); }
.ad-card .ad-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ad-card p { margin: 0; color: var(--muted); } .ad-why { font-size: .78rem; color: var(--muted); } .ad-unit { display: block; min-height: 90px; }
.ad-violet { border-left: 4px solid #7c5cff; } .ad-teal { border-left: 4px solid #2f9e77; } .ad-amber { border-left: 4px solid #f59e0b; } .ad-rose { border-left: 4px solid #e5484d; }
.consent-bar { position: fixed; left: .75rem; right: .75rem; bottom: calc(.75rem + env(safe-area-inset-bottom)); z-index: 150; display: grid; gap: .6rem; padding: .9rem 1rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.consent-bar p { margin: 0; font-size: .9rem; } @media (min-width: 760px) { .consent-bar { max-width: 620px; left: auto; } }
@media (max-width: 899px) { .consent-bar { bottom: calc(4.6rem + env(safe-area-inset-bottom)); } }
@media not all and (min-width: 1024px) {
  .app > .consent-bar { grid-row: 2; position: static; margin: 0 .75rem .4rem; max-width: none; max-height: 35vh; max-height: 35dvh; overflow-y: auto; }
}

/* ---- Phase 4: safety, reports, support ---- */
.support-msg > div { width: 100%; } .support-msg.is-staff { background: var(--surface-2); border-radius: 12px; padding: .6rem .8rem; }
.support-msg p { margin: .3rem 0 0; white-space: normal; overflow-wrap: anywhere; }
.notice details { margin-top: .5rem; } .notice summary { cursor: pointer; color: var(--primary); font-weight: 600; }
fieldset.field { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; } fieldset.field legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.sv-report { align-self: center; color: #fff; opacity: .8; } .sv-foot:has(.sv-report) { flex-wrap: wrap; }

/* ---- Phase 7: public home page, install guide, login notice, promotions ---- */
.guest-nav { display: flex; align-items: center; gap: .6rem; } .guest-nav a { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .8rem; border-radius: 999px; color: var(--muted); font-size: .9rem; }
.qr-box { display: flex; justify-content: center; margin: 1rem 0 .4rem; } .qr-box .qr { width: 220px; height: 220px; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.guest-nav a:hover { color: var(--text); background: var(--surface-2); }
.login-notice { display: flex; gap: .8rem; align-items: flex-start; max-width: 760px; margin: 0 auto 1rem; padding: 1rem 1.2rem; border-radius: var(--radius-sm); background: var(--info-bg); border: 1px solid var(--primary); color: var(--text); }
.login-notice .icon { color: var(--primary); flex: none; margin-top: .15rem; } .login-notice div { display: grid; gap: .2rem; } .login-notice span { color: var(--muted); font-size: .92rem; }
@media (max-width: 800px) { .login-notice { margin-left: 1rem; margin-right: 1rem; } }
.hero-install { margin: 0 0 1rem; } .hero-install a { display: inline-flex; gap: .4rem; align-items: center; }
.landing-block { margin: 2.2rem 0; } .landing-block h2 { margin-bottom: 1rem; }
.steps-row { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: 1fr; } @media (min-width: 700px) { .steps-row { grid-template-columns: repeat(3, 1fr); } }
.steps-row li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem 1.1rem; display: grid; gap: .35rem; }
.step-no { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: .9rem; }
.feature-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; grid-template-columns: 1fr; } @media (min-width: 700px) { .feature-grid { grid-template-columns: 1fr 1fr; } }
.feature-grid li { display: flex; gap: .9rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.feature-grid .icon { color: var(--primary); flex: none; margin-top: .1rem; } .feature-grid div { display: grid; gap: .2rem; }
.install-band { background: var(--surface-2); border-radius: var(--radius); padding: 1.4rem; display: grid; gap: 1rem; }
.install-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.store-soon { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem; border: 1px dashed var(--border); border-radius: 999px; color: var(--muted); font-size: .88rem; cursor: not-allowed; }
.guest-main:has(.install-steps) { max-width: 960px; }
.platform-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; } .platform-tabs a { padding: .45rem 1rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .92rem; }
.platform.is-current { border-color: var(--primary); } .here-pill { margin-left: .4rem; vertical-align: middle; }
.install-steps { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 1.4rem; grid-template-columns: 1fr; } @media (min-width: 760px) { .install-steps { grid-template-columns: repeat(2, 1fr); } }
.install-steps li { display: grid; gap: .8rem; align-content: start; } .install-steps figure { margin: 0; text-align: center; background: var(--surface-2); border-radius: var(--radius); padding: 1rem; }
.install-steps img { max-width: 100%; height: auto; max-height: 460px; width: auto; border-radius: 28px; box-shadow: var(--shadow); }
.install-steps li > div { display: grid; gap: .3rem; justify-items: start; } .install-steps p { margin: 0; }
details summary { cursor: pointer; font-weight: 600; padding: .5rem 0; } details p { margin: .2rem 0 .8rem; }
.sub-tabs { border-bottom: 0; padding: 0; margin-bottom: 1rem; flex-wrap: wrap; } .input-sm { width: 6rem; } .mono { font-family: ui-monospace, Consolas, monospace; } .plain-list { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; gap: .2rem; font-size: .9rem; }
