/* Chess AI Next Move Calculator - Authentic Chessigma Design System */
@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=Spline+Sans+Mono:wght@400;500;600;700&family=Syne:wght@700;800&display=swap');

:root, [data-cs-theme="dark"] {
  --csGround: #0d0d0d;
  --csPanel: #171717;
  --csChrome: #171717;
  --csPanelHi: #242424;
  --csLine: #262626;
  --csFace: #242424;
  --csFaceHi: #2e2e2e;
  --csEdge: #333333;
  --csEdgeHi: #434343;
  --csSole: #080808;
  --csSocket: #101010;
  --csSocketEdge: #222222;
  --csWell: #131313;
  --csWellEdge: #1a1a1a;
  --csWellDeep: #0a0a0a;
  --csScrim: rgba(0, 0, 0, 0.72);

  --csInk: #ffffff;
  --csInkBody: #d4d4d4;
  --csInkMeta: #a3a3a3;
  --csInkDim: #8f8f8f;

  /* Signature Chessigma Amber */
  --csAmber: #fbbf24;
  --csAmberHi: #fcd34d;
  --csAmberFaceHi: #e8b022;
  --csAmberDeep: #f59e0b;
  --csAmberSole: #8a5a06;
  --csAmberLine: #6b4c07;
  --csAmberWell: #1a1408;
  --csAmberInk: #17110a;
  --csAmberText: #fbbf24;

  --csDanger: #f26969;
  --csDangerLine: #5a2222;
  --csDangerSole: #5c1616;
  --csSuccess: #10b981;
  --csSuccessLine: #1c4b3a;

  /* Authentic Chessigma Board Colors */
  --board-light: #dee3ea;
  --board-dark: #3c465a;
  --board-selected: rgba(247, 247, 105, 0.65);
  --board-last-move: rgba(187, 203, 68, 0.52);
  --board-check: radial-gradient(circle, rgba(239, 68, 68, 0.95) 0%, rgba(239, 68, 68, 0.25) 75%);

  --csCutShadow: inset 0 2px 3px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.045);
  --csSeatShadow: inset 0 4px 6px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(0, 0, 0, 0.9);
  --csSocketShadow: inset 0 2px 0 rgba(0, 0, 0, 0.45);

  --csRadRead: 7px;
  --csRadKeySm: 9px;
  --csRadKey: 11px;
  --csRadPanel: 14px;

  --font-display: 'Syne', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ui: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Spline Sans Mono', monospace;

  --csLeadTitle: 1.3;
  --csLeadBody: 1.45;
  --csLeadFlat: 1.2;
}

/* Global Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--csAmber);
  outline-offset: 2px;
}

html, body {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  background-color: var(--csGround);
  color: var(--csInk);
  line-height: var(--csLeadBody);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

/* App Fullscreen Wrapper */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  box-sizing: border-box;
}

/* Header */
.app-header {
  height: 48px;
  min-height: 48px;
  background-color: var(--csChrome);
  border-bottom: 1px solid var(--csLine);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  flex-shrink: 0;
  z-index: 100;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--csInk);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-icon-wrap {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--csAmber);
  color: var(--csAmberInk);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--csInkMeta);
  font-family: var(--font-mono);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.dot-ready {
  background-color: var(--csSuccess);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
}

.status-dot.dot-calculating {
  background-color: var(--csAmberDeep);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.75);
  animation: pulse 0.8s infinite alternate ease-in-out;
}

.status-dot.dot-error {
  background-color: var(--csDanger);
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Locked Depth Chip */
.nmDepth {
  display: inline-flex;
  align-items: center;
}

.csChip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--csRadRead);
  background: var(--csPanelHi);
  border: 1px solid var(--csLine);
  color: var(--csInkMeta);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  line-height: var(--csLeadFlat);
  box-shadow: var(--csCutShadow);
}

/* Main Tool Grid */
.nmTool {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  height: calc(100% - 48px);
  overflow: hidden;
  box-sizing: border-box;
}

.nmToolInner {
  width: 100%;
  max-width: 1360px;
  height: 100%;
  margin: 0 auto;
  padding: 14px 20px 14px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
}

.nmGrid {
  display: grid;
  grid-template-columns: minmax(480px, 1.55fr) minmax(320px, 1fr);
  align-items: flex-start;
  gap: 24px;
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 58px);
  overflow: hidden;
  box-sizing: border-box;
}

/* Board Column */
.nmBoardCol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  justify-content: flex-start;
}

/* Top Bar over Board (Mode Tabs & Actions) */
.nmBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: min(660px, calc(100vh - 160px));
  margin: 0 auto 14px auto;
}

.nmBarTabs {
  flex: 1;
}

.csTabs {
  display: flex;
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKey);
  padding: 3px;
  gap: 3px;
  box-shadow: var(--csCutShadow);
}

.csTab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--csRadKeySm);
  color: var(--csInkMeta);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.csTab svg {
  flex-shrink: 0;
}

.csTab:hover {
  color: var(--csInk);
  background: rgba(255, 255, 255, 0.04);
}

.csTab[data-state="selected"] {
  background: var(--csFaceHi);
  border-color: var(--csEdge);
  color: var(--csInk);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.nmBarActions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.csIconBtn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKeySm);
  color: var(--csInkMeta);
  cursor: pointer;
  box-shadow: var(--csCutShadow);
  transition: all 0.12s ease;
}

.csIconBtn:hover {
  background: var(--csFaceHi);
  border-color: var(--csEdge);
  color: var(--csInk);
}

.csIconBtn:active {
  transform: translateY(1px);
}

/* Board Stage Wrap */
.nmBoardWrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: min(660px, calc(100vh - 160px));
  margin: 0 auto;
}

.nmBoardRow {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* Vertical Evaluation Bar (Desktop) */
.nmBarDesk {
  display: flex;
}

.eval-bar-shell {
  width: 20px;
  height: 100%;
  background: #3a3a3a;
  border-radius: var(--csRadRead);
  border: 1px solid var(--csBoardEdge);
  box-shadow: var(--csCutShadow);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.eval-bar-fill {
  position: absolute;
  inset: 0;
  background: #f5f5f4;
  transform: scaleY(0.5);
  transform-origin: bottom;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.eval-bar-midline {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(115, 115, 115, 0.7);
  z-index: 2;
}

.eval-bar-num {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #171717;
  bottom: 4px;
  z-index: 3;
  line-height: var(--csLeadFlat);
}

.eval-bar-num.num-black-adv {
  bottom: auto;
  top: 4px;
  color: #f5f5f4;
}

/* Chessboard Stack */
.nmBoardStack {
  flex: 1;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.nmBoardFrame {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  outline: 1px solid var(--csBoardEdge);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.chess-board-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
}

.board-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

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

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

.board-square.selected {
  background-color: var(--board-selected) !important;
}

.board-square.last-move {
  background-color: var(--board-last-move) !important;
}

.board-square.in-check {
  background: var(--board-check) !important;
}

.square-coord {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  font-family: var(--font-ui);
  line-height: 1;
}

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

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

.board-square.dark .square-coord {
  color: #7b889d;
}

.board-square.light .square-coord {
  color: #607089;
}

.chess-piece {
  width: 90%;
  height: 90%;
  pointer-events: none;
}

.legal-move-dot {
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.board-square.dark .legal-move-dot {
  background-color: rgba(255, 255, 255, 0.35);
}

.legal-move-capture {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.board-square.dark .legal-move-capture {
  border-color: rgba(255, 255, 255, 0.45);
}

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

/* Board Editor Palette */
.editor-panel {
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKey);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--csCutShadow);
}

.editor-panel.hidden {
  display: none;
}

.editor-pieces-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

.palette-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.palette-divider {
  width: 1px;
  height: 32px;
  background-color: var(--csLine);
  margin: 0 4px;
}

.palette-btn {
  width: 46px;
  height: 46px;
  background-color: var(--csSocket);
  border: 1px solid var(--csSocketEdge);
  border-radius: var(--csRadKeySm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  transition: all 0.12s ease;
  color: var(--csInk);
}

.palette-btn:hover {
  background-color: var(--csFaceHi);
  border-color: var(--csEdge);
  transform: translateY(-1px);
}

.palette-btn.selected {
  background-color: var(--csFaceHi);
  border-color: var(--csAmber);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.55);
}

.palette-btn img {
  width: 38px;
  height: 38px;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}

.palette-btn.trash-btn {
  color: var(--csDanger);
}

.palette-btn.trash-btn svg {
  width: 22px;
  height: 22px;
}

.palette-btn.trash-btn.selected {
  background-color: rgba(242, 105, 105, 0.2);
  border-color: var(--csDanger);
  box-shadow: 0 0 8px rgba(242, 105, 105, 0.4);
}

.editor-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--csLine);
  font-size: 13px;
}

.editor-turn-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-turn-label {
  color: var(--csInkMeta);
  font-weight: 600;
}

.turn-btn {
  background-color: var(--csSocket);
  color: var(--csInkDim);
  border: 1px solid var(--csSocketEdge);
  border-radius: var(--csRadKeySm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s ease;
}

.turn-btn.active {
  background-color: var(--csFaceHi);
  color: var(--csAmber);
  border-color: var(--csAmber);
}

.editor-quick-actions {
  display: flex;
  gap: 6px;
}

.editor-action-btn {
  background-color: var(--csSocket);
  color: var(--csInkBody);
  border: 1px solid var(--csSocketEdge);
  border-radius: var(--csRadKeySm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s ease;
}

.editor-action-btn:hover {
  background-color: var(--csFaceHi);
  color: var(--csInk);
}

/* Editor Mode Scrollability */
html.editor-mode-active,
body.editor-mode-active {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: auto !important;
  min-height: 100% !important;
  -webkit-overflow-scrolling: touch;
}

.editor-mode-active .app-layout {
  height: auto !important;
  min-height: 100dvh !important;
  overflow: visible !important;
}

.editor-mode-active .nmTool {
  height: auto !important;
  min-height: calc(100dvh - 48px) !important;
  overflow: visible !important;
  align-items: flex-start !important;
}

.editor-mode-active .nmToolInner {
  height: auto !important;
  min-height: auto !important;
  padding-top: 14px !important;
  padding-bottom: 40px !important;
  align-items: flex-start !important;
  overflow: visible !important;
}

.editor-mode-active .nmGrid {
  height: auto !important;
  max-height: none !important;
  align-items: flex-start !important;
  overflow: visible !important;
  padding-bottom: 30px !important;
}

.editor-mode-active .nmBoardCol {
  height: auto !important;
  justify-content: flex-start !important;
}


.editor-mode-active .nmBelowBoard {
  display: none !important;
}

.editor-mode-active .nmRail {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Move Navigation Strip */
.nmBelowBoard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.nmStrip {
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  height: 44px;
  padding: 4px;
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKey);
  box-shadow: var(--csCutShadow);
}

.nmStripStep {
  flex: none;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--csSocket);
  border: 1px solid var(--csSocketEdge);
  border-radius: var(--csRadKeySm);
  color: var(--csInkBody);
  cursor: pointer;
  transition: all 0.1s ease;
}

.nmStripStep:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.nmStripStep:not(:disabled):hover {
  background: var(--csFaceHi);
  color: var(--csInk);
}

.nmStripScroll {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.nmStripScroll::-webkit-scrollbar {
  display: none;
}

.nmStripEmpty {
  display: flex;
  align-items: center;
  padding: 0 4px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: var(--csLeadFlat);
  color: var(--csInkMeta);
}

.nmStripMovePill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--csInkBody);
  background: var(--csSocket);
  border: 1px solid var(--csSocketEdge);
  cursor: pointer;
  transition: all 0.12s ease;
}

.nmStripMovePill:hover, .nmStripMovePill.current {
  background: var(--csFaceHi);
  color: var(--csAmber);
  border-color: var(--csAmber);
}

/* Right Column: Analysis Rail */
.nmRail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  background: var(--csPanel);
  border: 1px solid var(--csLine);
  border-radius: var(--csRadPanel);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  margin-top: 44px;
  justify-content: flex-start;
  box-sizing: border-box;
}

/* 3D Tactile Amber Button */
.csBtn[data-tone="primary"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #fcd34d 0%, #fbbf24 100%);
  color: #17110a;
  border: 1px solid #f59e0b;
  border-bottom: 4px solid var(--csAmberSole);
  border-radius: var(--csRadKey);
  box-shadow: 0 4px 14px rgba(251, 191, 36, 0.3);
  cursor: pointer;
  transition: background-color 0.1s ease, transform 0.08s ease, border-bottom-width 0.08s ease;
}

.csBtn[data-tone="primary"]:hover {
  background: linear-gradient(180deg, #fde68a 0%, #fcd34d 100%);
}

.csBtn[data-tone="primary"]:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.csBtn[data-tone="primary"].analyzing {
  background: linear-gradient(180deg, #e8b022 0%, #d99a1b 100%);
  pointer-events: none;
}

.csBtnBody {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(23, 17, 10, 0.25);
  border-top-color: #17110a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Split Card: Best Move & Eval */
.nmBest {
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKey);
  box-shadow: var(--csCutShadow);
}

.nmBestCell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 10px 14px;
  flex: 1;
}

.nmBestCell[data-part="move"] {
  border-right: 1px solid var(--csWellEdge);
}

.csEyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--csInkMeta);
  line-height: var(--csLeadFlat);
}

.nmBestValue {
  overflow: hidden;
  font-size: 24px;
  font-weight: 800;
  line-height: var(--csLeadFlat);
  color: var(--csInk);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.nmBestCell[data-part="eval"] .nmBestValue {
  color: var(--csAmber);
}

/* Candidate Moves Container */
.nmLines {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.nmLinesEmpty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 16px;
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKeySm);
  box-shadow: var(--csCutShadow);
  font-size: 12.5px;
  color: var(--csInkDim);
  line-height: var(--csLeadBody);
}

.nmLine {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 4px 10px;
  border-radius: var(--csRadKeySm);
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  box-shadow: var(--csCutShadow);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.nmLine:hover {
  background: var(--csFaceHi);
  border-color: var(--csEdge);
}

.nmLine:first-child {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.05);
}

.nmLine:first-child:hover {
  border-color: rgba(251, 191, 36, 0.7);
  background: rgba(251, 191, 36, 0.1);
}

.nmLine .csNum {
  flex-shrink: 0;
  background: #202020;
  color: #d4d4d4;
  border: 1px solid #333333;
  border-radius: var(--csRadRead);
  padding: 3px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  box-shadow: var(--csCutShadow);
  line-height: var(--csLeadFlat);
}

.nmLine:first-child .csNum {
  background: rgba(251, 191, 36, 0.22);
  color: var(--csAmber);
  border-color: rgba(251, 191, 36, 0.5);
}

.nmLinePv {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: var(--csLeadFlat);
  color: var(--csInkMeta);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.nmLinePv::-webkit-scrollbar {
  display: none;
}

.nmLineMove {
  color: var(--csInkBody);
}

.nmLineMove[data-first="1"] {
  color: var(--csInk);
  font-weight: 700;
}

.nmLineDot {
  color: var(--csInkDim);
  font-weight: 600;
}

/* FEN Groove */
.nmFen {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nmFenGroove {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  padding: 4px 6px 4px 12px;
  background: var(--csWell);
  border: 1px solid var(--csWellEdge);
  border-radius: var(--csRadKeySm);
  box-shadow: var(--csCutShadow);
  transition: border-color 0.14s ease;
}

.nmFenGroove:focus-within {
  border-color: var(--csAmber);
  box-shadow: 0 0 0 1px var(--csAmber);
}

.csInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--csInkBody);
  font-family: var(--font-mono);
  font-size: 12.5px;
  outline: none;
}

.csInput::placeholder {
  color: var(--csInkDim);
}

.nmFenGroove .csIconBtn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.fen-error {
  color: var(--csDanger);
  font-size: 12px;
  padding: 0 4px;
}

.fen-error.hidden {
  display: none;
}

/* Foot Description */
.nmRailFoot {
  margin-top: 4px;
}

/* Mobile Responsive Layout (< 1024px) */
@media (max-width: 1023px) {
  .app-header {
    height: 38px;
    min-height: 38px;
    padding: 0 0.5rem;
  }

  .brand-logo {
    font-size: 0.95rem;
    gap: 0.35rem;
  }

  .brand-icon-wrap {
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
  }

  .status-text {
    display: none;
  }

  .nmTool {
    padding: 2px !important;
    height: calc(100% - 38px);
  }

  .nmToolInner {
    padding: 10px 4px 4px 4px !important;
    max-width: 100%;
  }

  .nmGrid {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    height: 100% !important;
    max-height: 100dvh !important;
    gap: 4px !important;
    overflow: hidden !important;
  }

  .nmBoardCol {
    height: auto;
    flex: 0 0 auto;
    gap: 6px;
    width: 100%;
    align-items: center;
  }

  .nmBar {
    width: 100%;
    max-width: min(calc(100vw - 8px), 560px, 66vh) !important;
    padding: 0 2px;
    margin: 4px auto 12px auto !important;
  }

  .csTab {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 12.5px;
    gap: 5px;
  }

  .csIconBtn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .nmBarDesk {
    display: none !important;
  }

  .nmBoardWrap {
    width: 100% !important;
    max-width: min(calc(100vw - 8px), 560px, 66vh) !important;
    margin: 0 auto !important;
    padding: 0 2px;
  }

  .nmBoardStack {
    width: 100% !important;
    max-width: 100% !important;
  }

  .nmBelowBoard {
    width: 100%;
    max-width: min(calc(100vw - 8px), 560px, 66vh) !important;
    margin: 0 auto;
    padding: 0 2px;
  }

  .nmStrip {
    height: 46px;
    padding: 3px;
  }

  .nmStripStep {
    width: 42px;
    min-width: 42px;
    min-height: 40px;
    height: 100%;
  }

  .nmStripMovePill {
    padding: 5px 10px;
    font-size: 13px;
  }

  /* Board Editor Palette on Mobile: 2 Clean Rows */
  .editor-panel {
    padding: 10px 8px;
    gap: 10px;
    width: 100%;
    max-width: min(calc(100vw - 8px), 560px, 66vh) !important;
  }

  .editor-pieces-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
  }

  .palette-group#palette-white-pieces {
    flex-basis: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
  }

  .palette-divider {
    display: none !important;
  }

  .palette-group#palette-black-pieces {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
  }

  .palette-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 2px;
    border-radius: 8px;
  }

  .palette-btn img {
    width: 36px;
    height: 36px;
    max-width: 100%;
    max-height: 100%;
  }

  .palette-btn.trash-btn svg {
    width: 22px;
    height: 22px;
  }

  .editor-controls-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--csLine);
  }

  .editor-turn-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }

  .turn-btn {
    flex: 1;
    min-height: 40px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
  }

  .editor-quick-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .editor-action-btn {
    flex: 1;
    min-height: 40px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
  }

  /* Cohesive Mobile Analysis Card */
  .nmRail {
    flex: 0 0 auto;
    gap: 8px;
    height: auto;
    min-height: 0;
    width: 100%;
    max-width: min(calc(100vw - 8px), 560px, 66vh);
    margin: 6px auto 16px auto;
    padding: 10px;
    background: var(--csPanel);
    border: 1px solid var(--csLine);
    border-radius: var(--csRadKey);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    overflow: visible;
  }

  .csBtn[data-tone="primary"] {
    min-height: 46px;
    padding: 8px 16px;
  }

  .csBtnBody {
    font-size: 1.05rem;
  }

  .nmLines {
    min-height: 0;
    gap: 4px;
  }

  .nmLine {
    height: 34px;
    padding: 2px 8px;
    gap: 8px;
  }

  .nmLine .csNum {
    padding: 2px 6px;
    font-size: 11.5px;
  }

  .nmLinePv {
    font-size: 12.5px;
    gap: 5px;
  }

  .nmFenGroove {
    height: 40px;
    padding: 2px 4px 2px 8px;
  }

  .nmFenGroove .csIconBtn {
    width: 34px;
    height: 34px;
  }

  .editor-mode-active .nmTool {
    height: auto !important;
    min-height: calc(100dvh - 38px) !important;
    overflow: visible !important;
  }

  .editor-mode-active .nmGrid {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding-bottom: 30px !important;
  }
}
