/* ===== Героинчик — theme & UI ===== */
*, *::before, *::after { box-sizing: border-box; }
:root {
	--accent: #D97757;
	--accent-2: #E89B7D;
	--accent-ink: #fff;
	--radius: 16px;
	--radius-sm: 11px;
	--dur: .22s;
	--ease: cubic-bezier(.22,.61,.36,1);
	--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
[data-theme="dark"] {
	--bg: #0c0d10; --bg-2: #14161d;
	--panel: rgba(23,25,32,.72); --panel-solid: #171922;
	--border: rgba(255,255,255,.09);
	--text: #eef0f4; --text-dim: #9aa0ac;
	--tile: #14151d; --tile-2:#1b1d27;
	--shadow: 0 18px 50px rgba(0,0,0,.55);
	--danger:#e5484d;
}
[data-theme="light"] {
	--bg: #f4efe8; --bg-2: #efe7db;
	--panel: rgba(255,255,255,.80); --panel-solid: #fff;
	--border: rgba(40,30,22,.12);
	--text: #241f1b; --text-dim: #7a726a;
	--tile: #e8e0d5; --tile-2:#ded4c6;
	--shadow: 0 18px 50px rgba(120,90,70,.18);
	--danger:#d33b40;
}

html, body { height: 100%; }
body {
	margin: 0;
	font-family: var(--font);
	color: var(--text);
	background: radial-gradient(1200px 800px at 15% -10%, var(--bg-2), var(--bg) 60%);
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* icons */
svg.ic, svg.brand-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
svg.ic.sm { width: 15px; height: 15px; }
svg.brand-ic { width: 26px; height: 26px; color: var(--accent); }
svg.brand-ic.sm { width: 20px; height: 20px; }

/* animated background orbs */
.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-orbs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; animation: float 18s var(--ease) infinite; }
.bg-orbs span:nth-child(1){ width: 460px; height: 460px; left: -120px; top: -120px; background: var(--accent); opacity:.35; }
.bg-orbs span:nth-child(2){ width: 380px; height: 380px; right: -100px; top: 20%; background: #6b6cff; opacity:.22; animation-delay: -6s; }
.bg-orbs span:nth-child(3){ width: 420px; height: 420px; left: 30%; bottom: -160px; background: var(--accent-2); opacity:.28; animation-delay: -11s; }
@keyframes float { 0%,100%{ transform: translate(0,0) scale(1); } 33%{ transform: translate(40px,30px) scale(1.08); } 66%{ transform: translate(-30px,20px) scale(.96); } }

/* ===== Login ===== */
.login { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; }
.login.leaving { animation: fadeOut .4s var(--ease) forwards; }
.login-card {
	width: min(420px, 94vw);
	background: var(--panel); backdrop-filter: blur(22px);
	border: 1px solid var(--border); border-radius: 24px;
	padding: 30px 28px; box-shadow: var(--shadow);
	animation: fadeUp .55s var(--ease) both;
}
.login-card.shake { animation: shake .4s var(--ease); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.brand-sub { color: var(--text-dim); margin: 8px 0 22px; font-size: 14px; line-height: 1.5; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 14px 0 7px; text-transform: uppercase; letter-spacing: .04em; }
.field {
	width: 100%; padding: 12px 14px; font-size: 15px; color: var(--text);
	background: var(--tile); border: 1px solid var(--border); border-radius: var(--radius-sm);
	transition: border-color var(--dur), box-shadow var(--dur), background var(--dur); outline: none; font-family: inherit;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
select.field { appearance: none; cursor: pointer; }
.key-row { display: flex; gap: 8px; }
.key-row .field { flex: 1; }
.avatar-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-opt {
	aspect-ratio: 1; display: grid; place-items: center; font-size: 20px; cursor: pointer;
	background: var(--tile); border: 1.5px solid transparent; border-radius: 12px;
	transition: transform var(--dur), border-color var(--dur), background var(--dur);
}
.avatar-opt:hover { transform: translateY(-2px) scale(1.06); background: var(--tile-2); }
.avatar-opt.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); transform: scale(1.06); }
.btn-primary {
	width: 100%; margin-top: 22px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer;
	color: var(--accent-ink); border: none; border-radius: var(--radius-sm);
	background: linear-gradient(135deg, var(--accent), var(--accent-2));
	box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
	transition: transform var(--dur), box-shadow var(--dur), filter var(--dur);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 55%, transparent); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }
.login-hint { display: flex; align-items: center; gap: 6px; justify-content: center; color: var(--text-dim); font-size: 12px; margin-top: 6px; }

/* buttons shared */
.icon-btn {
	display: inline-grid; place-items: center; width: 42px; height: 42px; cursor: pointer;
	color: var(--text); background: var(--tile); border: 1px solid var(--border); border-radius: 12px;
	transition: transform var(--dur), background var(--dur), color var(--dur), border-color var(--dur);
}
.icon-btn:hover { transform: translateY(-2px); background: var(--tile-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.accent { color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; }
.icon-btn.revealed { color: var(--accent); border-color: var(--accent); }

/* ===== App shell ===== */
.app { position: relative; z-index: 1; height: 100vh; display: flex; flex-direction: column; animation: fadeIn .5s var(--ease) both; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; gap: 12px; }
.topbar-left { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.conn { font-size: 12px; color: var(--text-dim); padding: 3px 9px; border-radius: 20px; background: var(--tile); border: 1px solid var(--border); }
.conn.online { color: #29c26f; }
.conn.online::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #29c26f; margin-right: 5px; vertical-align: middle; animation: pulse 1.8s infinite; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.sas { display: flex; align-items: center; gap: 6px; font-size: 15px; padding: 5px 11px; border-radius: 20px; background: var(--tile); border: 1px solid var(--border); letter-spacing: 2px; }
.ic-moon { display: none; }
[data-theme="light"] .ic-sun { display: none; }
[data-theme="light"] .ic-moon { display: inline-block; }
#theme-btn .ic { transition: transform .5s var(--ease); }
#theme-btn:hover .ic { transform: rotate(40deg); }

.stage { flex: 1; display: flex; gap: 14px; padding: 0 14px; min-height: 0; }

/* video grid */
.grid { flex: 1; display: grid; grid-template-columns: repeat(var(--cols,1), 1fr); gap: 12px; align-content: center; min-height: 0; padding: 4px; }
.tile {
	position: relative; aspect-ratio: 16/10; overflow: hidden; border-radius: var(--radius);
	background: linear-gradient(160deg, var(--tile-2), var(--tile)); border: 1px solid var(--border);
	box-shadow: var(--shadow); animation: tileIn .45s var(--ease) both;
	transition: box-shadow var(--dur), transform var(--dur);
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.tile.has-video video { display: block; }
.tile.self video { transform: scaleX(-1); }
.tile-avatar { position: absolute; inset: 0; margin: auto; width: 92px; height: 92px; display: grid; place-items: center; font-size: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent); animation: pop .4s var(--ease) both; }
.tile.has-video .tile-avatar { display: none; }
.tile-name { position: absolute; left: 12px; bottom: 12px; font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 20px; background: rgba(0,0,0,.5); color: #fff; backdrop-filter: blur(6px); }
.tile-badge { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.tile.speaking { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.tile.speaking::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); box-shadow: inset 0 0 0 2px var(--accent); animation: ring 1.2s var(--ease) infinite; pointer-events: none; }

/* side panel */
.side { width: 320px; display: flex; flex-direction: column; background: var(--panel); backdrop-filter: blur(18px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tabs { display: flex; padding: 8px; gap: 6px; border-bottom: 1px solid var(--border); }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-dim); background: transparent; border: none; border-radius: 10px; transition: color var(--dur), background var(--dur); position: relative; }
.tab .ic { width: 18px; height: 18px; }
.tab:hover { color: var(--text); background: var(--tile); }
.tab.active { color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.tab .count { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: rgba(255,255,255,.22); }
.tab.has-unread::after { content: ""; position: absolute; top: 7px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: fadeIn .3s var(--ease); }

.people-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 12px; transition: background var(--dur); animation: slideIn .35s var(--ease) both; }
.person:hover { background: var(--tile); }
.person-av { width: 38px; height: 38px; display: grid; place-items: center; font-size: 19px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: none; }
.person-name { font-size: 14px; font-weight: 500; }
.person-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); flex: none; transition: background var(--dur), box-shadow var(--dur); }
.person.speaking .person-dot { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }

/* chat */
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; align-self: flex-start; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--tile); border: 1px solid var(--border); animation: msgIn .32s var(--ease) both; }
.msg.me { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #000), var(--accent-2)); color: #fff; border: none; }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 11px; opacity: .8; margin-bottom: 3px; }
.msg-head b { font-weight: 700; }
.msg-body { font-size: 14px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-body a { color: inherit; text-decoration: underline; }
.msg-img { max-width: 100%; border-radius: 10px; margin-top: 2px; display: block; }
.msg audio { margin-top: 4px; height: 34px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 10px; background: rgba(0,0,0,.15); color: inherit; text-decoration: none; font-size: 13px; }
.hist-sep { text-align: center; font-size: 11px; color: var(--text-dim); margin: 6px 0; opacity: .7; }
.composer { display: flex; align-items: center; gap: 7px; padding: 10px; border-top: 1px solid var(--border); }
.composer .icon-btn { width: 38px; height: 38px; flex: none; }
.composer .icon-btn.on { color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; animation: pulse 1.2s infinite; }
.chat-input { flex: 1; min-width: 0; padding: 10px 13px; font-size: 14px; color: var(--text); background: var(--tile); border: 1px solid var(--border); border-radius: 20px; outline: none; font-family: inherit; transition: border-color var(--dur), box-shadow var(--dur); }
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* reactions bar */
.reactions-bar { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(14px); display: flex; gap: 6px; padding: 8px; border-radius: 18px; background: var(--panel); backdrop-filter: blur(18px); border: 1px solid var(--border); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity var(--dur), transform var(--dur); z-index: 12; }
.reactions-bar.open { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.react-opt { font-size: 22px; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer; background: transparent; border: none; border-radius: 12px; transition: transform var(--dur), background var(--dur); }
.react-opt:hover { transform: scale(1.35) translateY(-3px); background: var(--tile); }
.react-float { position: absolute; bottom: 60px; font-size: 34px; pointer-events: none; animation: floatUp 2.1s var(--ease) forwards; z-index: 5; }

/* control bar */
.controls { display: flex; justify-content: center; gap: 12px; padding: 16px; flex-wrap: wrap; }
.ctrl { position: relative; width: 54px; height: 54px; display: grid; place-items: center; cursor: pointer; color: var(--text); background: var(--panel); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); transition: transform var(--dur), background var(--dur), color var(--dur); }
.ctrl:hover { transform: translateY(-3px); }
.ctrl:active { transform: scale(.9); }
.ctrl .ic { width: 24px; height: 24px; }
.ctrl .ic-off { display: none; }
.ctrl.off { background: var(--danger); color: #fff; border-color: transparent; }
.ctrl.off .ic-on { display: none; }
.ctrl.off .ic-off { display: block; }
.ctrl.on { color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.ctrl.danger { color: #fff; background: linear-gradient(135deg, var(--danger), #ff6b6b); border-color: transparent; }
.ctrl.danger:hover { filter: brightness(1.08); }
#rec-btn.on { color: #fff; background: var(--danger); border-color: transparent; animation: pulse 1.3s infinite; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.5); backdrop-filter: blur(4px); animation: fadeIn .25s var(--ease); }
.modal-card { width: min(400px, 94vw); background: var(--panel-solid); border: 1px solid var(--border); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); animation: pop .3s var(--ease) both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 14px; cursor: pointer; }
.switch input { width: 42px; height: 24px; appearance: none; background: var(--tile); border: 1px solid var(--border); border-radius: 20px; position: relative; cursor: pointer; transition: background var(--dur); flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-dim); transition: transform var(--dur), background var(--dur); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: #fff; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(18px); z-index: 40; max-width: 90vw; padding: 12px 18px; font-size: 14px; color: var(--text); background: var(--panel-solid); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity var(--dur), transform var(--dur); }
.toast:not(.hidden) { opacity: 1; transform: translateX(-50%) translateY(0); }

/* drop hint */
.drop-hint { position: fixed; inset: 16px; z-index: 25; display: none; place-items: center; gap: 10px; font-size: 18px; font-weight: 600; color: var(--accent); border: 3px dashed var(--accent); border-radius: 24px; background: color-mix(in srgb, var(--accent) 12%, transparent); backdrop-filter: blur(6px); }
body.dropping .drop-hint { display: grid; animation: fadeIn .2s var(--ease); }

/* scrollbars */
.messages::-webkit-scrollbar, .people-list::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .people-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: scale(1.03); } }
@keyframes tileIn { from { opacity: 0; transform: scale(.9) translateY(14px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes ring { 0% { opacity: .9; } 100% { opacity: .2; } }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(0) scale(.6); } 20% { opacity: 1; transform: translateY(-20px) scale(1.2); } 100% { opacity: 0; transform: translateY(-160px) scale(1); } }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); } 30%,50%,70% { transform: translateX(-8px); } 40%,60% { transform: translateX(8px); } }

/* mobile */
@media (max-width: 820px) {
	.stage { flex-direction: column; }
	.side { width: auto; height: 40vh; }
	.grid { --cols: 2 !important; }
	.ctrl { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
