:root {
  --bg: #f6f6fb; --card: #fff; --text: #16161d; --muted: #6b6b7b; --line: #e6e6ef;
  --brand: #5b4bff; --brand-2: #8a7dff; --mine: #5b4bff; --mine-text: #fff; --theirs: #fff;
  --danger: #d9304f; --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0f14; --card: #1a1a22; --text: #f1f1f6; --muted: #9a9aab; --line: #2a2a35; --theirs: #22222c; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
h1 { font-size: 28px; margin: 0 0 8px; } h2.section { font-size: 15px; color: var(--muted); margin: 24px 4px 10px; font-weight: 600; }

.view { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.view.center { align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 14px; }
.scroll { flex: 1; overflow-y: auto; padding: 16px; }

.bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--card); min-height: 56px; }
.bar .brand { font-weight: 800; font-size: 20px; color: var(--brand); flex: 1; }
.bar .title { flex: 1; min-width: 0; } .bar .title div:first-child { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 6px; align-items: center; }
.brand { color: var(--brand); }

.hero { padding: 48px 24px 16px; text-align: center; } .hero .brand { font-size: 36px; font-weight: 800; }
.card { background: var(--card); border-radius: var(--radius); margin: 0 16px; padding: 18px; border: 1px solid var(--line); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input[type=text], input:not([type]), input[type=number] {
  font: inherit; font-size: 16px; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); outline: none; }
input:focus { border-color: var(--brand); }
.seg { display: flex; gap: 8px; } .seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 13px; border-radius: 12px; border: 1px solid var(--line); font-weight: 600; cursor: pointer; }
.seg input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.check { flex-direction: row !important; align-items: flex-start; font-weight: 400 !important; gap: 10px !important; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--brand); }
.err { color: var(--danger); min-height: 1em; margin: 0; font-size: 14px; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 11px 16px; border-radius: 12px; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.big { padding: 15px; font-size: 17px; } .btn.small { padding: 7px 12px; font-size: 14px; }
.btn.wide { width: 100%; margin: 4px 0; } .btn.ghost { border: none; background: none; color: var(--muted); }
.btn.huge { width: 100%; padding: 26px 18px; font-size: 20px; border-radius: 22px; display: flex; flex-direction: column; gap: 4px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: none; }
.btn.huge small { font-weight: 500; opacity: .85; font-size: 13px; }
.btn:active { transform: scale(.98); }
.icon { font-size: 26px; line-height: 1; background: none; border: none; color: var(--text); padding: 4px 8px; cursor: pointer; }

.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.topic { text-align: left; padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font: inherit; color: var(--text); cursor: pointer; }
.topic b { display: block; font-size: 15px; } .topic span { font-size: 12px; color: var(--muted); }

.pill { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); padding: 6px 12px; border-radius: 99px; font-weight: 600; font-size: 13px; }
.bigno { font-size: 64px; font-weight: 800; }

.chat { background: var(--bg); }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 16px; background: var(--theirs); border: 1px solid var(--line); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--mine); color: var(--mine-text); border-color: var(--mine); }
.msg .who { display: block; font-size: 12px; font-weight: 700; color: var(--brand); margin-bottom: 2px; cursor: pointer; }
.msg .meta { display: block; font-size: 11px; opacity: .7; text-align: right; margin-top: 2px; }
.msg.failed { opacity: .6; }
.sys { align-self: center; font-size: 12px; color: var(--muted); padding: 6px; }
.composer { display: flex; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.composer input { flex: 1; border-radius: 99px; }
.send { width: 48px; height: 48px; border-radius: 50%; border: none; background: var(--brand); color: #fff; font-size: 18px; cursor: pointer; flex: none; }
.ended { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; color: var(--muted); font-size: 14px; }

.sheet { border: none; border-radius: 20px 20px 0 0; margin: auto auto 0; width: 100%; max-width: 560px; background: var(--card); color: var(--text); padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet::backdrop { background: rgba(0,0,0,.4); } .sheet h3 { margin: 0 0 10px; }

.net { position: fixed; top: 0; left: 0; right: 0; z-index: 10; background: #333; color: #fff; text-align: center; font-size: 13px; padding: 6px; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90%; }

.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
.pulse { width: 80px; height: 80px; border-radius: 50%; background: var(--brand); animation: pulse 1.4s ease-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .spinner, .pulse { animation: none; } }

/* Photos */
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--line);
  background: var(--bg) center/cover no-repeat; color: var(--muted); font-size: 20px; padding: 0; cursor: pointer; }
.icon-btn { width: 44px; height: 48px; border: none; background: none; font-size: 22px; cursor: pointer; flex: none; padding: 0; }
.preview-wrap { position: relative; background: #000; border-radius: 14px; overflow: hidden; display: flex; justify-content: center; max-height: 45vh; }
.preview-wrap canvas { max-width: 100%; max-height: 45vh; display: block; }
.busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); }
.sheet .check { display: flex; margin: 10px 0; font-size: 14px; }
.sheet .seg { margin: 10px 0; }
.photo-bubble { display: flex; align-items: center; gap: 8px; background: none; border: none; color: inherit; font: inherit; padding: 4px 0; cursor: pointer; text-align: left; }
.photo-bubble[disabled] { cursor: default; opacity: .7; }
.photo-bubble .ph { font-size: 22px; }
.viewer { border: none; padding: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; background: #000; color: #fff; }
.viewer[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.viewer::backdrop { background: #000; }
.viewer img { max-width: 100%; max-height: 80vh; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: none; }
.viewer-note { font-size: 13px; opacity: .75; }

/* Bot check (Cloudflare Turnstile) - invisible unless a visitor must tap it */
.captcha { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; }

