/* ========================================================================
   Zayacchess — UI
   Палитра: брендовый красный + тёплый кремовый фон.
   Доска: деревянный walnut/maple, фигуры — из app/static/img/chesspieces/zayac.
   ======================================================================== */

:root {
  --accent: #0b6e4f;
  --accent-hover: #07553c;
  --accent-soft: #2e8b6a;
  --bg: #fbf7f4;
  --card: #ffffff;
  --border-soft: #ece0dc;
  --text: #2a1e1f;
  --muted: #8a6a6d;
  --ok: #3fa95a;
  --ok-soft: #e6f5eb;
  --fail: #d93b4a;
  --fail-soft: #fde8ea;

  /* Доска: светлые нейтрально-серые клетки */
  --board-light: #ece8e2;
  --board-light-2: #e4e0d9;
  --board-dark: #8a857c;
  --board-dark-2: #7b7671;
  --board-frame: #8a5e37;
  --board-frame-2: #6b4424;
  --board-label: #fdf5e8;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(42, 30, 31, .06);
  --shadow: 0 4px 14px rgba(42, 30, 31, .08);
  --shadow-lg: 0 10px 28px rgba(42, 30, 31, .12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Manrope', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(11, 110, 79, .18);
  flex-wrap: wrap;
}
header a.brand {
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -.01em;
  font-size: 1.15rem;
}
header a.brand .brand-logo { height: 30px; width: 30px; object-fit: contain; }
header .user-info { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
header .user-info b { font-weight: 700; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

h1 {
  margin: 8px 0 6px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
}
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: .95rem; }

/* ---- Темы задачи / подкатегории: крупные пилюли-бейджи ---- */
.themes-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 22px;
}
.themes-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-right: 2px;
}
.theme-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .005em;
  line-height: 1.2;
  box-shadow: 0 2px 6px rgba(11, 110, 79, .22);
}
.theme-pill.ghost {
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  box-shadow: none;
}
@media (max-width: 640px) {
  .themes-label { font-size: 1rem; }
  .theme-pill { font-size: .95rem; padding: 5px 12px; }
}

/* ---- Crumbs ---- */
.crumbs {
  margin: 4px 0 16px;
  font-size: .88rem;
  color: var(--muted);
}
.crumbs a { color: var(--accent); text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }

/* ---- Categories / subcategories ---- */
.cat-grid, .sub-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.cat-card, .sub-card {
  display: block;
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.cat-card:hover, .sub-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.cat-name, .sub-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.cat-meta, .sub-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
}
.prog-row { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin: 8px 0 4px; font-weight: 600; }
.prog-bar { height: 6px; background: var(--border-soft); border-radius: 3px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--accent); transition: width .25s; }

ul.courses { list-style: none; padding: 0; }
ul.courses li { background: var(--card); margin: 8px 0; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border-soft); }
ul.courses li a { font-size: 1.05rem; font-weight: 700; text-decoration: none; color: var(--text); }
ul.courses li .themes { color: var(--muted); margin-left: 1em; font-size: .88rem; }

/* ---- Levels ---- */
#levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.level {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.level.current { border-color: var(--accent); box-shadow: var(--shadow); }
.level.locked { opacity: .4; }
.lvl-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.count { color: var(--muted); font-size: .8rem; font-weight: 600; }
.streak-row { margin-top: 10px; font-size: .88rem; color: var(--muted); }
.streak-row b { color: var(--text); }

.play {
  margin-top: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  width: 100%;
  font-weight: 700;
  font-family: inherit;
  font-size: .92rem;
  transition: background .15s, transform .1s;
}
.play:hover { background: var(--accent-hover); }
.play:active { transform: scale(.98); }
.lock { color: #c9b8b8; font-size: 1.1em; }

/* ---- Streak cells ---- */
.streak-cells { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.streak-cells .cell {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 800;
  color: #fff;
  border: 1px solid transparent;
  background: var(--bg);
  cursor: default;
  transition: transform .1s;
}
.streak-cells .cell.ok { background: var(--ok); cursor: pointer; }
.streak-cells .cell.fail { background: var(--fail); cursor: pointer; }
.streak-cells .cell.empty { background: transparent; border-color: var(--border-soft); }
.streak-cells .cell:not(.empty):hover { transform: scale(1.15); }

/* ===========================
   Puzzle area — доска и контекст
   =========================== */
#puzzle-area {
  margin-top: 20px;
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
}
.puzzle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.puzzle-header #close {
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  font-family: inherit;
  padding: 6px 12px;
  transition: background .15s;
}
.puzzle-header #close:hover { background: var(--bg); border-color: var(--accent); }
#puzzle-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
#puzzle-info .pi-meta { color: var(--muted); font-size: .92rem; font-weight: 700; }
#puzzle-info .theme-pill { font-size: .95rem; padding: 4px 11px; }
#puzzle-info .puzzle-code {
  color: var(--muted);
  opacity: .55;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .02em;
  margin-left: 4px;
  user-select: all;
  text-decoration: none;
  cursor: pointer;
}
#puzzle-info a.puzzle-code:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ---- Деревянная рамка с подписями вокруг доски ---- */
.board-wrap {
  --frame: 22px;
  display: grid;
  grid-template-columns: var(--frame) 1fr var(--frame);
  grid-template-rows: var(--frame) 1fr var(--frame);
  width: min(92vw, 520px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  padding: 6px;
  background:
    linear-gradient(135deg, var(--board-frame) 0%, var(--board-frame-2) 100%);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .08),
    inset 0 0 0 2px rgba(0, 0, 0, .3),
    0 10px 28px rgba(42, 30, 31, .35);
}
.bw-top    { grid-column: 2; grid-row: 1; }
.bw-bottom { grid-column: 2; grid-row: 3; }
.bw-left   { grid-column: 1; grid-row: 2; }
.bw-right  { grid-column: 3; grid-row: 2; }
.bw-inner  { grid-column: 2; grid-row: 2; overflow: hidden; border-radius: 2px; }
.bw-files, .bw-ranks {
  color: var(--board-label);
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: .02em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  user-select: none;
  line-height: 1;
}
.bw-files { display: flex; justify-content: space-around; align-items: center; }
.bw-ranks { display: flex; flex-direction: column; justify-content: space-around; align-items: center; }
.bw-files span, .bw-ranks span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1em;
  text-align: center;
}
#board {
  width: 100% !important;
  max-width: 100%;
}
#status {
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  min-height: 1.4em;
  text-align: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
#status.ok { color: var(--ok); background: var(--ok-soft); }
#status.fail { color: var(--fail); background: var(--fail-soft); }
#turn-info { margin-top: 8px; color: var(--muted); text-align: center; font-size: .9rem; }

/* ---- Feedback ---- */
.feedback {
  margin-top: 16px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.feedback summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  user-select: none;
  padding: 4px 0;
}
.feedback[open] { padding-bottom: 14px; }
.fb-row { margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.fb-row label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.fb-row select, .fb-row input, .fb-row textarea {
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .92rem;
  background: #fff;
  color: var(--text);
}
.fb-row select:focus, .fb-row input:focus, .fb-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, .15);
}
#fb-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
}
#fb-send:hover { background: var(--accent-hover); }
#fb-send:disabled { background: #b8a5a7; cursor: wait; }
#fb-status { margin-left: 10px; font-size: .88rem; }

/* ---- Pager ---- */
.pager {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.pager-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.pager-head .pager-title { font-weight: 700; color: var(--text); }
.pager-head .pager-meta { color: var(--muted); font-size: .82rem; font-weight: 600; }
.pager-nav { display: flex; gap: 6px; align-items: center; }
.pager-btn {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .12s;
}
.pager-btn:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-page { color: var(--muted); font-size: .85rem; min-width: 60px; text-align: center; font-weight: 600; }
.pager-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}
.pz-chip {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 6px 2px;
  cursor: pointer;
  font-size: .72rem;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  transition: all .12s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pz-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.pz-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pz-chip.ok { border-color: var(--ok); }
.pz-chip.fail { border-color: var(--fail); }

/* ========================================================================
   Шахматная доска — переопределение chessboard.js под board.png (walnut).
   Градиенты имитируют прожилки и тёплые оттенки дерева.
   ======================================================================== */
.white-1e1d7 {
  background: linear-gradient(135deg, var(--board-light) 0%, var(--board-light-2) 100%) !important;
}
.black-3c85d {
  background: linear-gradient(135deg, var(--board-dark) 0%, var(--board-dark-2) 100%) !important;
}
/* chessboard.js стандартная рамка и нотация не используются — рамка у .board-wrap. */
.board-b72b1 { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }

/* ========================================================================
   Login
   ======================================================================== */
.login-box {
  max-width: 440px;
  margin: 40px auto;
  background: var(--card);
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
}
.login-box h1 { margin: 0 0 6px; text-align: center; font-size: 1.6rem; }
.login-step { margin-top: 18px; }
.login-step label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.role-buttons { display: flex; gap: 10px; }
.role-btn {
  flex: 1;
  background: #fff;
  border: 2px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 12px;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  transition: all .15s;
  font-family: inherit;
}
.role-btn:hover { border-color: var(--accent); color: var(--accent); }
.role-btn.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(11, 110, 79, .25);
}
.login-box input, .login-box select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}
.login-box input:focus, .login-box select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, .15);
}
.login-box .next {
  width: 100%;
  margin-top: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  transition: background .15s;
}
.login-box .next:hover:not(:disabled) { background: var(--accent-hover); }
.login-box .next:disabled { background: #c9b8b8; cursor: not-allowed; }

/* ---- User info in header (badges) ---- */
.user-info .role-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, .22);
  letter-spacing: .01em;
}
.user-info .pair { font-size: .82rem; opacity: .85; }
.user-info .logout {
  color: #fff;
  opacity: .75;
  text-decoration: none;
  margin-left: 4px;
  font-size: .82rem;
}
.user-info .logout:hover { opacity: 1; text-decoration: underline; }
.user-info .pair-jump {
  color: #fff;
  text-decoration: none;
  font-size: .82rem;
  background: rgba(255, 255, 255, .18);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
  transition: background .15s;
}
.user-info .pair-jump:hover { background: rgba(255, 255, 255, .32); }

/* ---- Viewers strip + comments ---- */
.viewers-strip {
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  color: var(--muted);
}
.viewers-strip .viewer { display: inline-block; margin-right: 10px; color: var(--text); font-weight: 600; }
.viewers-strip .viewer .role-t { color: var(--accent); font-weight: 700; }
.viewers-strip .viewer .role-s { color: #8a5a2e; font-weight: 700; }

.comments {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}
.comments h3 { margin: 0 0 10px; font-size: .95rem; color: var(--text); font-weight: 700; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: .9rem; }
.comment:last-child { border-bottom: none; }
.comment .author { font-weight: 700; color: var(--text); }
.comment .author .role-t { color: var(--accent); font-size: .78rem; font-weight: 700; }
.comment .author .role-s { color: #8a5a2e; font-size: .78rem; font-weight: 700; }
.comment .when { color: var(--muted); font-size: .75rem; margin-left: 8px; }
.comment .text { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; gap: 6px; margin-top: 10px; }
.comment-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  background: #fff;
}
.comment-form input:focus { outline: none; border-color: var(--accent); }
.comment-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  font-family: inherit;
}
.comment-form button:hover { background: var(--accent-hover); }

/* ========================================================================
   Mobile / tablet adaptation
   ======================================================================== */

/* Крупный планшет и ниже */
@media (max-width: 900px) {
  main { padding: 20px 16px 48px; }
  #levels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pager-grid { grid-template-columns: repeat(6, 1fr); }
}

/* Мобилка */
@media (max-width: 640px) {
  header {
    padding: 10px 14px;
  }
  header a.brand { font-size: 1rem; }
  header .user-info { font-size: .82rem; gap: 6px; }
  header .user-info .pair { display: none; }
  header .user-info .role-badge { padding: 2px 7px; font-size: .68rem; }

  main { padding: 16px 14px 40px; }

  .cat-grid, .sub-grid { grid-template-columns: 1fr; gap: 10px; }
  .cat-card, .sub-card { padding: 14px; }

  #levels { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .level { padding: 12px; }

  #puzzle-area { padding: 12px; border-radius: var(--radius); }
  .board-wrap { --frame: 18px; padding: 4px; }
  .bw-files, .bw-ranks { font-size: .95rem; }

  .pager-grid { grid-template-columns: repeat(5, 1fr); }
  .pager-head { gap: 6px; }
  .pager-head .pager-meta { width: 100%; }

  .login-box { margin: 20px auto; padding: 22px 18px; border-radius: var(--radius); }

  /* Комменты занимают всю ширину, отправка под инпутом */
  .comment-form { flex-direction: column; }
  .comment-form button { width: 100%; }
}

/* Очень маленькие экраны */
@media (max-width: 380px) {
  #levels { grid-template-columns: 1fr; }
  .streak-cells .cell { width: 20px; height: 20px; font-size: .72rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---- Мобильный drag на chessboard.js: отключаем нативный scroll/zoom при касании доски ---- */
#board, #board .square-55d11, .bw-inner {
  touch-action: none;
  -ms-touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- Тумблер auto-advance в заголовке задачи ---- */
.auto-advance {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: .88rem;
  font-weight: 700;
  color: var(--muted);
}
.auto-advance input { display: none; }
.auto-advance .switch {
  width: 34px;
  height: 20px;
  background: #d6cdc9;
  border-radius: 999px;
  position: relative;
  transition: background .18s;
  flex-shrink: 0;
}
.auto-advance .switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: left .18s;
}
.auto-advance input:checked + .switch { background: var(--accent); }
.auto-advance input:checked + .switch::after { left: 16px; }
.auto-advance:hover .switch { filter: brightness(1.05); }

/* ---- Кнопки «Следующая задача» / «Повторить» (без авто-перехода) ---- */
#next-area {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
#next-area button {
  font-family: inherit;
  font-weight: 700;
  font-size: .98rem;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  transition: background .15s, transform .05s;
}
#next-area button:hover { background: var(--accent-hover); }
#next-area button:active { transform: translateY(1px); }
#next-area button.secondary {
  background: transparent;
  color: var(--accent);
}
#next-area button.secondary:hover { background: var(--fail-soft); }

/* ---- Навигация разделов (Задачи / Игра) ---- */
.nav-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
  margin-right: 14px;
}
.nav-menu a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-menu a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-menu a.active { background: rgba(255,255,255,.18); color: #fff; }

@media (max-width: 640px) {
  .nav-menu {
    gap: 3px;
    margin: 4px 0 0 0;
    width: 100%;
    justify-content: center;
  }
  .nav-menu a { padding: 4px 8px; font-size: .78rem; }
  .auto-advance { font-size: .78rem; gap: 6px; }
  .auto-advance .switch { width: 30px; height: 18px; }
  .auto-advance .switch::after { width: 14px; height: 14px; }
  .auto-advance input:checked + .switch::after { left: 14px; }
}

/* ---- Профиль в шапке: аватар + рейтинг ---- */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  transition: background .15s;
}
.user-chip:hover { background: rgba(255,255,255,.16); }
.user-chip b { font-weight: 700; font-size: .92rem; }
.avatar-mini-wrap { position: relative; width: 26px; height: 26px; }
.avatar-mini {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; border: 1.5px solid rgba(255,255,255,.7);
  background: #fff;
}
.avatar-mini-placeholder {
  position: absolute; inset: 0;
  width: 26px; height: 26px; border-radius: 50%;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-weight: 800;
  font-size: .82rem;
  border: 1.5px solid rgba(255,255,255,.6);
}
.rating-chip {
  background: rgba(0,0,0,.18);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: .82rem;
  letter-spacing: .01em;
}

/* ---- Страница профиля ---- */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 18px;
}
.profile-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.profile-card h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  color: var(--accent);
}
.profile-card h3 { font-size: 1rem; color: var(--muted); margin: 0 0 10px; }
.avatar-row { display: flex; gap: 20px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.avatar-wrap { position: relative; width: 96px; height: 96px; }
.avatar-big {
  width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  background: var(--bg);
}
.avatar-placeholder {
  position: absolute; inset: 0;
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 2.3rem;
  color: var(--accent);
}
.avatar-actions { display: flex; flex-direction: column; gap: 6px; }
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--fail-soft); }
.profile-form-row {
  display: flex; gap: 10px; align-items: center;
  margin: 12px 0;
  flex-wrap: wrap;
}
.profile-form-row label { min-width: 60px; color: var(--muted); font-size: .92rem; font-weight: 700; }
.profile-form-row input[type=text],
.profile-form-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .95rem;
  background: var(--bg);
}
.profile-form-row input[type=text]:focus,
.profile-form-row select:focus { outline: none; border-color: var(--accent); }
.role-line { color: var(--muted); font-size: .92rem; }
.pair-current { font-size: 1.1rem; margin-bottom: 12px; }
.muted { color: var(--muted); }
.muted.small { font-size: .82rem; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
}
.stat-cell {
  padding: 14px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  text-align: center;
}
.stat-val {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1.1;
}
.stat-lbl { color: var(--muted); font-size: .78rem; font-weight: 700; margin-top: 4px; }
.cat-stats { list-style: none; padding: 0; margin: 0; }
.cat-stats li {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.cat-stats li:last-child { border-bottom: none; }
.cs-name { font-weight: 700; }
.cs-meta { color: var(--muted); }

/* ---- Аннотации на доске (SVG overlay) ---- */
.bw-inner { position: relative; }
.annotations-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}
.ann-sq { fill: rgba(21,140,40,.28); stroke: rgba(21,140,40,.6); stroke-width: 4; }
.ann-sq.ann-pair { fill: rgba(45,115,220,.25); stroke: rgba(45,115,220,.6); }
.ann-arrow { stroke: rgba(21,140,40,.75); stroke-width: 16; stroke-linecap: round; fill: none; }
.ann-arrow.ann-pair { stroke: rgba(45,115,220,.7); }
.ann-hint {
  margin-top: 8px;
  font-size: .82rem;
  text-align: center;
  color: var(--muted);
}

/* ========================================================================
   Chessground overrides — walnut/nature theme + sizing
   ======================================================================== */
/* Доска Chessground занимает всю bw-inner. */
.bw-inner #board.cg-wrap {
  width: 100%;
  height: 100%;
  display: block;
}
/* Walnut-палитра клеток (override chessground.brown.css). */
.cg-wrap cg-board {
  background-color: var(--board-light) !important;
  /* Inline SVG: 2x2 плитка, тёмные клетки в top-right и bottom-left. Тайл = 25% доски = 2x2 клеток.
     Итог: a8 (top-left) = light, a1 (bottom-left) = dark, h1 (bottom-right) = light, h8 (top-right) = dark. */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2' shape-rendering='crispEdges'><rect x='1' y='0' width='1' height='1' fill='%238a857c'/><rect x='0' y='1' width='1' height='1' fill='%238a857c'/></svg>") !important;
  background-size: 25% 25% !important;
  background-position: 0 0 !important;
  background-repeat: repeat !important;
}
/* Подсветка последнего хода и выделенной клетки. */
.cg-wrap cg-board square.last-move {
  background: rgba(11, 110, 79, .28) !important;
}
.cg-wrap cg-board square.selected {
  background: rgba(11, 110, 79, .45) !important;
}
.cg-wrap cg-board square.check {
  background: radial-gradient(ellipse at center, rgba(217,59,74,.65) 0%, rgba(217,59,74,0) 70%) !important;
}
.cg-wrap cg-board square.move-dest {
  background: radial-gradient(rgba(21,140,40,.4) 22%, transparent 24%) !important;
}
.cg-wrap cg-board square.premove-dest {
  background: radial-gradient(rgba(30,80,175,.4) 22%, transparent 24%) !important;
}
.cg-wrap cg-board square.oc.move-dest {
  background: radial-gradient(transparent 58%, rgba(21,140,40,.5) 60%) !important;
}

/* ---- Legacy chessboard.js styles остались выше — не мешают Chessground ---- */

/* ---- Games lobby / game view ---- */
.games-page h1 { margin-top: 4px; }
.games-create-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0 24px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.games-create-row label { color: var(--muted); font-weight: 700; font-size: .88rem; }
.games-create-row select {
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .92rem;
  background: #fff;
  color: var(--text);
}
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.game-card {
  background: var(--card);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.game-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.game-card .gc-head { display: flex; justify-content: space-between; align-items: center; font-size: .88rem; color: var(--muted); }
.game-card .gc-status { padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: .72rem; letter-spacing: .02em; }
.gc-status.waiting { background: #fff4d6; color: #8a5a10; }
.gc-status.active { background: var(--ok-soft); color: var(--ok); }
.gc-status.finished { background: var(--border-soft); color: var(--muted); }
.game-card .gc-players { font-weight: 700; }
.game-card .gc-players .gc-white::before { content: "♔ "; }
.game-card .gc-players .gc-black::before { content: "♚ "; }
.game-card .gc-actions { display: flex; gap: 6px; justify-content: flex-end; }
.games-empty { text-align: center; padding: 40px; color: var(--muted); }

.game-view {
  display: grid;
  grid-template-columns: minmax(0, 560px) 1fr;
  gap: 20px;
  margin-top: 14px;
}
@media (max-width: 900px) {
  .game-view { grid-template-columns: 1fr; }
}
.game-side {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.game-players-row { display: flex; justify-content: space-between; font-weight: 700; font-size: .92rem; }
.game-clock { font-family: 'SF Mono', Menlo, monospace; font-weight: 800; color: var(--accent); }
.game-chat {
  flex: 1;
  min-height: 180px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: .88rem;
}
.move-history {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  max-height: 220px;
}
.move-history__title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.move-history__body {
  overflow-y: auto;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: .88rem;
  line-height: 1.4;
  padding-right: 4px;
}
.mh-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  gap: 8px;
  padding: 2px 0;
  align-items: baseline;
}
.mh-row:nth-child(even) { background: rgba(138, 90, 46, 0.04); border-radius: 4px; }
.mh-num { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.mh-san { color: var(--fg); letter-spacing: .02em; }
.mh-empty { color: var(--muted); font-style: italic; }
.mh-fig {
  font-family: "DejaVu Sans", "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  font-size: 1.15em;
  line-height: 1;
  margin-right: 1px;
  vertical-align: -1px;
}
.mh-white .mh-fig { color: #f4e8d6; text-shadow: 0 0 0 #3a2410, -0.5px -0.5px 0 #3a2410, 0.5px -0.5px 0 #3a2410, -0.5px 0.5px 0 #3a2410, 0.5px 0.5px 0 #3a2410; }
.mh-black .mh-fig { color: #2a1a08; }
.gm-line { margin: 4px 0; }
.gm-line .gm-who { font-weight: 700; color: var(--accent); }
.gm-line .gm-who.spectator { color: var(--muted); }
.gm-line .gm-who.coach { color: #8a5a2e; }
.gm-line.system { color: var(--muted); font-style: italic; }
.game-chat-form { display: flex; gap: 6px; }
.game-chat-form input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .9rem; background: #fff;
}
.game-chat-form button {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; font-weight: 700; font-family: inherit;
}
.game-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.game-controls button {
  padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-soft);
  background: #fff; color: var(--text); font-family: inherit; font-weight: 700;
  font-size: .85rem; cursor: pointer; transition: all .15s;
}
.game-controls button:hover { border-color: var(--accent); color: var(--accent); }
.game-controls button.danger:hover { border-color: var(--fail); color: var(--fail); background: var(--fail-soft); }
.game-controls button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.game-controls button.primary:hover { background: var(--accent-hover); }
.game-banner {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 700;
  text-align: center;
}
.game-banner.pending { background: #fff4d6; color: #8a5a10; }
.game-banner.coach { background: #e5efff; color: #1e50af; }
.game-banner.end { background: var(--fail-soft); color: var(--fail); }

/* ---- Заглушка для раздела «Игра» ---- */
.games-stub {
  text-align: center;
  padding: 60px 20px;
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
  margin-top: 20px;
}
.games-stub h2 { font-size: 1.8rem; margin: 0 0 12px; color: var(--accent); }
.games-stub p { color: var(--muted); font-size: 1.05rem; max-width: 520px; margin: 8px auto; }
.games-stub .soon { display: inline-block; margin-top: 18px; padding: 6px 14px;
  background: var(--accent); color: #fff; border-radius: 999px; font-weight: 700; font-size: .85rem; }

/* ---- admin-note: плавающий виджет заметок админа ---- */
.admin-note {
  position: fixed; right: 14px; bottom: 14px; z-index: 9000;
  font-family: inherit;
}
.admin-note__toggle {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.1);
  background: #fff; color: var(--accent);
  font-size: 17px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.admin-note__toggle:hover { transform: scale(1.06); }
.admin-note__panel {
  position: absolute; right: 0; bottom: 46px;
  width: 280px; background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.admin-note--collapsed .admin-note__panel { display: none; }
.admin-note__head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; font-weight: 700; color: var(--muted);
}
.admin-note__all {
  color: var(--accent); text-decoration: none; font-size: .78rem;
}
.admin-note__all:hover { text-decoration: underline; }
.admin-note__path {
  font-family: ui-monospace, Menlo, monospace;
  font-size: .72rem; color: var(--muted); opacity: .7;
  word-break: break-all;
}
.admin-note textarea {
  width: 100%; min-height: 90px; resize: vertical;
  border: 1px solid rgba(0,0,0,.12); border-radius: 6px;
  padding: 6px 8px; font-family: inherit; font-size: .9rem;
  box-sizing: border-box;
}
.admin-note__foot {
  display: flex; justify-content: space-between; align-items: center;
}
.admin-note__status { font-size: .78rem; color: var(--muted); }
.admin-note__send {
  padding: 5px 14px; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
  font-size: .85rem;
}
.admin-note__send:hover { filter: brightness(1.08); }
.admin-note__send:disabled { opacity: .6; cursor: default; }

/* ---- /admin/feedback: список заметок ---- */
.admin-feedback-list { max-width: 900px; margin: 20px auto; padding: 0 16px; }
.admin-feedback-list h1 { color: var(--accent); margin-bottom: 16px; }
.afb-item {
  background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.afb-item.afb-resolved { opacity: .55; }
.afb-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; color: var(--muted); margin-bottom: 6px;
  gap: 10px; flex-wrap: wrap;
}
.afb-path {
  font-family: ui-monospace, Menlo, monospace; color: var(--accent);
  font-size: .82rem;
}
.afb-path a { color: inherit; text-decoration: none; }
.afb-path a:hover { text-decoration: underline; }
.afb-text { white-space: pre-wrap; font-size: .95rem; }
.afb-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.afb-btn {
  background: transparent; border: 1px solid rgba(0,0,0,.15);
  padding: 3px 10px; border-radius: 5px; cursor: pointer;
  font-size: .78rem; color: var(--muted);
}
.afb-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ========== ИИ-тренировка ========== */
.train-view {
  display: grid;
  grid-template-columns: 220px minmax(0, 600px) 220px;
  gap: 16px;
  margin-top: 8px;
  align-items: start;
}
@media (max-width: 1000px) {
  .train-view { grid-template-columns: 1fr; }
}
.train-left, .train-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.train-controls {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.train-controls .btn {
  background: var(--card, #fff);
  border: 1px solid var(--border-soft, rgba(0,0,0,.15));
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .92rem;
}
.train-controls .btn.primary {
  background: var(--accent, #5b6cff);
  color: #fff;
  border-color: var(--accent, #5b6cff);
}
.train-controls .btn:hover { filter: brightness(.95); }
.train-skill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
}
.train-skill input[type=range] { width: 140px; }
.skill-label {
  min-width: 140px;
  color: var(--muted);
  font-size: .82rem;
}
.train-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg, #f7f3ea);
  border: 1px solid var(--border-soft, rgba(0,0,0,.15));
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  user-select: none;
}
body.whatif-on .train-toggle {
  background: #fff3c4;
  border-color: #e6a800;
}

/* Eval bar — вертикальная полоса */
.eval-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.eval-bar {
  width: 28px;
  height: 320px;
  background: #222;
  border: 1px solid var(--border-soft, rgba(0,0,0,.2));
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-end;
}
.eval-bar-white {
  width: 100%;
  background: #f0ead4;
  transition: height 0.3s ease;
}
.eval-text {
  font-size: .85rem;
  text-align: center;
  line-height: 1.3;
  max-width: 200px;
}
.eval-text.great { color: #1a7d1a; font-weight: 700; }
.eval-text.good  { color: #2a8a2a; }
.eval-text.neutral { color: var(--muted); }
.eval-text.warn  { color: #c08000; }
.eval-text.bad   { color: #c44; font-weight: 700; }

/* What if popup */
.whatif-popup {
  background: #fffbe6;
  border: 2px solid #e6a800;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  font-size: .92rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.whatif-popup .wi-thinking { color: var(--muted); }
.whatif-popup .wi-head { font-weight: 600; }
.whatif-popup .wi-verdict {
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: 700;
}
.whatif-popup .wi-verdict.great { background: #dfffdf; color: #0d6e0d; }
.whatif-popup .wi-verdict.good  { background: #e8f7e8; color: #2a8a2a; }
.whatif-popup .wi-verdict.neutral { background: #f4f4f4; color: #555; }
.whatif-popup .wi-verdict.warn  { background: #fff3c4; color: #a07000; }
.whatif-popup .wi-verdict.bad   { background: #ffe0e0; color: #a02020; }
.whatif-popup .wi-eval { color: var(--muted); font-size: .85rem; }
.whatif-popup .wi-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.whatif-popup .btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-soft, rgba(0,0,0,.15));
  background: #fff;
  cursor: pointer;
  font-size: .9rem;
}
.whatif-popup .btn.primary {
  background: var(--accent, #5b6cff);
  color: #fff;
  border-color: var(--accent, #5b6cff);
}

/* Promotion dialog — overlay на доске при превращении пешки */
.promotion-dialog {
  position: absolute;
  z-index: 50;
  display: none;
  flex-direction: column;
  background: var(--card, #fff);
  border: 1px solid var(--border-soft, rgba(0,0,0,.15));
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
  overflow: hidden;
}
.promotion-dialog .promo-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #222;
  transition: background 0.12s;
}
.promotion-dialog .promo-btn:hover {
  background: var(--accent, #5b6cff);
  color: #fff;
}
.promotion-dialog .promo-cancel {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  aspect-ratio: auto;
  padding: 6px 0;
  border-top: 1px solid var(--border-soft, rgba(0,0,0,.15));
  color: var(--muted, #888);
}
.promotion-dialog .promo-cancel:hover {
  background: #c44;
  color: #fff;
}

/* Opening detector box — в aside партии */
.opening-box {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 58px;
}
.opening-box .op-eco {
  font-family: 'SF Mono', Menlo, monospace;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.opening-box.has-op .op-eco { color: var(--accent); }
.opening-box .op-name-ru {
  font-weight: 700;
  font-size: .95rem;
  color: var(--fg);
  line-height: 1.2;
}
.opening-box .op-name-en {
  font-size: .78rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.2;
}

/* Расширенное описание дебюта (раскрывающееся) */
.opening-box .op-extended {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.opening-box .op-extended__sum {
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
  padding: 2px 0;
  list-style: none;
  user-select: none;
}
.opening-box .op-extended__sum::-webkit-details-marker { display: none; }
.opening-box .op-extended__sum::before {
  content: "▸ ";
  display: inline-block;
  transition: transform .15s ease;
}
.opening-box .op-extended[open] .op-extended__sum::before {
  content: "▾ ";
}
.opening-box .op-extended__body {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.opening-box .op-ex-row {
  font-size: .82rem;
  line-height: 1.35;
  color: var(--fg);
}
.opening-box .op-ex-k {
  font-weight: 700;
  color: var(--muted);
  margin-right: 4px;
}
.opening-box .op-ex-v { color: var(--fg); }
.opening-box .op-ex-diff {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .75rem;
  text-transform: lowercase;
}
.opening-box .op-ex-diff.diff-easy   { background: #d8f0d4; color: #1f6a2a; }
.opening-box .op-ex-diff.diff-medium { background: #fff0c2; color: #8a5b00; }
.opening-box .op-ex-diff.diff-hard   { background: #ffd7d0; color: #9a2620; }

/* ---- Time control picker ---- */
.tc-picker {
  margin: 14px 0 6px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.tc-picker .tc-head {
  font-size: .88rem;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tc-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}
.tc-tile {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 6px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform .08s, border-color .12s, background .12s;
  font-family: inherit;
}
.tc-tile b { font-size: 1.05rem; font-weight: 700; }
.tc-tile span { font-size: .72rem; color: var(--muted); }
.tc-tile:hover { border-color: var(--accent-soft); transform: translateY(-1px); }
.tc-tile.active {
  border-color: var(--accent);
  background: #e8f5ee;
  box-shadow: 0 0 0 2px rgba(11, 110, 79, .12);
}
.tc-tile.active span { color: var(--accent); }
.tc-sliders {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tc-sliders label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  color: var(--text);
}
.tc-sliders input[type="range"] { flex: 1; accent-color: var(--accent); }
.tc-sliders .tc-preview {
  font-size: .92rem;
  color: var(--muted);
}
.tc-sliders .tc-preview b { color: var(--accent); font-size: 1rem; }

/* ---- Game card tc badge ---- */
.gc-meta { margin: 6px 0 8px; }
.gc-tc {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5ee;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.gc-tc-none { background: var(--border-soft); color: var(--muted); font-weight: 500; }

/* ---- Clock widget (рядом с доской) ---- */
.clock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  margin: 6px 0;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.clock-who {
  font-size: .82rem;
  color: var(--muted);
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clock-time {
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.clock.active {
  border-color: var(--accent);
  background: #edf7f1;
  box-shadow: 0 0 0 2px rgba(11, 110, 79, .10);
}
.clock.active .clock-time { color: var(--accent); }
.clock.low .clock-time {
  color: var(--fail);
  animation: clockLowPulse 1s ease-in-out infinite;
}
@keyframes clockLowPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* === Moves table на /train === */
.moves-panel {
  margin-top: 10px;
  background: #1e1f24;
  color: #e6e6ea;
  border-radius: 10px;
  border: 1px solid #2a2b31;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.10);
}
.moves-panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #2a2b31;
  font-size: .82rem;
}
.moves-engine-tag {
  color: #9aa0aa;
  letter-spacing: .02em;
}
.moves-engine-tag::before {
  content: "🤖 ";
  opacity: .9;
}
.moves-table-wrap {
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3b42 transparent;
}
.moves-table-wrap::-webkit-scrollbar { width: 6px; }
.moves-table-wrap::-webkit-scrollbar-thumb { background: #3a3b42; border-radius: 3px; }
.moves-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
}
.moves-table td {
  padding: 4px 10px;
  vertical-align: middle;
  border-top: 1px solid #26272d;
}
.moves-table tr:first-child td { border-top: 0; }
.moves-table .mv-num {
  width: 36px;
  color: #8a8f99;
  font-size: .85rem;
  text-align: right;
  background: #191a1e;
}
.moves-table .mv-cell {
  cursor: default;
  color: #e6e6ea;
}
.moves-table .mv-cell.mv-last {
  background: #2a66c8;
  color: #fff;
  font-weight: 600;
}
.piece-glyph {
  display: inline-block;
  font-size: 1.15em;
  line-height: 1;
  margin-right: 1px;
  vertical-align: -2px;
}
.piece-glyph.piece-w { color: #f3f3f6; text-shadow: 0 0 1px #000, 0 0 1px #000; }
.piece-glyph.piece-b { color: #111; text-shadow: 0 0 1px #fff, 0 0 1px #fff; }
/* В светлой whatif-popup — чёрные фигуры без белой обводки */
.whatif-popup .piece-glyph.piece-b { color: #1a1a1a; text-shadow: none; }

/* ========================================================================
   Морковки (вместо звёздочек) — skeleton, будет дополирован в design pass
   ======================================================================== */
.carrot {
  width: 16px; height: 16px;
  vertical-align: -3px;
  display: inline-block;
  user-select: none;
  pointer-events: none;
}
.carrot--lg { width: 22px; height: 22px; vertical-align: -5px; }
.carrot--xl { width: 32px; height: 32px; vertical-align: -7px; }

.rating-chip .carrot { margin-right: 4px; }

/* ========================================================================
   Тренерская — скелет (design TBD)
   ======================================================================== */
.trainer-page {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 14px;
}
.trainer-head h1 {
  margin: 0 0 6px 0;
  font-size: 1.6rem;
}
.trainer-head p.muted { margin: 0 0 18px 0; max-width: 720px; }
.trainer-head-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 18px 0;
}
.trainer-head-row h1 { margin: 0; }
.trainer-search {
  flex: 0 1 320px;
  min-width: 200px;
  padding: 8px 12px;
  font-size: .95rem;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.trainer-search:focus { border-color: var(--accent); }

.trainer-sort {
  padding: 8px 10px;
  font-size: .9rem;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.trainer-sort:focus { border-color: var(--accent); }

.sc-rename-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 22px; height: 22px;
  border-radius: 4px;
  font-size: 12px; line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: -2px;
  transition: color .12s, background .12s, border-color .12s;
}
.sc-rename-btn:hover {
  color: var(--accent);
  background: rgba(0,0,0,.04);
  border-color: var(--border-soft);
}

.trainer-attach {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.trainer-attach h2 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}
.trainer-attach .row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.trainer-attach select {
  flex: 1 1 260px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
}

.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.student-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s;
}
.student-card:hover { box-shadow: var(--shadow); }
.student-card.is-online { border-color: var(--ok); }
.student-card .sc-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.student-card .sc-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ccc; flex-shrink: 0;
}
.student-card.is-online .sc-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(63, 169, 90, .18);
}
.student-card .sc-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  flex: 1 1 auto;
}
.sc-carrots {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff6ea;
  border: 1px solid #f0d7a8;
  border-radius: 999px;
  padding: 2px 6px 2px 8px;
  font-weight: 700;
}
.sc-carrots .sc-rating { min-width: 22px; text-align: center; }

/* --- Pill-кнопка «морковки» (открывает диалог) --- */
.sc-carrots-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff6ea;
  border: 1.5px solid #e8b96a;
  border-radius: 999px;
  padding: 4px 12px 4px 8px;
  font-weight: 800;
  font-size: .98rem;
  color: #5a3a14;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s;
  line-height: 1.2;
}
.sc-carrots-btn .carrot { width: 18px; height: 18px; }
.sc-carrots-btn .sc-rating { min-width: 22px; text-align: center; }
.sc-carrots-btn .sc-edit-hint {
  font-size: .8rem;
  color: #a97a3a;
  margin-left: 2px;
  font-weight: 600;
}
.sc-carrots-btn:hover {
  background: #ffe9c8;
  box-shadow: 0 2px 8px rgba(232, 185, 106, .35);
}
.sc-carrots-btn:active { transform: scale(.96); }

/* --- Диалог ввода количества морковок --- */
.carrot-dialog {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.carrot-dialog[hidden] { display: none; }
.carrot-dialog .cd-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 18, 14, .55);
  backdrop-filter: blur(2px);
}
.carrot-dialog .cd-box {
  position: relative;
  background: #fffaf1;
  border: 2px solid #e8b96a;
  border-radius: 18px;
  padding: 22px 24px 18px;
  width: min(92vw, 420px);
  box-shadow: 0 12px 40px rgba(0,0,0,.28);
  animation: cdIn .18s ease-out;
}
@keyframes cdIn {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.carrot-dialog .cd-close {
  position: absolute; top: 8px; right: 10px;
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 1.5rem; line-height: 1;
  color: #8a6a3a; cursor: pointer; border-radius: 50%;
}
.carrot-dialog .cd-close:hover { background: #f3e4c8; color: #5a3a14; }
.carrot-dialog .cd-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.carrot-dialog .cd-head h3 {
  margin: 0; font-size: 1.1rem; color: #5a3a14; font-weight: 800;
}
.carrot-dialog .cd-head .cd-name { color: var(--accent); }
.carrot-dialog .carrot--xl { width: 36px; height: 36px; }
.carrot-dialog .cd-current {
  font-size: 1rem; color: #5a3a14;
  margin: 4px 0 14px;
}
.carrot-dialog .cd-current b { color: var(--accent); font-size: 1.2rem; }
.carrot-dialog .cd-quick {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.carrot-dialog .cd-q {
  padding: 8px 0;
  border-radius: 10px;
  border: 1.5px solid var(--border-soft);
  background: #fff;
  font-weight: 800; font-size: .98rem;
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s;
}
.carrot-dialog .cd-q:hover { transform: translateY(-1px); }
.carrot-dialog .cd-q-minus {
  color: #b14040; border-color: #edb8b8; background: #fff4f4;
}
.carrot-dialog .cd-q-minus:hover { background: #ffe4e4; border-color: #b14040; }
.carrot-dialog .cd-q-minus:disabled {
  opacity: .35; cursor: not-allowed; background: #f4f0ea; color: #aaa;
  border-color: var(--border-soft);
}
.carrot-dialog .cd-q-plus {
  color: #0b6e4f; border-color: #b4ddc5; background: #f1faf5;
}
.carrot-dialog .cd-q-plus:hover { background: #dbf1e6; border-color: #0b6e4f; }

.carrot-dialog .cd-custom {
  border-top: 1px dashed #e8d8b4;
  padding-top: 12px;
}
.carrot-dialog .cd-custom label {
  display: block; font-size: .9rem; color: #7a5a2a; margin-bottom: 6px;
}
.carrot-dialog .cd-row { display: flex; gap: 8px; }
.carrot-dialog .cd-input {
  flex: 1 1 auto;
  padding: 8px 10px;
  border: 1.5px solid #e8b96a;
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: #5a3a14;
}
.carrot-dialog .cd-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, .18);
}
.carrot-dialog .cd-apply {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.carrot-dialog .cd-apply:hover { filter: brightness(1.1); }
.carrot-dialog .cd-apply:disabled { opacity: .5; cursor: wait; }
.carrot-dialog .cd-hint {
  margin-top: 8px;
  font-size: .82rem;
  line-height: 1.4;
}
.carrot-dialog .cd-status {
  margin-top: 10px;
  min-height: 20px;
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
}
.carrot-dialog .cd-status.ok { color: var(--ok); font-weight: 700; }
.carrot-dialog .cd-status.fail { color: var(--fail); font-weight: 700; }

@media (max-width: 460px) {
  .carrot-dialog .cd-box { padding: 18px 16px 14px; }
  .carrot-dialog .cd-quick { grid-template-columns: repeat(3, 1fr); }
  .carrot-dialog .cd-q { padding: 10px 0; }
}
.btn-mini {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}
.btn-mini:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-mini:disabled { opacity: .5; cursor: wait; }

.sc-viewing {
  min-height: 52px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .95rem;
}
.sc-viewing-empty { font-style: italic; }
.sc-viewing-cat { margin-bottom: 4px; }
.sc-cat-title { font-weight: 600; }
.sc-puzzle-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.sc-puzzle-link:hover { text-decoration: underline; }
.sc-move {
  margin-top: 6px;
  font-size: .9rem;
  color: var(--text);
}
.sc-move-san {
  font-family: 'JetBrains Mono', monospace, monospace;
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}

.sc-recent { font-size: .9rem; }
.sc-recent summary { cursor: pointer; color: var(--muted); }
.sc-recent-list {
  list-style: none; padding: 6px 0 0 0; margin: 0;
  max-height: 140px; overflow-y: auto;
}
.sc-recent-list li { padding: 2px 0; }
.sc-recent-list li.ok   { color: var(--ok); }
.sc-recent-list li.fail { color: var(--fail); }
.sc-recent-list li a { color: inherit; text-decoration: none; }
.sc-recent-list li a:hover { text-decoration: underline; }

.sc-errors { font-size: .9rem; }
.sc-errors summary { cursor: pointer; color: var(--muted); }
.sc-errors-list {
  list-style: none; padding: 6px 0 0 0; margin: 0;
  max-height: 200px; overflow-y: auto;
}
.sc-errors-list .err-row {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-soft);
}
.sc-errors-list .err-row:last-child { border-bottom: none; }
.sc-errors-list .err-dt { font-size: .75rem; margin-right: 6px; }
.sc-errors-list .err-link { color: inherit; text-decoration: none; display: inline; }
.sc-errors-list .err-link:hover .err-sub { text-decoration: underline; }
.sc-errors-list .err-sub { font-weight: 500; }
.sc-errors-list .err-move { display: inline-block; margin-left: 4px; }
.sc-errors-list .err-wrong { color: var(--fail); font-weight: 700; }
.sc-errors-list .err-right { color: var(--ok); font-weight: 700; }

.err-history {
  display: inline-block;
  font-family: "Courier New", monospace;
  font-size: .95rem;
  line-height: 1.6;
  margin-top: 4px;
}
.err-history .err-mv-num { color: var(--muted); font-weight: 700; }
.err-history .err-mv-ellipsis { color: var(--muted); }
.err-history .err-mv-opp   { color: var(--text); }
.err-history .err-mv-stu   { color: var(--text); font-weight: 600; }
.err-history .err-mv-wrong { color: var(--fail); font-weight: 700; text-decoration: line-through; }
.err-history .err-mv-right { color: var(--ok); font-weight: 700; }
.err-history .err-mv-cur {
  background: #fff2a8;
  border-radius: 3px;
  padding: 0 3px;
  outline: 1px solid #e8c84e;
}
.err-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  font-family: inherit;
}
.err-nav-btn {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: .95rem;
  cursor: pointer;
  line-height: 1;
}
.err-nav-btn:hover:not([disabled]) { background: var(--accent); color: #fff; border-color: var(--accent); }
.err-nav-btn[disabled] { opacity: .4; cursor: not-allowed; }
.err-nav-pos { font-size: .85rem; color: var(--muted); min-width: 38px; text-align: center; }

.sc-foot {
  display: flex; gap: 8px; margin-top: auto;
  flex-wrap: wrap; align-items: center;
}
.sc-foot .btn { flex: 0 1 auto; }
.btn-follow { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-follow:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Observe controls (набор из «следить» + 2 чекбокса) */
.sc-observe-ctl {
  display: flex; align-items: center; gap: 8px;
  row-gap: 6px;
  flex: 1 1 auto; flex-wrap: wrap;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
/* компактная кнопка-пилюля для ряда действий карточки ученика
   (в отличие от круглой .btn-mini, умеет в текст) */
.btn-chip {
  padding: 4px 10px;
  font-size: .78rem;
  line-height: 1.2;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: #fff;
  white-space: nowrap;
  cursor: pointer;
}
.btn-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.sc-obs-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--muted);
  cursor: pointer; user-select: none;
}
.sc-obs-toggle input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0;
  accent-color: var(--accent);
}
.student-card.is-observing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(167, 40, 54, 0.12);
}
.student-card.is-observing .btn-follow {
  background: var(--fail, #b33); border-color: var(--fail, #b33);
}
.student-card.is-observing .sc-observe-ctl {
  background: rgba(167, 40, 54, 0.06);
}

/* Observe toast (уведомление «ученик перешёл к задаче N») */
.obs-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  background: #1f1f1f; color: #fff;
  padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  font-size: .9rem;
  display: flex; align-items: center; gap: 10px;
  max-width: 360px;
  animation: obs-toast-in .2s ease-out;
}
@keyframes obs-toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.obs-toast a { color: #ffcf6b; font-weight: 600; text-decoration: underline; }
.obs-toast__x {
  background: transparent; color: #fff; border: 0;
  cursor: pointer; font-size: 1rem; padding: 0 4px;
}

/* Панель "готов?" — часы стартуют когда оба подтвердили */
.ready-panel {
  margin: 8px 0;
  padding: 12px 14px;
  background: linear-gradient(135deg, #fff4d8 0%, #ffe5a8 100%);
  border: 2px solid #c09043;
  border-radius: 10px;
  box-shadow: 0 0 0 2px #c0904322;
}
.ready-panel__title { font-weight: 700; margin-bottom: 8px; color: #5c3a1c; }
.ready-panel__body { margin-bottom: 10px; display: flex; gap: 14px; flex-wrap: wrap; }
.ready-row { display: flex; align-items: center; gap: 6px; font-size: .92rem; color: #5c3a1c; }
.ready-row .ready-side { font-weight: 600; }
.ready-row .ready-mark { color: #8a5a2e; font-style: italic; }
.ready-row.is-ready .ready-mark { color: #2d7a2d; font-style: normal; font-weight: 700; }
.ready-panel__hint { margin-top: 6px; color: #8a5a2e !important; }

/* Глобальный тост "в твоей партии ждут" — стекуется в правом нижнем углу, кликабелен целиком */
.game-toast {
  position: fixed; right: 16px; z-index: 10000;
  width: 300px;
  background: linear-gradient(135deg, #3a2410 0%, #5c3a1c 100%);
  color: #fff5df !important;
  padding: 12px 36px 12px 14px;
  border-radius: 12px;
  border: 2px solid #c0904333;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px #c0904344;
  font-size: .92rem;
  text-decoration: none;
  cursor: pointer;
  display: block;
  animation: game-toast-in .25s ease-out, game-toast-pulse 2.4s ease-in-out infinite;
}
.game-toast:hover { transform: translateY(-1px); filter: brightness(1.08); }
.game-toast { bottom: 16px; }
.game-toast ~ .game-toast { bottom: 108px; }
.game-toast ~ .game-toast ~ .game-toast { bottom: 200px; }
@keyframes game-toast-in {
  from { transform: translateX(20px) scale(.96); opacity: 0; }
  to   { transform: translateX(0) scale(1);      opacity: 1; }
}
@keyframes game-toast-pulse {
  0%,100% { box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px #c0904344; }
  50%     { box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 3px #c0904388; }
}
.game-toast__title { font-weight: 700; font-size: 1rem; margin-bottom: 6px; color: #ffd98a; }
.game-toast__body  { line-height: 1.35; margin-bottom: 10px; }
.game-toast__body .muted { color: #d4b88a; }
.game-toast__acts  { display: flex; gap: 6px; }
.game-toast__acts .btn { padding: 6px 14px; font-size: .88rem; }
.game-toast__x {
  position: absolute; top: 6px; right: 8px;
  background: transparent; color: #d4b88a; border: 0;
  cursor: pointer; font-size: 1.1rem; padding: 2px 6px; line-height: 1;
}
.game-toast__x:hover { color: #fff5df; }

/* Индикатор «я наблюдаю за N» + тумблеры в шапке */
.observe-ctl {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px;
  padding: 2px 4px 2px 2px;
  border-radius: 999px;
  background: rgba(167, 40, 54, 0.08);
  border: 1px solid var(--accent);
}
.observe-indicator {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: .82rem; font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.observe-indicator:hover { background: var(--accent-hover); }
.obs-hdr-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--fg);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.obs-hdr-toggle input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0;
  accent-color: var(--accent);
}
.obs-stop-btn {
  background: transparent; color: var(--accent); border: 0;
  cursor: pointer; font-size: .9rem; font-weight: 700;
  padding: 0 6px; line-height: 1;
}
.obs-stop-btn:hover { color: var(--accent-hover); }

/* Ученик видит: «за тобой наблюдает учитель N» */
.watcher-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: #fff6d5; color: #8a5b00;
  font-size: .8rem; font-weight: 600;
}

/* Агрегат по уровням */
.sc-stats {
  display: flex; gap: 12px; align-items: flex-end;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.sc-stats-total { font-size: .9rem; flex: 1 1 auto; }
.sc-stats-pct.is-good { color: var(--ok); font-weight: 700; }
.sc-stats-pct.is-bad  { color: var(--fail); font-weight: 700; }

.sc-level-bar {
  display: flex; gap: 3px;
  height: 48px;
  flex-shrink: 0;
}
.lvl-col {
  display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-end;
  width: 18px;
  position: relative;
  border-bottom: 1px solid var(--border-soft);
}
.lvl-fill {
  background: var(--muted);
  border-radius: 2px 2px 0 0;
  transition: height .25s;
}
.lvl-good .lvl-fill { background: var(--ok); }
.lvl-mid  .lvl-fill { background: #e0a340; }
.lvl-bad  .lvl-fill { background: var(--fail); }
.lvl-empty .lvl-fill { background: var(--border-soft); }
.lvl-label {
  position: absolute;
  bottom: -14px; left: 0; right: 0;
  text-align: center;
  font-size: .65rem;
  color: var(--muted);
}
.sc-stats { padding-bottom: 22px; }

/* Слабые темы */
.sc-weak summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.sc-weak-list {
  list-style: none; padding: 6px 0 0 0; margin: 0;
  font-size: .88rem;
}
.sc-weak-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
}
.sc-weak-list li a {
  flex: 1 1 auto; color: inherit; text-decoration: none;
  display: flex; gap: 6px; align-items: baseline;
  min-width: 0;
}
.sc-weak-list li a:hover .w-name { text-decoration: underline; }
.sc-weak-list .w-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-weak-list .w-cat  { font-size: .8rem; }
.sc-weak-list .w-pct  { flex-shrink: 0; font-weight: 700; }
.sc-weak-list .w-pct.is-bad { color: var(--fail); }

/* Pulse-анимация при изменении морковок */
.sc-rating {
  display: inline-block;
  transition: transform .15s;
}
.sc-rating.pulse-up   { animation: carrotPulseUp   .45s ease-out; color: var(--ok); }
.sc-rating.pulse-down { animation: carrotPulseDown .45s ease-out; color: var(--fail); }
@keyframes carrotPulseUp {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  100% { transform: scale(1); color: inherit; }
}
@keyframes carrotPulseDown {
  0%   { transform: scale(1); }
  35%  { transform: scale(.75); }
  100% { transform: scale(1); color: inherit; }
}

/* Toast-host */
.toast-host {
  position: fixed;
  top: 72px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 10px 14px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .92rem;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .18s, transform .18s;
}
.toast.in { opacity: 1; transform: translateX(0); }
.toast--ok   { border-left-color: var(--ok); }
.toast--warn { border-left-color: #e0a340; }
.toast--err  { border-left-color: var(--fail); }
.toast .carrot { margin-right: 4px; }

/* Заявки в тренерской */
.trainer-requests {
  background: #fff7ea;
  border: 1px solid #f0d7a8;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.trainer-requests h2 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  font-weight: 700;
}
.req-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed #f0d7a8;
  flex-wrap: wrap;
}
.req-row:first-child { border-top: 0; }
.req-info { flex: 1 1 auto; min-width: 180px; }
.req-actions { display: flex; gap: 8px; }
.req-actions .btn { padding: 6px 12px; font-size: .9rem; }

/* Заявки в профиле ученика */
.trainers-pending { margin-top: 8px; }
.pending-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: #fff7ea;
  border: 1px dashed #f0d7a8;
  border-radius: var(--radius-sm);
  margin: 6px 0;
  font-size: .92rem;
}
.pending-row .btn { margin-left: auto; padding: 4px 10px; font-size: .85rem; }
.chip {
  display: inline-block;
  padding: 2px 10px;
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: 999px;
  font-weight: 600;
  font-size: .88rem;
  margin-right: 4px;
}

.whatif-popup .piece-glyph.piece-w { color: #555; text-shadow: 0 0 1px #000; }

/* ========== Post-game analysis panel ========== */
#analysis-panel {
  display: none;
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  max-height: 520px;
  overflow: hidden;
  display: none;
}
.apx-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #f5faf7;
  border-bottom: 1px solid var(--line);
  font-size: .95rem;
}
.apx-head b { color: var(--accent); }
.apx-progress {
  color: #666; font-size: .85rem; margin-left: 8px;
}
.apx-close {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: .95rem;
}
.apx-close:hover { background: #f0f0f0; }
.apx-body {
  max-height: 440px;
  overflow-y: auto;
  padding: 6px 10px;
}
.apx-row {
  display: grid;
  grid-template-columns: 48px 1fr 36px auto 60px 1fr;
  gap: 8px;
  align-items: center;
  padding: 5px 6px;
  border-bottom: 1px dashed #eee;
  font-size: .9rem;
}
.apx-ply { color: #999; font-variant-numeric: tabular-nums; }
.apx-san { font-weight: 600; font-family: var(--zc-ff-mono, monospace); }
.apx-tag { text-align: center; font-weight: 700; }
.apx-label { color: #666; font-size: .82rem; }
.apx-cp { text-align: right; font-variant-numeric: tabular-nums; color: #555; }
.apx-best { color: #888; font-size: .8rem; font-family: var(--zc-ff-mono, monospace); }

.apx-best        { }
.apx-row.apx-best        { background: #eefbf4; }
.apx-row.apx-excellent   { background: #f4fbf7; }
.apx-row.apx-good        { }
.apx-row.apx-inaccuracy  { background: #fff8e8; }
.apx-row.apx-inaccuracy .apx-tag { color: #c9881a; }
.apx-row.apx-mistake     { background: #fdecea; }
.apx-row.apx-mistake .apx-tag { color: #c0392b; }
.apx-row.apx-blunder     { background: #fcd7d3; }
.apx-row.apx-blunder .apx-tag { color: #a72836; font-size: 1.05rem; }

.apx-summary {
  margin-top: 6px;
  padding: 10px 14px;
  background: #f5faf7;
  border-top: 1px solid var(--line);
  font-size: .9rem;
  line-height: 1.55;
}
.apx-summary b { color: var(--accent); }

/* ========== Homework ========== */
.hw-badge {
  background: var(--accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  margin-left: 8px;
}
.hw-badge:hover { background: #07553c; }
.sc-hw { margin-top: 8px; }
.sc-hw-list { list-style: none; padding: 0; margin: 6px 0; }
.hw-row {
  display: grid;
  grid-template-columns: 1fr auto auto 24px;
  gap: 8px;
  padding: 4px 6px;
  border-bottom: 1px dashed #eee;
  font-size: .88rem;
  align-items: center;
}
.hw-row.hw-done { opacity: .6; }
.hw-row.hw-expired { opacity: .5; background: #fdecea; }
.hw-title { font-weight: 600; }
.hw-prog { font-variant-numeric: tabular-nums; color: #555; }
.hw-del {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 6px;
  cursor: pointer;
}
.sc-hw-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.sc-hw-form .sc-hw-sub { width: 100%; }
.sc-hw-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.sc-hw-form-row .sc-hw-target { flex: 0 0 64px; }
.sc-hw-form-row .sc-hw-days   { flex: 1 1 120px; min-width: 110px; }
.sc-hw-form-row .sc-hw-date   { flex: 1 1 140px; min-width: 130px; }
.sc-hw-form-row .sc-hw-add    { flex: 0 0 auto; margin-left: auto; }
.sc-hw-form input, .sc-hw-form select {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: .85rem;
  box-sizing: border-box;
}
.hw-page { max-width: 900px; margin: 0 auto; padding: 20px; }
.hw-list { display: grid; gap: 14px; margin-top: 18px; }
.hw-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.hw-card header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.hw-card header h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.hw-icon {
  display: inline-block;
  width: 28px; height: 28px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.hw-card.hw-done .hw-icon { background: #2e8b6a; }
.hw-card.hw-expired .hw-icon { background: #c0392b; }
.hw-progress { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin: 6px 0; }
.hw-bar {
  height: 10px;
  background: #f0f0f0;
  border-radius: 999px;
  overflow: hidden;
}
.hw-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}
.hw-card footer { margin: 6px 0 10px; font-size: .88rem; }

/* =============== История партий + разбор =============== */
.profile-history { grid-column: 1 / -1; }
.profile-history h2 { display: flex; align-items: center; gap: 12px; }
.btn-sm { padding: 4px 10px; font-size: .88rem; }
.history-list { display: flex; flex-direction: column; gap: 16px; margin-top: 10px; }
.history-day .history-date {
  font-weight: 700; color: var(--accent); margin-bottom: 6px; font-size: 1rem;
}
.history-items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center; gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.history-item .hi-side { font-size: 1.2rem; }
.history-item .hi-opp  { font-weight: 600; }
.history-item .hi-moves, .history-item .hi-time { font-size: .88rem; }
.rv-badge {
  padding: 2px 8px; border-radius: 6px; font-size: .82rem; font-weight: 700;
}
.rv-badge.rv-win  { background: #e3f4ea; color: #0b6e4f; }
.rv-badge.rv-loss { background: #fae2e2; color: #b14040; }
.rv-badge.rv-draw { background: #eee8d8; color: #6a5420; }
@media (max-width: 560px) {
  .history-item { grid-template-columns: auto 1fr auto; grid-auto-rows: auto; }
  .history-item .hi-moves, .history-item .hi-time { grid-column: span 2; }
}

.review-head {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px; font-size: 1rem;
}
.review-head .rv-result {
  font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: #f4ecd8; color: #6a5420;
}
.rv-session {
  padding: 6px 12px; border-radius: 8px;
  background: #e3f4ea; color: #0b6e4f; font-weight: 600;
}
.review-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px;
}
@media (max-width: 900px) { .review-grid { grid-template-columns: 1fr; } }
.rv-controls {
  display: flex; gap: 6px; margin-top: 12px; align-items: center; justify-content: center;
}
.rv-controls button {
  min-width: 44px; height: 36px;
  border: 1px solid var(--border-soft);
  background: #fff; border-radius: 8px;
  cursor: pointer; font-size: 1rem;
}
.rv-controls button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.rv-ply { font-weight: 700; min-width: 70px; text-align: center; }
.rv-slider { width: 100%; margin-top: 10px; accent-color: var(--accent); }
.rv-last { margin-top: 6px; text-align: center; font-size: .92rem; }

.review-side { display: flex; flex-direction: column; gap: 14px; }
.review-side .card {
  background: #fff; border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 14px;
}
.review-side h3 { margin: 0 0 8px; font-size: 1rem; color: var(--accent); }
.rv-invite-row { display: flex; gap: 6px; }
.rv-invite-row select {
  flex: 1 1 auto; padding: 6px 8px;
  border: 1px solid var(--border-soft); border-radius: 8px;
}
.rv-movelist {
  list-style: none; padding: 0; margin: 0;
  max-height: 280px; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px;
  font-size: .94rem;
}
.rv-movelist li { padding: 3px 6px; border-radius: 4px; cursor: pointer; }
.rv-movelist li:hover { background: #f4ecd8; }
.rv-movelist li.is-cur { background: var(--accent); color: #fff; }
.rv-movelist li.is-cur b { color: #fff; }
.rv-movelist .rv-mno { color: var(--muted); font-size: .85rem; }
.rv-pgn {
  width: 100%; min-height: 100px;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: .82rem;
  border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 8px; resize: vertical;
}

/* Review-badge в шапке + panel */
.review-badge {
  background: #fff0d8;
  border: 1px solid #e8b96a;
  color: #5a3a14;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .88rem;
  cursor: pointer;
  user-select: none;
}
.review-badge:hover { background: #ffe2b0; }
.review-panel {
  position: fixed; top: 60px; right: 16px; z-index: 9998;
  background: #fffaf1;
  border: 2px solid #e8b96a;
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 320px; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.review-panel .rp-head { font-weight: 800; margin-bottom: 8px; color: #5a3a14; }
.review-panel .rp-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 6px 0; border-bottom: 1px dashed #e8d8b4;
}
.review-panel .rp-row:last-of-type { border-bottom: none; }
.review-panel .rp-close {
  margin-top: 10px; width: 100%;
  padding: 6px; border: 1px solid var(--border-soft);
  background: #fff; border-radius: 8px; cursor: pointer;
}
.review-panel hr { border: none; border-top: 1px solid #e8d8b4; margin: 10px 0; }

/* ===== /openings — браузер 498 дебютов ===== */
.op-view {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) {
  .op-view { grid-template-columns: 1fr; }
}
.op-left {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-soft, #e2d8c0);
  border-radius: 10px;
  padding: 10px;
  position: sticky;
  top: 8px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.op-search-wrap { margin-bottom: 8px; }
#op-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-soft, #d5c99b);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}
.op-families {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.op-fam {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border-soft, #d5c99b);
  background: #faf7ee;
  color: #4a3e20;
  border-radius: 6px;
  cursor: pointer;
}
.op-fam.active {
  background: var(--accent, #5b6cff);
  color: #fff;
  border-color: var(--accent, #5b6cff);
}
.op-list {
  overflow-y: auto;
  flex: 1;
  min-height: 300px;
}
.op-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: inherit;
}
.op-item:hover { background: #f3ecd5; }
.op-item.active {
  background: var(--accent, #5b6cff);
  color: #fff;
}
.op-item__eco {
  font-family: 'JetBrains Mono', monospace, ui-monospace;
  font-weight: 700;
  min-width: 38px;
  font-size: 12px;
  opacity: 0.85;
}
.op-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.op-right {
  min-height: 400px;
}
.op-empty {
  padding: 40px 20px;
  text-align: center;
}
.op-detail {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-soft, #e2d8c0);
  border-radius: 10px;
  padding: 14px;
}
.op-detail__hd {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft, #e2d8c0);
}
.op-detail__title { flex: 1; min-width: 0; }
.op-detail__eco {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--accent, #5b6cff);
  font-size: 14px;
}
.op-detail__name {
  font-size: 18px;
  font-weight: 700;
  color: #2a2013;
}
.op-detail__name-en {
  font-size: 12px;
  color: #7a6a45;
  font-style: italic;
}
.op-nav {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-soft, #d5c99b);
  background: #faf7ee;
  cursor: pointer;
  font-size: 14px;
}
.op-nav:hover { background: var(--accent, #5b6cff); color: #fff; }

.op-detail__body {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 16px;
}
@media (max-width: 840px) {
  .op-detail__body { grid-template-columns: 1fr; }
}
.op-board-wrap { display: flex; flex-direction: column; gap: 8px; }
.op-board-wrap .board-wrap.op-board-frame {
  width: 100%;
  max-width: 420px;
  margin: 0;
}
.op-board-wrap .bw-inner #op-board,
.op-board-wrap .bw-inner #op-board.cg-wrap {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
@media (max-width: 600px) {
  /* chessground рисует координаты снаружи доски справа и снизу —
     оставляем им место, чтобы не резались на узком экране */
  .op-board-wrap { padding-right: 18px; }
  .op-detail { padding: 10px; }
  /* узкий экран — позволяем длинным описаниям переноситься */
  .op-desc .op-ex-k { min-width: 0; display: block; margin-bottom: 2px; }
  .op-desc .op-ex-v { display: block; overflow-wrap: anywhere; word-break: break-word; }
  .op-detail__name,
  .op-detail__name-en { overflow-wrap: anywhere; word-break: break-word; }
  .op-deep-v,
  .op-kv-nm,
  .op-kv-mv,
  .op-kv-id,
  .op-deep-mis-list li { overflow-wrap: anywhere; word-break: break-word; }
  .op-left { position: static; max-height: none; }
  .op-moves { overflow-wrap: anywhere; word-break: break-word; }
  .op-detail__hd { gap: 6px; }
  .op-nav { width: 28px; height: 28px; font-size: 12px; flex-shrink: 0; }
}
.op-board-ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.op-ply { font-size: 12px; color: #7a6a45; }
.op-moves {
  font-size: 13px;
  line-height: 1.6;
  color: #3a2e15;
  padding: 6px 8px;
  background: #faf7ee;
  border-radius: 6px;
  max-height: 140px;
  overflow-y: auto;
}
.mv-pair { margin-right: 8px; white-space: nowrap; }

.op-desc { display: flex; flex-direction: column; gap: 8px; }
.op-desc .op-ex-row {
  font-size: 13px;
  line-height: 1.5;
  padding: 4px 0;
  border-bottom: 1px dashed #ebdeba;
}
.op-desc .op-ex-k {
  font-weight: 600;
  color: #5a4a20;
  display: inline-block;
  min-width: 130px;
}
.op-desc .op-ex-v { color: #2a2013; }

/* --- партии мастеров --- */
.op-games { margin-top: 6px; }
.op-games__sum {
  cursor: pointer;
  font-weight: 700;
  color: #5a4a20;
  padding: 6px 0;
  border-top: 1px dashed #ebdeba;
}
.op-games__list { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.op-game-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #faf7ee;
  border: 1px solid #ebdeba;
  border-radius: 6px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: #2a2013;
  transition: background .15s;
}
.op-game-item:hover { background: #f4ecd0; border-color: #d7c48a; }
.op-game-item.active { background: #e8dba8; border-color: #a88d45; }
.op-game-players { display: flex; flex-direction: column; gap: 2px; }
.op-game-side { display: flex; gap: 6px; align-items: baseline; }
.op-game-nm { font-weight: 700; }
.op-game-rt { color: #7a6a45; font-size: 11px; }
.op-game-year { color: #7a6a45; font-size: 11px; white-space: nowrap; }
.op-game-res { font-weight: 700; color: #5a4a20; white-space: nowrap; }
.op-game-res.w { color: #0b6e4f; }
.op-game-res.b { color: #a72836; }
.op-game-res.d { color: #7a6a45; }

/* нав-кнопки по ходам */
.op-nav-btn { padding: 4px 8px !important; font-size: 14px; min-width: 32px; }

/* подсветка текущего хода в списке ходов */
.op-moves .mv-pair .mv-current { background: #f3e4a8; border-radius: 3px; padding: 0 2px; }

/* --- модалка key-variant preview (board_view) --- */
.kv-modal {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.kv-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 14, 8, .55);
  backdrop-filter: blur(2px);
}
.kv-modal__panel {
  position: relative; z-index: 1;
  background: #fff8e8;
  border: 1px solid #c8b170;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  max-width: 880px; width: min(92vw, 880px);
  max-height: 92vh; overflow: auto;
  padding: 12px 14px;
}
.kv-modal__hd {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; border-bottom: 1px solid #e5d4a1; padding-bottom: 8px; margin-bottom: 10px;
}
.kv-modal__title { font-weight: 700; color: #4a3a10; font-size: 1.05rem; }
.kv-modal__close {
  border: 0; background: #f0e3b6; color: #4a3a10;
  width: 32px; height: 32px; border-radius: 6px; font-size: 16px; cursor: pointer;
}
.kv-modal__close:hover { background: #e6d496; }
.kv-modal__body {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 720px) {
  .kv-modal__body { grid-template-columns: 1fr; }
}
.kv-frame { width: 100%; max-width: 420px; margin: 0; }
.kv-modal__body .bw-inner #kv-board,
.kv-modal__body .bw-inner #kv-board.cg-wrap { width: 100% !important; height: 100% !important; display: block; }
.kv-modal__side { display: flex; flex-direction: column; gap: 10px; }
.kv-modal__idea { font-size: 13px; color: #3a2e15; line-height: 1.45; }
.kv-modal__ctl { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kv-modal__moves {
  font-size: 13px; line-height: 1.6; color: #3a2e15;
  padding: 6px 8px; background: #faf7ee; border-radius: 6px;
  max-height: 220px; overflow-y: auto;
}
.kv-modal__moves .kv-m-ply { cursor: pointer; padding: 0 2px; border-radius: 3px; }
.kv-modal__moves .kv-m-ply:hover { background: #eadd9a; }
.kv-modal__moves .kv-m-ply.mv-current { background: #f3e4a8; font-weight: 700; }

/* Подпись стоимости подсказки «А что если?» */
.wi-cost { font-size: 11px; color: #a08040; margin-left: 4px; opacity: 0.9; }

/* ===== Сворачивалка «Описание режима» (единая для всех страниц) ===== */
.mode-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 6px 0;
}
.mode-head h1 { margin: 0 !important; }
.mode-intro__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #faf7ee;
  border: 1px solid var(--border-soft, #d5c99b);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  color: #4a3e20;
}
.mode-intro__btn:hover { background: #f3ecd5; }
.mode-intro__btn .mit-caret {
  transition: transform 0.15s ease;
  font-size: 10px;
}
.mode-intro__btn.is-collapsed .mit-caret { transform: rotate(-90deg); }
.mode-intro {
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.2s ease, opacity 0.15s ease, margin 0.2s ease;
  opacity: 1;
}
.mode-intro.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0 !important;
}

/* ===== /train board + eval (рядом и на мобилке) ===== */
.board-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  justify-content: center;
}
.board-row .board-wrap { flex: 0 1 auto; margin: 0; }
.board-row .eval-bar-wrap {
  flex: 0 0 auto;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-width: 34px;
}
.board-row .eval-bar-wrap .eval-bar {
  height: auto;
  flex: 1;
  min-height: 180px;
}
.board-row .eval-bar-wrap .eval-text {
  font-size: 0.72rem;
  max-width: 70px;
  word-break: break-word;
}
@media (max-width: 600px) {
  .board-row { gap: 4px; }
  .board-row .board-wrap { width: min(82vw, 520px); }
  .board-row .eval-bar-wrap { min-width: 22px; }
  .board-row .eval-bar-wrap .eval-bar { width: 16px; }
  .board-row .eval-bar-wrap .eval-text { font-size: 0.64rem; max-width: 56px; }
}

/* Турнир: без левой ECO-колонки */
.train-view--tournament {
  grid-template-columns: minmax(0, 600px) 220px;
}
@media (max-width: 1000px) {
  .train-view--tournament { grid-template-columns: 1fr; }
}

/* ===== /openings — список вариантов внутри ECO ===== */
.op-variants {
  margin-top: 8px;
  padding: 6px 8px;
  background: #faf7ee;
  border: 1px solid var(--border-soft, #d5c99b);
  border-radius: 6px;
}
.op-variants__sum {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #4a3e20;
  list-style: none;
  user-select: none;
}
.op-variants__sum::-webkit-details-marker { display: none; }
.op-variants__sum::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}
.op-variants[open] .op-variants__sum::before { transform: rotate(90deg); }
.op-variants__list {
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.op-v-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  color: #3a2e15;
}
.op-v-item:hover { background: #f3ecd5; }
.op-v-item.active {
  background: var(--accent, #5b6cff);
  color: #fff;
  border-color: var(--accent, #5b6cff);
}
.op-v-item.is-main .op-v-nm::after { content: ' ★'; color: #e6a800; }
.op-v-nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-v-ply { font-size: 11px; opacity: 0.75; flex-shrink: 0; }

/* Подробный разбор (deep) */
.op-deep { margin-top: 12px; border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; background: rgba(255,255,255,0.02); }
.op-deep__sum {
  list-style: none; cursor: pointer; user-select: none;
  padding: 10px 12px; font-weight: 600; color: var(--accent, #5b6cff);
  display: flex; align-items: center; gap: 8px;
}
.op-deep__sum::-webkit-details-marker { display: none; }
.op-deep__sum::before { content: '▸'; transition: transform 0.2s; font-size: 10px; opacity: 0.7; }
.op-deep[open] .op-deep__sum::before { transform: rotate(90deg); }
.op-deep__body { padding: 4px 12px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.op-deep-row { font-size: 13px; line-height: 1.5; }
.op-deep-k { font-weight: 600; opacity: 0.9; display: inline-block; margin-right: 4px; }
.op-deep-v { }
.op-deep-kv-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.op-kv-item {
  padding: 10px 12px;
  border: 1px solid rgba(91,108,255,0.2);
  border-left: 3px solid var(--accent, #5b6cff);
  background: rgba(91,108,255,0.06);
  border-radius: 6px;
  cursor: pointer; text-align: left; width: 100%;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.op-kv-item:hover { background: rgba(91,108,255,0.14); border-color: var(--accent, #5b6cff); }
.op-kv-nm { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.op-kv-mv { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; opacity: 0.95; margin-bottom: 6px; letter-spacing: 0.02em; line-height: 1.5; }
.op-kv-id { font-size: 12px; opacity: 0.85; line-height: 1.4; }
.op-kv-play { position: absolute; top: 8px; right: 10px; font-size: 11px; font-weight: 600; color: var(--accent, #5b6cff); opacity: 0.75; }
.op-kv-item:hover .op-kv-play { opacity: 1; }
.op-deep-mis-list { margin: 4px 0 0 20px; padding: 0; font-size: 13px; line-height: 1.5; }
.op-deep-mis-list li { margin-bottom: 4px; }
