.edit-gear > :not(.spinner-overlay) {
  animation: gear-spin 2s linear infinite;
  animation-play-state: paused;
}

.edit-gear.is-editing > :not(.spinner-overlay) {
  animation-play-state: running;
}

/* SAVE MODE — скрываем иконку */
.edit-gear.is-saving > :not(.spinner-overlay) {
  opacity: 0;
}

/* вращение шестерёнки */
@keyframes gear-spin {
  to { transform: rotate(360deg); }
}

/* =========================
   HIDDEN CLASS
========================= */
.hidden {
  display: none !important;
}

/* =========================
   SPINNER
========================= */

/* скрыт по умолчанию */
.spinner-overlay {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

/* показываем ТОЛЬКО при save */
.edit-gear.is-saving .spinner-overlay {
  display: flex;
}

.spinner {
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   TOURNAMENT RULES CSS — аккуратные параграфы, списки, спойлеры
========================================================= */

/* =========================================================
   GENERAL — всё внутри rules-view и rules-preview
========================================================= */
[data-role="rules-view"],
[data-role="rules-preview"] {
  font-size: 16px;
  line-height: 1.4em;
  color: #d2d1d1; /* основной текст */
  word-break: break-word;
}

/* Наследуем line-height и font-size всем потомкам */
[data-role="rules-view"] *,
[data-role="rules-preview"] * {
  font-size: inherit;
  line-height: inherit;
}

/* =========================================================
   PARAGRAPHS
========================================================= */
.rules-paragraph {
  white-space: pre-wrap;
  padding-bottom: 8px;
}

/* =========================================================
   LISTS
========================================================= */
.rules-list {
  padding-left: 1.8rem;
  list-style: none;
}

.rules-list li {
  position: relative;
  padding-left: 1.2rem;
  margin-bottom: 0.4em;
}

.rules-list li > span {
  display: inline;
}

.rules-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: #ff9900;
  font-size: inherit;
}

/* =========================================================
   LINKS
========================================================= */
.bb-link {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: border-color 0.2s ease;
}

.bb-link:hover {
  border-color: #5f85f6;
}

/* =========================================================
   STRIKE (BB [s])
========================================================= */
.bb-strike {
  position: relative;
  display: inline-block;
}

.bb-strike::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 52%;
  transform: translateY(-50%);
  height: 1.2px;
  background: currentColor;
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
}

/* =========================================================
   BB BUTTONS ACTIVE STATE
========================================================= */
button[data-bb].is-active {
  border: 1px solid #f8891a;
  background-color: rgba(244, 136, 27, 0.1);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

button[data-bb].is-active:hover {
  background-color: rgba(244, 136, 27, 0.2);
  border-color: #f88e1a;
}

/* =========================================================
   BB EDITOR — overlay + textarea (stable)
========================================================= */
.bb-editor-wrap {
  position: relative;
  width: 100%;
  height: 620px;
  min-height: 320px;
  overflow: hidden;
}

/* общие параметры — ДОЛЖНЫ СОВПАДАТЬ */
.bb-editor-highlight,
.bb-editor-input {
  font-family: 'Fira Code', monospace;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0;
  padding: 0.85rem;
  box-sizing: border-box;
  white-space: pre-wrap;
}

/* Тонкий скроллбар для редактора */
.bb-editor-wrap .bb-editor-highlight::-webkit-scrollbar,
.bb-editor-wrap .bb-editor-input::-webkit-scrollbar,
textarea.bb-editor-input::-webkit-scrollbar {
  width: 6px !important;
  height: 6px !important;
}

.bb-editor-wrap .bb-editor-highlight::-webkit-scrollbar-track,
.bb-editor-wrap .bb-editor-input::-webkit-scrollbar-track,
textarea.bb-editor-input::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 3px !important;
}

.bb-editor-wrap .bb-editor-highlight::-webkit-scrollbar-thumb,
.bb-editor-wrap .bb-editor-input::-webkit-scrollbar-thumb,
textarea.bb-editor-input::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2) !important;
  border-radius: 3px !important;
}

.bb-editor-wrap .bb-editor-highlight::-webkit-scrollbar-thumb:hover,
.bb-editor-wrap .bb-editor-input::-webkit-scrollbar-thumb:hover,
textarea.bb-editor-input::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35) !important;
}

.bb-editor-wrap .bb-editor-highlight,
.bb-editor-wrap .bb-editor-input,
textarea.bb-editor-input {
  scrollbar-width: thin !important;
  scrollbar-color: rgba(255, 255, 255, 0.2)
                 rgba(255, 255, 255, 0.05) !important;
}

/* overlay */
.bb-editor-highlight {
  position: absolute;
  inset: 0;
  overflow: auto; /* чтобы скролл работал */
  color: #d1d5db;
  pointer-events: none;
  overflow: auto;
  z-index: 1;
  padding-bottom: 1rem; /* теперь совпадает с textarea */
}

/* textarea */
.bb-editor-input {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: transparent !important;
  color: transparent !important;
  caret-color: #e5e7eb;
  overflow-y: auto;
  overflow-x: hidden;
  resize: none;
  padding-bottom: 1rem; /* <-- отступ снизу для курсора */
}

/* =========================================================
   RESPONSIVE — увеличенный шрифт на больших экранах
========================================================= */
@media (min-width: 768px) {
  .bb-editor-highlight,
  .bb-editor-input {
    font-size: 17px;
    line-height: 1.4em;
    padding: 0.95rem;
  }
}

/* =========================================================
   BB TAG HIGHLIGHT — grouped colors
========================================================= */
.bb-tag-bracket { color: #a17eff; }
.bb-tag-attr    { color: #c4a0f2; }
.bb-tag-value   { color: #e0bafc; }

.bb-tag-star    { color: #f9c878; }
.bb-tag-header  { color: #b078f5; font-weight: 500; }
.bb-tag-color   { color: #f26f6f; }
.bb-tag-link    { color: #5f85f6; }
.bb-tag-style   { color: #04d59e; }
.bb-tag        { color: #b078f5; font-weight: 500; text-shadow: 0 0 4px rgba(176, 120, 245, 0.2); }
.bb-tag-hr     { color: #9c9c88; text-shadow: 0 0 4px rgba(224, 224, 148, 0.2); }
.bb-tag-spoiler { color: #ec4899; }


/* =========================================================
   HORIZONTAL LINE
========================================================= */
.rules-hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, #2a2a35, transparent);
  margin: 16px 0;
}

/* =========================================================
   SPOILER — кнопка и скрытый блок
========================================================= */
.bb-spoiler-color {
  background: linear-gradient(180deg, #394360 0%, #2c364d 100%);
  color: #c8c9cd;
  font-weight: 600;
  border-radius: 0.5rem;
  box-shadow: 0 2px 6px rgba(20, 32, 62, 0.6);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.bb-spoiler-color:hover {
  background: linear-gradient(180deg, #404d6d 0%, #323c56 100%);
  box-shadow: 0 4px 12px rgba(23, 36, 66, 0.8);
}

.bb-spoiler-hidden {
  font-size: inherit;
  line-height: inherit;
}


/* =========================================================
   CUSTOM RADIO
========================================================= */
.custom-radio {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    user-select: none;
}

.custom-radio input {
    display: none;
}

.radio-mark {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    border: 1px solid #374151; /* gray-700 */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.radio-mark::after {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #3b82f6; /* blue-500 */
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.18s ease;
}

.custom-radio input:checked + .radio-mark {
    border-color: #3b82f6;
}

.custom-radio input:checked + .radio-mark::after {
    opacity: 1;
    transform: scale(1);
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.radio-label {
    color: #c3c4c5; /* gray-300 */
    font-size: 15px;
    transition: color 0.2s ease;
}

.custom-radio input:checked ~ .radio-label {
    color: #ffffff;
}


/* =========================================================
   UI SPINNER
========================================================= */
.ui-spinner-overlay {
    position: absolute;
    inset: 0;
    background: #14141b;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* сам спиннер */
.ui-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #555;
    border-top-color: #FFA500; /* оранжевый акцент */
    border-radius: 50%;
    animation: ui-spin 1s linear infinite;
}

/* плавное появление/исчезновение элементов */
.ui-fade {
    transition: opacity 0.25s ease;
}

/* анимация вращения */
@keyframes ui-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* ===============================
   Custom Toggle
================================ */

.ui-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ui-toggle input {
    display: none;
}

.ui-toggle-slider {
    width: 44px;
    height: 24px;
    background: #3a3a3a;
    border-radius: 999px;
    position: relative;
    transition: background 0.2s ease;
}

.ui-toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    background: #e3e2e2;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.2s ease;
}

/* Включено */
.ui-toggle input:checked + .ui-toggle-slider {
    background: #16a34a;
}

.ui-toggle input:checked + .ui-toggle-slider::before {
    transform: translateX(20px);
}

/* =========================================================
   GLOBAL SCROLLBAR — тонкий скроллбар для всей страницы
========================================================= */

/* Webkit (Chrome, Edge, Safari) */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
html *::-webkit-scrollbar,
body *::-webkit-scrollbar {
  width: 6px !important;
  height: 6px !important;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
html *::-webkit-scrollbar-track,
body *::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 3px !important;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
html *::-webkit-scrollbar-thumb,
body *::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2) !important;
  border-radius: 3px !important;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
html *::-webkit-scrollbar-thumb:hover,
body *::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35) !important;
}

/* Firefox */
html,
body,
html *,
body * {
  scrollbar-width: thin !important;
  scrollbar-color: rgba(255, 255, 255, 0.2)
                 rgba(255, 255, 255, 0.05) !important;
}

/* =========================================================
   SIDEBAR STYLES
========================================================= */

.sidebar-container {
  background-color: #14141b;
}

.sidebar-header {
  color: #d1d5db; /* gray-300 */
  border-bottom: 1px solid #1f2937; /* gray-800 */
}

.sidebar-nav button {
  color: #749ef8;
  transition: background-color 0.2s ease, color 0.2s ease;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
}

.sidebar-nav button:hover {
  background-color: #1c1f2b;
  color: #749ef8;
}

.sidebar-nav button:hover i {
  stroke: white;
}