/* Deep Study Page — overrides on top of base.css */
body {
    height: 100vh;
}

/* Home button provided by base.css */

/* Lines Selection View */
.lines-selection-view {
    display: block;
}

.home-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

.home-header {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInUp 1s ease-out;
}

.home-header h1 {
    font-family: 'Cormorant Garamond', cursive;
    font-size: clamp(2.2rem, 9vw, 5rem);
    color: #1a2332;
    text-shadow: none;
    margin-bottom: 20px;
}

.home-header p {
    font-size: 1.2rem;
    color: #4a5568;
    font-weight: 300;
}

/* Deep Study Interface */
.deep-study-interface {
    display: flex;
    height: 100vh;
    padding: 20px;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Analysis Section */
.analysis-section {
    flex: 0 0 420px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: calc(100vh - 40px);
    overflow: hidden;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(91, 155, 213, 0.1);
    /* backdrop-filter removed for light theme */
    border-radius: 8px;
    border: 1px solid rgba(91, 155, 213, 0.2);
    padding: 15px;
}

.analysis-header h3 {
    color: rgba(91, 155, 213, 0.95);
    font-size: 1.1rem;
    font-weight: 600;
}

.back-to-lines-btn {
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #4a5568;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.back-to-lines-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    color: #1a2332;
}

.selected-line-info {
    background: #ffffff;
    /* backdrop-filter removed for light theme */
    border-radius: 8px;
    border: 1px solid #dce3eb;
    padding: 15px;
}

.line-title {
    color: rgba(91, 155, 213, 0.95);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    overflow-wrap: anywhere;
}

.line-notation {
    background: #ffffff;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.4;
    border: 1px solid #dce3eb;
    overflow-wrap: anywhere;
}

.analysis-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    min-height: 0;
}

.theory-section, .variations-section {
    background: rgba(91, 155, 213, 0.03);
    /* backdrop-filter removed for light theme */
    border-radius: 8px;
    border: 1px solid #dce3eb;
    padding: 15px;
}

.theory-section h4, .variations-section h4 {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.theory-content {
    color: #4a5568;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ChessDB Analysis Styles */
.chessdb-analysis {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chessdb-analysis .evaluation {
    color: #4a5568;
    font-size: 0.9rem;
}

.chessdb-analysis .depth {
    color: #4a5568;
    font-size: 0.8rem;
}

.chessdb-analysis .principal-variation {
    color: #4a5568;
    font-size: 0.85rem;
}

.chessdb-analysis code {
    display: block;
    margin-top: 6px;
    word-break: break-all;
}

/* Variations Grid */
.variations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

/* Variation Tree Section */
/* Collapsible variation-tree section (by the annotations panel). */
.variation-tree-collapse {
    background: rgba(91, 155, 213, 0.03);
    border-radius: 8px;
    border: 1px solid #dce3eb;
    margin-top: 12px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.variation-tree-collapse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
}

.variation-tree-collapse-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #4a5568;
    font-size: 0.9rem;
    font-weight: 600;
}

.variation-tree-collapse-btn:hover {
    color: #1a2332;
}

.vt-chevron {
    font-size: 0.75rem;
    color: #7a8a9e;
    transition: color 0.15s ease;
}

.variation-tree-collapse-body {
    padding: 0 12px 12px;
}

/* Fullscreen mode (toggled by #tree-expand-btn). */
.variation-tree-collapse.expanded {
    position: fixed;
    top: 60px;
    left: 20px;
    right: 20px;
    height: calc(100vh - 120px);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(26,35,50,0.04);
    display: flex;
    flex-direction: column;
}

.variation-tree-collapse.expanded .variation-tree-collapse-body {
    flex: 1;
    display: block !important;
    min-height: 0;
}

.variation-tree-collapse.expanded .variation-tree-wrapper {
    height: 100%;
}

.tree-expand-btn {
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 4px;
    color: #4a5568;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tree-expand-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    color: #1a2332;
}

.tree-expand-btn svg {
    transition: transform 0.3s ease;
}

.variation-tree-collapse.expanded .tree-expand-btn svg {
    transform: rotate(180deg);
}

.variation-tree-wrapper {
    height: 320px;
    background: rgba(26, 35, 50, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(91, 155, 213, 0.03);
    overflow: hidden;
    position: relative;
    contain: layout style paint;
}

/* Ensure all tree interactions are contained */
.variation-tree-wrapper * {
    contain: layout style;
}

/* Add backdrop for expanded mode */
.variation-tree-collapse.expanded::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: -1;
}

.variation-item {
    background: rgba(240, 244, 248, 0.65);
    border: 1px solid #dce3eb;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.variation-item:hover {
    background: #ffffff;
    border-color: rgba(91, 155, 213, 0.3);
    transform: translateY(-1px);
}

.clickable-variation {
    cursor: pointer;
    transition: all 0.2s ease;
}

.clickable-variation:hover {
    background: rgba(91, 155, 213, 0.15) !important;
    border-color: rgba(91, 155, 213, 0.5) !important;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

.clickable-variation:active {
    transform: translateY(0) scale(0.98);
    background: rgba(91, 155, 213, 0.25) !important;
}

.variation-move {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.variation-stats {
    font-size: 0.75rem;
    color: #7a8a9e;
}

/* Master Games Styles */
.master-games {
    margin-bottom: 20px;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.master-game-item {
    background: rgba(240, 244, 248, 0.65);
    border: 1px solid #dce3eb;
    border-radius: 8px;
    padding: 10px 12px;
    transition: background 0.18s ease, border-color 0.18s ease,
                transform 0.18s ease, box-shadow 0.18s ease;
    cursor: pointer;
}

.master-game-item:hover {
    background: #ffffff;
    border-color: rgba(91, 155, 213, 0.45);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(45, 55, 72, 0.08);
}

.master-game-item.selected {
    background: #ffffff;
    border-color: #5b9bd5;
    box-shadow: 0 0 0 1px rgba(91, 155, 213, 0.35);
}

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

.white-player, .black-player {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.85rem;
}

.game-result {
    font-weight: 700;
    color: #4a5568;
    font-size: 0.82rem;
    padding: 2px 8px;
    background: rgba(45, 55, 72, 0.07);
    border-radius: 10px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.game-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #7a8a9e;
}

.game-event {
    flex: 1;
    margin-right: 8px;
}

.game-year {
    color: #7a8a9e;
}

.game-eco {
    color: rgba(217, 83, 79, 0.7);
    font-weight: 500;
    margin-left: 8px;
}

.games-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 8px;
}

.pagination-btn {
    background: rgba(217, 83, 79, 0.2);
    border: 1px solid rgba(217, 83, 79, 0.4);
    color: rgba(217, 83, 79, 0.9);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.pagination-btn:hover {
    background: rgba(217, 83, 79, 0.3);
    border-color: rgba(217, 83, 79, 0.6);
    transform: translateY(-1px);
}

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

.page-info {
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
}

.game-placeholder {
    text-align: center;
    color: #7a8a9e;
    font-style: italic;
    padding: 20px;
}

/* Statistics Section */
.statistics-section {
    margin-top: 20px;
    margin-bottom: 20px;
}

.statistics-header {
    margin-bottom: 12px;
}

.statistics-header h4 {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.total-games {
    color: #7a8a9e;
    font-size: 0.8rem;
}

.results-chart {
    margin-bottom: 12px;
}

.result-bar {
    display: flex;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
    margin-bottom: 6px;
}

.white-bar {
    background: linear-gradient(90deg, #f8f9fa, #e9ecef);
    transition: width 0.5s ease;
}

.draw-bar {
    background: linear-gradient(90deg, #6c757d, #495057);
    transition: width 0.5s ease;
}

.black-bar {
    background: linear-gradient(90deg, #343a40, #212529);
    transition: width 0.5s ease;
}

.result-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.white-label {
    color: rgba(248, 249, 250, 0.9);
}

.draw-label {
    color: rgba(108, 117, 125, 0.9);
}

.black-label {
    color: rgba(52, 58, 64, 0.9);
}

.rating-info {
    margin-bottom: 12px;
}

.avg-rating {
    color: rgba(217, 83, 79, 0.8);
    font-size: 0.8rem;
    font-weight: 500;
}

.popular-moves h5 {
    color: #4a5568;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
}

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

.popular-move-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: rgba(240, 244, 248, 0.65);
    border-radius: 4px;
    font-size: 0.75rem;
}

.move-san {
    font-weight: 600;
    color: #4a5568;
    min-width: 40px;
}

.move-popularity {
    color: #7a8a9e;
    flex: 1;
    text-align: center;
}

.move-score {
    color: rgba(91, 155, 213, 0.85);
    font-weight: 500;
    min-width: 40px;
    text-align: right;
}

.stats-placeholder {
    text-align: center;
    color: #7a8a9e;
    font-style: italic;
    padding: 15px;
    font-size: 0.8rem;
}

/* Notes Section */
.notes-section {
    flex: 0 0 350px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Engine Toggle Header - Metallic Finish */
.engine-toggles-header {
    background: linear-gradient(135deg, 
        rgba(120, 120, 120, 0.4), 
        rgba(80, 80, 80, 0.3),
        rgba(140, 140, 140, 0.2)
    );
    /* backdrop-filter removed for light theme */
    border-radius: 16px;
    border: 2px solid rgba(160, 160, 160, 0.4);
    padding: 20px;
    box-shadow: 
        inset 0 2px 0 rgba(91, 155, 213, 0.06),
        inset 0 -2px 0 rgba(240, 244, 248, 0.65),
        0 8px 24px #ffffff;
}

.engine-toggle-container {
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

/* Engine Settings Panel */
.engine-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dce3eb;
}

.engine-type-select {
    background: #ffffff;
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #1a2332;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.engine-type-select:hover {
    border-color: #7a8a9e;
}

.engine-type-select:focus {
    outline: none;
    border-color: #5b9bd5;
}

.engine-type-select option {
    background: #f0f4f8;
    color: #1a2332;
}

.depth-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.depth-control label {
    font-size: 0.75rem;
    color: #4a5568;
    font-weight: 500;
}

#depth-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(91, 155, 213, 0.06);
    border-radius: 2px;
    cursor: pointer;
}

#depth-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #5b9bd5;
    cursor: pointer;
    box-shadow: 0 0 4px rgba(91, 155, 213, 0.5);
}

#depth-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #5b9bd5;
    cursor: pointer;
    border: none;
}

#depth-value {
    min-width: 24px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #5b9bd5;
}

.engine-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 4px;
    border-radius: 8px;
}

.engine-toggle:hover {
    background: rgba(91, 155, 213, 0.04);
    transform: translateY(-1px);
}

/* Circular Metallic Buttons */
.circular-button {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, 
        rgba(180, 180, 180, 0.6), 
        rgba(120, 120, 120, 0.5),
        rgba(80, 80, 80, 0.6)
    );
    border: 1px solid rgba(200, 200, 200, 0.4);
    box-shadow: 
        inset 0 1px 3px #a0aec0,
        inset 0 -1px 3px rgba(240, 244, 248, 0.65),
        0 2px 6px rgba(26, 35, 50, 0.04);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.button-inner {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: linear-gradient(135deg, 
        rgba(160, 160, 160, 0.8), 
        rgba(100, 100, 100, 0.9)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.button-icon {
    font-size: 10px;
    font-weight: bold;
    color: rgba(40, 40, 40, 0.9);
    text-shadow: 0 1px 2px #a0aec0;
    transition: all 0.3s ease;
}

.toggle-label {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(240, 244, 248, 0.65);
    user-select: none;
    transition: all 0.3s ease;
}

/* Stockfish Active State - Pink Pulsation */
.engine-toggle.active .stockfish-button {
    background: linear-gradient(135deg, 
        rgba(217, 83, 79, 0.9), 
        rgba(180, 65, 62, 0.8),
        rgba(160, 50, 48, 0.9)
    );
    border-color: rgba(217, 83, 79, 0.8);
    animation: pink-pulse 2s ease-in-out infinite;
    box-shadow: 
        inset 0 3px 6px #a0aec0,
        inset 0 -3px 6px rgba(240, 244, 248, 0.65),
        0 0 20px rgba(217, 83, 79, 0.6);
}

.engine-toggle.active .stockfish-button .button-inner {
    background: linear-gradient(135deg, 
        rgba(217, 83, 79, 0.9), 
        rgba(217, 83, 79, 0.8)
    );
}

.engine-toggle.active .stockfish-button .button-icon {
    color: rgba(140, 35, 35, 1);
    text-shadow: 0 0 4px rgba(91, 155, 213, 0.3);
}

/* Leela Active State - Sky Blue Pulsation */
.engine-toggle.active .leela-button {
    background: linear-gradient(135deg, 
        rgba(91, 155, 213, 0.9), 
        rgba(58, 124, 192, 0.8),
        rgba(30, 80, 140, 0.9)
    );
    border-color: rgba(91, 155, 213, 0.8);
    animation: blue-pulse 2s ease-in-out infinite;
    box-shadow: 
        inset 0 3px 6px #a0aec0,
        inset 0 -3px 6px rgba(240, 244, 248, 0.65),
        0 0 20px rgba(91, 155, 213, 0.6);
}

.engine-toggle.active .leela-button .button-inner {
    background: linear-gradient(135deg, 
        rgba(91, 155, 213, 0.9), 
        rgba(91, 155, 213, 0.8)
    );
}

.engine-toggle.active .leela-button .button-icon {
    color: rgba(30, 80, 140, 1);
    text-shadow: 0 0 4px rgba(91, 155, 213, 0.3);
}

/* Pulsation Animations */
@keyframes pink-pulse {
    0%, 100% {
        box-shadow: 
            inset 0 3px 6px #a0aec0,
            inset 0 -3px 6px rgba(240, 244, 248, 0.65),
            0 0 20px rgba(217, 83, 79, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 
            inset 0 3px 6px rgba(91, 155, 213, 0.15),
            inset 0 -3px 6px rgba(26, 35, 50, 0.04),
            0 0 30px rgba(217, 83, 79, 0.8);
        transform: scale(1.05);
    }
}

@keyframes blue-pulse {
    0%, 100% {
        box-shadow: 
            inset 0 3px 6px #a0aec0,
            inset 0 -3px 6px rgba(240, 244, 248, 0.65),
            0 0 20px rgba(91, 155, 213, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 
            inset 0 3px 6px rgba(91, 155, 213, 0.15),
            inset 0 -3px 6px rgba(26, 35, 50, 0.04),
            0 0 30px rgba(91, 155, 213, 0.8);
        transform: scale(1.05);
    }
}

/* Hover Effects */
.circular-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        inset 0 3px 6px rgba(91, 155, 213, 0.2),
        inset 0 -3px 6px rgba(240, 244, 248, 0.65),
        0 6px 16px #ffffff;
}

.engine-toggle.active .toggle-label {
    text-shadow: 0 0 8px rgba(91, 155, 213, 0.15);
}

.notes-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.master-games, .common-mistakes {
    background: rgba(91, 155, 213, 0.03);
    /* backdrop-filter removed for light theme */
    border-radius: 8px;
    border: 1px solid #dce3eb;
    padding: 15px;
}

.master-games h4, .common-mistakes h4 {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

/* Data source indicator for master games */
.data-source {
    font-size: 0.7rem;
    font-weight: 400;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.data-source.source-local {
    background: rgba(92, 184, 92, 0.2);
    color: #5cb85c;
    border: 1px solid rgba(92, 184, 92, 0.4);
}

.data-source.source-lichess {
    background: rgba(201, 168, 76, 0.2);
    color: #c9a84c;
    border: 1px solid rgba(201, 168, 76, 0.4);
}

.games-count {
    font-weight: 400;
    color: #7a8a9e;
    font-size: 0.85rem;
}

/* Novelties Section */
/* --- Master-DB move explorer --- */
.explorer-panel {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #dce3eb;
    padding: 12px 15px;
    margin-top: 15px;
}

.explorer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.explorer-header h4 {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.explorer-caret {
    color: #7a8a9e;
    font-size: 0.85rem;
    transition: transform 0.15s ease;
}

.explorer-panel.collapsed .explorer-caret { transform: rotate(-90deg); }
.explorer-panel.collapsed .explorer-body { display: none; }

.explorer-body { margin-top: 10px; }

.explorer-placeholder {
    color: #7a8a9e;
    font-size: 0.85rem;
    text-align: center;
    padding: 8px;
}

.explorer-total {
    color: #7a8a9e;
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.explorer-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.explorer-row {
    display: grid;
    grid-template-columns: 48px 96px 1fr;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.explorer-move {
    font-family: 'SF Mono', Consolas, monospace;
    font-weight: 600;
    color: #1a2332;
    font-size: 0.9rem;
}

.explorer-count {
    font-size: 0.78rem;
    color: #4a5568;
    white-space: nowrap;
}

.explorer-pct { color: #7a8a9e; }

.wdl-bar {
    display: flex;
    height: 16px;
    border-radius: 3px;
    overflow: hidden;
    background: #eef2f6;
    font-size: 0.62rem;
    line-height: 16px;
    text-align: center;
}

.wdl-white { background: #e8edf2; color: #4a5568; }
.wdl-draw  { background: #b7c1cc; color: #2a3340; }
.wdl-black { background: #41505f; color: #f0f3f6; }

.novelties-section {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #dce3eb;
    padding: 15px;
    margin-top: 15px;
}

.novelties-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.novelties-header h4 {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.novelty-count {
    color: #7a8a9e;
    font-weight: 600;
    font-size: 0.85rem;
}

.novelties-caret {
    color: #7a8a9e;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    margin-bottom: 10px;
}

.novelties-section.collapsed .novelties-caret {
    transform: rotate(-90deg);
}

.novelties-section.collapsed .novelties-list {
    display: none;
}

.novelties-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.novelties-placeholder {
    color: #7a8a9e;
    font-size: 0.85rem;
    text-align: center;
    padding: 10px;
}

.novelty-item {
    background: rgba(91, 155, 213, 0.03);
    border-radius: 6px;
    padding: 12px;
    border-left: 3px solid #5cb85c;
}

.novelty-item.recommended {
    border-left-color: #2e9e5b;
    background: rgba(46, 158, 91, 0.06);
}

.novelty-item.playable {
    border-left-color: #d6a533;
    background: rgba(214, 165, 51, 0.06);
}

.novelty-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.novelty-move {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a2332;
}

.novelty-type-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.novelty-item.recommended .novelty-type-badge {
    background: rgba(46, 158, 91, 0.18);
    color: #2e9e5b;
}

.novelty-item.playable .novelty-type-badge {
    background: rgba(214, 165, 51, 0.2);
    color: #b9871f;
}

.novelty-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: #4a5568;
}

.novelty-eval {
    color: #5cb85c;
}

.novelty-freq {
    color: #7a8a9e;
}

.novelty-reason {
    font-size: 0.8rem;
    color: #7a8a9e;
    line-height: 1.4;
}

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

.mistakes-toggle-container {
    display: flex;
    align-items: center;
}

.mistakes-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.mistakes-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #7a8a9e;
}

.mistakes-control select {
    padding: 3px 6px;
    border: 1px solid #cdd6e0;
    border-radius: 5px;
    background: #fff;
    color: #4a5568;
    font-size: 0.78rem;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(91, 155, 213, 0.06);
    border: 1px solid #a0aec0;
    border-radius: 24px;
    transition: all 0.3s ease;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: rgba(91, 155, 213, 0.3);
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(26, 35, 50, 0.04);
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(91, 155, 213, 0.15);
    border-color: #7a8a9e;
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background: rgba(91, 155, 213, 0.35);
    box-shadow: 0 2px 8px rgba(91, 155, 213, 0.15);
}

/* Master games header + "upsets only" toggle */
.master-games-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.upsets-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.upsets-toggle-label {
    font-size: 0.78rem;
    color: #7a8a9e;
    white-space: nowrap;
}

/* Upset badge on a master-game item */
.upset-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(135deg, #e0625c, #c9443e);
    border: 1px solid rgba(201, 68, 62, 0.6);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(201, 68, 62, 0.3);
    white-space: nowrap;
}

/* Marks a master game that carries move-by-move annotations */
.annotated-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(135deg, #6fae6a, #4f9148);
    border: 1px solid rgba(79, 145, 72, 0.6);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(79, 145, 72, 0.3);
    white-space: nowrap;
}

body.ds-dark .annotated-badge {
    color: #e8f5e9;
    background: linear-gradient(135deg, #3d7a38, #2f5e2b);
    border-color: rgba(111, 174, 106, 0.5);
    box-shadow: none;
}

/* Compact opening profile line for the current position's dominant ECO */
.opening-profile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 6px 10px;
    font-size: 0.76rem;
    color: #5a6b7e;
    background: rgba(91, 155, 213, 0.06);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.opening-profile .op-eco {
    font-weight: 700;
    color: #4a5568;
}

.opening-profile .op-sep {
    color: #b8c2cc;
}

.opening-profile .op-upsets {
    color: #b94a44;
}

/* Result filter segmented control (All / 1-0 / ½-½ / 0-1) for master games */
.result-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.result-filter button {
    padding: 3px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #7a8a9e;
    background: rgba(91, 155, 213, 0.06);
    border: 1px solid #dce3eb;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.result-filter button:hover {
    background: rgba(91, 155, 213, 0.12);
    color: #4a5568;
}

.result-filter button.active {
    color: #ffffff;
    background: #5b9bd5;
    border-color: #5b9bd5;
}

.game-placeholder {
    color: #7a8a9e;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

#notes-textarea {
    width: 100%;
    min-height: 120px;
    background: #ffffff;
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #4a5568;
    padding: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
}

#notes-textarea::placeholder {
    color: #7a8a9e;
}

.save-notes-btn {
    background: rgba(217, 83, 79, 0.2);
    border: 1px solid rgba(217, 83, 79, 0.4);
    border-radius: 6px;
    color: rgba(217, 83, 79, 0.9);
    cursor: pointer;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.save-notes-btn:hover {
    background: rgba(217, 83, 79, 0.3);
    border-color: rgba(217, 83, 79, 0.6);
    color: rgba(217, 83, 79, 1);
}

/* Exported Lines Styles */
.exported-lines-container {
    width: 100%;
    max-width: 1000px;
    margin: 40px 0;
}

.no-lines-message {
    text-align: center;
    padding: 60px 20px;
    color: #7a8a9e;
}

.no-lines-message svg {
    margin-bottom: 20px;
}

.no-lines-message h3 {
    font-size: 1.5rem;
    color: #4a5568;
    margin-bottom: 10px;
}

.no-lines-message p {
    font-size: 1rem;
    color: #7a8a9e;
}

.exported-lines-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.exported-line-item {
    background: rgba(91, 155, 213, 0.03);
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.exported-line-item:hover {
    background: rgba(91, 155, 213, 0.04);
    border-color: rgba(91, 155, 213, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 35, 50, 0.04);
}

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

.line-opening {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(91, 155, 213, 0.95);
}

.line-date {
    font-size: 0.85rem;
    color: #7a8a9e;
}

.line-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.line-action-btn {
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #4a5568;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.line-action-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    color: #1a2332;
}

.delete-btn:hover {
    background: rgba(217, 83, 79, 0.2);
    border-color: rgba(217, 83, 79, 0.4);
    color: rgba(217, 83, 79, 0.9);
}

.study-btn {
    background: rgba(91, 155, 213, 0.2);
    border-color: rgba(91, 155, 213, 0.4);
    color: rgba(91, 155, 213, 0.95);
}

.study-btn:hover {
    background: rgba(91, 155, 213, 0.3);
    border-color: rgba(91, 155, 213, 0.6);
    color: rgba(91, 155, 213, 1);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glow {
    from {
        text-shadow: none;
    }
    to {
        text-shadow: none;
    }
}

/* Engine Analysis Section */
.engine-section {
    flex: 0 0 320px; /* Increased width for more content */
    display: flex;
    flex-direction: column;
    background: rgba(91, 155, 213, 0.04);
    /* backdrop-filter removed for light theme */
    border-radius: 15px;
    border: 1px solid #dce3eb;
    overflow: hidden;
}

.engine-header {
    padding: 20px;
    border-bottom: 1px solid #dce3eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.engine-header h3 {
    color: #1a2332;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.engine-toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.engine-toggle-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 8px;
    color: #1a2332;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.engine-toggle-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    border-color: #a0aec0;
    transform: translateY(-1px);
}

.engine-toggle-btn.active {
    background: rgba(91, 155, 213, 0.2);
    border-color: rgba(91, 155, 213, 0.5);
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

.toggle-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(91, 155, 213, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.toggle-indicator::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: rgba(91, 155, 213, 0.04);
    opacity: 0;
    transition: all 0.3s ease;
}

.engine-toggle-btn.active .toggle-indicator {
    background: #d9534f;
    box-shadow: 0 0 8px rgba(217, 83, 79, 0.6);
}

.engine-toggle-btn.active .toggle-indicator::before {
    opacity: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.5); opacity: 0; }
}

.toggle-text {
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
}

input:checked + .engine-slider {
    background-color: rgba(91, 155, 213, 0.6);
    border-color: rgba(91, 155, 213, 0.8);
}

input:checked + .engine-slider:before {
    transform: translateX(20px);
}

.engine-status {
    color: #4a5568;
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 30px;
}

.engine-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.engine-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: #4a5568;
    font-size: 0.9rem;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(91, 155, 213, 0.12);
    border-top: 3px solid rgba(91, 155, 213, 0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.engine-analysis {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.evaluation-display {
    background: #ffffff;
    border-radius: 8px;
    padding: 15px;
}

.eval-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(240, 244, 248, 0.65);
    border-radius: 8px;
    padding: 16px;
}

.eval-bar {
    flex: 1;
    height: 2px;
    background: #a0aec0;
    border-radius: 1px;
    position: relative;
    overflow: hidden;
}

.eval-bar::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -2px;
    width: 1px;
    height: 6px;
    background: rgba(91, 155, 213, 0.25);
    transform: translateX(-50%);
}

.eval-bar-fill {
    height: 100%;
    background: white;
    border-radius: 1px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    transform-origin: center;
}

.eval-score {
    color: #1a2332;
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 50px;
    text-align: right;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
}

.engine-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.candidate-moves, .principal-variation {
    background: rgba(240, 244, 248, 0.65);
    border-radius: 8px;
    padding: 12px;
}

.candidate-moves label, .principal-variation label {
    display: block;
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.candidates-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.candidate-move {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(91, 155, 213, 0.03);
    border-radius: 6px;
    border: 1px solid #dce3eb;
    transition: all 0.2s ease;
}

.candidate-move:hover {
    background: rgba(91, 155, 213, 0.04);
    border-color: #dce3eb;
}

.candidate-move.best {
    background: rgba(217, 83, 79, 0.1);
    border-color: rgba(217, 83, 79, 0.3);
    box-shadow: 0 0 8px rgba(217, 83, 79, 0.2);
}

.candidate-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.candidate-rank {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(91, 155, 213, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #1a2332;
}

.candidate-move.best .candidate-rank {
    background: rgba(217, 83, 79, 0.8);
}

.candidate-san {
    color: #1a2332;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
    min-width: 40px;
}

.candidate-eval {
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.candidate-move.best .candidate-eval {
    color: rgba(217, 83, 79, 1);
    font-weight: 600;
}

.candidate-placeholder {
    color: #7a8a9e;
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
    font-style: italic;
}

#pv-display {
    color: #1a2332;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.engine-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat {
    background: rgba(240, 244, 248, 0.65);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.stat label {
    display: block;
    color: #4a5568;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat span {
    color: #1a2332;
    font-weight: 600;
    font-size: 0.9rem;
}

.engine-disabled {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.disabled-message {
    text-align: center;
    color: #7a8a9e;
    max-width: 200px;
}

.disabled-message svg {
    margin-bottom: 15px;
}

.disabled-message p {
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
}

/* Chessboard Section */
.chessboard-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 500px;
    height: calc(100vh - 40px);
}

.chessboard-header {
    background: rgba(91, 155, 213, 0.06);
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    border-radius: 12px 12px 0 0;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chessboard-header h2 {
    color: #1a2332;
    font-size: 1.8rem;
    font-family: 'Cormorant Garamond', cursive;
    font-weight: 400;
    text-shadow: none;
}

.game-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.turn-indicator {
    color: #4a5568;
    font-size: 0.9rem;
    padding: 6px 12px;
    background: rgba(91, 155, 213, 0.04);
    border-radius: 20px;
    border: 1px solid #dce3eb;
}

/* Music Control - Bottom Right */
.music-control {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom));
    right: calc(30px + env(safe-area-inset-right));
    z-index: 1000;
}

.music-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(91, 155, 213, 0.04);
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    color: #1a2332;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.music-toggle:hover {
    background: rgba(91, 155, 213, 0.06);
    transform: scale(1.05);
}

.music-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: rgba(255,255,255,0.95);
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    border-radius: 12px;
    padding: 20px;
    min-width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.music-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.track-info {
    margin-bottom: 15px;
}

.track-name {
    color: #1a2332;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

.music-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 4px;
    background: rgba(91, 155, 213, 0.06);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
}

.track-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.track-btn, .mute-btn {
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #1a2332;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.track-btn:hover, .mute-btn:hover {
    background: rgba(91, 155, 213, 0.06);
}

/* Brightness Control - Bottom Left */
.brightness-control {
    position: fixed;
    bottom: 30px;
    left: 30px;
    display: flex;
    align-items: center;
    z-index: 1000;
}

.brightness-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    color: #4a5568;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.brightness-toggle:hover {
    background: rgba(255,255,255,0.85);
    color: #1a2332;
    border-color: #a0aec0;
    transform: scale(1.05);
}

.brightness-panel {
    position: absolute;
    bottom: 75px; /* Moved up from 55px */
    left: 0;
    width: 297px; /* 220px * 1.35 = 297px (35% wider) */
    background: transparent; /* Remove black background */
    border: none;
    border-radius: 0;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1001;
}

.brightness-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.brightness-controls {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap for better spacing */
}

.brightness-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brightness-label {
    color: #1a2332;
    font-size: 0.75rem;
    min-width: 70px;
    font-weight: 400;
    text-transform: lowercase;
}

.brightness-slider {
    flex: 1;
    height: 2px;
    background: rgba(91, 155, 213, 0.06);
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
    border: none;
}

.brightness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
    border: none;
}

.brightness-slider::-webkit-slider-thumb:hover {
    background: rgba(91, 155, 213, 0.3);
    transform: scale(1.1);
}

.brightness-slider::-webkit-slider-thumb:active {
    transform: scale(1.05);
}

.brightness-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #5b9bd5 0%, #94a7b8 100%);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(91, 155, 213, 0.3);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(91, 155, 213, 0.3);
}

.brightness-slider::-moz-range-thumb:hover {
    background: linear-gradient(135deg, #94a7b8 0%, #5b9bd5 100%);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(91, 155, 213, 0.5);
}

.brightness-slider::-moz-range-track {
    height: 8px;
    background: rgba(91, 155, 213, 0.06);
    border-radius: 4px;
    border: 1px solid #dce3eb;
}

.brightness-value {
    color: #4a5568;
    font-size: 0.75rem;
    min-width: 35px;
    text-align: right;
    font-weight: 400;
    background: none;
    padding: 0;
    border-radius: 0;
    border: none;
}

.chessboard-container {
    flex: 1;
    background: rgba(91, 155, 213, 0.06);
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    border-radius: 0 0 12px 12px;
    border-top: none;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Chessboard */
.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(80vh, 720px);
    height: min(80vh, 720px);
    border: 2px solid #dce3eb;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(26,35,50,0.08);
}

/* Engine recommendation highlights */
.chess-square.engine-highlight {
    background-color: rgba(92, 184, 92, 0.4) !important;
    box-shadow: inset 0 0 0 3px rgba(92, 184, 92, 0.8);
    animation: engine-pulse 2s ease-in-out infinite;
}

.chess-square.engine-highlight-from {
    /* From square - slightly more intense */
    background-color: rgba(92, 184, 92, 0.5) !important;
    box-shadow: inset 0 0 0 3px rgba(92, 184, 92, 0.9);
}

.chess-square.engine-highlight-to {
    /* To square - destination highlight */
    background-color: rgba(92, 184, 92, 0.4) !important;
    box-shadow: inset 0 0 0 3px rgba(92, 184, 92, 0.7);
}

@keyframes engine-pulse {
    0%, 100% {
        box-shadow: inset 0 0 0 3px rgba(92, 184, 92, 0.8);
    }
    50% {
        box-shadow: inset 0 0 0 3px rgba(92, 184, 92, 1);
    }
}

.chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    /* backdrop-filter removed for light theme */
}

.chess-piece {
    width: 80%;
    height: 80%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.chess-square:hover .chess-piece {
    transform: scale(1.1);
}

.chess-piece:active {
    cursor: grabbing;
}

.chess-piece:hover {
    cursor: grab;
}

/* Drag ghost styling */
#drag-ghost {
    cursor: grabbing !important;
    pointer-events: none;
}

/* Piece sprites provided by base.css */

.chess-square.light {
    background: var(--sq-light, #eae6df);
    /* backdrop-filter removed for light theme */
}

.chess-square.dark {
    background: var(--sq-dark, #94a7b8);
    /* backdrop-filter removed for light theme */
}

.chess-square:hover {
    background: rgba(91, 155, 213, 0.3) !important;
    transform: scale(1.05);
}

.chess-square.selected {
    background: rgba(91, 155, 213, 0.5) !important;
    box-shadow: inset 0 0 0 3px rgba(91, 155, 213, 0.8);
}

.chess-square.possible-move {
    background: rgba(92, 184, 92, 0.3) !important;
}

.chess-square.possible-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(92, 184, 92, 0.6);
    border-radius: 50%;
}

/* Drag hover highlighting */
.chess-square.drag-hover {
    background: rgba(201, 168, 76, 0.5) !important; /* Yellow highlight */
    box-shadow: inset 0 0 0 3px rgba(201, 168, 76, 0.8);
    animation: dragHover 0.3s ease-in-out;
}

@keyframes dragHover {
    from { 
        background: rgba(201, 168, 76, 0.2) !important;
        box-shadow: inset 0 0 0 1px rgba(201, 168, 76, 0.4);
    }
    to { 
        background: rgba(201, 168, 76, 0.5) !important;
        box-shadow: inset 0 0 0 3px rgba(201, 168, 76, 0.8);
    }
}

/* Move Navigation Controls */
.move-navigation {
    margin-top: 20px;
    padding: 15px;
    background: rgba(91, 155, 213, 0.04);
    border-radius: 10px;
    border: 1px solid #dce3eb;
}

.nav-header {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
    text-align: center;
}

.nav-header span:first-child {
    font-size: 14px;
    color: #4a5568;
    font-weight: 500;
}

#selected-line-display {
    font-size: 13px;
    color: #1a2332;
    font-family: 'Courier New', monospace;
    background: #ffffff;
    padding: 8px;
    border-radius: 5px;
    word-break: break-all;
    line-height: 1.4;
}

.nav-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
}

.nav-btn {
    background: rgba(91, 155, 213, 0.06);
    border: 1px solid #a0aec0;
    color: #1a2332;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: rgba(91, 155, 213, 0.08);
    border-color: #7a8a9e;
    transform: translateY(-1px);
}

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

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.move-counter {
    text-align: center;
    font-size: 12px;
    color: #4a5568;
    font-weight: 500;
}

/* Practice mode hint highlighting */
.chess-square.hint-from {
    background: rgba(201, 168, 76, 0.4) !important;
    box-shadow: inset 0 0 0 3px rgba(201, 168, 76, 0.8);
    animation: hintPulse 1s ease-in-out infinite alternate;
}

.chess-square.hint-to {
    background: rgba(40, 167, 69, 0.4) !important;
    box-shadow: inset 0 0 0 3px rgba(40, 167, 69, 0.8);
    animation: hintPulse 1s ease-in-out infinite alternate;
}

@keyframes hintPulse {
    from {
        box-shadow: inset 0 0 0 3px rgba(201, 168, 76, 0.8);
    }
    to {
        box-shadow: inset 0 0 0 3px rgba(201, 168, 76, 1);
    }
}

/* Board Controls */
.board-controls {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Move Navigation Controls */
.move-navigation-controls {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
    padding: 12px;
    background: rgba(240, 244, 248, 0.65);
    border-radius: 8px;
    border: 1px solid #dce3eb;
    visibility: visible !important;
    opacity: 1 !important;
}

.nav-arrow-btn {
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #4a5568;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.nav-arrow-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    border-color: #a0aec0;
    color: #1a2332;
    transform: scale(1.05);
}

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

.nav-arrow-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.nav-arrow-btn:disabled:hover {
    background: rgba(91, 155, 213, 0.04);
    border-color: #dce3eb;
    color: #4a5568;
    transform: none;
}

.move-counter {
    color: #4a5568;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0 12px;
    min-width: 100px;
    text-align: center;
}

/* Export Controls */
.export-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dce3eb;
    display: flex;
    justify-content: center;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(91, 155, 213, 0.2);
    border: 1px solid rgba(91, 155, 213, 0.4);
    border-radius: 6px;
    color: rgba(91, 155, 213, 0.95);
    cursor: pointer;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.export-btn:hover {
    background: rgba(91, 155, 213, 0.3);
    border-color: rgba(91, 155, 213, 0.6);
    color: rgba(91, 155, 213, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

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

.export-btn svg {
    transition: transform 0.3s ease;
}

.export-btn:hover svg {
    transform: scale(1.1);
}

/* Game Annotations */
.game-annotations {
    margin-top: 10px;
    background: rgba(217, 83, 79, 0.1);
    /* backdrop-filter removed for light theme */
    border-radius: 8px;
    border: 1px solid rgba(217, 83, 79, 0.2);
    padding: 12px;
    height: 180px;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    overflow-y: auto;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Custom scrollbar for game annotations */
.game-annotations::-webkit-scrollbar {
    width: 8px;
}

.game-annotations::-webkit-scrollbar-track {
    background: #f0f4f8;
    border-radius: 4px;
}

.game-annotations::-webkit-scrollbar-thumb {
    background: #cdd6e0;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.game-annotations::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.game-annotations::-webkit-scrollbar-corner {
    background: transparent;
}

.annotations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #dce3eb;
}

.annotations-header h4 {
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 400;
    margin: 0;
    text-transform: lowercase;
}

.annotations-count {
    color: #7a8a9e;
    font-size: 0.7rem;
    font-weight: 300;
}

.annotations-content {
    color: #4a5568;
    font-size: 0.75rem;
    line-height: 1.3;
}

.annotations-placeholder {
    color: #7a8a9e;
    font-style: italic;
    text-align: center;
    padding: 15px 10px;
    font-size: 0.7rem;
}

.move-annotation {
    margin-bottom: 6px;
    padding: 6px 8px;
    background: rgba(217, 83, 79, 0.05);
    border-radius: 4px;
    border-left: 2px solid rgba(217, 83, 79, 0.3);
}

.move-number {
    color: rgba(217, 83, 79, 0.9);
    font-weight: 500;
    margin-right: 6px;
    font-size: 0.75rem;
}

.move-notation {
    color: #4a5568;
    font-weight: 400;
    margin-right: 6px;
    font-size: 0.75rem;
}

.move-evaluation {
    color: #7a8a9e;
    font-size: 0.65rem;
    margin-left: 6px;
}

.move-comment {
    color: #4a5568;
    font-size: 0.7rem;
    margin-top: 3px;
    font-style: italic;
}

.control-btn {
    padding: 10px 20px;
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 8px;
    color: #1a2332;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    transform: translateY(-1px);
}

body.ds-dark .control-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: #3a4759;
    color: #e2e8f0;
}

body.ds-dark .control-btn:hover {
    background: rgba(143, 192, 240, 0.16);
    border-color: #5b9bd5;
}

.hyperfocus-btn {
    background: rgba(255,255,255,0.92);
    /* backdrop-filter removed for light theme */
    border: 1px solid rgba(240, 244, 248, 0.65);
    border-radius: 0;
    color: #1a2332;
}

.hyperfocus-btn:hover {
    background: rgba(240,244,248,0.9);
    border-color: rgba(255,255,255,0.92);
    transform: translateY(-1px);
}

/* Engine Analysis Highlights */
.engine-glow-piece {
    box-shadow: 0 0 15px rgba(217, 83, 79, 0.8), 0 0 25px rgba(217, 83, 79, 0.6) !important;
    border-radius: 50%;
    animation: engineGlow 2s ease-in-out infinite alternate;
}

.engine-highlight-square {
    background-color: rgba(217, 83, 79, 0.4) !important;
    box-shadow: inset 0 0 20px rgba(217, 83, 79, 0.6);
    animation: enginePulse 2s ease-in-out infinite alternate;
}

@keyframes engineGlow {
    0% {
        box-shadow: 0 0 15px rgba(217, 83, 79, 0.8), 0 0 25px rgba(217, 83, 79, 0.6);
    }
    100% {
        box-shadow: 0 0 20px rgba(217, 83, 79, 1), 0 0 35px rgba(217, 83, 79, 0.8);
    }
}

@keyframes enginePulse {
    0% {
        background-color: rgba(217, 83, 79, 0.3);
        box-shadow: inset 0 0 15px rgba(217, 83, 79, 0.5);
    }
    100% {
        background-color: rgba(217, 83, 79, 0.5);
        box-shadow: inset 0 0 25px rgba(217, 83, 79, 0.7);
    }
}

/* Chat Section */
.chat-section {
    flex: 1;
    max-width: 450px;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    background: rgba(91, 155, 213, 0.06);
    /* backdrop-filter removed for light theme */
    border: 1px solid #dce3eb;
    border-radius: 12px;
    overflow: hidden;
}

.chat-header {
    background: rgba(91, 155, 213, 0.04);
    padding: 20px;
    border-bottom: 1px solid #dce3eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.tab-btn {
    padding: 8px 16px;
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 20px;
    color: #4a5568;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    color: #4a5568;
}

.tab-btn.active {
    background: rgba(91, 155, 213, 0.3);
    border-color: rgba(91, 155, 213, 0.5);
    color: #1a2332;
}

.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
}

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

.chat-header h3 {
    color: #1a2332;
    font-size: 1.2rem;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4a5568;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #5b9bd5;
    border-radius: 50%;
    animation: skyBluePulse 2s infinite;
    box-shadow: 0 1px 3px rgba(26,35,50,0.05);
}

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

@keyframes skyBluePulse {
    0% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 1px 3px rgba(26,35,50,0.05);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
        box-shadow: 0 2px 6px rgba(26,35,50,0.08);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 1px 3px rgba(26,35,50,0.05);
    }
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 0; /* Force flex child to respect parent height */
}

/* Explorer Styles */
.explorer-header {
    padding: 15px 20px;
    border-bottom: 1px solid #dce3eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.position-info {
    flex: 1;
}

.opening-name {
    display: block;
    color: #1a2332;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.eco-code {
    color: #7a8a9e;
    font-size: 0.8rem;
    font-weight: 500;
}

.practice-btn {
    padding: 8px 12px;
    background: rgba(91, 155, 213, 0.6);
    border: 1px solid rgba(91, 155, 213, 0.8);
    border-radius: 8px;
    color: #1a2332;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.practice-btn:hover:not(:disabled) {
    background: rgba(91, 155, 213, 0.8);
    transform: translateY(-1px);
}

.practice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(91, 155, 213, 0.04);
    border-color: #dce3eb;
}

.explorer-stats {
    padding: 20px;
    border-bottom: 1px solid #dce3eb;
}

.stats-loading {
    text-align: center;
    color: #7a8a9e;
    font-size: 0.9rem;
    font-style: italic;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: rgba(91, 155, 213, 0.03);
    border-radius: 8px;
    border: 1px solid #dce3eb;
}

.stat-value {
    display: block;
    color: #1a2332;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-label {
    color: #4a5568;
    font-size: 0.8rem;
}

.win-rate-bar {
    height: 6px;
    background: rgba(91, 155, 213, 0.04);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 10px;
}

.win-rate-fill {
    height: 100%;
    background: linear-gradient(90deg, #5cb85c 0%, #c9a84c 50%, #d9534f 100%);
    transition: width 0.5s ease;
}

.explorer-moves {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.move-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: rgba(91, 155, 213, 0.03);
    border: 1px solid #dce3eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.move-item:hover {
    background: rgba(91, 155, 213, 0.04);
    border-color: rgba(91, 155, 213, 0.3);
    transform: translateX(4px);
}

.move-item.selected {
    background: rgba(91, 155, 213, 0.2);
    border-left: 3px solid rgba(91, 155, 213, 0.8);
    transform: translateX(5px);
}

.move-item.selected:hover {
    background: rgba(91, 155, 213, 0.25);
}

.move-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.move-san {
    color: #1a2332;
    font-size: 1rem;
    font-weight: 600;
    min-width: 40px;
}

.move-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.move-games {
    color: #4a5568;
    font-size: 0.85rem;
}

.move-percentage {
    color: #7a8a9e;
    font-size: 0.75rem;
}

.move-winrate {
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f0f4f8;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cdd6e0;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.3s ease-out;
}

.ai-message {
    gap: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(91, 155, 213, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: rgba(91, 155, 213, 0.3);
}

.ai-message .message-avatar {
    display: none;
}

.message-content {
    flex: 1;
}

.message-text {
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 12px;
    padding: 12px 16px;
    color: #1a2332;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

.user-message .message-text {
    background: rgba(91, 155, 213, 0.2);
    border-color: rgba(91, 155, 213, 0.3);
}

.ai-message .message-text {
    background: rgba(91, 155, 213, 0.15);
    border-color: rgba(91, 155, 213, 0.25);
    /* backdrop-filter removed for light theme */
}

.message-time {
    color: #7a8a9e;
    font-size: 0.75rem;
    padding-left: 16px;
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid #dce3eb;
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 25px;
    color: #1a2332;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

#chat-input::placeholder {
    color: #7a8a9e;
}

#chat-input:focus {
    border-color: rgba(91, 155, 213, 0.5);
    background: rgba(91, 155, 213, 0.06);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(91, 155, 213, 0.6);
    border: 1px solid rgba(91, 155, 213, 0.8);
    color: #1a2332;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-btn:hover {
    background: rgba(91, 155, 213, 0.8);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Design */
/* Deep Study's container is .deep-study-interface (a row of analysis /
   board / notes columns). Below ~1200px stack them so the fixed-width
   side columns and 500px-min board no longer force horizontal overflow. */
@media (max-width: 1200px) {
    .deep-study-interface {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        /* Clear the fixed Home button + iOS status bar in the stacked layout. */
        padding-top: calc(80px + env(safe-area-inset-top));
    }

    .analysis-section,
    .notes-section {
        flex: none;
        width: 100%;
        max-width: none;
    }

    .chessboard-section {
        min-width: auto;
        flex: 1;
    }

    .chessboard {
        width: min(85vw, 600px);
        height: min(85vw, 600px);
    }
}

@media (max-width: 768px) {
    .deep-study-interface {
        padding: 15px;
        gap: 15px;
        padding-top: calc(80px + env(safe-area-inset-top));
    }

    .chessboard {
        width: min(90vw, 500px);
        height: min(90vw, 500px);
    }

    .chess-square {
        font-size: 1.8rem;
    }

    .analysis-section,
    .notes-section,
    .chessboard-section {
        min-width: auto;
        width: 100%;
    }

    /* Trim board-panel padding so the bordered container stays within 100vw. */
    .chessboard-container { padding: 14px; }

    /* Comfortable thumb targets for move navigation + annotation swatches. */
    .nav-arrow-btn { min-width: 40px; height: 40px; }
    .review-controls .nav-arrow-btn { min-width: 40px; height: 40px; }
    .mm-swatch { width: 28px; height: 28px; }
    .context-menu-colors { gap: 10px; }
}

/* Common Mistakes Styles */
.mistakes-placeholder {
    color: #7a8a9e;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.mistakes-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4a5568;
    font-size: 0.85rem;
    padding: 15px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #a0aec0;
    border-top: 2px solid rgba(91, 155, 213, 0.3);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.mistake-item {
    background: rgba(255, 69, 0, 0.1);
    border: 1px solid rgba(255, 69, 0, 0.3);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.mistake-item:hover {
    background: rgba(255, 69, 0, 0.15);
    border-color: rgba(255, 69, 0, 0.4);
}

.mistake-move {
    font-weight: 600;
    color: rgba(255, 99, 71, 1);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.mistake-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #4a5568;
}

.mistake-frequency {
    color: rgba(255, 215, 0, 0.9);
}

.mistake-eval-drop {
    color: rgba(255, 69, 0, 0.9);
    font-weight: 500;
}

.mistake-description {
    font-size: 0.75rem;
    color: #7a8a9e;
    margin-top: 4px;
    font-style: italic;
}

/* Mistake move highlights */
.chess-square.mistake-highlight {
    background-color: rgba(255, 69, 0, 0.4) !important;
    box-shadow: inset 0 0 0 3px rgba(255, 69, 0, 0.8);
    animation: mistake-pulse 2s ease-in-out infinite;
}

.chess-square.mistake-highlight-from {
    /* From square - more intense red */
    background-color: rgba(255, 69, 0, 0.5) !important;
    box-shadow: inset 0 0 0 3px rgba(255, 69, 0, 0.9);
}

.chess-square.mistake-highlight-to {
    /* To square - destination highlight */
    background-color: rgba(255, 69, 0, 0.4) !important;
    box-shadow: inset 0 0 0 3px rgba(255, 69, 0, 0.7);
}

@keyframes mistake-pulse {
    0%, 100% {
        box-shadow: inset 0 0 0 3px rgba(255, 69, 0, 0.8);
    }
    50% {
        box-shadow: inset 0 0 0 3px rgba(255, 69, 0, 1);
    }
}

/* Theme toggle provided by base.css */

/* ---------------------------------------------------------------------------
   AI Coach panel (deep-analysis page)
--------------------------------------------------------------------------- */
.ai-coach {
    background: rgba(91, 155, 213, 0.03);
    border-radius: 8px;
    border: 1px solid #dce3eb;
    padding: 15px;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
}

.coach-header h4 {
    color: #4a5568;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.coach-context-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 10px;
}

.coach-ctx {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #5a6b7e;
    cursor: pointer;
    user-select: none;
}

.coach-ctx input {
    accent-color: #5b9bd5;
    cursor: pointer;
}

.coach-messages {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px;
    margin-bottom: 10px;
}

.coach-placeholder {
    color: #7a8a9e;
    font-size: 0.85rem;
    text-align: center;
    padding: 16px 8px;
}

.coach-message {
    font-size: 0.85rem;
    line-height: 1.45;
    padding: 8px 11px;
    border-radius: 10px;
    max-width: 92%;
    word-wrap: break-word;
}

.coach-message p {
    margin: 0 0 6px 0;
}

.coach-message p:last-child {
    margin-bottom: 0;
}

.coach-message-user {
    align-self: flex-end;
    background: #5b9bd5;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.coach-message-ai {
    align-self: flex-start;
    background: #f1f5fa;
    color: #2d3a48;
    border: 1px solid #dce3eb;
    border-bottom-left-radius: 3px;
}

.coach-input-row {
    display: flex;
    gap: 8px;
}

.coach-input-row input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #dce3eb;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #2d3a48;
    background: #fff;
    outline: none;
}

.coach-input-row input:focus {
    border-color: #5b9bd5;
}

.coach-input-row button {
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    background: #5b9bd5;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.coach-input-row button:hover {
    background: #4a86c0;
}


/* ============================================
   INLINE ANNOTATIONS PANEL (master games)
   ============================================ */

.game-annotations-panel {
    margin-top: 12px;
    background: rgba(240, 244, 248, 0.65);
    border: 1px solid #dce3eb;
    border-radius: 8px;
    overflow: hidden;
}

.annotations-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(217, 83, 79, 0.08);
    border-bottom: 1px solid #dce3eb;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
    flex-wrap: wrap;
    gap: 6px;
}

.annotations-panel-close {
    border: none;
    background: transparent;
    color: #7a8a9e;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s ease;
}

.annotation-translate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 8px;
}

.annotation-lang {
    font-size: 0.72rem;
    color: #4a5568;
    background: #fff;
    border: 1px solid #dce3eb;
    border-radius: 10px;
    padding: 2px 6px;
    cursor: pointer;
}

.annotation-translate-btn {
    border: 1px solid rgba(91, 155, 213, 0.5);
    background: rgba(91, 155, 213, 0.12);
    color: #3a6ea5;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.annotation-translate-btn:hover { background: rgba(91, 155, 213, 0.22); }
.annotation-translate-btn:disabled { opacity: 0.6; cursor: default; }

.am-comment-translated {
    text-decoration: underline dotted rgba(91, 155, 213, 0.6);
    text-underline-offset: 2px;
}

.annotations-panel-close:hover {
    color: rgba(217, 83, 79, 0.9);
}

.annotations-panel-body {
    padding: 12px;
    max-height: 320px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #4a5568;
    word-break: break-word;
}

.am-num {
    color: #7a8a9e;
    font-weight: 600;
    margin-right: 2px;
}

.am-move {
    color: #2d3748;
    font-weight: 600;
}

.am-result {
    color: rgba(217, 83, 79, 0.9);
    font-weight: 700;
}

.am-nag {
    color: rgba(217, 83, 79, 0.9);
    font-weight: 700;
    margin-left: 1px;
}

.am-comment {
    color: #5b7a52;
    font-style: italic;
}

.am-variation {
    color: #6a7488;
}

.am-variation .am-move {
    color: #4a5568;
    font-weight: 500;
}

.am-noann {
    color: #7a8a9e;
    font-style: italic;
    margin-bottom: 8px;
}

/* Currently-reviewed move highlight */
.am-move.am-current {
    background: rgba(91, 155, 213, 0.22);
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(91, 155, 213, 0.45);
    padding: 0 2px;
}

/* ===== Master-game review controls ===== */
.review-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(240, 244, 248, 0.5);
    border-bottom: 1px solid #dce3eb;
}

.review-controls .nav-arrow-btn {
    padding: 2px 6px;
    font-size: 0.8rem;
    line-height: 1.2;
}

.review-move-counter {
    margin-left: auto;
    font-size: 0.78rem;
    color: #7a8a9e;
    font-weight: 600;
}

.return-to-study-btn {
    margin-left: auto;
    margin-right: 8px;
    border: 1px solid rgba(91, 155, 213, 0.5);
    background: rgba(91, 155, 213, 0.12);
    color: #3a6ea5;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.return-to-study-btn:hover {
    background: rgba(91, 155, 213, 0.22);
}

/* ===== Engine panel (VPS) — bottom of the left analysis pane ===== */
.engine-panel {
    margin-top: 16px;
    background: #ffffff;
    border: 1px solid #dce3eb;
    border-radius: 10px;
    overflow: hidden;
}

.engine-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(91, 155, 213, 0.06);
    border-bottom: 1px solid #dce3eb;
}

.engine-panel-header h4 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: #2d3748;
}

.engine-depth-control {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 0.72rem;
    color: #7a8a9e;
}

.engine-depth-control input[type="range"] {
    width: 80px;
}

.engine-analyze-btn {
    border: 1px solid rgba(91, 155, 213, 0.5);
    background: rgba(91, 155, 213, 0.12);
    color: #3a6ea5;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.engine-analyze-btn:hover { background: rgba(91, 155, 213, 0.22); }

.engine-analyze-btn.active {
    background: #d9534f;
    border-color: #d9534f;
    color: #fff;
}

.engine-panel-body {
    display: flex;
    gap: 12px;
    padding: 12px;
}

.engine-eval-bar {
    position: relative;
    width: 14px;
    min-height: 96px;
    border-radius: 7px;
    background: #2d3748;
    overflow: hidden;
    flex: 0 0 auto;
}

.engine-eval-fill {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    background: #f0f4f8;
    transition: height 0.3s ease;
}

.engine-readout {
    flex: 1 1 auto;
    min-width: 0;
}

.engine-score-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.engine-score {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2d3748;
    font-variant-numeric: tabular-nums;
}

.engine-depth-label {
    font-size: 0.72rem;
    color: #7a8a9e;
}

.engine-assess {
    font-size: 0.76rem;
    color: #5a6b7e;
    margin-bottom: 8px;
}
.engine-assess:empty { margin-bottom: 0; }

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

.engine-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.engine-line-rank {
    width: 16px;
    color: #a0aec0;
    font-weight: 600;
    text-align: center;
    flex: 0 0 auto;
}

.engine-line-move {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-weight: 600;
    color: #2d3748;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.engine-line-eval {
    color: #5b9bd5;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}

.engine-empty {
    font-size: 0.78rem;
    color: #7a8a9e;
    font-style: italic;
}

/* ===== Load more master games ===== */
.load-more-games-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid #dce3eb;
    border-radius: 8px;
    background: rgba(91, 155, 213, 0.06);
    color: #3a6ea5;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.load-more-games-btn:hover { background: rgba(91, 155, 213, 0.14); }
.load-more-games-btn:disabled { opacity: 0.6; cursor: default; }

/* ===== Opening Plans (insights panel + annotated arrows) ===== */

.plan-insights {
    background: #fbfcfe;
    border: 1px solid #dce3eb;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

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

.plan-insights-header h4 {
    margin: 0;
    color: #4a5568;
    font-size: 0.95rem;
}

.plan-arrows-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #7a8a9e;
    cursor: pointer;
}

.plan-insights-body .plan-summary {
    color: #3a4658;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 12px;
    padding: 10px 12px;
    background: rgba(91, 155, 213, 0.07);
    border: 1px solid rgba(91, 155, 213, 0.16);
    border-radius: 10px;
}

.plan-block {
    position: relative;
    padding: 9px 12px 10px;
    margin-bottom: 8px;
    background: rgba(15, 30, 50, 0.03);
    border: 1px solid rgba(15, 30, 50, 0.08);
    border-left: 3px solid #cbd5e1;
    border-radius: 10px;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.plan-block:hover {
    background: rgba(15, 30, 50, 0.05);
}

.plan-block p {
    margin: 4px 0 0;
    color: #3a4658;
    font-size: 0.86rem;
    line-height: 1.45;
}

.plan-tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(15, 30, 50, 0.06);
    color: #4a5568;
}

.plan-win {
    border-left-color: rgba(46, 160, 67, 0.8);
}

.plan-win .plan-tag {
    background: rgba(46, 160, 67, 0.14);
    color: rgba(38, 130, 55, 0.98);
}

.plan-loss {
    border-left-color: rgba(217, 83, 79, 0.8);
}

.plan-loss .plan-tag {
    background: rgba(217, 83, 79, 0.14);
    color: rgba(190, 60, 56, 0.98);
}

.plan-strategy {
    border-left-color: rgba(91, 155, 213, 0.8);
}

.plan-strategy .plan-tag {
    background: rgba(91, 155, 213, 0.16);
    color: rgba(58, 112, 170, 0.98);
}

.plan-meta {
    margin: 8px 0 0;
    color: #7a8a9e;
    font-size: 0.74rem;
}

/* "Show plans" CTA shown when Auto plans is off */
.plan-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: rgba(91, 155, 213, 0.06);
    border: 1px dashed rgba(91, 155, 213, 0.3);
    border-radius: 10px;
}

.plan-cta-text {
    margin: 0;
    color: #7a8a9e;
    font-size: 0.84rem;
}

/* Header toggle group + Auto-plans toggle */
.plan-header-toggles {
    display: flex;
    align-items: center;
    gap: 12px;
}

.plan-enable-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #7a8a9e;
    cursor: pointer;
}

.plan-empty,
.plan-loading {
    color: #7a8a9e;
    font-size: 0.84rem;
    font-style: italic;
}

.generate-plans-btn {
    margin-top: 8px;
    padding: 8px 16px;
    border: 1px solid rgba(91, 155, 213, 0.5);
    border-radius: 8px;
    background: rgba(91, 155, 213, 0.12);
    color: #3a70aa;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.generate-plans-btn:hover:not(:disabled) {
    background: rgba(91, 155, 213, 0.22);
    border-color: rgba(91, 155, 213, 0.75);
    transform: translateY(-1px);
}

.generate-plans-btn:disabled,
.generate-plans-btn.plan-generating {
    opacity: 0.65;
    cursor: progress;
}

/* SVG arrow overlay, positioned over the board inside .chessboard-container */
#plan-arrows,
#best-move-arrow {
    position: absolute;
    pointer-events: none;
    z-index: 30;
}

/* Modern plan arrows: soft glow + gentle fade-in so they don't pop. */
#plan-arrows line,
#best-move-arrow line {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
    stroke-linejoin: round;
    animation: planArrowIn 0.22s ease-out both;
}

@keyframes planArrowIn {
    from { opacity: 0; }
    to { opacity: 0.92; }
}

.plan-arrow-label {
    fill: #2d3748;
    font-size: 11px;
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 3.5px;
    stroke-linejoin: round;
}

/* ---- Stale-while-revalidate: dim panels while refreshing (no flash) ---- */
.master-games-list,
.explorer-body,
#plan-insights-body,
.variations-display,
#opening-profile {
    transition: opacity 0.18s ease;
}

.master-games-list.is-updating,
.explorer-body.is-updating,
#plan-insights-body.is-updating,
.variations-display.is-updating,
#opening-profile.is-updating {
    opacity: 0.55;
}

/* ---- Move Explorer: "best move" highlight + badge ---- */
.explorer-best-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    margin-right: 10px;
    font-size: 0.76rem;
    color: #7a8a9e;
    cursor: pointer;
}

.explorer-row.best-move {
    background: rgba(91, 155, 213, 0.12);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(91, 155, 213, 0.35);
}

.explorer-best-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(91, 155, 213, 0.18);
    color: #3a70aa;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ===========================================================================
   Dedicated Deep-Study dark / minimalist mode (body.ds-dark, driven by the
   shared light/dark toggle in theme.js). Flat, muted surfaces — no gradients
   or heavy shadows.
   =========================================================================== */
.home-button-container { display: flex; align-items: center; gap: 10px; }

/* --- Page base --- */
body.ds-dark { background: #000000; }
body.ds-dark .background-image { background-image: none; background: #000000; }
body.ds-dark .background-overlay { background: #000000; opacity: 1; }

body.ds-dark .home-header h1 { color: #e2e8f0; text-shadow: none; }
body.ds-dark .home-header p { color: #94a7b8; }

/* --- Panels / cards / headers (flatten to solid dark) --- */
body.ds-dark .selected-line-info,
body.ds-dark .line-notation,
body.ds-dark .theory-section,
body.ds-dark .variations-section,
body.ds-dark .variation-tree-collapse,
body.ds-dark .master-games,
body.ds-dark .common-mistakes,
body.ds-dark .chessboard-header,
body.ds-dark .chessboard-container,
body.ds-dark .ai-coach,
body.ds-dark .novelties-section,
body.ds-dark .explorer-panel,
body.ds-dark .plan-insights {
    background: #181818;
    border-color: #2a2a2a;
    box-shadow: none;
}

body.ds-dark .explorer-header h4 { color: #e2e8f0; }
body.ds-dark .explorer-move { color: #e2e8f0; }
body.ds-dark .explorer-count { color: #cdd9e5; }
body.ds-dark .explorer-pct,
body.ds-dark .explorer-total,
body.ds-dark .explorer-placeholder { color: #94a7b8; }
body.ds-dark .wdl-bar { background: #101010; }
body.ds-dark .wdl-white { background: #cdd9e5; color: #1a2332; }
body.ds-dark .wdl-draw  { background: #6b7785; color: #f0f3f6; }
body.ds-dark .wdl-black { background: #1f2730; color: #cdd9e5; }

body.ds-dark .novelties-header h4 { color: #e2e8f0; }
body.ds-dark .novelty-count,
body.ds-dark .novelties-caret { color: #94a7b8; }
body.ds-dark .novelty-move { color: #e2e8f0; }
body.ds-dark .novelty-stats,
body.ds-dark .novelty-reason,
body.ds-dark .novelties-placeholder { color: #94a7b8; }
body.ds-dark .novelty-item.recommended {
    background: rgba(46, 158, 91, 0.12);
    border-left-color: #34b86a;
}
body.ds-dark .novelty-item.playable {
    background: rgba(214, 165, 51, 0.12);
    border-left-color: #e0b341;
}

body.ds-dark .engine-toggles-header {
    background: #181818;
    border: 1px solid #2a2a2a;
    box-shadow: none;
}

body.ds-dark .analysis-header {
    background: rgba(91, 155, 213, 0.12);
    border-color: rgba(91, 155, 213, 0.28);
}

/* --- Text --- */
body.ds-dark .chessboard-header h2 { color: #e2e8f0; text-shadow: none; }
body.ds-dark .line-notation,
body.ds-dark .theory-section h4,
body.ds-dark .variations-section h4,
body.ds-dark .theory-content,
body.ds-dark .master-games h4,
body.ds-dark .common-mistakes h4,
body.ds-dark .white-player,
body.ds-dark .black-player,
body.ds-dark .turn-indicator,
body.ds-dark .plan-insights-header h4 { color: #e2e8f0; }

body.ds-dark .game-details,
body.ds-dark .games-count,
body.ds-dark .upsets-toggle-label,
body.ds-dark .plan-arrows-toggle-wrap,
body.ds-dark .am-noann { color: #94a7b8; }

body.ds-dark .opening-profile .op-eco { color: #cdd9e5; }

/* --- Board --- */
/* Keep the board in its normal (light) colours in dark mode — only the
   surrounding UI goes dark (mirrors Mastermind's study/dark behaviour). */
body.ds-dark .chessboard { box-shadow: 0 2px 12px rgba(0,0,0,0.5); }

/* --- Master games list --- */
body.ds-dark .master-game-item {
    background: #101010;
    border-color: #2a2a2a;
}
body.ds-dark .master-game-item:hover {
    background: #1f1f1f;
    border-color: rgba(91, 155, 213, 0.5);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}
body.ds-dark .master-game-item.selected {
    background: #1f1f1f;
    border-color: #5b9bd5;
    box-shadow: 0 0 0 1px rgba(91, 155, 213, 0.45);
}
body.ds-dark .game-result {
    background: rgba(226, 232, 240, 0.1);
    color: #cdd9e5;
}
body.ds-dark .game-year,
body.ds-dark .game-rating { color: #8a94a8; }
body.ds-dark .game-placeholder { color: #6a7888; }

/* --- Opening profile line --- */
body.ds-dark .opening-profile {
    background: rgba(91, 155, 213, 0.08);
    border-color: #2a2a2a;
    color: #94a7b8;
}

/* --- Result filter chips --- */
body.ds-dark .result-filter button {
    background: #101010;
    border-color: #2a2a2a;
    color: #94a7b8;
}
body.ds-dark .result-filter button:hover { background: #1f1f1f; color: #cdd9e5; }
body.ds-dark .result-filter button.active {
    background: #5b9bd5;
    border-color: #5b9bd5;
    color: #000000;
}

/* --- Buttons / controls --- */
body.ds-dark .back-to-lines-btn,
body.ds-dark .pagination-btn {
    background: #101010;
    border-color: #2a2a2a;
    color: #cdd9e5;
}
body.ds-dark .back-to-lines-btn:hover,
body.ds-dark .pagination-btn:hover { background: #1f1f1f; color: #ffffff; }

/* --- Toggle switch track (unchecked) --- */
body.ds-dark .toggle-slider { background: #2a2a2a; }

/* --- Plan insights --- */
body.ds-dark .plan-insights { background: #101010; }
body.ds-dark .plan-summary,
body.ds-dark .plan-block p { color: #cdd9e5; }
body.ds-dark .plan-insights-body .plan-summary {
    background: rgba(91, 155, 213, 0.1);
    border-color: rgba(91, 155, 213, 0.22);
}
body.ds-dark .plan-block {
    background: rgba(226, 232, 240, 0.03);
    border-color: #2a2a2a;
    border-left-color: #2a2a2a;
}
body.ds-dark .plan-block:hover { background: rgba(226, 232, 240, 0.06); }
body.ds-dark .plan-strategy { border-left-color: rgba(91, 155, 213, 0.6); }
body.ds-dark .plan-tag { background: rgba(226, 232, 240, 0.08); color: #b6c2d0; }
body.ds-dark .plan-win .plan-tag { background: rgba(46, 160, 67, 0.2); color: #6fd98a; }
body.ds-dark .plan-loss .plan-tag { background: rgba(217, 83, 79, 0.2); color: #f08f8b; }
body.ds-dark .plan-strategy .plan-tag { background: rgba(91, 155, 213, 0.2); color: #8fc0f0; }
body.ds-dark .plan-meta { color: #94a7b8; }
body.ds-dark .plan-cta {
    background: rgba(91, 155, 213, 0.08);
    border-color: rgba(91, 155, 213, 0.35);
}
body.ds-dark .plan-cta-text { color: #94a7b8; }
body.ds-dark .plan-enable-toggle,
body.ds-dark .explorer-best-toggle { color: #94a7b8; }
body.ds-dark .explorer-row.best-move {
    background: rgba(91, 155, 213, 0.16);
    box-shadow: inset 0 0 0 1px rgba(91, 155, 213, 0.45);
}
body.ds-dark .explorer-best-badge {
    background: rgba(91, 155, 213, 0.24);
    color: #8fc0f0;
}
body.ds-dark .plan-arrow-label {
    fill: #e2e8f0;
    stroke: rgba(10, 14, 20, 0.85);
}

/* --- Scrollbars --- */
body.ds-dark .games-list::-webkit-scrollbar-thumb,
body.ds-dark .analysis-content::-webkit-scrollbar-thumb {
    background: #2a2a2a;
}
body.ds-dark .games-list::-webkit-scrollbar-track,
body.ds-dark .analysis-content::-webkit-scrollbar-track {
    background: #101010;
}

/* --- Annotations panel + review controls --- */
body.ds-dark .game-annotations-panel {
    background: #101010;
    border-color: #2a2a2a;
}
body.ds-dark .annotations-panel-header {
    background: rgba(217, 83, 79, 0.12);
    border-bottom-color: #2a2a2a;
    color: #cdd9e5;
}
body.ds-dark .annotation-lang {
    background: #101010;
    border-color: #2a2a2a;
    color: #cdd9e5;
}
body.ds-dark .annotation-translate-btn {
    background: rgba(91, 155, 213, 0.18);
    border-color: rgba(91, 155, 213, 0.5);
    color: #8fc0f0;
}
body.ds-dark .annotation-translate-btn:hover { background: rgba(91, 155, 213, 0.3); }
body.ds-dark .am-comment-translated { text-decoration-color: rgba(91, 155, 213, 0.7); }
body.ds-dark .annotations-panel-body { color: #b6c2d0; }
body.ds-dark .am-num { color: #6a7888; }
body.ds-dark .am-move { color: #e2e8f0; }
body.ds-dark .am-comment { color: #8fb98a; }
body.ds-dark .am-variation { color: #8a94a8; }
body.ds-dark .am-variation .am-move { color: #b6c2d0; }
body.ds-dark .review-controls {
    background: rgba(30, 40, 50, 0.6);
    border-bottom-color: #2a2a2a;
}
body.ds-dark .review-move-counter { color: #94a7b8; }
body.ds-dark .am-move.am-current {
    background: rgba(91, 155, 213, 0.3);
    box-shadow: 0 0 0 1px rgba(91, 155, 213, 0.6);
}
body.ds-dark .return-to-study-btn {
    background: rgba(91, 155, 213, 0.18);
    border-color: rgba(91, 155, 213, 0.5);
    color: #8fc0f0;
}
body.ds-dark .return-to-study-btn:hover { background: rgba(91, 155, 213, 0.3); }

/* --- Engine panel --- */
body.ds-dark .engine-panel {
    background: #101010;
    border-color: #2a2a2a;
}
body.ds-dark .engine-panel-header {
    background: rgba(91, 155, 213, 0.1);
    border-bottom-color: #2a2a2a;
}
body.ds-dark .engine-panel-header h4 { color: #e2e8f0; }
body.ds-dark .engine-depth-control { color: #94a7b8; }
body.ds-dark .engine-analyze-btn {
    background: rgba(91, 155, 213, 0.18);
    border-color: rgba(91, 155, 213, 0.5);
    color: #8fc0f0;
}
body.ds-dark .engine-analyze-btn:hover { background: rgba(91, 155, 213, 0.3); }
body.ds-dark .engine-analyze-btn.active {
    background: #d9534f;
    border-color: #d9534f;
    color: #fff;
}
body.ds-dark .engine-eval-bar { background: #000000; }
body.ds-dark .engine-eval-fill { background: #e2e8f0; }
body.ds-dark .engine-score { color: #e2e8f0; }
body.ds-dark .engine-depth-label { color: #94a7b8; }
body.ds-dark .engine-assess { color: #a8b6c6; }
body.ds-dark .engine-line-rank { color: #6a7888; }
body.ds-dark .engine-line-move { color: #cdd9e5; }
body.ds-dark .engine-line-eval { color: #8fc0f0; }
body.ds-dark .engine-empty { color: #94a7b8; }

/* --- Load more --- */
body.ds-dark .load-more-games-btn {
    background: rgba(91, 155, 213, 0.1);
    border-color: #2a2a2a;
    color: #8fc0f0;
}
body.ds-dark .load-more-games-btn:hover { background: rgba(91, 155, 213, 0.2); }

/* ============================================================
   Modern aesthetic pass — Sora brand headings
   ============================================================ */
.home-header h1,
.analysis-header h3,
.engine-header h3,
.chessboard-header h2,
.chat-header h3 {
    font-family: var(--font-brand);
    letter-spacing: -0.01em;
}

/* ============================================================
   Editable repertoire notation — move tree, comments, context
   menu, highlights (ported from Mastermind; ds-dark variants).
   ============================================================ */
.annotations-placeholder {
    color: rgba(26, 35, 50, 0.45);
    font-style: italic;
    text-align: center;
    padding: 24px 16px;
    font-size: 0.8rem;
    width: 100%;
}

.move-number {
    color: rgba(91, 155, 213, 0.7);
    font-weight: 500;
    font-size: 0.72rem;
    font-feature-settings: 'tnum';
    margin-right: 2px;
}

.move-item {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: #1a2332;
    margin: 1px 0;
}
.move-item:hover {
    background: rgba(91, 155, 213, 0.25);
    color: #1a2332;
    transform: translateY(-1px);
}
.move-item.active {
    background: linear-gradient(135deg, rgba(91, 155, 213, 0.5) 0%, rgba(91, 155, 213, 0.4) 100%);
    color: #1a2332;
    box-shadow: 0 2px 8px rgba(26, 35, 50, 0.06);
}
.move-item.in-path {
    background: rgba(91, 155, 213, 0.15);
}
/* Pinned ("locked") line: an amber underline runs along every move on it so the
   active blue move and the gold lock emphasis stay distinguishable. */
.move-item.locked-line {
    box-shadow: inset 0 -2px 0 0 rgba(224, 168, 58, 0.85);
    border-radius: 3px;
}
.move-item.active.locked-line {
    box-shadow: 0 2px 8px rgba(26, 35, 50, 0.06), inset 0 -2px 0 0 rgba(224, 168, 58, 0.95);
}
.move-item.white-move { color: #1a2332; }
.move-item.black-move { color: #44505f; }

.move-item.has-variation::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: rgba(91, 155, 213, 0.6);
    border-radius: 50%;
    margin-left: 3px;
    vertical-align: middle;
}

/* Variations — indented block sub-lines */
.variation-line {
    display: block;
    margin: 2px 0 2px 3px;
    padding-left: 10px;
    border-left: 2px solid rgba(91, 155, 213, 0.22);
    line-height: 1.7;
    color: #44505f;
}
.variation-line .move-item {
    font-size: 0.76rem;
    opacity: 0.9;
    padding: 1px 5px;
}
.variation-line .move-item:hover { opacity: 1; }
.variation-line .move-number { font-size: 0.68rem; opacity: 0.75; }
.variation-line .variation-line { border-left-color: rgba(91, 155, 213, 0.16); }

/* Comments */
.move-comment {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    color: #8a6d3b;
    font-style: italic;
    font-size: 0.74rem;
    line-height: 1.3;
    margin: 0 4px 0 1px;
    cursor: text;
    max-width: 100%;
}
.move-comment .comment-text { border-radius: 3px; padding: 0 2px; transition: background 0.15s ease; }
.move-comment .comment-text:hover { background: rgba(138, 109, 59, 0.12); }
.move-comment .comment-toggle {
    cursor: pointer;
    color: rgba(138, 109, 59, 0.7);
    font-style: normal;
    font-size: 0.65rem;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}
.move-comment .comment-toggle.open { transform: rotate(180deg); }

.add-note-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 3px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: rgba(91, 155, 213, 0.8);
    background: rgba(91, 155, 213, 0.12);
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.15s ease;
}
.add-note-btn:hover { background: rgba(91, 155, 213, 0.28); color: #1a2332; }

.comment-edit {
    font-family: inherit;
    font-size: 0.74rem;
    font-style: italic;
    color: #1a2332;
    border: 1px solid rgba(91, 155, 213, 0.5);
    border-radius: 4px;
    padding: 1px 5px;
    margin: 0 4px;
    min-width: 120px;
    background: #fff;
    outline: none;
    box-shadow: 0 1px 4px rgba(26, 35, 50, 0.08);
}

/* Per-move colour highlight tints */
.move-item.mm-hl { border-radius: 4px; }
.move-item.mm-hl-green { background: rgba(58, 157, 74, 0.22); box-shadow: inset 0 0 0 1px rgba(58, 157, 74, 0.5); }
.move-item.mm-hl-red { background: rgba(204, 75, 64, 0.22); box-shadow: inset 0 0 0 1px rgba(204, 75, 64, 0.5); }
.move-item.mm-hl-yellow { background: rgba(224, 168, 58, 0.24); box-shadow: inset 0 0 0 1px rgba(224, 168, 58, 0.55); }
.move-item.mm-hl-blue { background: rgba(59, 130, 196, 0.22); box-shadow: inset 0 0 0 1px rgba(59, 130, 196, 0.5); }

/* Context menu */
.move-context-menu {
    position: fixed;
    display: none;
    flex-direction: column;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 244, 248, 0.98) 100%);
    border: 1px solid rgba(91, 155, 213, 0.25);
    border-radius: 10px;
    padding: 6px;
    min-width: 180px;
    box-shadow: 0 1px 3px rgba(26, 35, 50, 0.05), 0 4px 12px rgba(26, 35, 50, 0.04);
    z-index: 20000;
}
.move-context-menu.visible { display: flex; }
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #44505f;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}
.context-menu-item:hover { background: rgba(91, 155, 213, 0.2); }
.context-menu-item svg { color: rgba(91, 155, 213, 0.7); flex-shrink: 0; }
.context-menu-item.context-menu-danger { color: rgba(248, 113, 113, 0.9); }
.context-menu-item.context-menu-danger:hover { background: rgba(248, 113, 113, 0.15); }
.context-menu-item.context-menu-danger svg { color: rgba(248, 113, 113, 0.7); }
.context-menu-divider { height: 1px; background: rgba(91, 155, 213, 0.12); margin: 4px 8px; }
.context-menu-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(26, 35, 50, 0.45);
    padding: 6px 14px 2px;
}
.context-menu-colors { display: flex; gap: 8px; padding: 4px 14px 8px; }
.mm-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, border-color 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
    color: rgba(26, 35, 50, 0.6);
}
.mm-swatch:hover { transform: scale(1.15); }
.mm-swatch.selected { border-color: #1a2332; }
.mm-sw-green { background: #3a9d4a; }
.mm-sw-red { background: #cc4b40; }
.mm-sw-yellow { background: #e0a83a; }
.mm-sw-blue { background: #3b82c4; }
.mm-sw-none { background: rgba(127, 138, 158, 0.15); border-color: rgba(127, 138, 158, 0.4); }

/* ---- Dark (ds-dark) variants ---- */
body.ds-dark .annotations-placeholder { color: #6b7785; }
body.ds-dark .move-number { color: #6f9fce; }
body.ds-dark .move-item,
body.ds-dark .move-item.white-move { color: #e2e8f0; }
body.ds-dark .move-item.black-move { color: #b3c0cf; }
body.ds-dark .move-item:hover { background: rgba(91, 155, 213, 0.28); color: #ffffff; }
body.ds-dark .move-item.active { color: #ffffff; }
body.ds-dark .variation-line { color: #94a7b8; border-left-color: rgba(91, 155, 213, 0.28); }
body.ds-dark .comment-edit { background: #15171a; color: #e2e8f0; border-color: rgba(91, 155, 213, 0.5); }
body.ds-dark .move-comment { color: #d6b87a; }
body.ds-dark .move-context-menu {
    background: linear-gradient(135deg, #121417 0%, #0c0d0f 100%);
    border-color: #2a2a2a;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
}
body.ds-dark .context-menu-item { color: #cdd9e5; }
body.ds-dark .context-menu-item:hover { background: rgba(91, 155, 213, 0.18); }
body.ds-dark .context-menu-divider { background: #2a2a2a; }
body.ds-dark .context-menu-label { color: #6b7785; }
body.ds-dark .mm-swatch.selected { border-color: #e2e8f0; }
body.ds-dark .add-note-btn { color: #8fc0f0; background: rgba(91, 155, 213, 0.16); }
body.ds-dark .add-note-btn:hover { color: #ffffff; }

/* ============================================================
   Phase 5: Moves panel (under board) + AI Coach + PGN collapse
   ============================================================ */
.moves-panel {
    margin-top: 16px;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}
.moves-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.moves-panel-header h4 {
    font-family: var(--font-brand);
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a2332;
    margin: 0;
}
.moves-panel-hint {
    font-size: 0.7rem;
    color: rgba(26, 35, 50, 0.45);
    font-style: italic;
}
/* Collapse toggle for the moves/annotations list (keeps the panel from pushing
   the page down while arrowing through a long line). */
.annotations-collapse-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(26, 35, 50, 0.5);
    font-size: 0.85rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: transform 0.2s ease, background 0.15s ease, color 0.15s ease;
}
.annotations-collapse-toggle:hover {
    background: rgba(91, 155, 213, 0.12);
    color: #1a2332;
}
.moves-panel.annotations-collapsed .annotations-collapse-toggle {
    transform: rotate(-90deg);
}
.moves-panel.annotations-collapsed .game-annotations {
    display: none;
}
body.ds-dark .annotations-collapse-toggle { color: #8a97a6; }
body.ds-dark .annotations-collapse-toggle:hover { color: #e2e8f0; }

/* Editable line title (the saved name) — looks like the panel title. */
.line-name-title {
    font-family: var(--font-brand);
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a2332;
    cursor: pointer;
    border-radius: 4px;
    padding: 1px 4px;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.line-name-title:hover {
    background: rgba(91, 155, 213, 0.12);
    text-decoration: underline dotted rgba(91, 155, 213, 0.6);
}
.line-name-edit {
    font-family: var(--font-brand);
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a2332;
    border: 1px solid rgba(91, 155, 213, 0.5);
    border-radius: 4px;
    padding: 1px 5px;
    min-width: 160px;
    max-width: 360px;
    background: #fff;
    outline: none;
    box-shadow: 0 1px 4px rgba(26, 35, 50, 0.08);
}
/* Unsaved-changes indicator (amber dot), hidden until dirty. */
.line-dirty-dot {
    display: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e0a83a;
    box-shadow: 0 0 0 2px rgba(224, 168, 58, 0.22);
    flex-shrink: 0;
}
.line-dirty-dot.show { display: inline-block; }
/* Save button — compact blue, pushed to the right edge. */
.notation-save-btn {
    margin-left: auto;
    flex-shrink: 0;
    font-family: var(--font-brand);
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent, #5b9bd5);
    border: 1px solid rgba(91, 155, 213, 0.9);
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
.notation-save-btn:hover { background: #4a8ac4; }
.notation-save-btn:active { transform: translateY(1px); }
.notation-save-btn:disabled {
    background: rgba(91, 155, 213, 0.35);
    border-color: rgba(91, 155, 213, 0.35);
    cursor: default;
    opacity: 0.7;
}
.notation-save-btn.saved {
    background: #3a9d4a;
    border-color: #3a9d4a;
}
/* Override the legacy red-tinted annotations box with a neutral surface and a
   taller, editable area now that it's the primary moves view. */
.moves-panel .game-annotations {
    margin-top: 0;
    background: rgba(91, 155, 213, 0.06);
    border: 1px solid rgba(91, 155, 213, 0.18);
    border-radius: 10px;
    padding: 14px;
    min-height: 120px;
    max-height: 300px;
    height: auto;
    line-height: 1.9;
    font-size: 0.85rem;
}

/* PGN collapse */
.line-notation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    margin-top: 8px;
    padding: 4px 0;
}
.line-notation-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(26, 35, 50, 0.5);
    font-weight: 600;
}
.line-notation-caret {
    color: rgba(26, 35, 50, 0.5);
    transition: transform 0.2s ease;
}
.selected-line-info.pgn-collapsed .line-notation-caret { transform: rotate(-90deg); }
.selected-line-info.pgn-collapsed .line-notation { display: none; }

/* ---- ds-dark variants ---- */
body.ds-dark .moves-panel-header h4 { color: #e2e8f0; }
body.ds-dark .moves-panel-hint { color: #6b7785; }
body.ds-dark .moves-panel .game-annotations {
    background: rgba(91, 155, 213, 0.08);
    border-color: #2a2a2a;
}
body.ds-dark .line-name-title { color: #e2e8f0; }
body.ds-dark .line-name-title:hover {
    background: rgba(91, 155, 213, 0.2);
    text-decoration-color: rgba(91, 155, 213, 0.7);
}
body.ds-dark .line-name-edit {
    color: #e2e8f0;
    background: #1a1f26;
    border-color: rgba(91, 155, 213, 0.6);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
body.ds-dark .notation-save-btn {
    color: #fff;
    background: #4a8ac4;
    border-color: rgba(91, 155, 213, 0.7);
}
body.ds-dark .notation-save-btn:hover { background: #5b9bd5; }
body.ds-dark .notation-save-btn.saved { background: #3a9d4a; border-color: #3a9d4a; }
body.ds-dark .line-notation-label,
body.ds-dark .line-notation-caret { color: #94a7b8; }
