/* Base + app-like behaviour (spec §6-7, §120-121, §189). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); color-scheme: dark; overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 var(--fs-md)/1.45 var(--font); letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: clip; overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;                 /* no double-tap zoom; pinch stays available for accessibility */
  -webkit-user-select: none; user-select: none;  /* app chrome isn't text; content that should be copyable opts back in */
}
input, textarea, select, [contenteditable], .msg-body, .selectable, .bio, .overview, .preview-overview, .diag { -webkit-user-select: text; user-select: text; }
img, svg, video { max-width: 100%; display: block; }
img { -webkit-user-drag: none; user-drag: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); } .small { font-size: var(--fs-sm); } .gold { color: var(--gold); }
.ic { width: 22px; height: 22px; flex: none; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.noscript { padding: 40px; text-align: center; }

/* ---------- splash (pure CSS; paints before JS) ---------- */
#splash { position: fixed; inset: 0; z-index: 1000; background: var(--black); display: grid; place-content: center; justify-items: center; gap: 18px; transition: opacity .4s var(--ease); }
#splash.done { opacity: 0; pointer-events: none; }
.splash-ring { width: 78px; height: 78px; border-radius: 50%; border: 3px solid var(--gold); box-shadow: var(--gold-glow); opacity: 0; animation: splashFallback .4s 2.6s forwards, breathe 1.8s var(--ease) infinite; }
.splash-word { font: 600 20px/1 var(--font-display); letter-spacing: .32em; padding-inline-start: .32em; opacity: 0; animation: splashFallback .4s 2.6s forwards; }
@keyframes splashFallback { to { opacity: 1; } }     /* only if the script never starts the opening: start from pure black */
#splash.static > .splash-ring, #splash.static > .splash-word { opacity: 1; animation-delay: 0s; }
.motion-off .splash-ring, .motion-off .splash-word { opacity: 1; }
#splash.intro { transition: none; }
#splash.intro > .splash-ring, #splash.intro > .splash-word { display: none; }
.intro-word { direction: ltr; display: flex; align-items: center; justify-content: center; font: 500 clamp(34px, 9.2vw, 66px)/1 var(--font-display); letter-spacing: .14em; color: #f1ebe0; user-select: none; }
.intro-word .iw-l, .intro-word .iw-v { opacity: 0; will-change: opacity, transform, filter; }
.intro-word .iw-o { display: inline-block; width: .86em; height: .86em; margin-inline: .02em .1em; }
.intro-tag { margin-top: clamp(14px, 3vw, 24px); font: 500 clamp(10px, 2.5vw, 13px)/1 var(--font); letter-spacing: .42em; padding-inline-start: .42em; color: rgba(241,235,224,.62); opacity: 0; text-align: center; }
.splash-word span, .brand-o { color: var(--gold); }

/* ---------- UNISNOV Ring loader (§102) ---------- */
.ring-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 28px 0; min-height: 96px; }
.ring-loader-ring { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--gold); box-shadow: var(--gold-glow); animation: breathe 1.6s var(--ease) infinite; }
.ring-lg .ring-loader-ring { width: 64px; height: 64px; border-width: 3px; }
.ring-loader-label { font-size: var(--fs-sm); color: var(--text-2); }
.ring-inline { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold); display: inline-block; animation: breathe 1.4s var(--ease) infinite; flex: none; }
@keyframes breathe { 0%, 100% { transform: scale(.88); opacity: .7; box-shadow: 0 0 0 0 rgba(231,185,107,0); } 50% { transform: scale(1); opacity: 1; box-shadow: var(--gold-glow); } }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-ring { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--gold); box-shadow: var(--gold-glow); flex: none; }
.brand-ring.lg { width: 64px; height: 64px; border-width: 3px; margin: 0 auto; }
.brand-word { font: 600 19px/1 var(--font-display); letter-spacing: .22em; }
.brand-word.lg { font-size: 24px; letter-spacing: .3em; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--touch); padding: 0 20px; border-radius: var(--r-pill); font-weight: 600; font-size: var(--fs-md); border: 1px solid transparent; transition: filter var(--t-fast), background var(--t-fast), border-color var(--t-fast); white-space: nowrap; }
.btn .ic { width: 18px; height: 18px; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: var(--fs-sm); }
.btn-gold { background: var(--gold-metal); color: #1a1206; box-shadow: 0 6px 18px -8px rgba(231,185,107,.6); }
.btn-outline-gold { border-color: var(--gold); color: var(--gold); }
.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: var(--danger-soft); color: #ff8b8e; }
.btn-link { color: var(--text-2); padding: 0 8px; }
.link-btn { color: var(--gold); font-size: var(--fs-sm); padding: 6px 0; }
@media (hover: hover) { .btn:hover { filter: brightness(1.08); } .btn-ghost:hover { border-color: var(--line-strong); } }
.icon-btn { width: var(--touch); height: var(--touch); display: inline-grid; place-items: center; border-radius: 50%; color: var(--text); flex: none; transition: background var(--t-fast); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); } }

/* ---------- forms ---------- */
.input { width: 100%; min-height: 48px; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 16px; outline: none; transition: border-color var(--t-fast); }
.input:focus { border-color: rgba(231,185,107,.6); }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: none; }
.field { display: grid; gap: 7px; margin-bottom: var(--s4); }
.field label { font-size: var(--fs-sm); color: var(--text-2); }
.field-hint { font-size: 12.5px; color: var(--text-3); min-height: 1em; }
.field-hint.good { color: var(--gold); } .field-hint.bad, .form-error { color: #ff8b8e; font-size: var(--fs-sm); }
.form { display: grid; gap: var(--s2); }
.inline-form { display: flex; gap: var(--s2); }

/* ---------- toggle / segmented / chips ---------- */
.toggle { width: 50px; height: 30px; border-radius: 15px; background: var(--surface-3); position: relative; flex: none; transition: background var(--t-med); border: 1px solid var(--line); }
.toggle::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #d9d6d0; transition: transform var(--t-med) var(--ease); }
.toggle[aria-checked="true"] { background: var(--gold-lo); border-color: transparent; }
.toggle[aria-checked="true"]::after { background: #fff; transform: translateX(20px); }
[dir="rtl"] .toggle[aria-checked="true"]::after { transform: translateX(-20px); }
.segmented { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 10px 12px; margin: -10px -12px; }   /* room for the glow inside the scroll clip */
.segmented::-webkit-scrollbar { display: none; }
.seg { min-height: 38px; padding: 0 18px; border-radius: var(--r-pill); color: var(--text-2); background: var(--surface-1); border: 1px solid var(--line); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; flex: none; transition: all var(--t-fast); }
.seg[aria-selected="true"] { color: #1a1206; background: var(--gold-metal); border-color: transparent; box-shadow: 0 2px 10px rgba(231,185,107,.28); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); font-size: var(--fs-sm); color: var(--text-2); }
.chip-gold { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--surface-2); color: var(--text-2); }
.pill-gold { background: var(--gold-soft); color: var(--gold); }

/* ---------- avatars (no broken-image icon, reserved size) ---------- */
.avatar { position: relative; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #2a2a2d, #151516); display: grid; place-items: center; flex: none; overflow: visible; color: var(--text-2); font-weight: 650; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; opacity: 0; transition: opacity var(--t-med); }
.avatar > img.loaded { opacity: 1; }
.avatar.add { border: 1.5px dashed var(--line-strong); color: var(--text-2); }
.avatar.ring-host { box-shadow: 0 0 0 2.5px var(--gold), var(--gold-glow); }
.avatar.ring-member { box-shadow: 0 0 0 2px var(--ring-member); }
.presence-dot { position: absolute; inset-block-end: 2px; inset-inline-end: 2px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--bg); background: var(--text-3); }
.presence-dot.on { background: var(--ok); } .presence-dot.busy { background: var(--busy); }

/* ---------- posters (fixed aspect, premium placeholder) ---------- */
.poster { display: flex; flex-direction: column; gap: 8px; width: var(--poster-w); flex: none; text-align: start; }
.poster-art { position: relative; width: 100%; border-radius: var(--r-md); overflow: hidden; background: linear-gradient(160deg, #1d1b18, #0e0e0f); box-shadow: 0 10px 24px -14px rgba(0,0,0,.9); }
.poster-art > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--t-med); }
.poster-art > img.loaded { opacity: 1; }
.poster-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 10px; text-align: center; }
.poster-fallback-ring { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(231,185,107,.55); }
.poster-fallback-title { font-size: var(--fs-xs); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.poster-meta { display: grid; gap: 2px; min-width: 0; }
.poster-title { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poster-sub { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { .poster:hover .poster-art { box-shadow: 0 0 0 1.5px rgba(231,185,107,.55), 0 14px 28px -14px rgba(0,0,0,.9); } }

/* ---------- states ---------- */
.state { display: grid; justify-items: center; gap: 10px; padding: 28px var(--s4); text-align: center; color: var(--text-2); }
.state-error .ic { color: #ff8b8e; }
.notice { padding: 12px 14px; border-radius: var(--r-md); background: var(--gold-soft); color: var(--gold-hi); font-size: var(--fs-sm); display: grid; gap: 10px; }

/* ---------- dialog / overlay (in-document, above everything) ---------- */
.overlay { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity var(--t-med); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.overlay.open { opacity: 1; } .overlay.closing { opacity: 0; }
.dialog { width: 100%; max-height: calc(100dvh - var(--sat) - 24px); overflow: auto; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 8px var(--gutter) calc(var(--s6) + var(--sab)); transform: translateY(24px); transition: transform var(--t-med) var(--ease); overscroll-behavior: contain; }
.overlay.open .dialog { transform: none; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.dialog-title { font-size: var(--fs-lg); }
.dialog-text { color: var(--text-2); margin-bottom: var(--s4); }
.dialog-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s4); flex-wrap: wrap; }
@media (min-width: 768px) { .overlay { align-items: center; } .dialog { width: min(520px, 92vw); border-radius: var(--r-xl); padding-bottom: var(--s6); } .dialog-wide { width: min(820px, 94vw); } }

/* ---------- toast ---------- */
.toast-host { position: fixed; z-index: var(--z-toast); inset-inline: 0; bottom: calc(var(--bottom-nav-h) + 16px + var(--sab)); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding-inline: var(--gutter); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; padding: 12px 16px; border-radius: var(--r-md); background: rgba(22,22,24,.96); border: 1px solid rgba(231,185,107,.35); box-shadow: 0 12px 32px -10px rgba(0,0,0,.8); font-size: var(--fs-sm); opacity: 0; transform: translateY(10px); transition: all var(--t-med) var(--ease); }
.toast.show { opacity: 1; transform: none; }
.toast-action { color: var(--gold); font-weight: 700; white-space: nowrap; }
@media (min-width: 768px) { .toast-host { bottom: 24px; } }

/* ---------- Motion Off / reduced motion (§26) ---------- */
.motion-off *, .motion-off *::before, .motion-off *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; animation-iteration-count: 1 !important; }
.motion-off .ring-loader-ring, .motion-off .splash-ring, .motion-off .ring-inline { animation: breathe 1.6s var(--ease) infinite !important; }   /* functional loading indicator stays */
.data-saver .poster-art > img { filter: saturate(.8); }

/* Owner rules: no zoom gestures, no selecting/copying names or content (text fields excepted). */
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, video { -webkit-user-drag: none; }
/* No visible scrollbars anywhere (owner rule): scrolling works the same, the gray bar is gone. */
html, body, * { scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar, *::-webkit-scrollbar { display: none; width: 0; height: 0; background: transparent; }
