/* For Review */
.container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    margin: 20px auto 0 auto;
    flex: 1;
    min-height: 0;
    height: calc(100% - var(--nav-height, 48px) - 20px);
}

.top-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.bottom-row {
    display: flex;
    gap: 20px;
    flex-grow: 1;
    min-height: 0;
}

.panel {
    border: 2px solid black;
    padding: 10px;
    display: flex;
    box-sizing: border-box;
}

.controls-left {
    flex: 1.618;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.controls-right {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.editor-panel {
    flex: 1.618;
    flex-direction: column;
    height: 100%;
}

.results-panel {
    flex: 1;
    flex-direction: column;
    height: 100%;
    position: relative; /* For Review */
}

.help-btn {
    width: auto;
}

.help-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid black;
    box-sizing: border-box;
}

.help-overlay[hidden] {
    display: none;
}

.help-overlay-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 2px solid black;
    flex-shrink: 0;
}

.help-overlay-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.help-overlay-actions a {
    color: inherit;
}

.help-overlay-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px;
    font-family: sans-serif;
    line-height: 1.45;
}

.help-overlay-body h1 {
    margin-top: 0;
    font-size: 1.2rem;
}

.help-overlay-body h2 {
    font-size: 1.05rem;
}

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

.editor-header-actions {
    display: flex;
    gap: 10px;
}

.llm-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    border: 2px solid black;
    box-sizing: border-box;
}

.llm-panel[hidden] {
    display: none;
}

.llm-cors-note {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.35;
}

.llm-label {
    font-size: 0.9rem;
    font-weight: bold;
}

.llm-endpoint,
.llm-field,
.llm-prompt {
    width: 100%;
    border: 2px solid black;
    padding: 6px 8px;
    font-family: sans-serif;
    font-size: 0.8125rem;
    box-sizing: border-box;
    background: white;
    color: black;
}

.llm-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.llm-field-group {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.llm-prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.llm-prompt {
    font-family: monospace;
    resize: vertical;
    min-height: 200px;
}

#btn-llm-fetch {
    align-self: flex-start;
    width: 120px;
}

.result-buttons {
    display: flex;
    gap: 10px;
}

button,
input[type="file"],
select {
    border: 2px solid black;
    background-color: white;
    color: black;
    padding: 5px 10px;
    font-family: sans-serif;
    cursor: pointer;
}

button {
    border-radius: 6px;
    text-align: center;
}

#btn-copy-code,
#btn-copy-pgn,
#btn-copy-json {
    width: 100px;
}

#btn-start {
    width: 140px;
}

#btn-verify {
    width: 100px;
}

select,
input[type="file"] {
    border-radius: 0;
}

button:hover {
    background-color: black;
    color: white;
}

.code-editor-wrap {
    position: relative;
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.code-editor-wrap pre,
.code-editor-wrap textarea {
    margin: 0;
    padding: 10px;
    border: 2px solid black;
    font-family: monospace;
    font-size: 0.8125rem;
    line-height: 1.4;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    tab-size: 4;
}

.code-editor-wrap pre {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    background-color: white;
}

.code-editor-wrap textarea {
    position: relative;
    z-index: 1;
    flex-grow: 1;
    width: 100%;
    resize: none;
    background: transparent;
    color: transparent;
    caret-color: black;
}

.code-editor-wrap pre code {
    display: block;
    min-height: 100%;
}

.hl-keyword {
    color: #0000cc;
}

.hl-type {
    color: #2b6cb0;
}

.hl-preproc {
    color: #805ad5;
}

.hl-string {
    color: #a31515;
}

.hl-char {
    color: #a31515;
}

.hl-number {
    color: #098658;
}

.hl-comment {
    color: #6a737d;
}

.hl-operator {
    color: #333;
}

.result-content {
    flex-grow: 1;
    border: 2px solid black;
    padding: 10px;
    overflow-y: auto;
    font-family: sans-serif;
    box-sizing: border-box;
}

.pgn-display {
    background-color: #f0f0f0;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    font-family: monospace;
    white-space: pre-wrap;
}

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background-color: black;
    color: white;
    padding: 10px 20px;
    font-family: sans-serif;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

.board-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid black;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    border: 2px solid black;
    margin-bottom: 10px;
}

.chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.square-light {
    background-color: #eee;
}

.square-dark {
    background-color: #999;
}

.chess-piece {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: sans-serif;
    font-weight: bold;
}

.playback-btn {
    width: 80px;
}

.fog-view-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-family: sans-serif;
    font-size: 0.9em;
}

.fog-view-controls[hidden] {
    display: none;
}

.fog-view-controls label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.chess-piece.fog-tile {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

@media (max-width: 900px) {
    .container {
        height: auto;
        min-height: 100vh;
    }

    .top-row,
    .bottom-row {
        flex-direction: column;
    }

    .controls-left,
    .controls-right,
    .editor-panel,
    .results-panel {
        flex: none;
        width: 100%;
    }

    .code-editor-wrap {
        min-height: 400px;
    }

    .results-panel {
        min-height: 400px;
    }

    .chessboard {
        max-width: 100%;
    }
}

@media (max-width: 450px) {
    .playback-controls {
        gap: 4px;
        font-size: 0.9rem;
    }

    .playback-btn {
        width: auto !important;
        padding: 5px 6px;
        font-size: 0.9rem;
    }

    #btn-play-pause {
        width: auto !important;
        min-width: 50px;
    }

    .result-buttons {
        gap: 4px;
    }

    .result-buttons button {
        width: auto !important;
        padding: 5px 6px;
        font-size: 0.85rem;
    }

    .speed-controls {
        gap: 3px !important;
    }

    .speed-btn {
        padding: 4px 5px !important;
        font-size: 0.85rem;
    }

    #move-counter {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .panel-header {
        font-size: 0.9rem;
    }
}