/* Bosko 200: панель. Взято из одобренного макета docs/design-ui/mockup/panel.html */

/* ===== Токены ===== */
:root {
  --bg: #131011;
  --surface: #1c1718;
  --surface-hi: #261e1f;
  --field: #1f1a1b;
  --field-hover: #2a2223;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .15);
  --chip: #352729;
  --hover: rgba(255, 255, 255, .05);
  --text: #f8fafc;
  --text-2: rgba(255, 255, 255, .86);
  --muted: rgba(255, 255, 255, .6);
  --faint: rgba(255, 255, 255, .4);
  --primary: #d9363e;
  --primary-hover: #b92c33;
  --primary-ink: #ff7a80;
  --primary-soft: rgba(217, 54, 62, .16);
  --danger: #d23b39;
  --danger-ink: #f26663;
  --success: #2c974d;
  --success-ink: #4cc574;
  --warn: #f0b232;
  --secondary: #4b4345;
  --radius: 5px;
  --radius-btn: 4px;
  --radius-card: 8px;
  --header-h: 60px;
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  /* То, что в светлой теме меняется не только оттенком */
  --border-soft: rgba(255, 255, 255, .05);
  --overlay-weak: rgba(255, 255, 255, .07);
  --overlay: rgba(255, 255, 255, .1);
  --secondary-hover: #5a5153;
  --switch-off: var(--secondary);
  --save-off-bg: #3b2a2d;
  --save-off-text: rgba(248, 250, 252, .78);
  --icon-bg: #3b2a2d;
  --tile-hover: #221b1c;
  --toast-bg: #2b2123;
  --err-text: #ffc2c0;
  --ok-text: #b8ecc8;
  --tag-req-text: #ff9c9a;
  --check-border: rgba(255, 255, 255, .3);
  --shadow: rgba(0, 0, 0, .45);
  --shadow-strong: rgba(0, 0, 0, .8);
  --scrim: rgba(10, 5, 6, .6);
  color-scheme: dark;
}

/* ===== Светлая тема (кнопка ☀/☾ в шапке, выбор хранится в браузере) ===== */
:root[data-theme="light"] {
  --bg: #f4f0f0;
  --surface: #ffffff;
  --surface-hi: #ffffff;
  --field: #f8f5f5;
  --field-hover: #f1ebeb;
  --border: rgba(40, 12, 16, .11);
  --border-strong: rgba(40, 12, 16, .2);
  --border-soft: rgba(40, 12, 16, .07);
  --chip: #f5e3e4;
  --hover: rgba(40, 12, 16, .04);
  --overlay-weak: rgba(40, 12, 16, .06);
  --overlay: rgba(40, 12, 16, .09);
  --text: #1d1416;
  --text-2: rgba(29, 20, 22, .84);
  --muted: rgba(29, 20, 22, .6);
  --faint: rgba(29, 20, 22, .42);
  --primary-ink: #c02a32;
  --primary-soft: rgba(217, 54, 62, .1);
  --danger-ink: #c42b2b;
  --success-ink: #1d8644;
  --warn: #a26800;
  --secondary: #ebe3e4;
  --secondary-hover: #e0d5d6;
  --switch-off: #cdc2c3;
  --save-off-bg: #f4e0e1;
  --save-off-text: #a1474d;
  --icon-bg: #f2dedf;
  --tile-hover: #fffafa;
  --toast-bg: #ffffff;
  --err-text: #8e1c22;
  --ok-text: #1b6232;
  --tag-req-text: #b3261e;
  --check-border: rgba(40, 12, 16, .32);
  --shadow: rgba(70, 20, 25, .16);
  --shadow-strong: rgba(70, 20, 25, .22);
  --scrim: rgba(30, 10, 12, .35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 150px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--font); overflow-x: clip; -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
code {
  padding: 1px 5px; border-radius: 4px; background: var(--overlay-weak);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; color: var(--text-2);
}
/* Части, которые нужны только без JavaScript или только с ним */
.js .nojs-only { display: none !important; }
html:not(.js) .js-only { display: none !important; }

/* Иконки в стиле Lucide: контур, stroke 2 */
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; }
.ic-xs { width: 14px; height: 14px; }
.ic-brand { width: 20px; height: 20px; flex: none; fill: currentColor; }

/* ===== Шапка сайта ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: var(--header-h); padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
/* Полоса «Демо-версия» под шапкой (только при DEMO=1) */
.demo-strip {
  padding: 7px 20px; text-align: center; font-size: 13px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary-ink); border-bottom: 1px solid var(--border);
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--hover); }
.burger { display: none; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; text-decoration: none;
}
.brand .logo { width: 32px; height: 32px; flex: none; }
.brand b { color: var(--muted); font-weight: 600; }
.spacer { flex: 1; }
.user { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px 0 6px;
  border: 0; border-radius: 4px; background: transparent;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--hover); }
.user-btn .ic { color: var(--muted); }
.avatar {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; overflow: hidden; border-radius: 50%;
  background: #c27c0e; color: #fff; font-size: 13px; font-weight: 600; object-fit: cover;
}
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; min-width: 210px; padding: 6px;
  background: var(--surface-hi); border: 1px solid var(--border-strong); border-radius: 6px;
  box-shadow: 0 16px 40px var(--shadow);
}
/* Без JavaScript меню открывается при наведении и фокусе */
html:not(.js) .user:hover .user-menu, html:not(.js) .user:focus-within .user-menu { display: block !important; }
.user-menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 4px; background: transparent; color: var(--text-2); text-align: left; text-decoration: none;
}
.menu-item:hover { background: var(--hover); color: var(--text); }
.menu-item.danger { color: var(--danger-ink); }

/* ===== Каркас: меню + содержимое ===== */
.layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100vh - var(--header-h)); overflow-y: auto; scrollbar-width: thin;
  padding: 18px 14px 28px; border-right: 1px solid var(--border);
}
.guild {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 22px; padding: 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
  text-align: left; text-decoration: none;
}
.guild:hover { border-color: var(--border-strong); }
.guild > .ic { color: var(--muted); }
.guild-icon {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; overflow: hidden; border-radius: 6px;
  background: var(--icon-bg); font-size: 14px; font-weight: 700; object-fit: cover;
}
.guild-text { flex: 1; min-width: 0; line-height: 1.25; }
.guild-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.guild-text small { color: var(--muted); font-size: 13px; }
.nav-title { margin: 0 12px 8px; color: var(--muted); font-size: 14px; }
.nav { display: grid; gap: 2px; }
.nav + .nav-title { margin-top: 18px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px;
  border-radius: var(--radius); color: var(--text-2); font-size: 16px; font-weight: 500; text-decoration: none;
}
a.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--primary-ink); }
.nav-item.is-soon { color: var(--muted); cursor: default; }
.nav-item.is-soon .ic { opacity: .75; }
.nav-label { min-width: 0; }
.pill {
  display: inline-flex; align-items: center; flex: none; height: 20px; margin-left: auto; padding: 0 7px;
  border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.pill-new { background: var(--primary); color: #fff; }
.pill-soon { padding: 0; background: none; color: var(--faint); font-weight: 400; }

.main { min-width: 0; padding: 20px 32px 72px; }
.main-inner { max-width: 1180px; }
.page-narrow { width: min(1120px, 100% - 32px); margin: 0 auto; padding: 32px 0 72px; }

/* ===== Шапка раздела ===== */
.page-head { display: flex; align-items: flex-start; gap: 14px; }
.page-head-main { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 10px 16px; min-width: 0; }
/* Заголовок обычной строкой текста: ✎ идёт сразу за последним словом и не отрывается на телефоне */
.page-title {
  min-width: 0; margin: 0; padding: 2px 0;
  font-size: 30px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; text-wrap: balance;
}
.page-title > .sq-btn, .page-title > .title-input { margin-left: 10px; vertical-align: middle; }
.page-title > .sq-btn { position: relative; top: -3px; }
.title-input {
  max-width: 100%; width: 22ch; height: 42px; padding: 0 10px; vertical-align: middle;
  border: 1px solid var(--primary); border-radius: var(--radius); background: var(--field); color: var(--text);
  font-size: 22px; font-weight: 600; box-shadow: 0 0 0 3px rgba(217, 54, 62, .25);
}
.title-input:focus { outline: none; }
/* Название меняется по ✎: поле видно только во время переименования (без JavaScript видно всегда) */
.js .page-title .title-input { display: none; }
.js .page-title.is-renaming .title-input { display: inline-block; }
.js .page-title.is-renaming #titleName, .js .page-title.is-renaming #renameBtn { display: none !important; }
.page-lead { max-width: 760px; margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.head-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }

.sq-btn {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--radius-btn); background: var(--primary); color: #fff; text-decoration: none;
  transition: background .15s, color .15s;
}
.sq-btn:hover { background: var(--primary-hover); }
.sq-outline { border: 1.5px solid var(--primary); background: transparent; color: var(--primary-ink); }
.sq-outline:hover { background: var(--primary-soft); }
.sq-soft { background: var(--primary-soft); color: var(--primary-ink); }
.sq-soft:hover { background: var(--primary); color: #fff; }
.sq-soft.sq-del:hover { background: var(--danger); }
.sq-danger { background: var(--danger); }
.sq-danger:hover { background: #b73230; }
.sq-ghost { background: transparent; color: var(--muted); }
.sq-ghost:hover { background: rgba(210, 59, 57, .15); color: var(--danger-ink); }
.sq-sm { width: 34px; height: 34px; }

/* Переключатель: кружок нарисован градиентом, без ::before (надёжно во всех браузерах) */
.switch {
  flex: none; width: 42px; height: 24px; margin: 0;
  appearance: none; -webkit-appearance: none; border-radius: 999px;
  background: radial-gradient(circle closest-side, #fff 0 8.5px, transparent 9.5px) 0 0 / 24px 24px no-repeat, var(--switch-off);
  cursor: pointer; transition: background-color .18s, background-position .18s;
}
.switch:checked { background-color: var(--primary); background-position: 18px 0; }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 0; border-radius: var(--radius-btn);
  color: var(--text); font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background .15s, color .15s, opacity .15s;
}
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #f8fafc; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-ghost { border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger-ghost { border: 1px solid rgba(210, 59, 57, .5); background: transparent; color: var(--danger-ink); }
.btn-danger-ghost:hover { background: rgba(210, 59, 57, .12); }
.btn-sm { height: 34px; padding: 0 14px; }
/* «Сохранить» неактивная, пока нечего сохранять, но читается */
.btn-save[aria-disabled="true"], .btn-save[aria-disabled="true"]:hover {
  background: var(--save-off-bg); color: var(--save-off-text); box-shadow: inset 0 0 0 1px var(--border); cursor: default;
}

/* Липкая полоса действий */
.toolbar {
  position: sticky; top: var(--header-h); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  margin: 14px -32px 0; padding: 12px 32px; background: var(--bg); transition: box-shadow .15s;
}
.toolbar.stuck { box-shadow: 0 1px 0 var(--border), 0 12px 20px -14px var(--shadow-strong); }
.toolbar-btns { display: flex; gap: 8px; margin-left: auto; }

/* ===== Сообщения: ошибки и «сохранено» ===== */
.alert {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding: 12px 14px;
  border: 1px solid; border-radius: 6px; font-size: 14.5px;
}
.alert .ic { margin-top: 1px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-err { border-color: rgba(210, 59, 57, .45); background: rgba(210, 59, 57, .1); color: var(--err-text); }
.alert-err .ic { color: var(--danger-ink); }
.alert-ok { border-color: rgba(44, 151, 77, .45); background: rgba(44, 151, 77, .1); color: var(--ok-text); }
.alert-ok .ic { color: var(--success-ink); }
.js .alert-ok.toastable { display: none; }  /* с JavaScript то же самое показывает всплывашка */

/* ===== Карточки-секции ===== */
.card {
  margin-top: 16px; padding: 22px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-card);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-title { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.card-hint { max-width: 760px; margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 18px; }
.section-title { margin: 28px 0 0; font-size: 20px; font-weight: 600; }
.hint.after { margin-top: 12px; font-size: 14px; }

/* Поля */
.fields { display: grid; gap: 18px; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; transition: opacity .15s; }
.field.is-off { opacity: .5; }
.label { color: var(--text-2); font-size: 14px; font-weight: 500; }
.label .optional { color: var(--faint); font-weight: 400; }
.req { margin-left: 3px; color: var(--danger-ink); font-style: normal; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.input, .textarea, .select select {
  width: 100%; min-width: 0; height: 42px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--field); color: var(--text);
  font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 140px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input:hover, .textarea:hover, .select select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 54, 62, .25);
}
::placeholder { color: var(--faint); opacity: 1; }
.select, .input-icon { position: relative; }
.select select { padding: 0 36px 0 34px; appearance: none; -webkit-appearance: none; cursor: pointer; text-overflow: ellipsis; }
.select select option { background: var(--field); color: var(--text); }
.select .lead, .select .trail, .input-icon .lead { position: absolute; top: 50%; transform: translateY(-50%); pointer-events: none; }
.select .lead, .input-icon .lead { left: 11px; color: var(--faint); }
.select .trail { right: 10px; color: var(--muted); }
.input-icon .input { padding-left: 36px; }
.input-row { display: flex; gap: 8px; }
.input-row > .input-icon { flex: 1; min-width: 0; }
.field-foot { display: flex; justify-content: space-between; gap: 10px; color: var(--faint); font-size: 12.5px; }
.counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.counter.is-warn { color: var(--warn); }
.field-err { margin: 0; color: var(--danger-ink); font-size: 13px; }
.num { display: flex; align-items: center; gap: 10px; }
.num .input { width: 110px; }
.num span { color: var(--muted); font-size: 14px; }

/* ===== Выбор ролей: чипы + «+» со списком ===== */
.picker {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  min-height: 50px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--field);
}
.picker-empty { padding: 0 4px; color: var(--faint); font-size: 14px; }
/* Без JavaScript: роли списком галочек */
.picker-fallback { display: flex; flex-wrap: wrap; gap: 8px; }
.picker.is-enhanced .picker-fallback { display: none; }
.role-opt {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px;
  border-radius: 4px; background: var(--chip); font-size: 14px; font-weight: 500; cursor: pointer;
}
.role-opt input { margin: 0; accent-color: var(--primary); }
.role-opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; height: 32px; padding: 0 4px 0 10px;
  border-radius: 4px; background: var(--chip); font-size: 14px; font-weight: 500;
}
.chip.is-locked { padding-right: 10px; }
.chip.is-locked .ic { color: var(--faint); }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip-x {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 4px; background: transparent; color: var(--muted);
}
.chip-x:hover { background: var(--overlay); color: var(--text); }
.chip-add {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 4px; background: var(--primary-soft); color: var(--primary-ink);
}
.chip-add:hover, .chip-add[aria-expanded="true"] { background: var(--primary); color: #fff; }
.pop {
  position: absolute; top: calc(100% + 6px); left: -1px; z-index: 30;
  width: min(320px, calc(100% + 2px)); padding: 8px;
  background: var(--surface-hi); border: 1px solid var(--border-strong); border-radius: 6px;
  box-shadow: 0 18px 40px var(--shadow);
}
.pop-search { position: relative; margin-bottom: 6px; }
.pop-search .lead { position: absolute; top: 50%; left: 10px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.pop-search input {
  width: 100%; height: 38px; padding: 0 10px 0 34px;
  border: 1px solid var(--border); border-radius: 4px; background: var(--field); color: var(--text);
}
.pop-search input:focus { outline: none; border-color: var(--primary); }
.pop-list { max-height: 244px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 4px; background: transparent; color: var(--text-2); font-size: 15px; text-align: left;
}
.pop-item:hover:not(:disabled), .pop-item:focus-visible { background: var(--hover); color: var(--text); }
.pop-item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.pop-item:disabled { opacity: .5; cursor: not-allowed; }
.pop-item small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.pop-empty { margin: 0; padding: 10px; color: var(--muted); font-size: 14px; text-align: center; }

/* ===== Сообщение с кнопкой ===== */
.msg-grid { display: grid; gap: 24px; }
.img-box {
  position: relative; display: grid; place-items: center; min-height: 140px; overflow: hidden;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--field);
}
.img-box img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.img-box[data-state="ok"] { border-style: solid; }
.img-box[data-state="ok"] .img-msg { display: none; }
.img-msg { display: grid; justify-items: center; gap: 8px; max-width: 340px; padding: 18px; color: var(--muted); font-size: 13.5px; text-align: center; }
.img-msg .ic { width: 26px; height: 26px; color: var(--faint); }
.img-box[data-state="bad"] .img-msg, .img-box[data-state="bad"] .img-msg .ic { color: var(--danger-ink); }

/* Предпросмотр как настоящий Discord (размеры и цвета тёмной темы) */
.preview-label { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--muted); font-size: 14px; font-weight: 500; }
.preview-label b { color: var(--text-2); font-weight: 500; }
.dc, .dc * { font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.dc {
  padding: 12px 16px 14px; border-radius: 8px; background: #313338;
  color: #dbdee1; font-size: 16px; line-height: 1.375; -webkit-font-smoothing: antialiased;
}
.dc-msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px; }
.dc-avatar { width: 40px; height: 40px; margin-top: 2px; overflow: hidden; border-radius: 50%; }
.dc-avatar svg { display: block; width: 100%; height: 100%; }
.dc-meta { line-height: 22px; }
.dc-name { color: #f2f3f5; font-size: 16px; font-weight: 500; }
.dc-bot {
  position: relative; top: -2px; display: inline-flex; align-items: center; gap: 1px; height: 15px;
  margin-left: 4px; padding: 0 4px 0 2px; border-radius: 3px; background: #5865f2; color: #fff;
  font-size: 10px; line-height: 15px; font-weight: 500; text-transform: uppercase; vertical-align: middle;
}
.dc-bot .ic { width: 13px; height: 13px; stroke-width: 3; }
.dc-time { margin-left: 4px; color: #949ba4; font-size: 12px; font-weight: 500; }
.dc-embed {
  display: grid; max-width: 516px; margin-top: 4px; padding: 8px 16px 16px 12px;
  border-left: 4px solid var(--stripe, #5865f2); border-radius: 4px; background: #2b2d31;
}
.dc-embed > *:not([hidden]) { margin-top: 8px; }
.dc-embed-title { color: #f2f3f5; font-size: 16px; line-height: 22px; font-weight: 600; overflow-wrap: anywhere; }
.dc-embed-desc { color: #dbdee1; font-size: 14px; line-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-embed-desc strong { color: #dbdee1; font-weight: 700; }
.dc-embed-empty { margin: 0; color: #949ba4; font-size: 13px; font-style: italic; }
.dc-embed-img { display: block; max-width: 100%; max-height: 300px; margin-top: 16px; border-radius: 4px; object-fit: cover; }
.dc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dc-btn {
  --b: #5865f2;
  display: inline-flex; align-items: center; max-width: 100%; height: 32px; min-width: 60px; padding: 2px 16px;
  border-radius: 3px; background: var(--b); color: #fff; font-size: 14px; line-height: 16px; font-weight: 500;
  overflow-wrap: anywhere; transition: background .15s;
}
.dc-btn[data-style="secondary"] { --b: #4e5058; }
.dc-btn[data-style="success"] { --b: #248046; }
.dc-btn[data-style="danger"] { --b: #da373c; }

/* ===== Вопросы формы ===== */
.count-pill {
  flex: none; padding: 3px 10px; border-radius: 4px; background: var(--primary-soft);
  color: var(--primary-ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.q-fallback { display: grid; gap: 10px; }
.q-row { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--field); }
.q-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.q-list.is-sorting { user-select: none; -webkit-user-select: none; }
.q {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 12px 12px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--field);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.q.is-editing { grid-template-columns: auto minmax(0, 1fr); align-items: start; padding: 14px; border-color: rgba(217, 54, 62, .6); }
.q.dragging { position: relative; z-index: 2; border-color: var(--primary); background: var(--field-hover); box-shadow: 0 12px 28px var(--shadow); }
.q-handle {
  display: grid; place-items: center; width: 28px; height: 40px; padding: 0;
  border: 0; border-radius: 4px; background: transparent; color: var(--faint); cursor: grab; touch-action: none;
}
.q-handle:hover { background: var(--hover); color: var(--text); }
.q.dragging .q-handle { cursor: grabbing; color: var(--text); }
.q-num {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 4px;
  background: var(--chip); color: var(--text-2); font-size: 14px; font-weight: 600;
}
.q-body { min-width: 0; }
.q-label { margin: 0; font-size: 15.5px; font-weight: 500; overflow-wrap: anywhere; }
.q-ph { margin: 2px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.q-ph.is-empty { color: var(--faint); font-style: italic; }
.q-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 4px; background: var(--overlay-weak); color: var(--text-2); font-size: 12.5px;
}
.tag-req { background: rgba(210, 59, 57, .15); color: var(--tag-req-text); }
.q-actions { display: flex; gap: 6px; }
.q-form { display: grid; gap: 14px; }
.q-checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.q-form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 15px; cursor: pointer; }
.check input {
  flex: none; width: 20px; height: 20px; margin: 0; appearance: none; -webkit-appearance: none;
  border: 1.5px solid var(--check-border); border-radius: 3px; background: var(--bg); cursor: pointer;
}
.check input:checked {
  border-color: var(--primary);
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.q-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; margin-top: 10px;
  border: 1.5px dashed rgba(217, 54, 62, .55); border-radius: 6px; background: transparent;
  color: var(--primary-ink); font-size: 15px; font-weight: 500;
}
.q-add:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.q-add:disabled { border-color: var(--border); color: var(--faint); cursor: not-allowed; }

/* Шаблон ника */
.nick-ex {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--hover); font-size: 14px;
}
.nick-ex-label { color: var(--muted); }
.nick-ex-value { font-weight: 600; overflow-wrap: anywhere; }
.nick-ex-value.is-muted { color: var(--muted); font-weight: 400; }
.nick-warn { flex-basis: 100%; color: var(--warn); font-size: 13px; }

/* ===== Карточки-переключатели (дополнительные настройки) ===== */
.opts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.opt {
  display: grid; align-content: start; gap: 14px; padding: 16px;
  border: 1.5px solid var(--border); border-radius: 6px; background: var(--field); transition: border-color .15s;
}
.opt:has(.opt-head .switch:checked) { border-color: var(--primary); }
.opt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; cursor: pointer; }
.opt-title { display: block; margin-bottom: 4px; font-size: 17px; font-weight: 600; line-height: 1.3; }
.opt-desc { display: block; color: var(--muted); font-size: 14px; }
.opt-extra { padding-top: 14px; border-top: 1px solid var(--border); }
.opt:not(:has(.opt-head .switch:checked)) .opt-extra { display: none; }
.hl { color: var(--primary-ink); }

/* Опасная зона */
.danger-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  margin-top: 16px; padding: 18px 22px; border: 1px solid rgba(210, 59, 57, .3); border-radius: var(--radius-card);
}
.danger-row b { font-weight: 600; }

/* ===== Плитки: типы заявок, шаблоны, разделы, серверы ===== */
.tiles { display: grid; gap: 14px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.tile-wrap { position: relative; display: grid; }
.tile {
  display: grid; align-content: start; gap: 6px; min-height: 128px; padding: 16px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-card); background: var(--surface);
  color: var(--text); text-decoration: none; transition: border-color .15s, background .15s;
}
a.tile:hover { border-color: var(--border-strong); background: var(--tile-hover); }
.tile-top { display: flex; align-items: center; gap: 10px; min-height: 22px; padding-right: 34px; }
.tile-top .ic { color: var(--primary-ink); }
.tile-name { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tile-meta { color: var(--muted); font-size: 14px; }
.tile-state { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; font-size: 13.5px; }
.tile-state .ic { width: 15px; height: 15px; }
.tile-state.ok { color: var(--success-ink); }
.tile-state.warn { color: var(--warn); }
.tile-state.bad { color: var(--danger-ink); }
.tile-x { position: absolute; top: 10px; right: 10px; margin: 0; }
.tile.is-soon { color: var(--muted); }
.tile.is-soon .ic { color: var(--faint); }
.tile-add {
  place-content: center; justify-items: center; gap: 8px; text-align: center;
  border: 1.5px dashed rgba(217, 54, 62, .55); background: transparent; color: var(--primary-ink); font-weight: 500;
}
a.tile-add:hover { border-color: var(--primary); background: var(--primary-soft); }
.tile-add .ic { width: 24px; height: 24px; }

/* Серверы */
.server-tile { justify-items: center; align-content: center; gap: 10px; min-height: 200px; text-align: center; }
.server-icon {
  display: grid; place-items: center; width: 64px; height: 64px; overflow: hidden; border-radius: 50%;
  background: var(--icon-bg); font-size: 22px; font-weight: 700; object-fit: cover;
}
.server-tile .btn { margin-top: 4px; pointer-events: none; }

/* Пусто */
.empty {
  display: grid; justify-items: start; gap: 8px; margin-top: 16px; padding: 28px 22px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-card);
}
.empty b { font-size: 17px; font-weight: 600; }
.empty p { margin: 0 0 8px; color: var(--muted); }

/* Строки списка (идущие сборы) */
.rows { display: grid; }
.row-item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.row-item:first-child { border-top: 0; padding-top: 0; }
.row-item:last-child { padding-bottom: 0; }
.row-main { min-width: 0; }
.row-main b { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 14px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.row-btns form { margin: 0; }
.badge {
  display: inline-flex; align-items: center; height: 22px; margin-left: 6px; padding: 0 8px; vertical-align: 1px;
  border-radius: 4px; background: var(--primary-soft); color: var(--primary-ink); font-size: 12.5px; font-weight: 500;
}

/* Таблица */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-size: 13px; font-weight: 500; }
.table td:first-child, .table th:first-child { width: 48px; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-text td { white-space: normal; }
.table-text td:first-child { width: 40%; color: var(--text-2); }
.table tbody tr:hover { background: var(--hover); }

details.more { margin-top: 16px; }
details.more summary { color: var(--text-2); cursor: pointer; font-weight: 500; }
details.more[open] summary { margin-bottom: 12px; }

/* Всплывающее уведомление */
.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 100;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 12px 16px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--toast-bg);
  box-shadow: 0 16px 40px var(--shadow); font-weight: 500;
  opacity: 0; visibility: hidden; transform: translate(-50%, 16px);
  transition: opacity .2s, transform .2s, visibility 0s linear .2s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .2s, transform .2s; }
.toast .ic { color: var(--success-ink); }
.toast.is-err .ic { color: var(--danger-ink); }

/* Страница ошибки */
.error-box { max-width: 560px; margin: 12vh auto 0; text-align: center; }
.error-box h1 { margin: 0 0 10px; font-size: 30px; }
.error-box p { margin: 0 0 22px; color: var(--muted); }

/* ===== Широкий экран: предпросмотр справа ===== */
@media (min-width: 1200px) {
  .msg-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 400px); align-items: start; }
  .preview { position: sticky; top: calc(var(--header-h) + 84px); }
}

/* ===== Планшет и телефон: меню выезжает по бургеру ===== */
@media (max-width: 960px) {
  .burger { display: inline-grid; margin-left: -6px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 45;
    width: min(304px, 86vw); height: auto;
    background: var(--surface); border-right: 1px solid var(--border-strong);
    transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  .sidebar.open { transform: none; visibility: visible; transition: transform .22s ease; box-shadow: 16px 0 40px var(--shadow); }
  /* Без JavaScript меню не спрятано, а стоит над содержимым */
  html:not(.js) .sidebar { position: static; width: auto; height: auto; transform: none; visibility: visible; border-right: 0; border-bottom: 1px solid var(--border); }
  html:not(.js) .burger { display: none; }
  .sidebar .guild { background: var(--field); }
  .sidebar .nav-item.active { background: var(--primary-soft); }
  .scrim { position: fixed; inset: var(--header-h) 0 0 0; z-index: 44; background: var(--scrim); }
  .main { padding: 16px 16px 56px; }
  .toolbar { margin: 12px -16px 0; padding: 10px 16px; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .page-title { font-size: 24px; }
  .head-tools { flex-basis: 100%; margin-left: 0; }
  .toolbar-btns { width: 100%; margin-left: 0; }
  .toolbar-btns .btn { flex: 1 1 auto; padding: 0 12px; }
  .card { padding: 16px; }
  .card-title { font-size: 18px; }
  .danger-row { padding: 16px; }
  .page-narrow { padding-top: 20px; }
  /* Плитки строками */
  .tile { min-height: 0; }
  .tile-state { margin-top: 2px; }
  .server-tile { grid-template-columns: auto minmax(0, 1fr) auto; justify-items: start; align-items: center; min-height: 0; text-align: left; }
  .server-icon { width: 48px; height: 48px; font-size: 18px; }
  .server-tile .btn { display: none; }
  .server-tile .go { color: var(--muted); }
  /* 16px в полях, чтобы iPhone не увеличивал страницу при фокусе */
  .input, .textarea, .select select, .pop-search input, .title-input { font-size: 16px; }
}
@media (min-width: 641px) { .server-tile .go { display: none; } }
@media (max-width: 480px) {
  .user-name { display: none; }
  .user-btn { padding: 0 6px; }
  .q { gap: 10px; }
  .q-actions { flex-direction: column; }
}
@media (max-width: 400px) {
  .brand { font-size: 18px; }
  .btn-publish .ic { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ===== Кнопка темы ===== */
.theme-btn .ic-moon { display: none; }
:root[data-theme="light"] .theme-btn .ic-sun { display: none; }
:root[data-theme="light"] .theme-btn .ic-moon { display: block; }
:root[data-theme="light"] .preview .dc { box-shadow: 0 8px 22px var(--shadow); }
