:root {
	--bg:        #0d0a0f;
	--card:      #1a1520;
	--card-2:    #16111b;
	--raised:    #221a29;
	--line:      #342a3c;
	--line-soft: #271f2e;

	--text:    #f1e8ef;
	--text-2:  #d4c4ce;
	--muted:   #a088a0;

	--accent:        #ff4f8b;
	--accent-strong: #e83a73;
	--accent-soft:   rgba(255, 79, 139, 0.14);
	--accent-glow:   rgba(255, 79, 139, 0.32);

	--gold:      #ffd27a;
	--gold-line: #b9923a;

	--ok:     #5fe08a;
	--ok-line:#2c8a52;
	--warn:   #ffce5c;
	--warn-line:#a8842f;
	--danger: #ff5c7a;
	--purple: #c79bff;
	--purple-line:#6b4ca8;

	--radius:    16px;
	--radius-sm: 10px;
	--radius-xs: 8px;
	--shadow:    0 18px 50px rgba(0, 0, 0, 0.55);
	--shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	min-height: 100vh;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	color: var(--text);
	background:
		radial-gradient(1100px 560px at 50% -12%, rgba(255, 79, 139, 0.14), transparent 60%),
		radial-gradient(900px 520px at 110% 8%, rgba(199, 123, 255, 0.10), transparent 55%),
		radial-gradient(800px 600px at -10% 110%, rgba(255, 138, 180, 0.06), transparent 55%),
		var(--bg);
	background-attachment: fixed;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: #45374e; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.wrap {
	max-width: 600px;
	margin: 0 auto;
	padding: 28px 16px 56px;
}

.brand {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	margin: 8px 0 26px;
	animation: rise 0.5s ease both;
}
.brand-mark {
	font-size: 2rem;
	line-height: 1;
	filter: drop-shadow(0 4px 10px rgba(255, 79, 139, 0.45));
}
.brand-text { text-align: left; }
.brand h1 {
	margin: 0;
	font-size: 2rem;
	font-weight: 800;
	letter-spacing: 0.5px;
	background: linear-gradient(95deg, #fff 8%, #ffb3d2 45%, var(--accent) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}
.brand-sub {
	margin: 2px 0 0;
	font-size: 0.8rem;
	color: var(--muted);
	letter-spacing: 0.3px;
}

.card {
	position: relative;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 120px),
		var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 26px;
	box-shadow: var(--shadow);
	animation: rise 0.45s ease both;
}
.card::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgba(255, 180, 210, 0.16), transparent);
	border-radius: var(--radius) var(--radius) 0 0;
}

h2.section-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 1.05rem;
	font-weight: 700;
	margin: 26px 0 14px;
}
.section-ico { font-size: 1.05rem; }

form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.2px; }

input, select, textarea {
	font: inherit;
	width: 100%;
	min-height: 46px;
	padding: 12px 14px;
	background: var(--card-2);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	color: var(--text);
	font-size: 0.95rem;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder { color: #7a6478; }
input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--accent);
	background: #1a131f;
	box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
	font: inherit;
	cursor: pointer;
	border: none;
	border-radius: var(--radius-sm);
	font-weight: 600;
	transition: transform 0.12s ease, filter 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
button:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; }

.btn-primary,
.set-foot .btn-primary,
.link-form button {
	min-height: 46px;
	padding: 12px 20px;
	color: #fff;
	background: linear-gradient(180deg, var(--accent), var(--accent-strong));
	box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover,
.link-form button:hover { filter: brightness(1.07); box-shadow: 0 6px 20px var(--accent-glow); }
.btn-block { width: 100%; }

.link-btn {
	background: transparent;
	color: var(--muted);
	padding: 8px 12px;
	font-weight: 500;
	border-radius: var(--radius-xs);
	min-height: 38px;
}
.link-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.error {
	color: var(--danger);
	min-height: 18px;
	font-size: 0.85rem;
	margin: 10px 0 0;
}

.auth-card { max-width: 420px; margin: 4vh auto 0; }
.auth-lead { margin: 0 0 18px; color: var(--text-2); font-size: 0.95rem; text-align: center; }
.vk-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	background: #4a76a8;
	box-shadow: 0 4px 14px rgba(74, 118, 168, 0.4);
}
.vk-btn:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(74, 118, 168, 0.5); }

.tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 22px;
	padding: 5px;
	background: var(--card-2);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
}
.tab {
	flex: 1;
	padding: 11px;
	background: transparent;
	border: none;
	border-radius: 9px;
	color: var(--muted);
	font-size: 0.92rem;
	font-weight: 600;
}
.tab:hover { color: var(--text-2); }
.tab.active {
	color: #fff;
	background: linear-gradient(180deg, var(--accent), var(--accent-strong));
	box-shadow: 0 4px 12px var(--accent-glow);
}

.topbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding-bottom: 18px;
	margin-bottom: 4px;
	border-bottom: 1px solid var(--line-soft);
	font-size: 0.9rem;
}
.user { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: radial-gradient(circle at 50% 35%, #3a2a3a, #16111b);
	border: 1px solid var(--line);
	font-size: 1.05rem;
	flex: 0 0 auto;
}
.user-meta { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta b { color: var(--text); font-weight: 700; }

.link-form { flex-direction: row; flex-wrap: wrap; gap: 10px; }
.link-form input { flex: 1 1 160px; min-width: 140px; }
.link-form button { flex: 0 0 auto; }

.empty-note {
	text-align: center;
	padding: 28px 16px;
	border: 1px dashed var(--line);
	border-radius: var(--radius-sm);
	margin-top: 12px;
}

.links {
	list-style: none;
	padding: 0;
	margin: 14px 0 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.links li {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	background: var(--card-2);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-sm);
	transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.links li:hover { border-color: #50405a; transform: translateY(-1px); }

.links .meta { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.links .label { font-weight: 700; font-size: 1rem; }
.links .url { color: var(--muted); font-size: 0.8rem; word-break: break-all; overflow-wrap: anywhere; }

.links .status {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 3px;
	font-size: 0.8rem;
}

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.74rem;
	font-weight: 600;
	border: 1px solid var(--line);
	color: var(--text-2);
	background: rgba(255, 255, 255, 0.03);
	white-space: nowrap;
}
.badge.ok    { color: var(--ok);     border-color: var(--ok-line);   background: rgba(95, 224, 138, 0.10); }
.badge.warn  { color: var(--warn);   border-color: var(--warn-line); background: rgba(255, 206, 92, 0.10); }
.badge.bad   { color: var(--danger); border-color: var(--danger);    background: rgba(255, 92, 122, 0.10); }
.badge.muted { color: var(--muted);  background: rgba(255, 255, 255, 0.02); }
.err-hint { cursor: help; color: var(--warn); }

.links .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.links .act, .links .del {
	background: var(--raised);
	color: var(--text-2);
	border: 1px solid var(--line);
	padding: 9px 13px;
	min-height: 40px;
	font-size: 0.82rem;
	border-radius: var(--radius-xs);
	font-weight: 600;
}
.links .act:hover { color: var(--text); border-color: var(--accent); background: #2a2030; }
.links .del { margin-left: auto; color: var(--muted); }
.links .del:hover { color: var(--danger); border-color: var(--danger); background: rgba(255, 92, 122, 0.08); }

.links .act.autoplay { color: var(--ok); border-color: var(--ok-line); background: rgba(95, 224, 138, 0.08); }
.links .act.autoplay:hover { background: rgba(95, 224, 138, 0.16); border-color: var(--ok); }
.links .act.autoplay.on { color: var(--danger); border-color: var(--danger); background: rgba(255, 92, 122, 0.10); }
.links .act.autoplay.on:hover { background: rgba(255, 92, 122, 0.18); }
.links .act.broadcast { color: var(--purple); border-color: var(--purple-line); background: rgba(167, 123, 255, 0.10); }
.links .act.broadcast:hover { background: rgba(167, 123, 255, 0.20); color: #ddc4ff; }

.subpanel {
	margin-top: 22px;
	padding: 16px;
	background: var(--card-2);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-sm);
	animation: rise 0.35s ease both;
}
.subpanel-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	font-size: 0.9rem;
	margin-bottom: 12px;
}
.subpanel-head b { color: var(--text); }

.msg-list {
	max-height: 340px;
	overflow-y: auto;
	background: #100a13;
	border: 1px solid var(--line-soft);
	border-radius: var(--radius-xs);
	padding: 12px;
	font-size: 0.82rem;
	line-height: 1.55;
	font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}
.msg { padding: 2px 0; word-break: break-word; }
.msg-time { color: var(--muted); margin-right: 6px; }
.msg-kind { color: var(--accent); font-weight: 600; }

.set-panel { padding: 14px; }
.set-form { gap: 6px; }

.set-section {
	background: #130d17;
	border: 1px solid var(--line-soft);
	border-radius: var(--radius-xs);
	padding: 0 10px;
}
.set-section + .set-section { margin-top: 6px; }
.set-section > summary {
	cursor: pointer;
	padding: 9px 0;
	font-weight: 600;
	font-size: 0.85rem;
	list-style: none;
	user-select: none;
	display: flex;
	align-items: center;
	gap: 6px;
}
.set-section > summary::-webkit-details-marker { display: none; }
.set-section > summary::before { content: "▸"; color: var(--accent); font-size: 0.75rem; transition: transform 0.15s; }
.set-section[open] > summary::before { transform: rotate(90deg); }
.set-section[open] { padding-bottom: 10px; }

.set-field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.set-label { color: var(--muted); font-size: 0.76rem; }

.set-switch {
	flex-direction: row;
	align-items: center;
	gap: 9px;
	cursor: pointer;
	font-size: 0.84rem;
	display: flex;
	margin: 0;
}
.set-switch input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }

.set-field input[type="number"],
.set-field input[type="text"],
.set-select,
.set-filter {
	min-height: 34px;
	padding: 7px 9px;
	background: #100a13;
	border: 1px solid var(--line-soft);
	border-radius: 7px;
	color: var(--text);
	font-size: 0.84rem;
}
.set-field input[type="number"] { max-width: 130px; }
.set-select { width: 100%; max-width: 100%; }

.set-slider-row { display: flex; align-items: center; gap: 10px; }
.set-slider-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 4px; }
.set-slider-val {
	color: var(--accent);
	font-size: 0.78rem;
	min-width: 64px;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.set-multi { display: flex; flex-direction: column; gap: 1px; }
.set-multi-scroll {
	max-height: 190px;
	overflow-y: auto;
	border: 1px solid var(--line-soft);
	border-radius: 7px;
	padding: 5px;
	background: #100a13;
}
.set-check {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 4px 6px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.82rem;
}
.set-check:hover { background: var(--accent-soft); }
.set-check input { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.set-check span { word-break: break-word; }

.set-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.set-foot .btn-primary { min-height: 38px; padding: 8px 16px; font-size: 0.85rem; }
.set-status { font-size: 0.82rem; }
.set-status.ok { color: var(--ok); }
.set-status.bad { color: var(--danger); }

.match-panel {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px;
	background: rgba(8, 4, 9, 0.80);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	animation: fade 0.2s ease both;
}

.match-window {
	width: min(1200px, 100%);
	height: min(800px, 100%);
	display: flex;
	flex-direction: column;
	border: 1px solid var(--gold-line);
	border-radius: var(--radius);
	box-shadow: 0 0 0 1px rgba(255, 210, 122, 0.18), var(--shadow);
	overflow: hidden;
	background: #150a14;
	animation: pop 0.22s ease both;
}

.match-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	font-size: 0.92rem;
	padding: 13px 18px;
	color: var(--gold);
	background: linear-gradient(180deg, #1c1708, #120d04);
	border-bottom: 1px solid #6b5417;
	flex: 0 0 auto;
}
.match-head-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.match-head-title b { color: #fff; }
.match-head .link-btn:hover { color: var(--gold); background: rgba(255, 210, 122, 0.1); }

.match-mode {
	display: inline-block;
	margin-left: 8px;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.5px;
	color: #ffe6a3;
	background: rgba(185, 146, 58, 0.20);
	border: 1px solid var(--gold);
	white-space: nowrap;
}

.match-body {
	flex: 1 1 auto;
	overflow: hidden;
	display: flex;
	background: #1b1320;
}
.match-empty {
	margin: auto;
	padding: 30px 16px;
	text-align: center;
	color: var(--muted);
	background: rgba(21, 10, 20, 0.7);
	border: 1px dashed #6b5417;
	border-radius: 12px;
}
#match-frame {
	flex: 1 1 auto;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	background: #1b1320;
}

.match-trial {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	padding: 11px 18px;
	color: #ffe6c2;
	background: linear-gradient(180deg, #7a4c1c, #4a2c0c);
	border-bottom: 1px solid var(--gold);
	box-shadow: inset 0 0 24px rgba(255, 206, 92, 0.12);
	animation: trial-pulse 1.5s ease-in-out infinite;
}
@keyframes trial-pulse {
	0%, 100% { box-shadow: inset 0 0 24px rgba(255, 206, 92, 0.12); }
	50%      { box-shadow: inset 0 0 30px rgba(255, 206, 92, 0.30); }
}
.match-trial .mt-text {
	font-weight: 800;
	font-size: 1rem;
	letter-spacing: 0.3px;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
	margin-right: auto;
}
.mt-btn, .mc-btn {
	padding: 9px 16px;
	min-height: 40px;
	font-size: 0.85rem;
	font-weight: 600;
	border-radius: var(--radius-xs);
	border: 1px solid var(--line);
	cursor: pointer;
}
.mt-btn:disabled, .mc-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.mt-condemn, .mc-trial.mt-condemn { color: #fff; background: #c0392b; border-color: #ff7a7a; }
.mt-condemn:not(:disabled):hover { background: #e04434; }
.mt-acquit { color: #d6ffe2; background: rgba(28, 122, 69, 0.85); border-color: #4fe08a; }
.mt-acquit:not(:disabled):hover { background: #1c7a45; }
.match-trial .mt-hint { color: #ffe6c2; font-size: 0.78rem; opacity: 0.85; }

.match-controls {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 9px;
	padding: 11px 16px;
	background: linear-gradient(180deg, #120d04, #1c1708);
	border-top: 1px solid #6b5417;
}
.match-controls .mc-btn {
	background: var(--raised);
	color: var(--text);
}
.match-controls .mc-btn:hover:not(:disabled) { border-color: var(--accent); }

.mc-manual { color: var(--ok); border-color: var(--ok-line); background: rgba(95, 224, 138, 0.10) !important; }
.mc-manual:hover { background: rgba(95, 224, 138, 0.18) !important; }
.mc-manual.on { color: var(--gold); border-color: var(--warn-line); background: rgba(168, 131, 51, 0.18) !important; }

.mc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mc-actions.disabled { opacity: 0.55; }
.mc-trial { color: #ffd0a0; border-color: #7a4c1c; background: rgba(208, 138, 58, 0.12) !important; }
.mc-trial:not(:disabled):hover { background: rgba(208, 138, 58, 0.22) !important; }

.mc-chat { flex-direction: row; align-items: center; gap: 7px; margin: 0; }
.mc-chat input {
	min-height: 40px;
	min-width: 180px;
	padding: 8px 12px;
	background: #100a13;
	border: 1px solid var(--line);
	border-radius: var(--radius-xs);
	color: var(--text);
	font-size: 0.86rem;
}
.mc-chat input:disabled { opacity: 0.45; cursor: not-allowed; }

.mc-smiles {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 3px;
	flex: 1 1 100%;
	margin-top: 2px;
}
.mc-smiles .mc-smile {
	width: 22px;
	height: 22px;
	cursor: pointer;
	border-radius: 5px;
	padding: 1px;
	border: 1px solid transparent;
	transition: background 0.12s, border-color 0.12s, transform 0.12s;
}
.mc-smiles .mc-smile:hover { background: rgba(95, 224, 138, 0.18); border-color: var(--ok); transform: scale(1.15); }
.mc-smiles.disabled { opacity: 0.45; pointer-events: none; }

.mc-hint { color: var(--muted); font-size: 0.78rem; }
.mc-status { font-size: 0.8rem; margin-left: auto; font-weight: 600; }
.mc-status.ok { color: var(--ok); }
.mc-status.bad { color: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop  { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 640px) {
	.wrap { padding: 40px 20px 64px; }
	.brand h1 { font-size: 2.2rem; }
}

@media (max-width: 600px) {
	.match-panel { padding: 0; }
	.match-window {
		width: 100%;
		height: 100%;
		border-radius: 0;
		border: 0;
	}
	.match-head { padding: 12px 14px; }
	.match-trial, .match-controls { padding: 10px 12px; }
	.mc-chat { flex: 1 1 100%; }
	.mc-chat input { flex: 1 1 auto; min-width: 0; }
	.mc-status { flex-basis: 100%; margin-left: 0; }
}

@media (max-width: 420px) {
	.card { padding: 18px; }
	.links li { padding: 14px; }
	.links .act, .links .del { flex: 1 1 auto; justify-content: center; text-align: center; }
	.links .del { flex: 0 0 auto; }
}
