:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #111015;
  --bg-elevated: #18171d;
  --panel: rgba(31, 29, 37, 0.88);
  --panel-strong: #211f28;
  --field: #17161c;
  --line: rgba(214, 198, 255, 0.12);
  --line-strong: rgba(174, 118, 255, 0.34);
  --text: #f6f2ff;
  --muted: #a9a3b4;
  --accent: #a855f7;
  --accent-bright: #c084fc;
  --accent-soft: rgba(168, 85, 247, 0.16);
  --danger: #fb7185;
  --success: #a78bfa;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; background: linear-gradient(160deg, #151419 0%, #111015 48%, #17131d 100%); }
body, button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
a { color: inherit; }

.ambient-glow { position: fixed; z-index: -1; width: 36rem; height: 36rem; border-radius: 50%; filter: blur(110px); opacity: .18; pointer-events: none; }
.ambient-glow-one { top: -18rem; right: -13rem; background: #8b5cf6; }
.ambient-glow-two { bottom: -22rem; left: -16rem; background: #6d28d9; }

.app-shell { width: min(1040px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; padding: 32px 0 124px; }
.screen { display: none; animation: screen-in .2s ease; }
.screen.is-active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel { border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: 0 24px 70px rgba(0,0,0,.25), inset 0 1px rgba(255,255,255,.025); backdrop-filter: blur(24px); }
.eyebrow { margin: 0 0 7px; color: var(--accent-bright); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1,h2,p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 6vw, 3.7rem); line-height: 1; letter-spacing: -.055em; }
h2 { margin-bottom: 8px; font-size: 1.25rem; letter-spacing: -.025em; }
code { color: #d8b4fe; }

.brand-header { display: flex; align-items: center; gap: 20px; max-width: 760px; margin: 4vh auto 28px; }
.brand-icon { width: 90px; height: 90px; border-radius: 24px; box-shadow: 0 0 34px rgba(168,85,247,.28); }
.brand-subtitle { margin: 0; color: var(--muted); font-size: 1.03rem; line-height: 1.5; }
.service-strip { display: flex; align-items: center; gap: 14px; max-width: 760px; margin: 0 auto 20px; padding: 16px 18px; }
.service-strip div { display: flex; flex-wrap: wrap; gap: 5px 10px; }
.service-strip strong { font-size: .92rem; }
.service-strip span:not(.service-dot) { color: var(--muted); font-size: .84rem; }
.service-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 14px var(--accent); }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.action-card { display: flex; min-height: 330px; flex-direction: column; align-items: stretch; padding: 26px; }
.action-card-primary { background: linear-gradient(145deg, rgba(92,47,138,.48), rgba(31,29,37,.9) 60%); border-color: var(--line-strong); }
.action-card > div:nth-child(2) { flex: 1; }
.action-card p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.card-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 24px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--accent-soft); color: #e9d5ff; font-size: 1.55rem; box-shadow: 0 0 25px rgba(168,85,247,.12); }

.primary-button,.secondary-button,.ghost-button,.icon-action,.topbar-button,.attach-button,.send-button { border: 0; transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.primary-button,.secondary-button { min-height: 48px; border-radius: 15px; padding: 12px 18px; font-weight: 800; }
.primary-button { background: linear-gradient(135deg,#9333ea,#7c3aed); color: #fff; box-shadow: 0 12px 28px rgba(124,58,237,.25); }
.primary-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 15px 32px rgba(124,58,237,.34); }
.secondary-button { border: 1px solid var(--line); background: #27242f; color: var(--text); }
.secondary-button:hover:not(:disabled) { border-color: var(--line-strong); background: #2d2937; }
.compact-button { min-width: 140px; }
.field-label { display: block; margin-bottom: 8px; color: #d8d2df; font-size: .78rem; font-weight: 700; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 10px; }
input,textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: none; background: var(--field); color: var(--text); }
input:focus,textarea:focus { border-color: rgba(192,132,252,.62); box-shadow: 0 0 0 3px rgba(168,85,247,.12); }
.join-row input { min-width: 0; padding: 12px 14px; }
.icon-action { width: 48px; border: 1px solid var(--line); border-radius: 14px; background: #27242f; color: #d8b4fe; font-weight: 800; }
.inline-error,.fatal-error { margin: 10px 0 0; color: #fecdd3; font-size: .84rem; }

.active-room-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; padding: 22px; border-color: var(--line-strong); }
.active-room-card p:last-child { margin: 0; color: var(--muted); }
.steps { margin-top: 16px; padding: 25px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.steps ol { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: rgba(23,22,28,.7); }
.steps li > span { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px; background: var(--accent-soft); color: #d8b4fe; font-weight: 900; }
.steps li p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.install-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 20px; }
.text-link { color: #d8b4fe; font-weight: 700; text-decoration: none; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, minmax(84px,120px)); gap: 6px; transform: translateX(-50%); padding: 8px; border: 1px solid var(--line-strong); border-radius: 24px; background: rgba(24,23,29,.92); box-shadow: 0 18px 55px rgba(0,0,0,.5), 0 0 30px rgba(126,34,206,.13); backdrop-filter: blur(25px); }
.nav-item { position: relative; display: grid; justify-items: center; gap: 4px; border: 0; border-radius: 17px; padding: 9px 12px 8px; background: transparent; color: #8f8999; font-size: .72rem; font-weight: 700; }
.nav-item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.nav-item.is-active { background: var(--accent-soft); color: #e9d5ff; box-shadow: inset 0 0 0 1px rgba(192,132,252,.16); }
.nav-badge { position: absolute; top: 7px; right: 25px; width: 7px; height: 7px; border-radius: 50%; background: #d8b4fe; box-shadow: 0 0 10px #a855f7; }

.chat-topbar { position: sticky; z-index: 10; top: 12px; display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; gap: 12px; min-height: 72px; padding: 12px 14px; }
.topbar-button { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 15px; background: #27242f; color: var(--text); font-size: 1.35rem; }
.danger-button { color: #fda4af; }
.chat-heading { min-width: 0; text-align: center; }
.chat-heading h1 { margin: 0 0 4px; font-size: 1.12rem; letter-spacing: -.02em; }
.connection-status { overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.connection-status[data-state="online"] { color: #d8b4fe; }
.connection-status[data-state="offline"] { color: #fda4af; }
.chat-empty { display: grid; justify-items: center; max-width: 560px; margin: 16vh auto 0; padding: 44px 30px; text-align: center; }
.chat-empty p { max-width: 380px; color: var(--muted); line-height: 1.6; }
.empty-symbol { display: grid; place-items: center; width: 74px; height: 74px; margin-bottom: 20px; border: 1px solid var(--line-strong); border-radius: 24px; background: var(--accent-soft); color: #d8b4fe; font-size: 2rem; box-shadow: 0 0 30px rgba(168,85,247,.15); }
.chat-room { display: grid; grid-template-rows: auto auto 1fr auto auto; height: calc(100dvh - 170px); min-height: 560px; margin-top: 14px; overflow: hidden; }
.room-info-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.room-info-bar div { display: flex; align-items: baseline; gap: 7px; }
.room-info-bar span { color: var(--muted); font-size: .78rem; }
.ghost-button { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: transparent; color: #d8b4fe; font-size: .82rem; font-weight: 800; }
.invite-sheet { padding: 14px 18px; border-bottom: 1px solid var(--line); background: rgba(45,35,57,.55); }
.invite-sheet p { margin: 0 0 10px; color: var(--muted); font-size: .78rem; }
.invite-sheet input { padding: 10px 12px; }
.invite-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.messages { min-height: 0; overflow-y: auto; padding: 22px; scroll-behavior: smooth; }
.message { width: fit-content; max-width: min(76%,680px); margin-bottom: 10px; padding: 11px 13px 7px; border: 1px solid transparent; border-radius: 18px; }
.message p { margin-bottom: 4px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.48; }
.message time { display: block; color: rgba(235,228,245,.5); font-size: .68rem; text-align: right; }
.message.incoming { border-bottom-left-radius: 5px; background: #292630; }
.message.outgoing { margin-left: auto; border-color: rgba(192,132,252,.16); border-bottom-right-radius: 5px; background: linear-gradient(145deg,#542778,#43235d); }
.system-message { width: fit-content; max-width: 78%; margin: 13px auto; padding: 7px 11px; border-radius: 999px; background: rgba(23,22,28,.72); color: var(--muted); font-size: .74rem; text-align: center; }
.transfer-summary { display: grid; gap: 7px; padding: 10px 16px; border-top: 1px solid var(--line); background: rgba(37,31,45,.85); }
.transfer-summary div { display: flex; justify-content: space-between; gap: 12px; font-size: .75rem; }
.transfer-summary span { color: var(--muted); }
progress { width: 100%; height: 5px; overflow: hidden; border: 0; border-radius: 999px; accent-color: var(--accent); }
.composer { display: grid; grid-template-columns: 46px 1fr 46px; align-items: end; gap: 9px; padding: 12px; border-top: 1px solid var(--line); background: rgba(24,23,29,.96); }
.attach-button,.send-button { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; }
.attach-button { border: 1px solid var(--line); background: #292630; color: #d8b4fe; font-size: 1.55rem; }
.composer textarea { resize: none; min-height: 46px; max-height: 120px; padding: 12px 14px; line-height: 1.35; }
.send-button { background: linear-gradient(135deg,#9333ea,#7c3aed); color: #fff; box-shadow: 0 8px 22px rgba(124,58,237,.28); }
.send-button svg { width: 23px; height: 23px; fill: currentColor; }

.page-header { max-width: 680px; margin: 4vh auto 25px; text-align: center; }
.page-header p:last-child { color: var(--muted); }
.settings-group { max-width: 760px; margin: 0 auto 15px; padding: 23px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.setting-row div { display: grid; gap: 5px; }
.setting-row span,.setting-note { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.setting-note { margin: 14px 0 0; }
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { display: block; width: 51px; height: 29px; border: 1px solid var(--line); border-radius: 999px; background: #2a2731; transition: .2s; }
.switch span::after { content: ""; display: block; width: 21px; height: 21px; margin: 3px; border-radius: 50%; background: #96909f; transition: .2s; }
.switch input:checked + span { border-color: var(--line-strong); background: #572879; box-shadow: 0 0 20px rgba(168,85,247,.2); }
.switch input:checked + span::after { transform: translateX(22px); background: #e9d5ff; }
.security-list { display: grid; gap: 10px; margin: 15px 0 0; padding: 0; list-style: none; }
.security-list li { display: flex; gap: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(23,22,28,.64); }
.security-list li > span { color: #c084fc; }
.security-list p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.about-card { display: grid; grid-template-columns: 70px 1fr; gap: 17px; }
.about-card > img { width: 70px; height: 70px; border-radius: 20px; box-shadow: 0 0 24px rgba(168,85,247,.24); }
.about-card > div p:last-child { margin: 0; color: var(--muted); line-height: 1.5; }
.about-card dl { grid-column: 1/-1; margin: 5px 0 0; }
.about-card dl div { display: flex; justify-content: space-between; padding: 11px 0; border-top: 1px solid var(--line); }
.about-card dt { color: var(--muted); }
.about-card dd { margin: 0; }
.about-links { grid-column: 1/-1; display: flex; gap: 18px; }
.about-links a { color: #d8b4fe; font-weight: 700; text-decoration: none; }

.sheet-backdrop { position: fixed; z-index: 40; inset: 0; background: rgba(0,0,0,.58); backdrop-filter: blur(5px); }
.bottom-sheet { position: fixed; z-index: 41; left: 50%; bottom: 0; width: min(560px,100%); max-height: 75dvh; overflow-y: auto; transform: translateX(-50%); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 28px 28px 0 0; padding: 12px 18px max(24px,env(safe-area-inset-bottom)); background: #201e26; box-shadow: 0 -20px 70px rgba(0,0,0,.55), 0 0 45px rgba(126,34,206,.12); animation: sheet-in .18s ease; }
@keyframes sheet-in { from { transform: translate(-50%,100%); } }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 15px; border-radius: 99px; background: #514b5b; }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.file-action { display: flex; align-items: center; gap: 14px; width: 100%; border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: #2a2731; color: var(--text); text-align: left; }
.file-action > span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: #d8b4fe; font-size: 1.5rem; }
.file-action div { display: grid; gap: 3px; }
.file-action small { color: var(--muted); }
.transfers { display: grid; gap: 9px; margin-top: 14px; }
.muted { color: var(--muted); font-size: .8rem; }
.transfer-card { display: grid; gap: 7px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: #18171d; }
.transfer-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-card > span { color: var(--muted); font-size: .76rem; }
.download-link { color: #d8b4fe; font-size: .82rem; font-weight: 800; }

@media (max-width:760px) {
  .app-shell { width: min(100% - 20px,620px); padding: max(14px,env(safe-area-inset-top)) 0 118px; }
  .brand-header { margin-top: 12px; }
  .brand-icon { width: 72px; height: 72px; border-radius: 20px; }
  .home-grid,.steps ol { grid-template-columns: 1fr; }
  .action-card { min-height: 0; }
  .active-room-card { align-items: stretch; flex-direction: column; }
  .chat-topbar { top: max(8px,env(safe-area-inset-top)); }
  .chat-room { height: calc(100dvh - 154px - env(safe-area-inset-top)); margin-top: 9px; border-radius: 20px; }
  .messages { padding: 15px; }
  .message { max-width: 88%; }
  .bottom-nav { bottom: max(8px,env(safe-area-inset-bottom)); width: calc(100% - 20px); grid-template-columns: repeat(3,1fr); border-radius: 22px; }
  .nav-item { min-width: 0; }
  .page-header { margin-top: 18px; }
}

@media (max-width:420px) {
  .app-shell { width: calc(100% - 14px); }
  .brand-header { gap: 13px; }
  .brand-icon { width: 62px; height: 62px; }
  .brand-subtitle { font-size: .88rem; }
  .service-strip div { display: grid; }
  .panel { border-radius: 20px; }
  .action-card,.steps,.settings-group { padding: 19px; }
  .invite-actions { grid-template-columns: 1fr; }
}
