/**
 * Diverge Chess Study · shared paper and forest design
 * Core board and review components; visual composition below
 */

body.diverge-ui {
  --bg-main: var(--dg-paper);
  --bg-card: var(--dg-surface);
  --bg-card-hover: var(--dg-green-soft);
  --border-color: var(--dg-line);
  --border-focus: var(--dg-green);
  --text-main: var(--dg-ink);
  --text-muted: var(--dg-muted);
  --text-dim: var(--dg-muted);
  --brand-green: var(--dg-green);
  --brand-gold: var(--dg-gold);
  --brand-red: var(--dg-red);
  --brand-blue: var(--dg-blue);
  --board-light: var(--dg-board-light);
  --board-dark: var(--dg-board-dark);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* Header Navbar */
.studio-navbar {
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 100;
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.studio-logo {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.studio-fork-icon {
  color: var(--brand-green, #07C160);
  display: block;
}

.studio-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(7, 193, 96, 0.15);
  color: var(--brand-green);
  border: 1px solid rgba(7, 193, 96, 0.3);
  font-weight: 600;
}

.studio-header-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-meta-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.game-meta-result {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--brand-gold);
}

.studio-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.engine-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6B7280;
}

.status-dot.ready { background: var(--brand-green); box-shadow: 0 0 8px rgba(7, 193, 96, 0.5); }
.status-dot.loading { background: var(--brand-gold); animation: pulse 1.2s infinite; }
.status-dot.error { background: var(--brand-red); }

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.btn-header {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #ffffff;
}

.btn-primary:hover {
  background: #06AD56;
}

/* Workspace Layout */
.studio-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(420px, 640px) 1fr;
  gap: 20px;
  padding: 20px 24px;
  max-width: 1680px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 980px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

/* Board Column */
.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.maia-board-wrapper {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1;
  background: #151515;
  border-radius: 12px;
  box-shadow: 0 20px 48px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  border: none;
}

.maia-chessboard {
  width: 100%;
  height: 100%;
  position: relative;
}

.maia-square {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.maia-square.light { background-color: var(--board-light); }
.maia-square.dark { background-color: var(--board-dark); }

.maia-square.selected {
  background-color: rgba(20, 85, 30, 0.5) !important;
}

.maia-square.light.last-move-from,
.maia-square.light.last-move-to {
  background-color: #cdd26a !important;
}
.maia-square.dark.last-move-from,
.maia-square.dark.last-move-to {
  background-color: #829769 !important;
}

.maia-square.check {
  background: radial-gradient(circle, rgba(250, 81, 81, 0.85) 0%, rgba(250, 81, 81, 0.35) 75%, transparent 100%) !important;
  animation: check-pulse 1.8s ease-in-out infinite;
}

@keyframes check-pulse {
  0% { filter: drop-shadow(0 0 2px rgba(250, 81, 81, 0.4)); }
  50% { filter: drop-shadow(0 0 8px rgba(250, 81, 81, 0.8)); }
  100% { filter: drop-shadow(0 0 2px rgba(250, 81, 81, 0.4)); }
}

.coord {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.75;
}

.coord-rank {
  top: 3px;
  left: 4px;
}

.coord-file {
  bottom: 2px;
  right: 4px;
}

.maia-square.light .coord { color: var(--board-dark); }
.maia-square.dark .coord { color: var(--board-light); }

.maia-piece {
  width: 90%;
  height: 90%;
  cursor: grab;
  position: relative;
  z-index: 10;
  transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
}

.maia-piece svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.maia-piece:hover {
  transform: scale(1.04);
}

.maia-piece:active {
  cursor: grabbing;
  transform: scale(1.12);
}

.legal-hint-dot {
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.legal-hint-ring {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.32);
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.maia-board-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.maia-board-svg-overlay line[stroke-dasharray] {
  animation: dash-flow 1.2s linear infinite;
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -20;
  }
}

/* Board Bottom Navigation Controls */
.board-controls {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.btn-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.btn-nav:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-nav.muted {
  opacity: 0.55;
}

.branch-banner {
  width: 100%;
  max-width: 600px;
  background: rgba(250, 157, 59, 0.12);
  border: 1px solid rgba(250, 157, 59, 0.35);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--brand-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Analysis Column (Right) */
.analysis-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Evaluation Trend Chart */
.eval-chart-wrapper {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.eval-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.eval-chart-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eval-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.eval-chart-badge {
  font-size: 11px;
  font-family: monospace;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.eval-chart-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.eval-chart-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot-cyan { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-blue); box-shadow: 0 0 5px rgba(0, 210, 255, 0.6); }
.dot-red { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-red); }
.dot-orange { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-gold); }
.dot-gold { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-gold); }

.eval-chart-body {
  width: 100%;
  height: 125px;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

.eval-chart-svg {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.eval-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  display: none;
  z-index: 10;
  backdrop-filter: blur(4px);
}

/* Divergence Insight Box */
.divergence-box {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.divergence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-gold);
  background: rgba(250, 157, 59, 0.12);
  padding: 3px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.divergence-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
}

/* Three-way Comparison Panel */
.compare-panel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.compare-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
  cursor: default;
  min-width: 0;
}

.compare-card:hover {
  background: var(--bg-card-hover);
}

.compare-card.card-engine {
  border-color: rgba(7, 193, 96, 0.25);
}

.compare-card.card-intuition {
  border-color: rgba(230, 165, 32, 0.25);
}

.compare-card.card-played {
  border-color: rgba(255, 255, 255, 0.12);
}

.compare-card.card-played.is-blunder {
  border-color: rgba(250, 81, 81, 0.35);
  background: rgba(250, 81, 81, 0.04);
}

.compare-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.compare-card-label .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-engine { background: var(--brand-green); }
.dot-intuition { background: #e6a520; }
.dot-played { background: var(--text-muted); }

.compare-card-san {
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-card-meta {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-match-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(7, 193, 96, 0.15);
  color: var(--brand-green);
  margin-left: 4px;
  vertical-align: middle;
}

/* Tabs: Blunder Leaderboard & Move Notation */
.panel-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--brand-green);
  border-bottom: 2px solid var(--brand-green);
  background: rgba(7, 193, 96, 0.05);
}

.tab-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0 0 10px 10px;
  flex: 1;
  max-height: 520px;
  overflow-y: auto;
  padding: 14px;
}

/* Blunder & Divergence Moments */
.divergence-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.filter-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.18);
}

.filter-pill.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.filter-pill.pill-beyond.active {
  background: rgba(0, 210, 255, 0.15);
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.filter-pill.pill-trap.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--brand-gold);
  color: var(--brand-gold);
}

.filter-pill.pill-style.active {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.blunder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.blunder-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.blunder-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.16);
}

.blunder-card.active {
  border-color: rgba(230, 165, 32, 0.6);
  background: rgba(230, 165, 32, 0.08);
}

/* Beyond Intuition Card Variation */
.blunder-card.card-beyond-intuition {
  border-color: rgba(0, 210, 255, 0.25);
  background: rgba(0, 210, 255, 0.03);
}

.blunder-card.card-beyond-intuition:hover {
  background: rgba(0, 210, 255, 0.06);
  border-color: rgba(0, 210, 255, 0.45);
}

.blunder-card.card-beyond-intuition.active {
  border-color: var(--brand-blue);
  background: rgba(0, 210, 255, 0.12);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.18);
}

/* Intuition Trap Card Variation */
.blunder-card.card-intuition-trap {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.03);
}

.blunder-card.card-intuition-trap:hover {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.45);
}

.blunder-card.card-intuition-trap.active {
  border-color: var(--brand-gold);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.18);
}

/* Style Divergence Card Variation */
.blunder-card.card-style-divergence {
  border-color: rgba(167, 139, 250, 0.25);
  background: rgba(167, 139, 250, 0.03);
}

.blunder-card.card-style-divergence:hover {
  background: rgba(167, 139, 250, 0.06);
  border-color: rgba(167, 139, 250, 0.45);
}

.blunder-card.card-style-divergence.active {
  border-color: var(--brand-blue);
  background: rgba(167, 139, 250, 0.12);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.18);
}

/* Review Metrics Summary Banner (Engine Accuracy) */
.review-metrics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.metric-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-side-label {
  display: flex;
  align-items: center;
}

.side-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.side-badge.side-white {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.side-badge.side-black {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
}

.metric-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.metric-title {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}

.metric-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--brand-green);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
}

.blunder-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.blunder-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.blunder-card-title {
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.blunder-move-num {
  color: var(--text-muted);
  font-weight: 600;
}

.blunder-side-icon {
  font-size: 11px;
}

.blunder-san {
  color: var(--text-main);
}

.blunder-tags-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.blunder-type-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.tag-beyond {
  background: rgba(0, 210, 255, 0.16);
  color: var(--brand-blue);
  border: 1px solid rgba(0, 210, 255, 0.35);
}

.tag-trap {
  background: rgba(245, 158, 11, 0.16);
  color: var(--brand-gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.tag-blunder {
  background: rgba(239, 68, 68, 0.18);
  color: var(--brand-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.tag-mistake {
  background: rgba(245, 158, 11, 0.18);
  color: var(--brand-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.tag-inaccuracy {
  background: rgba(245, 158, 11, 0.12);
  color: var(--brand-gold);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.tag-style {
  background: rgba(167, 139, 250, 0.18);
  color: var(--brand-blue);
  border: 1px solid rgba(167, 139, 250, 0.35);
}

.blunder-loss-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-red);
  white-space: nowrap;
  margin-left: auto;
  background: rgba(239, 68, 68, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
}

.blunder-loss-tag.tag-gain {
  color: var(--brand-blue);
  background: rgba(0, 210, 255, 0.1);
}

.blunder-loss-tag.tag-style-loss {
  color: var(--brand-blue);
  background: rgba(167, 139, 250, 0.1);
}

.blunder-card-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.sub-best-move strong {
  color: var(--brand-green);
  font-weight: 700;
}

.sub-trap-prob {
  color: #fbbf24;
  font-size: 11px;
}

/* Move Notation Table */
.move-notation-table {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.notation-row {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
}

.notation-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.notation-num {
  width: 38px;
  color: var(--text-dim);
  font-size: 12px;
}

.notation-move {
  flex: 1;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notation-move:hover {
  background: rgba(255, 255, 255, 0.08);
}

.notation-move.active {
  background: rgba(7, 193, 96, 0.2);
  color: var(--brand-green);
  font-weight: 700;
}

.annotation-badge {
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
}
.annotation-blunder { color: var(--brand-red); }
.annotation-mistake { color: var(--brand-gold); }
.annotation-beyond { color: var(--brand-blue); }
.annotation-trap { color: var(--brand-gold); }

/* PGN Import Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 520px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.pgn-textarea {
  width: 100%;
  height: 180px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Global Drag & Drop Overlay */
.drag-drop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: all 0.2s ease;
}

.drag-drop-card {
  border: 2px dashed var(--brand-green);
  background: rgba(7, 193, 96, 0.08);
  border-radius: 16px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: pulse-drop 1.5s infinite alternate ease-in-out;
}

@keyframes pulse-drop {
  from { transform: scale(0.98); }
  to { transform: scale(1.02); }
}

/* Floating Toast Notification */
.studio-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.studio-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Blank Home State Hero Landing Card */
.studio-home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 20px;
  background: rgba(18, 24, 38, 0.6);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  gap: 18px;
  margin: 12px 0;
  transition: all 0.2s ease;
}

.studio-home-hero:hover {
  border-color: rgba(7, 193, 96, 0.35);
  background: rgba(18, 24, 38, 0.85);
}

.home-hero-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.home-hero-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(7, 193, 96, 0.12);
  border: 1px solid rgba(7, 193, 96, 0.25);
  color: var(--brand-green);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.home-hero-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
}

.home-hero-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 420px;
  line-height: 1.5;
}

.home-hero-actions {
  width: 100%;
  max-width: 320px;
}

.btn-home-primary {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand-green);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(7, 193, 96, 0.3);
  transition: all 0.15s ease;
}

.btn-home-primary:hover {
  background: #06ae56;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(7, 193, 96, 0.4);
}

.btn-home-primary:active {
  transform: translateY(0);
}

.home-hero-samples {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.home-samples-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.home-samples-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn-sample-chip {
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sample-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-1px);
}

.home-hero-tips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  width: 100%;
}

/* Mobile & PWA Responsive Optimization */
@media (max-width: 768px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .studio-navbar {
    height: auto;
    min-height: 56px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .studio-header-center {
    order: 3;
    width: 100%;
    justify-content: center;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }

  .studio-header-actions {
    margin-left: auto;
    gap: 6px;
  }

  .engine-status-pill {
    padding: 3px 6px;
    font-size: 11px;
  }

  .studio-layout {
    padding: 10px 12px;
    gap: 14px;
  }

  .board-controls {
    width: 100%;
    justify-content: space-between;
  }

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

  .compare-panel {
    gap: 6px;
  }

  .compare-card {
    padding: 8px 6px;
  }

  .compare-card-san {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .studio-title {
    font-size: 13px;
  }

  .studio-badge {
    display: none;
  }

  #elo-selector {
    max-width: 85px;
  }

  .engine-status-pill span:not(.status-dot) {
    display: none;
  }

  .btn-sample-chip {
    width: 100%;
  }
}



/* Chess Study composition: board → alternatives → key moves. */
body{font-size:14px;user-select:auto}
.studio-navbar{height:auto;min-height:74px;gap:20px;padding:18px 30px;background:var(--bg-card)}
.studio-logo{width:34px;height:34px;background:var(--brand-green);border-radius:9px}.studio-fork-icon{color:var(--dg-on-green)}
.studio-title{font-size:16px;letter-spacing:-.3px;gap:10px}.studio-badge{background:var(--dg-green-soft);border:0;border-radius:5px;font-size:10px;padding:4px 7px}
.game-meta-badge{font-size:12px;font-weight:500;flex-wrap:wrap;justify-content:center}.game-meta-result{background:var(--dg-gold-soft);font:12px var(--dg-mono);padding:4px 7px}
.studio-header-actions{gap:8px}.btn-header{background:var(--dg-raised);height:36px;border-radius:7px;padding:0 13px}.btn-header:hover{background:var(--dg-green-soft);border-color:var(--border-color)}.btn-primary,.btn-home-primary{background:var(--brand-green);color:var(--dg-on-green);border-color:var(--brand-green)}.btn-primary:hover,.btn-home-primary:hover{background:var(--brand-green);filter:brightness(.95)}.btn-theme{font-size:11px;color:var(--text-muted)}
.studio-layout{grid-template-columns:minmax(330px,1.25fr) minmax(270px,.9fr) minmax(265px,.82fr);gap:24px;padding:28px 30px;max-width:1560px;align-items:start}
.board-column{gap:13px;min-width:0;align-items:stretch}.workspace-section-heading{display:flex;justify-content:space-between;align-items:center;gap:10px;font-size:12px;font-weight:650;min-height:22px;margin-bottom:3px}.workspace-section-heading small{font-size:10px;color:var(--text-muted);font-weight:400}
.maia-board-wrapper{max-width:none;border-radius:5px;background:var(--dg-board-light);box-shadow:0 5px 20px #243a3212}.coord{color:#284634!important;font-size:10px}
.board-controls{max-width:none;border:0;border-bottom:1px solid var(--border-color);border-radius:0;box-shadow:none;background:transparent;padding:0 0 12px;gap:10px;flex-wrap:wrap}.btn-nav-group{gap:5px}.btn-nav{border:0;width:32px;height:32px;background:transparent;border-radius:6px;font-size:13px}.btn-nav:hover{background:var(--dg-green-soft);transform:none}.branch-banner{max-width:none;background:var(--dg-gold-soft);border:0}.eval-chart-wrapper{padding:15px 0;border:0;border-radius:0;box-shadow:none;background:transparent;width:100%}.eval-chart-header{gap:8px;flex-wrap:wrap}.eval-chart-legend{font-size:10px;gap:8px}.eval-chart-body{height:105px}.eval-chart-tooltip{background:var(--dg-raised);color:var(--text-main);border-color:var(--border-color);box-shadow:var(--dg-shadow);max-width:90%;white-space:normal}.eval-chart-badge{background:var(--dg-green-soft);font-family:var(--dg-mono)}.dot-cyan{box-shadow:none}.status-dot.ready{box-shadow:none}
.analysis-column{gap:18px}.studio-insight-heading{padding:1px 0 3px}.studio-eyebrow{font-size:9px;letter-spacing:1.8px;color:var(--text-muted);display:block;margin-bottom:12px}.studio-insight-heading h1{font:27px/1.5 Georgia,"Songti SC",serif;letter-spacing:-.5px}.studio-insight-heading p{font-size:12px;line-height:1.9;color:var(--text-muted);margin-top:10px}
.divergence-box{border:0;border-radius:0;padding:0;background:transparent;box-shadow:none;gap:15px}.divergence-badge{background:var(--dg-gold-soft);color:var(--brand-gold);font-size:11px;padding:5px 9px}.compare-panel{grid-template-columns:1fr;gap:10px;margin-top:0}.compare-card{background:var(--dg-raised);padding:15px 16px;gap:7px;border:1px solid var(--border-color)!important;position:relative}.compare-card.card-engine{border-left:3px solid var(--brand-blue)!important}.compare-card.card-intuition{border-left:3px solid var(--brand-gold)!important}.compare-card.card-played{border-left:3px solid var(--text-muted)!important}.compare-card.card-played.is-blunder{background:var(--dg-red-soft)}.compare-card-label{color:var(--text-muted);font-weight:500;letter-spacing:0;font-size:11px}.compare-card-san{font:25px/1.4 var(--dg-mono);color:var(--text-main)}.compare-card-meta{white-space:normal;font-size:11px;line-height:1.8}.dot-engine{background:var(--brand-blue)}.dot-intuition{background:var(--brand-gold)}.divergence-content{padding:15px;background:var(--dg-gold-soft);border-radius:8px;font-size:12px;line-height:1.9;overflow-wrap:anywhere}.compare-match-badge{background:var(--dg-green-soft)}
.studio-engine-tools{border-top:1px solid var(--border-color);padding-top:14px;font-size:11px;color:var(--text-muted)}.studio-engine-tools summary{cursor:pointer;margin-bottom:10px}.studio-engine-tools>div{margin:8px 0}.engine-status-pill{padding:4px 0;background:transparent;border:0;border-radius:0;font-size:10px}.studio-engine-tools .btn-header{height:30px;font-size:11px}
.review-column{display:flex;flex-direction:column;gap:16px;min-width:0}.review-column>.workspace-section-heading{margin-bottom:0}.review-metrics-card{display:grid;grid-template-columns:1fr 1fr;gap:12px;padding:18px;border-radius:9px;box-shadow:none;background:var(--dg-surface)}.metric-player-row{flex-direction:column;align-items:flex-start;gap:11px}.metric-divider{display:none}.metric-group{display:flex;flex-direction:column;gap:7px}.metric-value{font:27px var(--dg-mono);color:var(--text-main)}.side-badge.side-white,.side-badge.side-black{background:var(--dg-paper);border:1px solid var(--border-color);color:var(--text-main);font-size:10px;padding:3px 6px}
.panel-tabs{border-radius:9px 9px 0 0;background:var(--dg-surface)}.tab-btn{font-size:12px;padding:13px 8px;font-weight:500}.tab-btn.active{background:var(--dg-green-soft)}.tab-content{padding:12px;max-height:550px;background:var(--dg-surface)}.divergence-filters{gap:5px;flex-wrap:wrap;overflow:visible}.filter-pill{font-size:10px;padding:5px 8px;border-radius:5px;background:transparent}.filter-pill.active{background:var(--brand-green);color:var(--dg-on-green);border-color:var(--brand-green)}.filter-pill.pill-beyond.active{background:var(--dg-blue-soft);color:var(--brand-blue);border-color:var(--brand-blue)}.filter-pill.pill-trap.active{background:var(--dg-gold-soft);color:var(--brand-gold);border-color:var(--brand-gold)}
.blunder-card{background:var(--dg-raised);padding:12px;border-color:var(--border-color)}.blunder-card:hover{border-color:var(--brand-green)}.blunder-card-title{font-size:12px;flex-wrap:wrap}.blunder-card-top{flex-wrap:wrap;gap:6px}.blunder-card.card-beyond-intuition,.blunder-card.card-beyond-intuition:hover{background:var(--dg-blue-soft);border-color:var(--border-color)}.blunder-card.card-beyond-intuition.active{background:var(--dg-blue-soft);border-color:var(--brand-blue);box-shadow:none}.blunder-card.card-intuition-trap,.blunder-card.card-intuition-trap:hover{background:var(--dg-gold-soft);border-color:var(--border-color)}.blunder-card.card-intuition-trap.active{background:var(--dg-gold-soft);border-color:var(--brand-gold);box-shadow:none}.tag-beyond,.blunder-loss-tag.tag-gain{background:var(--dg-blue-soft);color:var(--brand-blue);border-color:var(--brand-blue)}.tag-trap,.tag-mistake,.tag-inaccuracy{background:var(--dg-gold-soft);color:var(--brand-gold);border-color:var(--brand-gold)}.tag-blunder,.blunder-loss-tag{background:var(--dg-red-soft);color:var(--brand-red);border-color:var(--brand-red)}.notation-row:hover,.notation-move:hover{background:var(--dg-green-soft)}.notation-move.active{background:var(--brand-green);color:var(--dg-on-green)}.notation-move{font:12px var(--dg-mono)}
.modal-card{padding:27px;max-width:560px;gap:14px;box-shadow:var(--dg-shadow);max-height:calc(100dvh - 40px);overflow:auto}.modal-title{font:26px Georgia,"Songti SC",serif}.modal-description{font-size:12px;color:var(--text-muted);line-height:1.8}.pgn-textarea{background:var(--dg-paper);padding:14px;border-radius:8px;line-height:1.8}.modal-card .studio-eyebrow{margin-bottom:0}.drag-drop-card{background:var(--dg-surface);box-shadow:var(--dg-shadow)}.studio-toast{background:var(--dg-ink);color:var(--dg-surface);border:0;box-shadow:var(--dg-shadow);max-width:90vw;font-size:12px}
.studio-home-hero{padding:22px 12px;background:var(--dg-paper);border:0;gap:18px;margin:0}.studio-home-hero:hover{background:var(--dg-paper)}.home-hero-icon{background:var(--dg-green-soft);border:0}.home-hero-title{font:21px/1.55 Georgia,"Songti SC",serif;color:var(--text-main)}.home-hero-subtitle{color:var(--text-muted);font-size:11px;line-height:1.9}.btn-home-primary{padding:12px 9px;font-size:11px}.btn-sample-chip{background:var(--dg-surface);border-color:var(--border-color);color:var(--text-main);font-size:10px;white-space:normal}.home-tip-item{font-size:10px;color:var(--text-muted)}
@media(max-width:1180px){.studio-navbar{flex-wrap:wrap;padding:16px 24px;gap:12px}.studio-header-center{order:3;flex-basis:100%;justify-content:center}.studio-layout{grid-template-columns:minmax(320px,1.15fr) minmax(285px,1fr);gap:25px;padding:24px}.review-column{grid-column:1/-1}.review-column .tab-content{max-height:370px}.review-column .review-metrics-card{max-width:400px}.blunder-list{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.review-metrics-card .metric-player-row{flex-direction:row;align-items:center}}
@media(max-width:720px){.studio-navbar{padding:14px 16px}.studio-title{font-size:14px}.studio-badge{display:none}.studio-brand{gap:8px}.studio-header-actions{gap:5px}.btn-header{font-size:11px;padding:0 9px;height:33px}.studio-layout{display:flex;flex-direction:column;padding:19px 16px;gap:25px}.board-column,.analysis-column,.review-column{width:100%}.workspace-section-heading small{font-size:9px}.compare-panel{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.compare-card{padding:10px 8px}.compare-card-label{font-size:10px;gap:4px}.compare-card-san{font-size:19px}.compare-card-meta{font-size:10px}.compare-card-label .dot{width:5px;height:5px}.studio-insight-heading h1{font-size:24px}.blunder-list{display:flex;flex-direction:column}.review-column .review-metrics-card{max-width:none}.modal-card{padding:20px;width:calc(100% - 28px)}.modal-card>div[style]{flex-wrap:wrap;gap:12px}.home-hero-title{font-size:23px}.home-hero-subtitle{max-width:320px}.btn-home-primary{font-size:12px}}
.modal-overlay{visibility:hidden}.modal-overlay.open{visibility:visible}.btn-header:disabled{opacity:.45;cursor:not-allowed}.btn-header:disabled:hover{background:var(--dg-raised);filter:none}.btn-primary:disabled:hover{background:var(--brand-green)}
