/* ChessCoach — Flat Warm Dark Theme */

/* ===== Design Tokens ===== */
:root {
    --bg-0: #0f0f11;
    --bg-1: #161618;
    --bg-2: #1e1e21;
    --bg-3: #26262a;
    --bg-4: #303036;
    --border: #2a2a2e;
    --border-hi: #38383e;
    --accent: #c9a84c;
    --accent-dim: #8a7535;
    --accent-bg: rgba(201,168,76,0.07);
    --text: #e2ddd5;
    --text-2: #9e9991;
    --text-3: #5c5955;
    --green: #6abd6a;
    --orange: #d4923a;
    --red: #c95050;
    --blue: #5b8fc9;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);
    --radius: 8px;
    --radius-sm: 5px;
    --font: 'Inter', -apple-system, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

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

/* ===== Base ===== */
html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Focus ===== */
:focus-visible {
    outline: 2px solid rgba(201,168,76,0.4);
    outline-offset: 2px;
}

/* ===== Selection ===== */
::selection {
    background: rgba(201,168,76,0.22);
    color: var(--text);
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--bg-4);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ===== Top Bar ===== */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    height: 48px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
}

.brand-icon { display: block; color: var(--accent); }

.brand-chess {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
    letter-spacing: -0.3px;
}

.brand-sy {
    font-family: 'Pacifico', cursive;
    font-size: 18px;
    color: var(--accent);
    margin-left: -1px;
    margin-top: -3px;
}

.topbar-import {
    flex: 1;
    display: flex;
    gap: 6px;
    max-width: 360px;
}

.topbar-import input {
    flex: 1;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text);
    padding: 4px 16px;
    font-size: 12px;
    font-family: var(--font);
    outline: none;
    transition: border-color 120ms;
}

.topbar-import input::placeholder {
    color: var(--text-3);
}

.topbar-import input:focus {
    border-color: var(--accent-dim);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* ===== Skill Toggle ===== */
.skill-toggle {
    display: flex;
    gap: 1px;
    background: var(--bg-0);
    border-radius: 20px;
    padding: 2px;
    border: 1px solid var(--border);
}

.skill-toggle button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 12px;
    background: transparent;
    border: none;
    color: var(--text-3);
    border-radius: 18px;
    cursor: pointer;
    transition: background 120ms, color 120ms;
    line-height: 1.2;
}

.skill-toggle button .level-name {
    font-size: 11px;
    font-weight: 500;
}

.skill-toggle button .level-range {
    font-size: 9px;
    opacity: 0.55;
}

.skill-toggle button.active {
    background: var(--bg-4);
    color: var(--text);
}

.skill-toggle button.active .level-range {
    color: var(--accent);
    opacity: 1;
}

.skill-toggle button:hover:not(.active) {
    color: var(--text-2);
}

/* ===== Buttons ===== */
.btn {
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--text-2);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    transition: background 120ms, color 120ms, border-color 120ms;
    white-space: nowrap;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn:hover {
    background: var(--bg-4);
    color: var(--text);
}

.btn:active { transform: scale(0.97); }

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

.btn-accent {
    background: var(--accent-dim);
    border-color: transparent;
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent);
    color: #000;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.btn-nav {
    padding: 4px 8px;
    background: var(--bg-2);
    border-color: var(--border);
    color: var(--text-2);
}

.btn-nav:hover {
    background: var(--bg-3);
    color: var(--text);
}

.btn-icon-text {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-icon-text svg {
    flex-shrink: 0;
}

.btn-llm-keys {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    letter-spacing: 0.3px;
    position: relative;
}

.btn-llm-keys:hover {
    color: var(--accent);
    border-color: var(--accent-dim);
    background: var(--bg-2);
}

/* Tooltip for LLM Keys */
.btn-llm-keys[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-3);
    color: var(--text);
    font-size: 11px;
    font-weight: 400;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 50;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    letter-spacing: 0;
    pointer-events: none;
    max-width: 260px;
    white-space: normal;
    text-align: left;
}

/* ===== Main Layout ===== */
.layout {
    display: flex;
    height: calc(100vh - 48px);
    overflow: hidden;
}

/* ===== Board Section ===== */
.board-section {
    /* Budget: topbar 48 + player-bars 40 + toolbar 28 + movelist ~115 + engine ~95 +
       eval-graph ~36 + margins/padding ~30 ≈ 392. Round to 390. */
    --board-size: min(480px, calc(100vh - 390px));
    width: calc(var(--board-size) + 48px);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border);
    background: var(--bg-0);
    scrollbar-width: none;   /* Firefox */
}

.board-section::-webkit-scrollbar {
    width: 0;
    display: none;           /* Chrome/Edge */
}

/* ===== Analysis Section ===== */
.analysis-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-1);
}

/* ===== Player Bars ===== */
.board-top,
.board-bottom {
    padding: 2px 0;
    flex-shrink: 0;
}

.player-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
}

.player-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
}

/* ===== Board + Eval Bar ===== */
.board-with-eval {
    display: flex;
    gap: 4px;
    align-items: stretch;
    flex-shrink: 0;
}

.eval-bar {
    width: 18px;
    background: #1a1a1e;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.eval-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 50%;
    background: #ddd8cc;
    transition: height 400ms;
}

.eval-label {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 8px;
    font-weight: 700;
    z-index: 1;
    top: 4px;
    letter-spacing: -0.3px;
    mix-blend-mode: difference;
    color: #fff;
}

.board-wrap {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    flex-shrink: 0;
}

#board {
    width: 100%;
    height: 100%;
}

/* ===== Board Toolbar ===== */
.board-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.toolbar-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.toolbar-opening {
    font-size: 12px;
    color: var(--accent);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.toolbar-spacer { flex: 1; }

.status-text {
    font-size: 11px;
    color: var(--text-3);
    flex-shrink: 0;
}

/* ===== Section Labels ===== */
.section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-3);
}

/* ===== Move List ===== */
.movelist-area {
    margin-top: 4px;
    display: none;
    flex-shrink: 0;
}

.movelist-area.active { display: block; }

.movelist-header { padding: 2px 0; }

.game-info {
    font-size: 11px;
    color: var(--text-2);
}

.movelist {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 1px;
    max-height: 60px;
    overflow-y: auto;
    padding: 4px 8px;
    background: var(--bg-1);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    scrollbar-width: thin;
}

.move-num {
    font-size: 11px;
    color: var(--text-3);
    min-width: 22px;
    text-align: right;
    padding-right: 2px;
    font-family: var(--mono);
}

.move-cell {
    font-size: 12px;
    font-family: var(--mono);
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 120ms;
    color: var(--text-2);
}

.move-cell:hover { background: var(--bg-3); color: var(--text); }

.move-cell.active {
    background: var(--accent-bg);
    outline: 1px solid var(--accent-dim);
    color: var(--accent);
}

/* Quality tints — background only, no colored text */
.move-cell.best     { background: rgba(106,189,106,0.08); }
.move-cell.good     { background: rgba(106,189,106,0.05); }
.move-cell.inaccuracy { background: rgba(212,146,58,0.10); }
.move-cell.mistake  { background: rgba(212,146,58,0.16); }
.move-cell.blunder  { background: rgba(201,80,80,0.16); }

/* Variation lines */
.variation-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 1px;
    padding: 2px 0 2px 12px;
    border-left: 2px solid var(--bg-4);
    margin: 2px 0;
    font-size: 11px;
    width: 100%;
}

.variation-line .move-cell { font-size: 11px; opacity: 0.8; }
.variation-line .move-num  { font-size: 10px; }

.variation-line .variation-line {
    padding-left: 10px;
    border-left-color: var(--border);
    font-size: 10px;
}

.variation-line .variation-line .move-cell {
    font-size: 10px;
    opacity: 0.65;
}

/* ===== Movelist Nav ===== */
.movelist-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    flex-shrink: 0;
}

.nav-spacer { flex: 1; }

/* ===== Engine Lines ===== */
.engine-lines-area {
    margin-top: 4px;
    flex-shrink: 0;
}

.engine-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    height: 24px;
    flex-shrink: 0;
}

.engine-header-spacer { flex: 1; }

.depth-badge {
    font-size: 10px;
    color: var(--text-3);
    background: var(--bg-2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--mono);
}

.deep-eval-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-3);
    user-select: none;
}

.deep-eval-toggle input[type="checkbox"] {
    width: 12px;
    height: 12px;
    accent-color: var(--accent);
    cursor: pointer;
}

.deep-eval-toggle:hover .toggle-label { color: var(--text-2); }

.engine-lines {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.engine-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-family: var(--mono);
    transition: background 120ms;
    border: 1px solid transparent;
}

.engine-line:hover {
    background: var(--bg-2);
    border-color: var(--border);
}

.line-eval {
    font-weight: 700;
    min-width: 48px;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-2);
    text-align: center;
    flex-shrink: 0;
}

.line-eval.positive { color: var(--green); }
.line-eval.negative { color: var(--red); }
.line-eval.neutral  { color: var(--text-2); }

.line-pv {
    color: var(--text-2);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* ===== Dot Loader (CSS-only 3-dot animation) ===== */
.engine-placeholder {
    padding: 6px 8px;
    color: var(--text-3);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot-loader {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.dot-loader::before,
.dot-loader::after,
.dot-loader span {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-3);
    animation: dot-pulse 1.2s ease-in-out infinite;
}

.dot-loader::before { animation-delay: 0s; }
.dot-loader span    { animation-delay: 0.2s; }
.dot-loader::after  { animation-delay: 0.4s; }

@keyframes dot-pulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40%           { opacity: 1;   transform: scale(1); }
}

/* ===== Opening Explorer ===== */
.explorer-area { margin-top: 4px; flex-shrink: 0; }

.explorer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    height: 24px;
}

.opening-name {
    font-size: 11px;
    color: var(--accent);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explorer-count {
    font-size: 11px;
    color: var(--text-3);
    margin-left: auto;
}

.explorer-moves {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.explorer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.explorer-move {
    font-family: var(--mono);
    font-weight: 600;
    min-width: 40px;
    color: var(--text);
}

.explorer-bar-wrap {
    flex: 1;
    height: 10px;
    border-radius: 2px;
    overflow: hidden;
    background: var(--bg-3);
}

.explorer-bar {
    display: flex;
    height: 100%;
}

.explorer-w { background: #ccc5b4; }
.explorer-d { background: #606060; }
.explorer-b { background: #2e2e2e; }

.explorer-games {
    font-size: 11px;
    color: var(--text-3);
    min-width: 40px;
    text-align: right;
    font-family: var(--mono);
}

.explorer-loading {
    padding: 6px 0;
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
}

/* ===== Eval Graph ===== */
.eval-graph-area {
    margin-top: 4px;
    height: 32px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-1);
    flex-shrink: 0;
}

.eval-graph-area canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

/* ===== Panel Tabs ===== */
.panel-tabs {
    display: flex;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding: 0 12px;
    gap: 0;
    height: 36px;
}

.tab {
    padding: 0 16px;
    height: 36px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 120ms, border-color 120ms;
    display: flex;
    align-items: center;
}

.tab:hover { color: var(--text-2); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
}

.tab-content.active { display: flex; }

.tab-scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px;
    scrollbar-width: thin;
}

/* ===== Analysis Panel ===== */
.analysis-loading { padding: 0; }

.skeleton {
    background: var(--bg-2);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    animation: skeleton-pulse 1.6s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.35; }
    50%       { opacity: 0.6; }
}

.skeleton-title { height: 24px; width: 55%; }
.skeleton-bar   { height: 6px;  width: 75%; }
.skeleton-text  { height: 12px; width: 100%; }
.skeleton-text.short { width: 55%; }

/* ===== Move Header ===== */
.move-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.move-notation {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -1px;
    color: var(--text);
    line-height: 1;
}

/* ===== Quality Pill ===== */
.quality-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.quality-pill.best       { background: rgba(106,189,106,0.10); color: var(--green); }
.quality-pill.good       { background: rgba(106,189,106,0.07); color: var(--green); }
.quality-pill.inaccuracy { background: rgba(212,146,58,0.12);  color: var(--orange); }
.quality-pill.mistake    { background: rgba(212,146,58,0.17);  color: var(--orange); }
.quality-pill.blunder    { background: rgba(201,80,80,0.14);   color: var(--red); }

/* ===== Eval Change ===== */
.eval-change {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.eval-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: var(--bg-0);
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.eval-tiny-label {
    font-size: 9px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.eval-num {
    font-weight: 700;
    font-family: var(--mono);
    font-size: 15px;
    line-height: 1;
}

.eval-num.positive { color: var(--green); }
.eval-num.negative { color: var(--red); }
.eval-num.neutral  { color: var(--text-2); }

.eval-arrow {
    color: var(--text-3);
    font-size: 14px;
}

.cp-loss-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--red);
    background: rgba(201,80,80,0.10);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
}

/* ===== Findability (inline in move header, next to pill) ===== */
.find-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-0);
    border: 1px solid var(--border);
}

.find-inline-pct {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
}

.find-inline-pct.easy   { color: var(--green); }
.find-inline-pct.medium { color: var(--orange); }
.find-inline-pct.hard   { color: var(--red); }

.find-inline-label {
    font-size: 10px;
    color: var(--text-3);
    white-space: nowrap;
}

/* ===== Best Move Info (mistakes/blunders) ===== */
.best-move-info {
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.best-move-row,
.best-findable-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.best-move-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    min-width: 56px;
}

.best-move-san {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 14px;
    color: var(--green);
}

.best-move-san.findable {
    color: var(--accent);
}

/* ===== Explanation Text ===== */
.explanation {
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 8px;
    min-height: 20px;
}

.explanation strong { color: var(--accent); font-weight: 600; }
.explanation em     { color: var(--text-2); font-style: italic; }

/* ===== AI Analysis Section ===== */
.ai-analysis {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.ai-analysis-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ai-loading-bar {
    flex: 1;
    height: 3px;
    background: var(--bg-3);
    border-radius: 2px;
    overflow: hidden;
}

.ai-loading-fill {
    height: 100%;
    width: 40%;
    background: var(--accent);
    border-radius: 2px;
    animation: ai-loading-slide 1.4s ease-in-out infinite;
}

@keyframes ai-loading-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.ai-analysis-text {
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text);
}

.ai-analysis-text strong { color: var(--accent); font-weight: 600; }
.ai-analysis-text em     { color: var(--text-2); font-style: italic; }

/* ===== Tap-to-Move Highlights ===== */
.square-highlight {
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

.square-highlight.selected {
    inset: 0;
    background: rgba(201, 168, 76, 0.35);
}

.square-highlight.move-hint {
    top: 50%;
    left: 50%;
    width: 28%;
    height: 28%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
}

.square-highlight.capture-hint {
    inset: 0;
    border-radius: 50%;
    background: transparent;
    border: 5px solid rgba(0, 0, 0, 0.25);
}

/* ===== Clickable Moves ===== */
.clickable-move {
    color: var(--accent);
    font-family: var(--mono);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px dashed var(--accent-dim);
    transition: color 120ms, border-color 120ms;
    padding: 0 1px;
}

.clickable-move:hover {
    color: #fff;
    border-bottom-color: var(--accent);
}

/* ===== Suggestion Box ===== */
.suggestion-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.suggestion-icon { display: none; }

/* ===== Threat Tags ===== */
.threats-compact { margin-top: 12px; }

.threats-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.threat-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.threat-tag.tactic  { background: rgba(91,143,201,0.10); color: var(--blue);   border-color: rgba(91,143,201,0.2); }
.threat-tag.warning { background: rgba(212,146,58,0.10); color: var(--orange); border-color: rgba(212,146,58,0.2); }
.threat-tag.danger  { background: rgba(201,80,80,0.10);  color: var(--red);    border-color: rgba(201,80,80,0.2); }

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    flex: 1;
    text-align: center;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.15;
}

.empty-state p { color: var(--text-2); font-size: 13px; }
.empty-hint    { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ===== Move Chat (inline) ===== */
.move-chat-area {
    margin: 8px 0 12px;
}

.move-chat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.move-chat-row input {
    flex: 1;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    font-size: 12px;
    font-family: var(--font);
    outline: none;
    transition: border-color 120ms;
}

.move-chat-row input:focus {
    border-color: var(--accent-dim);
}

.move-chat-row input::placeholder { color: var(--text-3); }

.chat-send-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--accent-dim);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 120ms, transform 100ms;
}

.chat-send-btn:hover  { background: var(--accent); }
.chat-send-btn:active { transform: scale(0.92); }

.hint-btn {
    height: 30px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 120ms, border-color 120ms;
    letter-spacing: 0.3px;
}

.hint-btn:hover {
    background: var(--accent-bg);
    border-color: var(--accent-dim);
}

/* ===== Position Chat Bar (fixed bottom of panel) ===== */
.position-chat-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-1);
    flex-shrink: 0;
}

.position-chat-bar input {
    flex: 1;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    font-size: 12px;
    font-family: var(--font);
    outline: none;
    transition: border-color 120ms;
}

.position-chat-bar input:focus { border-color: var(--accent-dim); }
.position-chat-bar input::placeholder { color: var(--text-3); }

/* ===== Chat Messages ===== */
.inline-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.inline-chat-messages:empty { display: none; }

.chat-msg { display: flex; }
.chat-msg.user      { justify-content: flex-end; }
.chat-msg.assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: 88%;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.55;
}

.chat-msg.user .chat-bubble {
    background: var(--accent-dim);
    color: #fff;
    border-radius: 10px 10px 2px 10px;
}

.chat-msg.assistant .chat-bubble {
    background: var(--bg-3);
    color: var(--text);
    border-radius: 10px 10px 10px 2px;
}

.chat-msg.assistant.hint .chat-bubble {
    background: var(--bg-3);
    border: 1px solid rgba(201,168,76,0.2);
    color: var(--text);
    border-radius: 10px 10px 10px 2px;
}

.chat-bubble strong { color: var(--accent); }

/* ===== Coach Panel ===== */
.coach-progress { padding: 12px 0; }

.progress-bar {
    height: 4px;
    background: var(--bg-3);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width 300ms;
}

.progress-label { font-size: 12px; color: var(--text-2); }

/* ===== Coach Summary ===== */
.coach-summary {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 16px;
}

.accuracy-ring {
    position: relative;
    width: 96px;
    height: 96px;
    flex-shrink: 0;
}

.accuracy-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--bg-3);
    stroke-width: 5;
}

.ring-fg {
    fill: none;
    stroke: var(--green);
    stroke-width: 5;
    stroke-dasharray: 264;
    stroke-dashoffset: 264;
    stroke-linecap: butt;
    transition: stroke-dashoffset 600ms, stroke 400ms;
}

.ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
}

/* ===== Stats Row ===== */
.summary-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-2);
}

.stat-row span:nth-child(2) { flex: 1; }

.stat-num {
    font-weight: 600;
    font-family: var(--mono);
    color: var(--text);
}

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

.dot.best       { background: var(--green); }
.dot.good       { background: rgba(106,189,106,0.5); }
.dot.inaccuracy { background: var(--orange); }
.dot.mistake    { background: rgba(212,146,58,0.7); }
.dot.blunder    { background: var(--red); }

/* ===== Coach Moments ===== */
.coach-moments { margin-top: 12px; }

.moment-card {
    background: var(--bg-2);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    /* Top border colored by quality class */
    border-top: 3px solid var(--border);
    overflow: hidden;
}

.moment-card.best       { border-top-color: var(--green); }
.moment-card.good       { border-top-color: rgba(106,189,106,0.5); }
.moment-card.inaccuracy { border-top-color: var(--orange); }
.moment-card.mistake    { border-top-color: rgba(212,146,58,0.8); }
.moment-card.blunder    { border-top-color: var(--red); }

.moment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.moment-move {
    font-weight: 600;
    font-family: var(--mono);
    color: var(--text);
    font-size: 13px;
}

.moment-quality {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
}

.moment-quality.inaccuracy { color: var(--orange); background: rgba(212,146,58,0.12); }
.moment-quality.mistake    { color: var(--orange); background: rgba(212,146,58,0.17); }
.moment-quality.blunder    { color: var(--red);    background: rgba(201,80,80,0.14); }

.moment-body  { font-size: 12px; color: var(--text-2); line-height: 1.45; }
.moment-alt   { font-size: 12px; margin-top: 4px; color: var(--text-2); }
.moment-click { font-size: 11px; color: var(--accent); cursor: pointer; margin-top: 4px; display: inline-block; }
.moment-click:hover { text-decoration: underline; }

.pattern-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 8px 12px;
    background: var(--bg-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 4px;
}

.pattern-tag.strength { color: var(--green); }
.pattern-tag.weakness { color: var(--orange); }
.pattern-icon { font-size: 13px; }

/* ===== Overlay / Dialog ===== */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.overlay.active { display: flex; }

.dialog {
    background: var(--bg-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius);
    padding: 24px;
    min-width: 280px;
    box-shadow: var(--shadow);
}

.dialog h3 {
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.promotion-pieces {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.promotion-piece {
    width: 60px;
    height: 60px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 120ms;
    border: 1px solid transparent;
}

.promotion-piece:hover {
    background: var(--bg-3);
    border-color: var(--border-hi);
}

.settings-dialog {
    width: 440px;
    max-width: 90vw;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.settings-note {
    font-size: 12px;
    color: var(--text-2);
    background: var(--bg-3);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    line-height: 1.45;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-2);
}

.settings-form select,
.settings-form input {
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 120ms;
}

.settings-form .apikey-input {
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--mono);
    letter-spacing: 0.5px;
}

.settings-form select:focus,
.settings-form input:focus { border-color: var(--accent-dim); }

.settings-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.settings-status {
    font-size: 12px;
    padding: 4px 0;
    min-height: 20px;
}

.settings-status.success { color: var(--green); }
.settings-status.error   { color: var(--red); }

.settings-hint {
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.45;
    margin-top: 4px;
}

.settings-hint code {
    background: var(--bg-3);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-2);
}

/* Lichess auth section */
.lichess-auth-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.lichess-status {
    font-size: 12px;
    color: var(--text-3);
    flex: 1;
}

.lichess-status .lichess-connected {
    color: var(--green);
}

.btn-lichess {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #4a4a4a;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-lichess:hover { background: #5a5a5a; }
.btn-lichess svg { opacity: 0.8; }

.btn-muted {
    background: transparent;
    color: var(--text-3);
    border: 1px solid var(--border);
    font-size: 11px;
    cursor: pointer;
}
.btn-muted:hover { color: var(--red); border-color: var(--red); }

.lichess-token-details {
    margin-bottom: 4px;
}

.lichess-token-details summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--text-3);
    margin-bottom: 6px;
}

.lichess-token-details summary:hover { color: var(--text-2); }

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text);
    background: var(--bg-3);
    border: 1px solid var(--border-hi);
    /* Top border as color indicator instead of left border */
    border-top-width: 2px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 180ms, transform 180ms;
    box-shadow: var(--shadow);
    pointer-events: auto;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-top-color: var(--green); }
.toast.error   { border-top-color: var(--red); }
.toast.warning { border-top-color: var(--orange); }
.toast.info    { border-top-color: var(--blue); }

/* ===== Mobile Summary Strip (above tabs on mobile) ===== */
/* Mobile bottom nav removed — single scrollable layout */

/* ===== Responsive: Medium ===== */
@media (max-width: 1200px) {
    .skill-toggle button .level-range { display: none; }
}

@media (max-width: 1024px) {
    .board-section { padding: 8px 10px; --board-size: min(400px, calc(100vh - 390px)); }
    .board-wrap    { width: var(--board-size); height: var(--board-size); }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .board-section {
        width: 100%;
        flex: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 8px 12px;
        overflow-y: visible;
    }

    .analysis-section {
        min-height: 300px;
        overflow: visible;
    }

    .board-with-eval { width: 100%; }

    .board-wrap {
        width: calc(100% - 24px);  /* 18px eval bar + 4px gap + 2px breathing */
        max-width: 360px;
        height: auto;
        aspect-ratio: 1;
    }

    .eval-graph-area { height: 48px; }

    .movelist { max-height: 100px; }

    .topbar { gap: 6px; padding: 0 8px; height: 42px; }
    .brand-chess { font-size: 14px; }
    .brand-sy { font-size: 13px; }
    .brand-icon { width: 16px; height: 16px; }
    .topbar-import { max-width: none; flex: 1; }
    .topbar-import input { padding: 4px 12px; font-size: 12px; }
    .topbar-right  { gap: 4px; margin-left: 0; }

    .skill-toggle { display: none; }

    .btn-llm-keys { padding: 4px 8px; font-size: 11px; }

    /* Hide bottom chat bars on mobile — buttons are accessible through UI */
    .position-chat-bar { display: none; }
}

@media (max-width: 480px) {
    .board-section { padding: 8px; }
    .topbar { padding: 0 6px; }
    .brand-icon { display: none; }
    .brand-chess { font-size: 13px; }
    .brand-sy { font-size: 12px; }
    .topbar-import input { font-size: 11px; }
    .board-wrap { width: 100%; }
}
