/* =====================================================================
   Ovicam — public app styles
   ===================================================================== */
:root {
  --ink: #0e1018; --panel: #161926; --panel2: #1d2130; --panel3: #252a3d; --line: #2a2f45;
  --text: #eceefb; --dim: #979eba; --faint: #6b7190;
  --violet: #9482ff; --violet-d: #7560f5; --rose: #ff5f7e; --mint: #5de3c1; --amber: #ffc15e;
  --radius: 18px;
  --font: "Avenir Next", "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html, body { min-height: 100%; }
body { background: var(--ink); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; min-height: 100dvh; }
[hidden] { display: none !important; }
a { color: var(--violet); }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
button, select, input, textarea { font: inherit; color: inherit; }
kbd { background: var(--panel3); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; font-size: .8em; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--dim); }
.hint { color: var(--faint); font-size: .85rem; }
.center { text-align: center; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 999px; padding: 10px 18px; font-weight: 700; cursor: pointer; transition: background .15s, transform .1s, border-color .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--panel3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--violet); color: var(--ink); border-color: transparent; }
.btn.primary:hover { background: #a698ff; }
.btn.danger { color: var(--rose); }
.btn.danger.big { background: var(--rose); color: var(--ink); border-color: transparent; }
.btn.big { width: 100%; padding: 15px 24px; font-size: 1.05rem; }
.btn.small { padding: 6px 14px; font-size: .88rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.icon { width: 46px; height: 46px; padding: 0; flex: none; }
.icon-btn { width: 48px; height: 48px; padding: 0; font-size: 1.15rem; flex: none; }
.icon-btn[aria-pressed="false"] { background: var(--rose); border-color: transparent; filter: saturate(.9); }
.grow { flex: 1; }

/* ------------------------------------------------------------- fields */
.field { display: grid; gap: 6px; }
.field > span { font-size: .86rem; color: var(--dim); font-weight: 600; }
.field small { color: var(--faint); font-weight: 500; }
input:not([type=checkbox]):not([type=radio]), select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; width: 100%; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--violet); outline: none; }
textarea { resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; color: var(--dim); cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--violet); width: 17px; height: 17px; flex: none; }
.check.small { font-size: .82rem; }
.check b { color: var(--text); }
.form-error { background: rgba(255, 95, 126, .12); border: 1px solid rgba(255, 95, 126, .35); color: #ffb3c2; padding: 10px 14px; border-radius: 12px; font-size: .9rem; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 4px; }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: 9px 12px; font-weight: 700; color: var(--dim); cursor: pointer; }
.segmented button[aria-checked="true"], .segmented button[aria-selected="true"] { background: var(--violet); color: var(--ink); }
.segmented button:disabled { opacity: .4; cursor: not-allowed; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.tags:focus-within { border-color: var(--violet); }
.tags input { flex: 1; min-width: 140px; border: 0 !important; background: transparent !important; padding: 6px 8px !important; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: rgba(148, 130, 255, .16); color: #cfc7ff; border-radius: 999px; padding: 4px 6px 4px 11px; font-size: .86rem; font-weight: 600; }
.tag button { border: 0; background: transparent; color: inherit; cursor: pointer; width: 20px; height: 20px; border-radius: 50%; line-height: 1; }
.tag button:hover { background: rgba(255, 255, 255, .1); }

details.filters { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: rgba(255, 255, 255, .015); }
details.filters summary { cursor: pointer; font-weight: 700; font-size: .92rem; display: flex; justify-content: space-between; gap: 8px; list-style: none; }
details.filters summary::-webkit-details-marker { display: none; }
details.filters summary::after { content: "▾"; color: var(--dim); }
details.filters[open] summary::after { content: "▴"; }
details.filters summary small { color: var(--violet); font-weight: 600; margin-left: auto; }
details.filters[open] > .grid-2 { margin: 14px 0 8px; }

/* ------------------------------------------------------------- layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--line); background: rgba(14, 16, 24, .85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.online-pill { display: flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; }
.online-pill b { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 0 rgba(93, 227, 193, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(93, 227, 193, 0); } 100% { box-shadow: 0 0 0 0 rgba(93, 227, 193, 0); } }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.member-menu { display: flex; align-items: center; gap: 4px; }
.member-name { font-weight: 700; padding: 0 6px; }
.member-name::before { content: "● "; color: var(--mint); }

.banner { padding: 11px clamp(16px, 3vw, 32px); text-align: center; font-weight: 600; font-size: .93rem; background: rgba(148, 130, 255, .14); color: #d9d3ff; border-bottom: 1px solid rgba(148, 130, 255, .25); }
.banner.rose { background: rgba(255, 95, 126, .14); color: #ffc2ce; border-color: rgba(255, 95, 126, .3); }
.banner.mint { background: rgba(93, 227, 193, .12); color: #b9f5e5; border-color: rgba(93, 227, 193, .25); }
.banner.amber { background: rgba(255, 193, 94, .12); color: #ffe2b0; border-color: rgba(255, 193, 94, .25); }

.screen { flex: 1; width: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* -------------------------------------------------------- setup screen */
#screen-setup { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(24px, 5vw, 72px); align-items: center; max-width: 1140px; margin: 0 auto; padding: clamp(24px, 5vw, 64px) clamp(16px, 4vw, 40px); }
.hero h1 { font-size: clamp(2rem, 4.4vw, 3.4rem); line-height: 1.08; letter-spacing: -.035em; margin: 28px 0 18px; text-wrap: balance; }
.lead { color: var(--dim); font-size: 1.08rem; max-width: 34em; }
.hero-points { list-style: none; padding: 0; margin-top: 28px; display: grid; gap: 12px; }
.hero-points li { display: flex; gap: 12px; align-items: center; font-weight: 600; }
.hero-points span { width: 36px; height: 36px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; }
.setup-card { padding: clamp(18px, 3vw, 28px); display: grid; gap: 18px; box-shadow: 0 30px 80px -40px rgba(117, 96, 245, .45); }

.preview { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: radial-gradient(circle at 30% 30%, #20253a, #121522); border: 1px solid var(--line); }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; color: var(--dim); font-size: .9rem; }
.preview-empty > span { font-size: 1.8rem; }
.preview.has-video .preview-empty { display: none; }

/* ------------------------------------------------------------- orbs */
.orbs { position: relative; width: 220px; height: 110px; }
.orb { position: absolute; top: 0; width: 110px; height: 110px; border-radius: 50%; mix-blend-mode: screen; }
.orb.a { left: 0; background: radial-gradient(circle at 35% 35%, #b9adff, var(--violet-d) 72%); animation: driftA 5.5s ease-in-out infinite; }
.orb.b { right: 0; background: radial-gradient(circle at 65% 35%, #ffa7ba, var(--rose) 72%); animation: driftB 5.5s ease-in-out infinite; }
@keyframes driftA { 50% { transform: translateX(60px); } }
@keyframes driftB { 50% { transform: translateX(-60px); } }
.orbs.small { width: 140px; height: 70px; }
.orbs.small .orb { width: 70px; height: 70px; }
.orbs.small .orb.a { animation-name: driftAs; animation-duration: 2.4s; }
.orbs.small .orb.b { animation-name: driftBs; animation-duration: 2.4s; }
@keyframes driftAs { 50% { transform: translateX(38px); } }
@keyframes driftBs { 50% { transform: translateX(-38px); } }
.orbs.merged .orb { animation: none; transition: transform .5s; }
.orbs.merged .orb.a { transform: translateX(35px); }
.orbs.merged .orb.b { transform: translateX(-35px); }
@media (prefers-reduced-motion: reduce) { .orb { animation: none !important; } .dot { animation: none; } }

/* -------------------------------------------------------- chat screen */
.chat { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; padding: 16px; height: calc(100dvh - 64px); }
.chat.text-mode { grid-template-columns: minmax(0, 760px); justify-content: center; }
.chat.text-mode .stage { display: none; }
.stage { position: relative; display: grid; min-height: 0; }
.remote { position: relative; background: #07080d; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 0; }
.remote video { width: 100%; height: 100%; object-fit: cover; background: #07080d; }
.overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; background: radial-gradient(circle at 50% 40%, rgba(117, 96, 245, .14), transparent 60%), #0a0b12; transition: opacity .3s; }
.overlay.clear { opacity: 0; pointer-events: none; }
.overlay-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; }
.overlay-sub { color: var(--dim); max-width: 30em; }
.remote-flags { position: absolute; left: 14px; top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.flag-chip { background: rgba(10, 11, 18, .72); backdrop-filter: blur(6px); border-radius: 999px; padding: 5px 11px; font-size: .82rem; font-weight: 700; }
.local { position: absolute; right: 14px; bottom: 14px; width: clamp(120px, 22%, 240px); aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .12); background: #111; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.local video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.local-off { position: absolute; inset: 0; display: grid; place-items: center; background: #15172a; color: var(--dim); font-size: .8rem; font-weight: 700; }

.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.partner { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, var(--violet), var(--rose)); color: var(--ink); flex: none; }
.partner-meta { display: grid; line-height: 1.25; min-width: 0; }
.partner-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partner-meta small { color: var(--dim); }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--dim); font-weight: 700; font-size: .9rem; }
.common { font-size: .84rem; color: var(--mint); }

.messages { list-style: none; padding: 4px 2px; margin: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 120px; scroll-behavior: smooth; }
.msg { max-width: 82%; padding: 8px 13px; border-radius: 16px; background: var(--panel2); word-wrap: break-word; overflow-wrap: anywhere; font-size: .95rem; align-self: flex-start; border-bottom-left-radius: 5px; animation: pop .18s ease-out; }
.msg.mine { align-self: flex-end; background: var(--violet-d); color: #fff; border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }
.msg.flagged { opacity: .85; }
.msg time { display: block; font-size: .7rem; opacity: .6; margin-top: 2px; }
.msg.sys { align-self: center; background: transparent; color: var(--faint); font-size: .82rem; text-align: center; max-width: 95%; padding: 4px; }
.msg.sys.warn { color: var(--amber); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.typing { color: var(--dim); font-size: .82rem; font-style: italic; margin-top: -6px; }
.composer { display: flex; gap: 8px; }
.composer input { border-radius: 999px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ dialogs */
.dialog { margin: auto; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--text); padding: 26px; width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 30px 90px rgba(0, 0, 0, .6); }
.dialog.wide { width: min(640px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(5, 6, 10, .72); backdrop-filter: blur(4px); }
.dialog h2 { font-size: 1.35rem; margin-bottom: 8px; letter-spacing: -.02em; }
.dialog > .segmented { margin: 4px 36px 20px 0; }
.dlg-close { position: absolute; right: 14px; top: 14px; }
.dlg-close button { border: 0; background: var(--panel2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; color: var(--dim); }
.dlg-close button:hover { color: var(--text); }
.radio-list { display: grid; gap: 6px; margin-top: 8px; }
.radio-list label { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.radio-list label:has(input:checked) { border-color: var(--rose); background: rgba(255, 95, 126, .08); }
.radio-list input { accent-color: var(--rose); }
.rules { display: grid; gap: 10px; padding-left: 20px; margin: 14px 0; color: var(--dim); }
.rules b { color: var(--text); }

.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 18px; }
.stat { background: var(--panel2); border-radius: 14px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; letter-spacing: -.03em; }
.stat span { color: var(--dim); font-size: .82rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 4px; justify-items: center; text-align: center; background: var(--panel2); }
.badge .ico { font-size: 2rem; }
.badge b { font-size: .95rem; }
.badge small { color: var(--dim); font-size: .78rem; line-height: 1.35; }
.badge.locked .ico { filter: grayscale(1); opacity: .35; }
.badge.locked b { color: var(--dim); }
.badge.earned { border-color: rgba(148, 130, 255, .45); background: linear-gradient(180deg, rgba(148, 130, 255, .14), var(--panel2)); }
.progress { width: 100%; height: 5px; background: var(--panel3); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--violet); border-radius: 99px; }

/* ----------------------------------------------------- blocker & toast */
.blocker { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 10, .9); backdrop-filter: blur(6px); }
.blocker-card { padding: 34px; max-width: 460px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.blocker-icon { font-size: 2.6rem; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100% - 32px)); }
.toast { display: flex; gap: 12px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45); animation: pop .25s ease-out; }
.toast .ico { font-size: 1.6rem; }
.toast b { display: block; }
.toast small { color: var(--dim); }
.toast.error { border-color: rgba(255, 95, 126, .4); }
.toast.success { border-color: rgba(93, 227, 193, .4); }

/* --------------------------------------------------------- responsive */
@media (max-width: 960px) {
  #screen-setup { grid-template-columns: 1fr; }
  .hero { text-align: center; display: grid; justify-items: center; }
  .hero-points { justify-items: start; }
  .chat { grid-template-columns: 1fr; grid-template-rows: minmax(240px, 45dvh) minmax(0, 1fr); height: auto; min-height: calc(100dvh - 64px); }
  .chat.text-mode { grid-template-rows: minmax(0, 1fr); grid-template-columns: 1fr; }
  .side { min-height: 360px; }
}
@media (max-width: 560px) {
  .hide-sm { display: none; }
  .online-pill { display: none !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .chat { padding: 8px; gap: 8px; }
  .profile-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat b { font-size: 1.25rem; }
  .topbar { gap: 8px; }
}
