﻿/* ============================================================
   CHESS TRAINER PRO v4 â€” Design System
   ============================================================ */

/* --- Design Tokens --- */
:root {
  --ct-primary: #0ea5e9;
  --ct-primary-dark: #0284c7;
  --ct-primary-light: #38bdf8;
  --ct-accent: #8b5cf6;
  --ct-bg-main: #f8fafc;
  --ct-bg-card: #ffffff;
  --ct-border: rgba(226, 232, 240, 0.8);
  --ct-text-main: #0f172a;
  --ct-text-muted: #64748b;
  --ct-text-light: #94a3b8;
  --ct-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --ct-shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.06);
  --ct-shadow-lg: 0 16px 40px -8px rgba(15, 23, 42, 0.1);
  --ct-radius: 14px;
  --ct-radius-sm: 8px;
  --ct-glass-bg: rgba(255, 255, 255, 0.85);
  --ct-glass-blur: blur(12px);
  --ct-success: #22c55e;
  --ct-error: #ef4444;
  --ct-warning: #f59e0b;
}

.dark {
  --ct-primary: #38bdf8;
  --ct-primary-dark: #0ea5e9;
  --ct-bg-main: #0b0f19;
  --ct-bg-card: #111827;
  --ct-border: rgba(51, 65, 85, 0.8);
  --ct-text-main: #f1f5f9;
  --ct-text-muted: #94a3b8;
  --ct-text-light: #64748b;
  --ct-glass-bg: rgba(17, 24, 39, 0.85);
  --ct-shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.25);
  --ct-shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.35);
}

/* --- Reset --- */
.ct-wrapper,
.ct-wrapper *,
.ct-wrapper *::before,
.ct-wrapper *::after {
  box-sizing: border-box;
}

/* chessboard.js needs content-box */
.ct-wrapper #chess-board,
.ct-wrapper #chess-board * {
  box-sizing: content-box;
}

.hidden { display: none !important; }

/* --- Base Wrapper --- */
.ct-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 500px;
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  width: 100%;
  margin: 1rem 0;
  padding-bottom: 0.75rem;
  border-radius: var(--ct-radius);
  border: 1px solid var(--ct-border);
  box-shadow: var(--ct-shadow-lg);
  position: relative;
  overflow: visible;
  transition: all 0.3s ease;
}

/* Fullscreen */
.ct-wrapper.fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding-bottom: 0 !important;
  z-index: 99999;
  border-radius: 0;
  max-height: none !important;
  overflow: hidden;
}
.ct-wrapper.fullscreen .ct-main-layout {
  flex: 1;
}

.ct-wrapper-locked {
  overflow: hidden;
  min-height: 620px;
}

.ct-access-preview {
  position: relative;
  min-height: inherit;
}

.ct-access-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.14) 0%, rgba(248, 250, 252, 0.42) 100%);
  pointer-events: none;
}

.dark .ct-access-preview::after {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.18) 0%, rgba(2, 6, 23, 0.42) 100%);
}

.ct-wrapper-locked .ct-access-preview {
  filter: blur(10px) saturate(0.88);
  transform: scale(1.015);
  transform-origin: center top;
}

.ct-access-main {
  display: grid !important;
  grid-template-columns: minmax(180px, 0.9fr) minmax(0, 1.2fr) minmax(180px, 0.8fr);
  min-height: 520px;
}

.ct-access-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--ct-bg-card);
}

.ct-access-panel-left {
  border-right: 1px solid var(--ct-border);
}

.ct-access-panel-right {
  border-left: 1px solid var(--ct-border);
}

.ct-access-panel-head {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ct-text-light);
}

.ct-access-line,
.ct-access-card {
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(226, 232, 240, 0.72) 100%);
  border: 1px solid rgba(203, 213, 225, 0.82);
}

.dark .ct-access-line,
.dark .ct-access-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.88) 0%, rgba(15, 23, 42, 0.78) 100%);
  border-color: rgba(51, 65, 85, 0.82);
}

.ct-access-line {
  height: 54px;
}

.ct-access-line-short {
  width: 72%;
}

.ct-access-card {
  min-height: 92px;
}

.ct-access-card-tall {
  min-height: 184px;
}

.ct-access-board-area {
  justify-content: center;
}

.ct-access-board {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: var(--ct-shadow-md);
  background-color: #f0d9b5;
  background-image:
    linear-gradient(45deg, #b58863 25%, transparent 25%),
    linear-gradient(-45deg, #b58863 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #b58863 75%),
    linear-gradient(-45deg, transparent 75%, #b58863 75%);
  background-size: 25% 25%;
  background-position: 0 0, 0 12.5%, 12.5% -12.5%, -12.5% 0;
}

.ct-access-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.24) 0%, rgba(226, 232, 240, 0.48) 100%);
  z-index: 15;
}

.dark .ct-access-overlay {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.3) 0%, rgba(2, 6, 23, 0.58) 100%);
}

.ct-access-dialog {
  width: min(520px, 100%);
  padding: 1.4rem 1.35rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 28px 80px -36px rgba(15, 23, 42, 0.52);
  text-align: center;
}

.dark .ct-access-dialog {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: 0 28px 80px -34px rgba(2, 6, 23, 0.78);
}

.ct-access-dialog-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.7rem;
  border-radius: 16px;
  background: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.12);
  color: var(--ct-primary);
  font-size: 28px !important;
}

.ct-access-kicker {
  margin-bottom: 0.35rem;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ct-primary-dark);
}

.dark .ct-access-kicker {
  color: var(--ct-primary);
}

.ct-access-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  color: var(--ct-text-main);
}

.ct-access-message {
  margin: 0.85rem auto 0;
  max-width: 38ch;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ct-text-muted);
}

.ct-access-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 1rem;
  padding: 0.72rem 1.05rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
}

.ct-access-btn-primary {
  background: var(--ct-primary);
  color: #fff;
}

.ct-access-btn-primary:hover {
  background: var(--ct-primary-dark);
  color: #fff;
}

@media (max-width: 1023px) {
  .ct-wrapper-locked {
    min-height: 540px;
  }

  .ct-access-main {
    display: flex !important;
    flex-direction: column;
    min-height: 440px;
  }

  .ct-access-panel-left,
  .ct-access-panel-right {
    display: none;
  }

  .ct-access-dialog {
    padding: 1.2rem 1rem;
  }

  .ct-access-title {
    font-size: 24px;
  }
}

/* Ghost piece above everything */
.piece-417db {
  z-index: 100001 !important;
}

/* ============================================================
   HEADER
   ============================================================ */
.ct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.45rem 0.9rem;
  background: var(--ct-glass-bg);
  backdrop-filter: var(--ct-glass-blur);
  -webkit-backdrop-filter: var(--ct-glass-blur);
  border-bottom: 1px solid var(--ct-border);
  min-height: 56px;
  flex-shrink: 0;
  z-index: 10;
}

.ct-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
}

.ct-header-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #e2e8f0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.12) 0%, transparent 34%), linear-gradient(180deg, #334155 0%, #0f172a 100%);
  border: 1px solid rgba(71, 85, 105, 0.9);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 24px -20px rgba(15, 23, 42, 0.95);
  flex-shrink: 0;
}

.dark .ct-header-icon {
  color: #f8fafc;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 34%), linear-gradient(180deg, #334155 0%, #020617 100%);
  border-color: rgba(100, 116, 139, 0.72);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.08), 0 14px 24px -18px rgba(2, 6, 23, 0.9);
}

.ct-header-text {
  min-width: 0;
  overflow: hidden;
}

.ct-pgn-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ct-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ct-pgn-players {
  font-size: 11px;
  color: var(--ct-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ct-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
}

.ct-header-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  padding: 0.2rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.dark .ct-header-right {
  background: rgba(11, 15, 25, 0.55);
  border-color: rgba(51, 65, 85, 0.8);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.08);
}

/* --- Phase Tabs --- */
.ct-phase-tabs {
  display: flex;
  gap: 2px;
  background: var(--ct-bg-main);
  padding: 3px;
  border-radius: var(--ct-radius-sm);
  border: 1px solid var(--ct-border);
}

.ct-phase-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--ct-text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}

.ct-phase-tab .material-symbols-outlined {
  font-size: 16px;
}

.ct-phase-tab:hover {
  color: var(--ct-text-main) !important;
  background: var(--ct-bg-card) !important;
}

.ct-phase-tab-active,
.ct-phase-tab.ct-phase-tab-active {
  background: var(--ct-primary) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.ct-due-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--ct-error);
  color: #fff;
  padding: 0 5px;
  border-radius: 8px;
  line-height: 1.6;
  min-width: 16px;
  text-align: center;
}

/* Mobile: hide labels */
.ct-phase-label { display: none; }

@media (min-width: 768px) {
  .ct-phase-label { display: inline; }
}

/* --- Icon Buttons (header) --- */
.ct-icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  border: 1px solid var(--ct-border);
  background: var(--ct-bg-card);
  color: var(--ct-text-muted);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ct-icon-btn .material-symbols-outlined {
  font-size: 20px;
}

.ct-icon-btn:hover {
  background: var(--ct-primary) !important;
  color: #fff !important;
  border-color: var(--ct-primary) !important;
}

.ct-icon-btn:hover .material-symbols-outlined {
  color: #fff !important;
}

/* Dark mode toggle icon swap */
.dark-show { display: none; }
.dark .dark-show { display: inline-flex; }
.dark .dark-hide { display: none; }

#theme-toggle-btn {
  padding: 0.55rem;
}

/* ============================================================
   STATS STRIP
   ============================================================ */
.ct-stats-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background: var(--ct-bg-card);
  border-bottom: 1px solid var(--ct-border);
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.ct-stats-strip::-webkit-scrollbar {
  display: none;
}

.ct-stats-strip-mobile {
  display: flex;
}

.ct-line-stats-panel-desktop,
.ct-sidebar-summary {
  display: none;
}

.ct-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  border: 1px solid rgba(var(--ct-primary-rgb, 14, 165, 233), 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.92) 100%);
  font-size: 12px;
  flex: 0 0 auto;
  min-width: 88px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 24px -22px rgba(15, 23, 42, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ct-stat-label {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ct-primary-dark);
  background: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.08);
}

.ct-stat-val {
  font-weight: 800;
  color: var(--ct-text-main);
  letter-spacing: -0.03em;
}

.ct-stat-pill-new {
  border-color: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.18);
}

.ct-stat-pill-new .ct-stat-val,
.ct-stat-pill-learning .ct-stat-val,
.ct-stat-pill-mastered .ct-stat-val {
  color: var(--ct-text-main);
}

.ct-stat-pill-learning {
  border-color: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.18);
}

.ct-stat-pill-mastered {
  border-color: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.18);
}

.dark .ct-stat-pill {
  border-color: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.24);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96) 0%, rgba(15, 23, 42, 0.96) 100%);
  box-shadow: 0 16px 28px -24px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(148, 163, 184, 0.05);
}

.dark .ct-stat-label {
  color: var(--ct-primary);
  background: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.14);
}

.ct-sidebar-summary {
  border-bottom: 1px solid var(--ct-border);
  background: linear-gradient(180deg, rgba(226, 232, 240, 0.78) 0%, rgba(248, 250, 252, 0.98) 100%);
}

.dark .ct-sidebar-summary {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96) 0%, rgba(11, 15, 25, 1) 100%);
}

.ct-sidebar-summary-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 0.9rem 0.4rem;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ct-text-muted);
}

.ct-sidebar-summary-head .material-symbols-outlined {
  font-size: 18px;
  color: var(--ct-primary);
}

.dark .ct-sidebar-summary-head .material-symbols-outlined {
  color: var(--ct-primary);
}

.ct-line-stats-panel-desktop {
  gap: 0.5rem;
  padding: 0 0.9rem 0.9rem;
}

.ct-line-stats-panel-desktop .ct-stat-pill {
  align-items: flex-start;
  justify-content: space-between;
  flex-direction: column;
  min-height: 60px;
  width: 100%;
  padding: 0.8rem 0.8rem 0.75rem;
}

.ct-line-stats-panel-desktop .ct-stat-label {
  font-size: 11px;
  letter-spacing: 0.02em;
}

.ct-line-stats-panel-desktop .ct-stat-val {
  font-size: 20px;
  line-height: 1;
}

/* ============================================================
   SETTINGS OVERLAY
   ============================================================ */
.ct-settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.ct-settings-overlay.hidden { display: none !important; }

.ct-settings-card {
  background: var(--ct-bg-card);
  border-radius: var(--ct-radius);
  box-shadow: var(--ct-shadow-lg);
  width: 90%;
  max-width: 380px;
  overflow: hidden;
  animation: ctSlideDown 0.25s ease;
}

@keyframes ctSlideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ct-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ct-border);
}

.ct-settings-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.ct-settings-body {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ct-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 0;
  font-size: 13px;
  color: var(--ct-text-main);
  cursor: pointer;
}

.ct-setting-row span:first-child {
  flex: 1;
  padding-right: 0.5rem;
}

/* Toggle switch */
.ct-toggle {
  appearance: none;
  width: 40px;
  height: 22px;
  background: var(--ct-border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.ct-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ct-toggle:checked {
  background: var(--ct-primary);
}

.ct-toggle:checked::after {
  transform: translateX(18px);
}

/* Mini select */
.ct-mini-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--ct-border);
  border-radius: 6px;
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.ct-mini-select:focus {
  outline: none;
  border-color: var(--ct-primary);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.ct-toast-area {
  position: absolute;
  top: 60px;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.ct-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--ct-radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #1e293b;
  box-shadow: var(--ct-shadow-md);
  animation: ctToastIn 0.3s ease, ctToastOut 0.3s ease 2.7s forwards;
  max-width: 320px;
}

.ct-toast .material-symbols-outlined {
  font-size: 18px;
}

.ct-toast-success { background: #16a34a; }
.ct-toast-error   { background: #dc2626; }
.ct-toast-info    { background: #0284c7; }

@keyframes ctToastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes ctToastOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ============================================================
   MAIN LAYOUT â€” Mobile-first
   ============================================================ */
.ct-main-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  padding-bottom: 0.5rem;
}

/* --- Sidebars (hidden on mobile by default) --- */
.ct-sidebar {
  display: none;
  flex-direction: column;
  background: var(--ct-bg-card);
  overflow: hidden;
}

.ct-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ct-sidebar-toggle {
  display: none;
}

.ct-sidebar-divider {
  height: 1px;
  background: var(--ct-border);
  flex-shrink: 0;
}

.ct-desktop-only { display: none; }
.ct-resize-handle { display: none; }

/* ============================================================
   LEFT SIDEBAR â€” TOC + Moves
   ============================================================ */
.ct-toc-panel {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ct-toc-header,
.ct-moves-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ct-text-light);
  flex-shrink: 0;
  border-bottom: 1px solid var(--ct-border);
}

.ct-toc-header .material-symbols-outlined,
.ct-moves-header .material-symbols-outlined {
  font-size: 16px;
}

.ct-toc-list {
  overflow-y: auto;
  padding: 0.25rem;
  flex: 1;
}

.ct-toc-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--ct-text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.ct-toc-item:hover {
  background: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.12) !important;
  color: var(--ct-primary) !important;
}

.ct-toc-item-active {
  background: var(--ct-primary) !important;
  color: #fff !important;
}

.ct-toc-item .material-symbols-outlined {
  font-size: 16px;
  flex-shrink: 0;
}

.ct-toc-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--ct-text-light);
  background: var(--ct-bg-main);
  padding: 0 6px;
  border-radius: 8px;
}

.ct-toc-item-active .ct-toc-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ============================================================
   UNIFIED LINE TREE
   ============================================================ */
.ct-line-tree {
  overflow-y: auto;
  flex: 1;
  padding: 0.4rem 0.35rem 0.65rem;
}

/* Group (one per Event / section) */
.ct-tree-group {
  margin-bottom: 6px;
}

.ct-tree-group-header {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.62rem;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ct-text-muted);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: rgba(148, 163, 184, 0.08);
  width: 100%;
  text-align: left;
  box-shadow: none;
}

.ct-tree-group-header:hover {
  background: rgba(148, 163, 184, 0.15) !important;
  color: var(--ct-text-main) !important;
}

.ct-tree-chevron {
  font-size: 16px !important;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.ct-tree-collapsed .ct-tree-chevron {
  transform: rotate(-90deg);
}

.ct-tree-group-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ct-tree-group-count {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--ct-text-light);
  background: rgba(148, 163, 184, 0.14);
  padding: 0 6px;
  border-radius: 8px;
}

/* Group body: lines sub-list */
.ct-tree-group-body {
  padding-left: 10px;
  overflow: hidden;
  max-height: 9999px;
  transition: max-height 0.25s ease;
}

.ct-tree-collapsed .ct-tree-group-body {
  max-height: 0;
}

/* Individual line button */
.ct-tree-line-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.42rem 0.58rem;
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ct-text-muted);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: rgba(15, 23, 42, 0.02);
  width: 100%;
  text-align: left;
  box-shadow: none;
}

.ct-tree-line-item:hover {
  background: rgba(148, 163, 184, 0.15) !important;
  color: var(--ct-text-main) !important;
}

.ct-tree-line-active {
  background: rgba(203, 213, 225, 0.72) !important;
  color: var(--ct-text-main) !important;
  font-weight: 700;
  border: 1px solid rgba(148, 163, 184, 0.34);
}

.ct-tree-line-active .ct-tree-line-icon,
.ct-tree-line-active .ct-tree-line-label,
.ct-tree-line-active .ct-tree-line-num {
  color: inherit !important;
}

.ct-tree-line-active .ct-tree-group-count,
.ct-tree-line-active .ct-tree-line-count,
.ct-tree-group-header:hover .ct-tree-group-count,
.ct-tree-line-item:hover .ct-tree-group-count {
  color: inherit;
}

.ct-tree-line-icon {
  font-size: 11px;
  flex-shrink: 0;
  min-width: 14px;
  text-align: center;
}

.ct-tree-line-num {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--ct-text-light);
  min-width: 26px;
  text-align: right;
}

.ct-tree-line-active .ct-tree-line-num {
  color: var(--ct-text-muted);
}

.ct-tree-line-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dark .ct-tree-group-header {
  background: rgba(51, 65, 85, 0.32);
}

.dark .ct-tree-group-header:hover {
  background: rgba(71, 85, 105, 0.44) !important;
  color: var(--ct-text-main) !important;
}

.dark .ct-tree-group-count {
  background: rgba(71, 85, 105, 0.48);
  color: #cbd5e1;
}

.dark .ct-tree-line-item {
  background: rgba(30, 41, 59, 0.34);
  color: #cbd5e1;
}

.dark .ct-tree-line-item:hover {
  background: rgba(71, 85, 105, 0.48) !important;
  color: #f8fafc !important;
}

.dark .ct-tree-line-active {
  background: rgba(71, 85, 105, 0.74) !important;
  border-color: rgba(148, 163, 184, 0.24);
  color: #f8fafc !important;
}

/* When there's only one group, the body has no padding */
.ct-tree-group:only-child > .ct-tree-group-body {
  padding-left: 0;
}

/* High-specificity overrides — neutralise theme button coloring */
body .ct-wrapper .ct-tree-group-header {
  background: rgba(148, 163, 184, 0.08) !important;
  color: var(--ct-text-muted) !important;
  border: none !important;
  box-shadow: none !important;
}
body .ct-wrapper .ct-tree-group-header:hover {
  background: rgba(148, 163, 184, 0.18) !important;
  color: var(--ct-text-main) !important;
}
body .ct-wrapper .ct-tree-line-item {
  background: rgba(15, 23, 42, 0.02) !important;
  color: var(--ct-text-muted) !important;
  border: none !important;
  box-shadow: none !important;
}
body .ct-wrapper .ct-tree-line-item:hover {
  background: rgba(148, 163, 184, 0.15) !important;
  color: var(--ct-text-main) !important;
}
body .ct-wrapper .ct-tree-line-active {
  background: rgba(203, 213, 225, 0.72) !important;
  color: var(--ct-text-main) !important;
  border: 1px solid rgba(148, 163, 184, 0.34) !important;
}
.dark body .ct-wrapper .ct-tree-line-item,
body .dark .ct-wrapper .ct-tree-line-item {
  background: rgba(30, 41, 59, 0.34) !important;
  color: #cbd5e1 !important;
}
.dark body .ct-wrapper .ct-tree-line-item:hover,
body .dark .ct-wrapper .ct-tree-line-item:hover {
  background: rgba(71, 85, 105, 0.48) !important;
  color: #f8fafc !important;
}
.dark body .ct-wrapper .ct-tree-line-active,
body .dark .ct-wrapper .ct-tree-line-active {
  background: rgba(71, 85, 105, 0.74) !important;
  color: #f8fafc !important;
}

/* Timer Row — always visible, content fades */
.ct-timer-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  margin-top: 2px;
  background: var(--ct-bg-card);
  border: 1px solid var(--ct-border);
  border-radius: 6px;
  width: 100%;
  min-height: 34px;
  transition: opacity 0.2s;
}

.ct-timer-row.ct-timer-idle {
  opacity: 0.3;
}

.ct-timer-row.ct-timer-idle .ct-timer-fill {
  width: 100% !important;
  background: var(--ct-border);
}

.ct-timer-pause-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ct-border);
  background: var(--ct-bg-main);
  color: var(--ct-text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.ct-timer-pause-btn:hover {
  background: rgba(14,165,233,0.12) !important;
  color: var(--ct-primary) !important;
  border-color: var(--ct-primary) !important;
}

.ct-timer-pause-btn .material-symbols-outlined {
  font-size: 16px !important;
}

.ct-timer-icon {
  font-size: 16px !important;
  color: var(--ct-primary);
  flex-shrink: 0;
}

.ct-timer-display {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
  color: var(--ct-text-main);
}

.ct-timer-track {
  flex: 1;
  height: 5px;
  background: var(--ct-border);
  border-radius: 99px;
  overflow: hidden;
}

.ct-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--ct-primary);
  border-radius: 99px;
  transition: width 0.1s linear;
}

.ct-timer-fill.ct-timer-warning { background: var(--ct-warning); }
.ct-timer-fill.ct-timer-danger  { background: var(--ct-error); }

/* --- Moves --- */
.ct-moves-wrapper {
  flex: 1 1 0;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ct-moves-wrapper.hidden {
  display: none;
}

.ct-moves-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.95rem 1.15rem 1.15rem;
  -webkit-overflow-scrolling: touch;
}

.ct-moves-list {
  line-height: 2.15;
  font-size: 15px;
}

.move-row {
  display: inline;
  margin-right: 0.25rem;
}

.move-num {
  display: inline-block;
  min-width: 1.45rem;
  font-size: 13px;
  font-weight: 700;
  color: var(--ct-text-light);
  margin-right: 0.2rem;
}

.move-item {
  display: inline-block;
  padding: 4px 7px;
  margin: 2px 3px 2px 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--ct-text-main);
  background: transparent;
  border: none;
}

.move-item:hover {
  background: var(--ct-primary);
  color: #fff;
}

.move-item.past {
  color: var(--ct-text-main);
  background: rgba(0, 0, 0, 0.03);
}

.move-item.active {
  background: var(--ct-primary);
  color: #fff;
  font-weight: 700;
  padding: 4px 7px;
  font-size: 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.move-item.future-hidden {
  color: var(--ct-text-light);
  opacity: 0.35;
  cursor: default;
}

.move-item.future-hidden:hover {
  background: transparent;
  color: var(--ct-text-light);
  transform: none;
}

.move-block-comment {
  display: block;
  background: var(--ct-bg-main);
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 12px;
  font-style: italic;
  border-radius: 6px;
  color: var(--ct-text-main);
  line-height: 1.5;
  border: 1px solid var(--ct-border);
}

.move-variant-block {
  display: block;
  font-size: 0.9em;
  color: var(--ct-text-muted);
  background: rgba(0, 0, 0, 0.02);
  padding: 6px 10px;
  border-radius: 6px;
  margin: 4px 0 4px 0.5rem;
  line-height: 1.6;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.variant-move {
  display: inline-block;
  font-weight: 600;
  color: var(--ct-text-main);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  transition: all 0.15s;
}

.variant-move:hover {
  background: #64748b;
  color: #fff;
}

.variant-bracket { display: none; }

.nag {
  font-size: 0.75em;
  font-weight: 900;
  color: #f59e0b;
  margin-left: 2px;
  vertical-align: super;
}

.ct-inline-comment {
  display: block;
  width: 100%;
  padding: 5px 10px;
  margin: 3px 0 6px;
  background: var(--ct-bg-card);
  border-left: 3px solid var(--ct-primary);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  font-style: italic;
  color: var(--ct-text-main);
  line-height: 1.4;
  word-break: break-word;
}

.ct-initial-comment {
  margin-top: 0;
  margin-bottom: 10px;
  border-left-color: var(--ct-text-muted);
  background: var(--ct-bg-main);
}

/* ============================================================
   RIGHT SIDEBAR â€” Line Selector + Comment + Actions
   ============================================================ */
.ct-line-selector-wrap {
  padding: 0.5rem;
  flex-shrink: 0;
}

.ct-line-select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--ct-border);
  border-radius: 6px;
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ct-line-select:focus {
  outline: none;
  border-color: var(--ct-primary);
}

.ct-autoplay-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.ct-sidebar-footer {
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(248, 250, 252, 0.92) 18%, rgba(248, 250, 252, 1) 100%);
  flex-shrink: 0;
}

/* Comment Panel */
.ct-comment-panel {
  margin: 0.55rem 0.65rem 0.35rem;
  padding: 0.72rem 0.8rem 0.78rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(241, 245, 249, 0.98) 100%);
  border-radius: 14px;
  border: 1px solid rgba(203, 213, 225, 0.78);
  flex-shrink: 0;
  max-height: 146px;
  overflow-y: auto;
  box-shadow: 0 14px 32px -28px rgba(15, 23, 42, 0.38);
}

.ct-comment-eyebrow {
  margin-bottom: 0.42rem;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ct-text-light);
}

.ct-comment-content {
  font-size: 13px;
  line-height: 1.58;
  color: var(--ct-text-main);
}

.dark .ct-comment-panel {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-color: rgba(51, 65, 85, 0.84);
  box-shadow: 0 18px 34px -28px rgba(2, 6, 23, 0.82);
}

.dark .ct-comment-content {
  color: #e2e8f0;
}

/* Action Buttons */
.ct-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem 0;
  flex-shrink: 0;
}

.ct-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--ct-border);
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ct-action-btn .material-symbols-outlined {
  font-size: 18px;
}

.ct-action-btn:hover {
  background: var(--ct-primary) !important;
  color: #fff !important;
  border-color: var(--ct-primary) !important;
}

/* ============================================================
   CENTER â€” Board Area
   ============================================================ */
.ct-board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  background: var(--ct-bg-main);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.ct-board-container {
  width: 100%;
  max-width: min(calc(100vw - 1rem), calc(100vh - 340px), 440px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Section indicator */
.ct-section-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  margin-bottom: 0.35rem;
  background: var(--ct-bg-card);
  border: 1px solid var(--ct-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ct-text-main);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.ct-section-indicator .material-symbols-outlined {
  font-size: 16px;
  color: var(--ct-primary);
  flex-shrink: 0;
}

.ct-section-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.ct-line-counter {
  font-size: 11px;
  color: var(--ct-text-light);
  font-weight: 700;
  flex-shrink: 0;
  margin-left: auto;
}

/* Board */
.ct-board,
#chess-board {
  width: 100% !important;
  aspect-ratio: 1 / 1;
  border-radius: var(--ct-radius-sm);
  overflow: visible !important;
  box-shadow: var(--ct-shadow-md);
}

#chess-board img { cursor: grab; }
#chess-board img:active { cursor: grabbing; }

.highlight-square {
  box-shadow: inset 0 0 0 4px var(--ct-primary) !important;
  background-color: rgba(14, 165, 233, 0.15) !important;
}

/* Progress Strip — thinner, green accent to distinguish from timer */
.ct-progress-strip {
  width: 100%;
  padding: 0.25rem 0 0;
}

.ct-progress-track {
  width: 100%;
  height: 3px;
  background: var(--ct-border);
  border-radius: 99px;
  overflow: hidden;
}

.ct-progress-fill {
  height: 100%;
  background: var(--ct-success);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 99px;
}

/* Nav Controls under board */
.ct-board-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0;
  width: 100%;
}

.ct-nav-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ct-border);
  background: var(--ct-bg-card);
  color: var(--ct-text-muted);
  border-radius: var(--ct-radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.ct-nav-btn .material-symbols-outlined {
  font-size: 22px;
}

.ct-nav-btn:hover {
  background: rgba(14, 165, 233, 0.12) !important;
  color: var(--ct-primary) !important;
  border-color: var(--ct-primary) !important;
}

.ct-nav-btn:active {
  transform: scale(0.95);
}

.ct-nav-btn-accent {
  background: var(--ct-primary);
  color: #fff;
  border-color: var(--ct-primary);
}

.ct-nav-btn-success {
  background: var(--ct-success);
  color: #fff;
  border-color: var(--ct-success);
}

.ct-nav-btn-accent:hover {
  background: var(--ct-primary-dark) !important;
  color: #fff !important;
  border-color: var(--ct-primary-dark) !important;
}

.ct-nav-btn-success:hover {
  background: #16a34a !important;
  color: #fff !important;
  border-color: #16a34a !important;
}

/* Status Message */
.ct-status-msg {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.ct-status-msg.ct-info {
  background: #e0f2fe;
  color: #075985;
}

.ct-status-msg.ct-success {
  background: #dcfce7;
  color: #166534;
}

.ct-status-msg.ct-error {
  background: #fee2e2;
  color: #991b1b;
}

/* ============================================================
   MOBILE BOTTOM PANEL
   ============================================================ */
.ct-mobile-bottom {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 1) 100%);
  border-top: 1px solid var(--ct-border);
  max-height: min(30vh, 196px);
  min-height: 104px;
  overflow: hidden;
}

.dark .ct-mobile-bottom {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98) 0%, rgba(11, 15, 25, 1) 100%);
}

.ct-mobile-moves-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.7rem 0.65rem;
  -webkit-overflow-scrolling: touch;
}

.ct-mobile-moves-area .ct-moves-list {
  font-size: 14px;
  line-height: 1.95;
}

.ct-mobile-moves-area .move-item,
.ct-mobile-moves-area .move-item.active {
  padding: 3px 6px;
  margin: 1px 2px 1px 0;
  font-size: 14px;
}

.ct-mobile-moves-area .move-num {
  min-width: 1.2rem;
  font-size: 12px;
  margin-right: 0.15rem;
}

.ct-mobile-comment {
  padding: 0.5rem 0.75rem;
  font-size: 12px;
  font-style: italic;
  color: var(--ct-text-main);
  border-top: 1px solid var(--ct-border);
  background: var(--ct-bg-main);
  max-height: 78px;
  overflow-y: auto;
}

.ct-mobile-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0.3rem 0.65rem;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-top: 1px solid rgba(226, 232, 240, 0.72);
}

.ct-mobile-status.ct-success { background: #dcfce7; color: #166534; }
.ct-mobile-status.ct-error   { background: #fee2e2; color: #991b1b; }

@media (max-width: 767px) {
  .ct-wrapper {
    margin: 0.75rem 0;
    border-radius: 12px;
  }

  .ct-board-area {
    padding: 0.35rem 0.35rem 0.2rem;
  }

  .ct-board-container {
    max-width: min(calc(100vw - 1rem), 440px);
  }

  .ct-board-nav {
    gap: 0.3rem;
    padding: 0.3rem 0 0.1rem;
  }

  .ct-nav-btn {
    width: 40px;
    height: 40px;
  }

  .ct-nav-btn .material-symbols-outlined {
    font-size: 20px;
  }

  .ct-status-msg {
    min-height: 24px;
    padding: 0.2rem 0.45rem;
    font-size: 12px;
  }

  .ct-mobile-bottom {
    max-height: min(28vh, 172px);
  }

  .ct-wrapper.ct-phase-practice .ct-mobile-bottom {
    max-height: min(24vh, 148px);
  }

  .ct-wrapper.ct-phase-practice .ct-mobile-moves-area {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }
}

/* ============================================================
   COMPLETION MODAL
   ============================================================ */
.ct-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  animation: ctFadeIn 0.25s ease;
}

@keyframes ctFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ct-modal {
  background: var(--ct-bg-card);
  border-radius: var(--ct-radius);
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: ctScaleIn 0.25s ease;
}

@keyframes ctScaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.ct-modal-icon { font-size: 56px; margin-bottom: 0.75rem; }
.ct-modal-title { font-size: 22px; font-weight: 700; margin-bottom: 0.4rem; color: var(--ct-text-main); }
.ct-modal-message { font-size: 14px; color: var(--ct-text-muted); margin-bottom: 1.25rem; }
.ct-modal-message strong { font-size: 1.4em; display: block; color: var(--ct-primary); margin-bottom: 0.25rem; }

.ct-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.ct-modal-btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ct-modal-btn-primary {
  background: var(--ct-primary);
  color: #fff;
}

.ct-modal-btn-primary:hover {
  background: var(--ct-primary-dark);
  transform: translateY(-1px);
}

.ct-modal-btn-secondary {
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  border: 1px solid var(--ct-border);
}

.ct-modal-btn-secondary:hover {
  background: var(--ct-bg-card);
}

/* Line phase badges */
.ct-line-phase-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.phase-new,
.phase-learning,
.phase-practicing,
.phase-review {
  background: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.10);
  color: var(--ct-primary-dark);
  border: 1px solid rgba(var(--ct-primary-rgb, 14, 165, 233), 0.18);
}

.dark .phase-new,
.dark .phase-learning,
.dark .phase-practicing,
.dark .phase-review {
  background: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.14);
  color: var(--ct-primary);
  border-color: rgba(var(--ct-primary-rgb, 14, 165, 233), 0.24);
}

/* ============================================================
   TABLET (>= 768px)
   ============================================================ */
@media (min-width: 768px) {
  .ct-board-container {
    max-width: min(520px, calc(100vh - 280px));
  }

  .ct-header {
    padding: 0.45rem 1.1rem;
  }

  .ct-header-left {
    flex: 0 1 auto;
  }
}

/* ============================================================
   DESKTOP (>= 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  .ct-desktop-only { display: inline-flex !important; }

  .ct-wrapper {
    --ct-left-col: 280px;
    --ct-right-col: 360px;
    --ct-board-max: min(620px, calc(100vh - 280px));
  }

  /* Hide mobile-only elements */
  .ct-mobile-bottom { display: none !important; }

  /* 4-column grid: capítulos | tablero | handle | notación
     El handle (8px) es arrastrable para redistribuir el ancho entre tablero y notación. */
  .ct-main-layout {
    display: grid !important;
    grid-template-columns: var(--ct-left-col) minmax(320px, 1fr) 8px minmax(0, var(--ct-right-col));
    grid-template-areas: "left center handle right";
    flex: 1;
    min-height: 0;
    overflow: visible;
    transition: none;
  }

  .ct-sidebar-left  { grid-area: left; }
  .ct-board-area    { grid-area: center; }
  .ct-resize-handle { grid-area: handle; }
  .ct-sidebar-right { grid-area: right; }

  /* Resize handle */
  .ct-resize-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    background: var(--ct-border);
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    position: relative;
    z-index: 10;
  }
  .ct-resize-handle:hover,
  .ct-resize-handle.ct-resizing {
    opacity: 1;
    background: var(--ct-primary);
  }
  .ct-resize-grip {
    display: block;
    width: 2px;
    height: 40px;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.5;
    pointer-events: none;
  }

  .ct-sidebar {
    display: flex !important;
  }

  .ct-sidebar-left {
    position: relative;
    border-right: 1px solid var(--ct-border);
    overflow: visible;
  }

  .ct-sidebar-right {
    border-left: 1px solid var(--ct-border);
    min-width: 0;
    overflow: hidden;
  }

  .ct-sidebar-left .ct-sidebar-inner {
    transition: opacity 0.22s ease, transform 0.22s ease;
  }

  .ct-sidebar-toggle {
    position: absolute;
    top: 16px;
    right: -17px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(51, 65, 85, 0.78);
    border-radius: 14px;
    background: linear-gradient(180deg, #334155 0%, #0f172a 100%);
    color: #e2e8f0;
    box-shadow: 0 16px 28px -18px rgba(15, 23, 42, 0.82), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s ease;
  }

  .ct-sidebar-toggle .material-symbols-outlined {
    font-size: 20px;
    color: currentColor !important;
  }

  .ct-sidebar-toggle:hover {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%) !important;
    color: #fff !important;
    border-color: rgba(96, 165, 250, 0.92) !important;
    transform: translateY(-1px);
  }

  /* Board sizing â€” leave room for timer row (~40px), nav (~52px), progress (~12px), status (~32px) */
  .ct-board-area {
    padding: 0.8rem 1.15rem;
    align-items: center;
    justify-content: flex-start;
    overflow: visible;
  }

  .ct-stats-strip-mobile {
    display: none !important;
  }

  .ct-sidebar-summary {
    display: block;
  }

  .ct-line-stats-panel-desktop {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ct-board-container {
    max-width: var(--ct-board-max);
  }

  .ct-board, #chess-board {
    max-width: var(--ct-board-max);
  }

  .ct-wrapper.ct-left-collapsed {
    --ct-left-col: 54px;
    --ct-right-col: 360px;
    --ct-board-max: min(700px, calc(100vh - 240px));
  }

  .ct-wrapper.ct-left-collapsed .ct-sidebar-left .ct-sidebar-inner {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-12px);
  }

  .ct-wrapper.ct-left-collapsed .ct-sidebar-left {
    background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
    border-right-color: rgba(51, 65, 85, 0.82);
    box-shadow: inset -1px 0 0 rgba(148, 163, 184, 0.05);
  }

  .ct-wrapper.ct-left-collapsed .ct-sidebar-toggle {
    background: linear-gradient(180deg, #475569 0%, #111827 100%) !important;
    border-color: rgba(100, 116, 139, 0.88);
    color: #f8fafc;
  }

  /* Wrapper constraints */
  .ct-wrapper {
    /* No max-height: let content determine natural height */
  }

  .ct-wrapper.fullscreen {
    max-height: none;
  }
}

/* ============================================================
   WIDE DESKTOP (>= 1280px)
   ============================================================ */
@media (min-width: 1280px) {
  .ct-wrapper {
    --ct-left-col: 320px;
    --ct-right-col: 360px;
    --ct-board-max: min(660px, calc(100vh - 260px));
  }

  .ct-wrapper.ct-left-collapsed {
    --ct-left-col: 60px;
    --ct-right-col: 360px;
    --ct-board-max: min(760px, calc(100vh - 220px));
  }
}

/* ============================================================
   MATERIAL ICONS ALIGNMENT FIX
   ============================================================ */
.ct-wrapper .material-symbols-outlined {
  font-family: "Material Symbols Outlined" !important;
  font-style: normal;
  font-display: block;
  user-select: none;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  vertical-align: middle !important;
  line-height: 1 !important;
}

/* ============================================================
   WORDPRESS / HELLO ELEMENTOR THEME ISOLATION
   Neutralise inherited theme styles without overriding our own
   component classes. Each button type (.ct-nav-btn, .ct-icon-btn,
   .ct-phase-tab, .ct-action-btn, etc.) carries its own complete
   visual definition already.
   ============================================================ */
body .ct-wrapper :where(button, select, input) {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: inherit;
  line-height: inherit;
  box-sizing: border-box;
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
  background: transparent;
  color: inherit;
  border: none;
}

body .ct-wrapper :where(button, select, input):focus-visible {
  outline: 2px solid var(--ct-primary);
  outline-offset: 2px;
}

/* ============================================================
   INTERACTIVE CONTROL HARDENING
   Scoped selectors beat theme defaults without relying on a
   destructive global reset.
   ============================================================ */
.ct-wrapper .ct-phase-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius-sm);
  background: var(--ct-bg-main);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.ct-wrapper .ct-phase-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.45rem 0.85rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ct-text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.ct-wrapper .ct-phase-tab:hover {
  background: var(--ct-bg-card) !important;
  color: var(--ct-text-main) !important;
}

.ct-wrapper .ct-phase-tab-active,
.ct-wrapper .ct-phase-tab.ct-phase-tab-active {
  background: var(--ct-primary) !important;
  color: #fff !important;
  box-shadow: 0 8px 16px -10px rgba(14, 165, 233, 0.9), 0 2px 8px rgba(14, 165, 233, 0.3);
}

.ct-wrapper .ct-icon-btn,
.ct-wrapper .ct-nav-btn,
.ct-wrapper .ct-timer-pause-btn,
.ct-wrapper .ct-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius-sm);
  background: var(--ct-bg-card);
  color: var(--ct-text-muted);
  cursor: pointer;
  box-shadow: var(--ct-shadow-sm);
}

.ct-wrapper .ct-icon-btn {
  width: 40px;
  height: 40px;
  padding: 0.55rem;
}

.ct-wrapper .ct-nav-btn {
  width: 46px;
  height: 46px;
}

.ct-wrapper .ct-timer-pause-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--ct-bg-main);
}

.ct-wrapper .ct-sidebar-toggle {
  appearance: none;
  border-radius: 14px;
  border-color: rgba(51, 65, 85, 0.78);
  background: linear-gradient(180deg, #334155 0%, #0f172a 100%) !important;
  color: #e2e8f0;
  box-shadow: 0 16px 28px -18px rgba(15, 23, 42, 0.82), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ct-wrapper .ct-sidebar-toggle .material-symbols-outlined {
  font-size: 20px;
  color: currentColor !important;
}

.ct-wrapper.ct-left-collapsed .ct-sidebar-toggle {
  background: linear-gradient(180deg, #475569 0%, #111827 100%) !important;
  border-color: rgba(100, 116, 139, 0.88);
  color: #f8fafc;
}

.ct-wrapper .ct-icon-btn:hover,
.ct-wrapper .ct-nav-btn:hover,
.ct-wrapper .ct-timer-pause-btn:hover,
.ct-wrapper .ct-sidebar-toggle:hover {
  border-color: var(--ct-primary) !important;
  color: var(--ct-primary) !important;
}

.ct-wrapper .ct-icon-btn:hover {
  background: var(--ct-primary) !important;
  color: #fff !important;
}

.ct-wrapper .ct-icon-btn:hover .material-symbols-outlined {
  color: #fff !important;
}

.ct-wrapper .ct-nav-btn:hover,
.ct-wrapper .ct-timer-pause-btn:hover,
.ct-wrapper .ct-sidebar-toggle:hover {
  background: rgba(14, 165, 233, 0.12) !important;
}

.ct-wrapper .ct-sidebar-toggle:hover {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #fff !important;
}

.ct-wrapper .ct-sidebar-toggle:hover .material-symbols-outlined {
  color: #fff !important;
}

.ct-wrapper .ct-nav-btn-accent {
  background: var(--ct-primary);
  color: #fff;
  border-color: var(--ct-primary);
}

.ct-wrapper .ct-nav-btn-success {
  background: var(--ct-success);
  color: #fff;
  border-color: var(--ct-success);
}

.ct-wrapper .ct-nav-btn-accent:hover {
  background: var(--ct-primary-dark) !important;
  color: #fff !important;
  border-color: var(--ct-primary-dark) !important;
}

.ct-wrapper .ct-nav-btn-success:hover {
  background: #16a34a !important;
  color: #fff !important;
  border-color: #16a34a !important;
}

.ct-wrapper .ct-action-btn,
.ct-wrapper .ct-modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 42px;
  padding: 0.7rem 0.95rem;
  border-radius: 8px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
}

.ct-wrapper .ct-action-btn {
  width: 100%;
  border: 1px solid var(--ct-border);
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  box-shadow: var(--ct-shadow-sm);
}

.ct-wrapper .ct-action-btn:hover {
  background: var(--ct-primary) !important;
  color: #fff !important;
  border-color: var(--ct-primary) !important;
}

.ct-wrapper .ct-mini-select,
.ct-wrapper .ct-line-select {
  min-height: 38px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--ct-border);
  border-radius: 8px;
  background: var(--ct-bg-main);
  color: var(--ct-text-main);
  line-height: 1.2;
}

.ct-wrapper .ct-toggle {
  appearance: none;
}
