/*
 * Стиль — как у deelter.ru: почти чёрный фон, прямые углы, тонкие линии, моноширинные
 * подписи капсом. Акцент — основной цвет бота из config.json ядра, его подставляет app.js.
 */

:root {
	--bg: #080808;
	--surface: #0f0f0f;
	--raised: #151515;
	--line: #262626;
	--line-strong: #3a3a3a;
	--text: #f2f2f0;
	--muted: #9b9b9b;
	--faint: #6a6a6a;
	--accent: #ff337d;
	--on-accent: #fff;
	--ok: #7dec07;
	--warn: #f6a621;
	--bad: #ed1642;
	--mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
	--side: 300px;
	--gap: 24px;
	color-scheme: dark;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #444 #111; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.6 Arial, Helvetica, sans-serif; -webkit-font-smoothing: antialiased; }
::selection { background: var(--text); color: var(--bg); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

a { color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: clamp(34px, 3.8vw, 52px); font-weight: 700; letter-spacing: -.045em; line-height: 1.05; margin: 10px 0; overflow-wrap: anywhere; }

.eyebrow { font: 11px/1.6 var(--mono); letter-spacing: 1.6px; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.lead { margin: 0 0 32px; max-width: 680px; font-size: 16px; }
.loading { padding: 48px; color: var(--muted); }

/* ─── Кнопки ─────────────────────────────────────────────────────────────── */

.button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 42px;
	padding: 9px 18px;
	border: 1px solid var(--line-strong);
	background: transparent;
	color: var(--text);
	text-decoration: none;
	transition: border-color 140ms, background-color 140ms, transform 140ms;
}
.button:hover:not(:disabled) { border-color: var(--muted); }
.button:disabled { opacity: .4; cursor: default; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.button.primary:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent); filter: brightness(1.08); }
.button.ghost { border-style: dashed; color: var(--muted); }
.button.ghost:hover { color: var(--text); }

.link { border: none; background: none; padding: 2px 4px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }
.icon-btn { width: 38px; height: 38px; border: 1px solid transparent; background: none; color: var(--faint); flex: none; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--bad); }

/* ─── Шапка ──────────────────────────────────────────────────────────────── */

.top {
	position: sticky;
	top: 0;
	z-index: 20;
	display: grid;
	grid-template-columns: var(--side) 1fr auto;
	align-items: center;
	min-height: 64px;
	padding: 0 var(--gap);
	background: rgba(8, 8, 8, .92);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--line);
}
.wordmark { font-size: 22px; font-weight: 900; letter-spacing: -1.2px; }
.wordmark span { font: 10px var(--mono); letter-spacing: 1.4px; vertical-align: top; margin-left: 6px; color: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav-btn { min-height: 40px; padding: 8px 18px; background: none; border: 1px solid transparent; color: var(--muted); font-size: 15px; }
.nav-btn:hover { color: var(--text); }
.nav-btn.active { border-color: var(--line-strong); color: var(--text); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.user img { width: 28px; height: 28px; border-radius: 50%; filter: grayscale(1); }

/* ─── Раскладка ──────────────────────────────────────────────────────────── */

.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - 65px); }

.side {
	position: sticky;
	top: 65px;
	height: calc(100vh - 65px);
	display: flex;
	flex-direction: column;
	border-right: 1px solid var(--line);
	background: var(--bg);
}
.side input { margin: 16px 16px 8px; }
.side-list { overflow-y: auto; padding: 0 8px 24px; }
.side-category { font: 11px/1.6 var(--mono); letter-spacing: 1.8px; text-transform: uppercase; color: var(--accent); margin: 26px 10px 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.side-category:first-child { margin-top: 8px; }
.side-module { font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 10px 2px; }
.side-item {
	display: block;
	width: 100%;
	text-align: left;
	padding: 8px 12px;
	font-size: 15px;
	border: none;
	border-left: 2px solid transparent;
	background: none;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.side-item:hover { color: var(--text); background: var(--surface); }
.side-item.active { color: var(--text); border-left-color: var(--accent); background: var(--surface); }
.side-item.nested { padding-left: 24px; font-size: 14px; }
.side-item .folder { color: var(--faint); }

.main { padding: 48px 56px 150px; max-width: 1180px; width: 100%; min-width: 0; }
.empty { padding-top: 12vh; }

/* ─── Поля ввода ─────────────────────────────────────────────────────────── */

input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
	min-height: 42px;
	padding: 9px 13px;
	background: var(--surface);
	border: 1px solid var(--line-strong);
	border-radius: 0;
	min-width: 0;
	transition: border-color 140ms;
}
input:hover, select:hover, textarea:hover { border-color: #555; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); }
input.invalid, textarea.invalid { border-color: var(--bad); }
input.wide, select.wide { width: min(100%, 420px); }
input.narrow { width: 140px; }
textarea { width: 100%; min-height: 96px; resize: vertical; }
textarea.code, .code { font: 13.5px/1.6 var(--mono); tab-size: 4; }
textarea.raw { min-height: 62vh; }
input[type=color] { width: 44px; height: 38px; padding: 3px; background: var(--surface); border: 1px solid var(--line-strong); }
input[type=range] { width: 220px; accent-color: var(--accent); }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); cursor: pointer; transition: background-color 140ms; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--text); transition: transform 140ms; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); background: var(--on-accent); }
.switch input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 3px; }

label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); min-height: 38px; }
label.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); }
.segmented button { min-height: 40px; padding: 8px 16px; border: none; border-right: 1px solid var(--line-strong); background: none; color: var(--muted); }
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--text); background: var(--surface); }
.segmented button.on { background: var(--text); color: var(--bg); }

.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 12px var(--mono); padding: 3px 8px; border: 1px solid var(--line-strong); background: none; color: var(--muted); }
button.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.warn { color: var(--warn); border-color: #5a3f10; }

.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.stack > input.wide, .stack > .segmented, .stack > select { align-self: flex-start; }

/* ─── Форма ──────────────────────────────────────────────────────────────── */

.tabs { display: flex; flex-wrap: wrap; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.tab-btn { min-height: 46px; padding: 11px 20px; margin-bottom: -1px; background: none; border: 1px solid transparent; border-bottom: none; color: var(--muted); font-size: 15px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-color: var(--line); background: var(--bg); box-shadow: inset 0 2px 0 var(--accent); }

.object { display: flex; flex-direction: column; width: 100%; }
.object .object { padding: 0 0 0 20px; border-left: 1px solid var(--line); }

.field {
	display: grid;
	grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
	gap: 8px 40px;
	align-items: start;
	padding: 22px 0;
	border-bottom: 1px solid var(--line);
}
.field.block { grid-template-columns: minmax(0, 1fr); }
.field:last-child { border-bottom: none; }
.field-head { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding-top: 8px; min-width: 0; }
.field.block .field-head { padding-top: 0; }
.field-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-weight: 600; font-size: 15.5px; }
.field-key { font: 11px var(--mono); color: var(--faint); font-weight: 400; }
.field-desc { color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 560px; }
.field-body { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.group-title { font: 11px/1.6 var(--mono); letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent); padding: 28px 0 8px; border-bottom: 1px solid var(--line); }
details.advanced { border-top: 1px solid var(--line); }
details.advanced > summary { cursor: pointer; padding: 16px 0; color: var(--muted); font: 11px var(--mono); letter-spacing: 1.6px; text-transform: uppercase; }
details.advanced > summary:hover { color: var(--text); }

.list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.list-item { display: flex; gap: 10px; align-items: flex-start; }
.list-item > .grow { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.list > .button { align-self: flex-start; }
details.item { width: 100%; border: 1px solid var(--line); background: var(--surface); padding: 0 18px; }
details.item[open] { padding-bottom: 4px; }
details.item > summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details.item .field { border-bottom-color: #1d1d1d; }

.errors { border: 1px solid var(--bad); background: rgba(237, 22, 66, .08); padding: 14px 18px; margin-bottom: 24px; }
.errors ul { margin: 8px 0 0; padding-left: 18px; }
.errors li { font: 12.5px var(--mono); }

.guild-switch { margin: -8px 0 28px; }
.notice-box { border-left: 3px solid var(--accent); background: var(--surface); padding: 12px 16px; color: var(--muted); }
.notice-box strong { color: var(--text); }
.badge { font: 10px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; padding: 4px 6px; background: var(--accent); color: var(--on-accent); }
.field.own > .field-head .field-label > span:first-child { color: var(--accent); }

.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .72); display: flex; align-items: center; justify-content: center; padding: 24px; }
.dialog { width: min(1080px, 100%); max-height: 88vh; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line-strong); }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-foot { border-bottom: none; border-top: 1px solid var(--line); }
.dialog h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.02em; }
.dialog-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 0; flex: 1; }
.history-list { border-right: 1px solid var(--line); overflow-y: auto; padding: 8px; }
.dialog-body textarea { border: none; height: 100%; min-height: 50vh; resize: none; background: var(--surface); }
@media (max-width: 760px) { .dialog-body { grid-template-columns: 1fr; } .history-list { max-height: 30vh; border-right: none; border-bottom: 1px solid var(--line); } }

/* ─── Редактор шаблонов ──────────────────────────────────────────────────── */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input { flex: 1; min-width: 200px; }

.editor-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--line-strong); background: var(--surface); height: 62vh; min-height: 320px; }
.editor-wrap:focus-within { border-color: var(--text); }
.gutter {
	margin: 0;
	padding: 10px 10px 10px 14px;
	overflow: hidden;
	text-align: right;
	color: var(--faint);
	font: 13.5px/1.6 var(--mono);
	border-right: 1px solid var(--line);
	user-select: none;
}
textarea.editor { height: 100%; min-height: 0; border: none; background: transparent; padding: 10px 14px; resize: none; white-space: pre; overflow: auto; }
textarea.editor:hover, textarea.editor:focus { border: none; }

.check-status { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.check-line { font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.check-line.ok { color: var(--ok); }
.check-line.bad { color: var(--bad); }
.check-line.warn { color: var(--warn); }

/* ─── Нижняя панель и уведомления ────────────────────────────────────────── */

.bar {
	position: fixed;
	min-height: 70px;
	bottom: 0;
	left: var(--side);
	right: 0;
	z-index: 15;
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 14px 56px;
	background: rgba(8, 8, 8, .94);
	backdrop-filter: blur(8px);
	border-top: 1px solid var(--line);
}
.bar .note { flex: 1; color: var(--muted); font: 11px var(--mono); letter-spacing: 1.2px; text-transform: uppercase; }
.bar .note.dirty { color: var(--warn); }

.toast {
	position: fixed;
	right: 24px;
	bottom: 84px;
	z-index: 30;
	max-width: 440px;
	padding: 12px 18px;
	background: var(--text);
	color: var(--bg);
	border-left: 3px solid var(--accent);
}
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

/* ─── Вход ───────────────────────────────────────────────────────────────── */

.login { grid-column: 1 / -1; max-width: 520px; margin: 14vh auto; padding: 0 24px; }
.login h1 { font-size: clamp(40px, 6vw, 64px); margin: 16px 0; }
.login .button { margin-top: 24px; padding: 14px 22px; }

body.notice main { max-width: 520px; margin: 16vh auto; padding: 0 24px; }
body.notice h1 { font-size: 40px; }

/* ─── Узкие экраны ───────────────────────────────────────────────────────── */

@media (max-width: 960px) {
	.field { grid-template-columns: minmax(0, 1fr); gap: 8px; }
	.field-head { padding-top: 0; }
	.main { padding: 28px 24px 140px; }
	.bar { padding: 12px 24px; }
}

@media (max-width: 760px) {
	:root { --side: 0px; --gap: 16px; }
	.top { grid-template-columns: 1fr auto; padding: 8px 16px; }
	.nav { grid-column: 1 / -1; order: 3; padding-bottom: 6px; }
	.user span { display: none; }
	.layout { grid-template-columns: minmax(0, 1fr); }
	.side { position: static; height: auto; max-height: 38vh; border-right: none; border-bottom: 1px solid var(--line); }
	.main { padding: 24px 16px 140px; }
	.bar { left: 0; padding: 12px 16px; }
	input[type=range] { width: 140px; }
	.editor-wrap { height: 55vh; }
}

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