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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.5;
    font-size: 14px;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 9999;
    font-size: 1rem;
    color: #666;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #eee;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Header */
header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    background: #2c3e50;
    color: white;
    gap: 16px;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Main Navigation Tabs */
.main-nav {
    display: flex;
    gap: 4px;
    margin-left: 20px;
}

.nav-tab {
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}

.nav-tab:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.nav-tab.active {
    background: #f0f2f5;
    color: #2c3e50;
}

.nav-tab .badge {
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.header-actions {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

.btn-header {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-header:hover {
    background: #2980b9;
}

.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.85rem;
}

.btn-header:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.nav-link:hover {
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.user-info a {
    color: rgba(255,255,255,0.7);
}

.admin-switcher {
    margin-right: 8px;
}

.btn-admin-switch {
    padding: 4px 10px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-admin-switch:hover {
    background: rgba(255,255,255,0.25);
}

.auth-links {
    display: flex;
    gap: 8px;
}

.signin-btn {
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.8rem;
}

.signin-btn:hover {
    background: rgba(255,255,255,0.2);
}

.session-expired-banner {
    background: #e74c3c;
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Error toast */
.error-toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #e74c3c;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
}

.error-toast button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}

/* Login required screen */
.login-required {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
}

.login-box h2 {
    margin-bottom: 12px;
    color: #2c3e50;
}

.login-box p {
    color: #666;
    margin-bottom: 24px;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-login {
    display: block;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-login.microsoft {
    background: #0078d4;
    color: white;
}

.btn-login.microsoft:hover {
    background: #106ebe;
}

.btn-login.google {
    background: #4285f4;
    color: white;
}

.btn-login.google:hover {
    background: #3367d6;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 99;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Saving indicator */
.saving-indicator {
    color: #3498db;
    font-weight: 500;
}

.sync-status {
    font-size: 0.85rem;
    color: #888;
}

.sync-status.saved {
    color: #27ae60;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow: hidden;
    background: #f0f2f5;
}

/* ============================================
   SOLVER TAB LAYOUT
   ============================================ */
.solver-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    padding: 20px;
    height: 100%;
    overflow: auto;
}

.solver-board-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.solver-controls-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 350px;
    max-width: 500px;
}

.solver-controls-section h2 {
    font-size: 1.1rem;
    margin: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.solver-result {
    background: #f9f9f9;
    border-radius: 6px;
    padding: 16px;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.result-duration {
    color: #666;
    font-size: 0.85rem;
}

.result-output {
    background: #1a1a2e;
    color: #a0ffa0;
    padding: 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    max-height: 60vh;
    min-height: 200px;
    overflow-y: auto;
    margin: 0;
}

.btn-copy {
    padding: 4px 8px;
    font-size: 0.75rem;
    background: #eee;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    margin-left: auto;
}

.btn-copy:hover {
    background: #ddd;
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.solver-empty {
    color: #888;
    text-align: center;
    padding: 40px 20px;
}

.preview-section {
    margin-top: 8px;
}

.conditions-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ============================================
   COMPOSITIONS TAB LAYOUT
   ============================================ */
/* Old grid layout - no longer used */
.compositions-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1px;
    background: #ddd;
}

/* Composition List Panel (old - kept for reference) */
.composition-list-panel {
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Compositions Tab Layout */
.compositions-tab {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Compositions Toolbar */
.compositions-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.toolbar-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
    min-width: 100px;
}

.toolbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-nav .btn-nav {
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.toolbar-nav .btn-nav:hover:not(:disabled) {
    background: #e8e8e8;
}

.toolbar-nav .btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-nav .nav-input {
    width: 60px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
}

.toolbar-nav .nav-input:focus {
    outline: none;
    border-color: #3498db;
}

.toolbar-nav .nav-total {
    color: #666;
    font-size: 0.9rem;
}

.toolbar-nav .dirty-mark {
    color: #e67e22;
    font-weight: bold;
    font-size: 1.1rem;
}

.toolbar-empty {
    color: #888;
    font-size: 0.85rem;
}

.toolbar-spacer {
    flex: 1;
}

.btn-toolbar {
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-toolbar:hover {
    background: #e8e8e8;
}

.btn-toolbar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Export dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    min-width: 200px;
    overflow: hidden;
}

.export-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    transition: background 0.15s;
}

.export-option:hover {
    background: #f5f5f5;
}

.export-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.export-option:not(:last-child) {
    border-bottom: 1px solid #eee;
}

.export-count {
    font-size: 0.8rem;
    color: #888;
}

.composition-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.composition-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.composition-item:hover {
    background: #f5f5f5;
}

.composition-item.selected {
    background: #e8f4fc;
}

.composition-item.dirty {
    background: #fef3e6;
}

.comp-number {
    font-weight: 500;
    color: #666;
    min-width: 32px;
}

.comp-stip {
    color: #888;
    font-size: 0.8rem;
}

.list-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid #eee;
}

.list-actions .btn-primary {
    flex: 1;
}

.list-actions .btn-secondary {
    flex: 1;
}

/* Solution area */
.solution-area {
    display: flex;
    flex-direction: column;
}

.solution-area label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.solution-area textarea {
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    resize: vertical;
}

/* Send to Solver */
.send-to-solver-section {
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.btn-send-solver {
    width: 100%;
    padding: 10px;
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-send-solver:hover {
    background: #8e44ad;
}

/* Linked Tests Section */
.linked-tests-section {
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    margin-bottom: 8px;
}

.section-header .count {
    color: #888;
    font-weight: normal;
}

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

.linked-test-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.linked-test-item:hover {
    background: #eaeaea;
}

.linked-test-item .test-date {
    color: #666;
}

.linked-test-item .test-duration {
    color: #888;
    font-size: 0.8rem;
}

.linked-test-item .test-pool {
    color: #888;
    font-size: 0.75rem;
    padding: 1px 4px;
    background: #e9ecef;
    border-radius: 3px;
}

.btn-unlink {
    margin-left: auto;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
}

.btn-unlink:hover {
    color: #e74c3c;
}

.linked-tests-empty {
    color: #888;
    font-size: 0.85rem;
    padding: 8px 0;
}

.btn-link-test {
    margin-top: 8px;
    padding: 6px 12px;
    background: none;
    border: 1px dashed #ccc;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-link-test:hover {
    border-color: #3498db;
    color: #3498db;
}

/* ============================================
   TESTS TAB LAYOUT
   ============================================ */
.tests-layout {
    padding: 20px;
    overflow: auto;
}

.tests-panel {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

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

.tests-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.tests-filter {
    display: flex;
    gap: 8px;
}

.filter-select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.btn-refresh {
    padding: 6px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.btn-refresh:hover {
    background: #e0e0e0;
}

.tests-table {
    width: 100%;
}

.tests-table-header {
    display: grid;
    grid-template-columns: 100px 100px 150px 100px 80px 60px 80px;
    gap: 8px;
    padding: 12px 20px;
    background: #f5f5f5;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
}

.tests-table-body {
    max-height: 400px;
    overflow-y: auto;
}

.test-row {
    display: grid;
    grid-template-columns: 100px 100px 150px 100px 80px 60px 80px;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 0.9rem;
}

.test-row:hover {
    background: #f9f9f9;
}

.test-row.selected {
    background: #e8f4fc;
}

.tests-empty {
    padding: 40px 20px;
    text-align: center;
    color: #888;
}

.test-detail {
    border-top: 2px solid #3498db;
    padding: 20px;
}

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

.test-detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.test-detail-header h3 {
    margin: 0;
}

.btn-back {
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-back:hover {
    background: #e4e6e9;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
}

.btn-close:hover {
    color: #333;
}

.test-detail-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.test-problem-info {
    font-size: 0.9rem;
}

.test-problem-info div {
    margin-bottom: 8px;
}

.test-problem-info code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
}

.test-input,
.test-output {
    grid-column: 1 / -1;
}

.test-input label,
.test-output label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 8px;
}

.test-input pre {
    background: #f5f5f5;
    color: #333;
    padding: 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin: 0;
    border: 1px solid #ddd;
}

.test-output pre {
    background: #1a1a2e;
    color: #a0ffa0;
    padding: 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin: 0;
}

.test-linked-compositions {
    grid-column: 1 / -1;
}

.test-linked-compositions label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 8px;
}

.test-linked-compositions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.test-linked-compositions li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.test-linked-compositions a {
    color: #3498db;
}

.btn-unlink-small {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-unlink-small:hover {
    color: #e74c3c;
}

.test-detail-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* Full width select in modals */
.full-width-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    margin: 12px 0;
}

/* Legacy support - map old class names */
.problem-list-panel {
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    display: flex;
    gap: 6px;
    align-items: center;
}

.list-count {
    font-weight: normal;
    color: #888;
    font-size: 0.85rem;
}

/* Collection badge - prominent indicator when filtered */
.collection-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #3498db;
    color: white;
}

.collection-badge .collection-name {
    font-weight: 600;
    font-size: 0.85rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collection-badge .btn-clear-filter {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collection-badge .btn-clear-filter:hover {
    background: rgba(255,255,255,0.4);
}

.collection-filter {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    gap: 6px;
    align-items: center;
}

.collection-select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    background: white;
}

.btn-delete-collection {
    padding: 4px 8px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
}

.btn-delete-collection:hover {
    background: #c0392b;
}

.btn-delete-collection:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.problem-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.problem-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.problem-item:hover {
    background: #f5f5f5;
}

.problem-item.selected {
    background: #e8f4fc;
}

.problem-item.solving {
    background: #fff8e6;
}

.problem-item.dirty {
    background: #fef3e6;
}

.dirty-mark {
    color: #e67e22;
    font-weight: bold;
}

.problem-number {
    font-weight: 500;
    color: #666;
    min-width: 32px;
}

.problem-stip {
    color: #888;
    font-size: 0.8rem;
}

.solving-indicator {
    margin-left: auto;
    animation: spin 1s linear infinite;
    color: #f39c12;
}

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

.list-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 0.85rem;
}

.list-nav {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid #eee;
}

.btn-nav {
    flex: 1;
    padding: 6px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-nav:hover:not(:disabled) {
    background: #e0e0e0;
}

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

.list-jump {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid #eee;
    font-size: 0.8rem;
}

.list-jump label {
    color: #666;
}

.list-jump input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

/* Editor Panel */
.editor-panel {
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.editor-panel.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

.editor-layout {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 16px;
    overflow-y: auto;
    min-height: 0;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 250px;
}

/* Board Area */
.board-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: fit-content;
}

.board-container {
    width: fit-content;
    position: relative;
}

/* Full-screen drop zone for main board drag-to-delete */
.main-board-drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.drag-off-indicator {
    display: none;
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

.board-container.dragging-piece .drag-off-indicator {
    display: block;
}

.board-container.dragging-piece .chess-board {
    outline: 2px dashed #e74c3c;
    outline-offset: 2px;
}

/* Chess board with CSS custom properties for dynamic sizing */
.chess-board {
    --square-size: 40px;
    --label-width: 18px;
    --board-width: calc(var(--square-size) * 8);
    display: flex;
    flex-direction: column;
    border: 2px solid #333;
    background: #333;
    position: relative;
    z-index: 10;  /* Above main-board-drop-zone so drops land on board */
}

.board-row {
    display: flex;
    align-items: center;
}

.rank-label {
    width: var(--label-width);
    text-align: center;
    font-size: 0.7rem;
    color: #666;
}

.file-labels {
    height: var(--label-width);
}

.file-label {
    width: var(--square-size);
    text-align: center;
    font-size: 0.7rem;
    color: #666;
}

.board-square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.board-square.light {
    background: #f0d9b5;
}

.board-square.dark {
    background: #b58863;
}

.board-square:hover {
    outline: 2px solid #3498db;
    outline-offset: -2px;
}

.piece {
    font-size: calc(var(--square-size) * 0.8);
    line-height: 1;
    cursor: grab;
    user-select: none;
}

.piece:active {
    cursor: grabbing;
}

.piece.white {
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.piece.black {
    color: #000;
    text-shadow: 0 0 1px #fff;
}

.piece.neutral {
    color: #666;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #000, 1px 1px 0 #000;
}

/* Toolbox section */
.toolbox-section {
    margin-top: 4px;
}

.btn-toolbox-toggle {
    background: none;
    border: none;
    color: #888;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 0;
}

.btn-toolbox-toggle:hover {
    color: #555;
}

.toolbox {
    margin-top: 6px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.palette-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

.palette-sep {
    width: 8px;
}

.transform-row {
    display: flex;
    gap: 3px;
    align-items: center;
}

.palette-piece {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    background: #e0e0e0;
    user-select: none;
}

.palette-piece:hover {
    background: #d0d0d0;
}

.palette-piece.selected {
    border-color: #3498db;
    background: #cce5ff;
}

.palette-piece.white {
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.palette-piece.black {
    color: #000;
}



.btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
}

.btn-small:hover {
    background: #d0d0d0;
}

.btn-small.active {
    background: #e74c3c;
    color: white;
    border-color: #c0392b;
}

.transform-sep {
    width: 6px;
}

.btn-icon-small {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    color: #333;
}

.btn-icon-small:hover {
    background: #d0d0d0;
    border-color: #3498db;
}

/* Diagram footer below board */
.diagram-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    margin-left: var(--label-width, 18px);
    width: var(--board-width, 320px);
    font-size: 0.85rem;
}

.piece-count {
    color: #555;
}

.stip-editor-container {
    position: relative;
}

.diagram-conditions {
    color: #666;
    font-size: 0.8rem;
    cursor: pointer;
}

.diagram-conditions:hover {
    color: #3498db;
}

.conditions-editor-container {
    position: relative;
    flex: 1;
    min-width: 0;
}

.diagram-conditions.clickable {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.diagram-conditions.clickable:hover {
    background: #e8f4fc;
    color: #3498db;
}

.conditions-popover {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 180px;
    max-width: 280px;
}

.conditions-popover .condition-select {
    width: 100%;
    padding: 4px 6px;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 6px;
}

.conditions-popover .conditions-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.conditions-popover .condition-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #e8f4fc;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

.conditions-popover .condition-tag button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1;
    color: #666;
}

.conditions-popover .condition-tag button:hover {
    color: #c0392b;
}

.diagram-stip {
    font-weight: 600;
}

.diagram-stip.clickable {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
}

.diagram-stip.clickable:hover {
    background: #e8f4fc;
}

/* FEN input row */
.fen-row {
    display: flex;
    gap: 4px;
    margin-left: 18px; /* align with board */
}

.fen-input {
    flex: 1;
    padding: 5px 8px;
    font-family: monospace;
    font-size: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    color: #555;
}

.fen-input:focus {
    outline: none;
    border-color: #3498db;
    background: white;
}

.btn-copy {
    padding: 4px 8px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-copy:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.btn-copy:active {
    background: #d0d0d0;
}

/* Stipulation popover */
.stip-popover {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 10px;
    z-index: 100;
}

.stip-row-popover {
    display: flex;
    gap: 6px;
    align-items: center;
}

.stip-select-popover {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
}

.stip-moves-input {
    width: 50px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

/* Notes Area */
.notes-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.notes-area label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.notes-area textarea {
    flex: 1;
    min-height: 150px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    resize: none;
}

/* Metadata Fields */
.metadata-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-row label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    min-width: 55px;
}

.field-row input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.field-row-actions {
    gap: 12px;
}

.btn-remove-field {
    background: none;
    border: none;
    color: #ccc;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.btn-remove-field:hover {
    color: #e74c3c;
}

/* Add field */
.add-field-container {
    position: relative;
}

.btn-add-field {
    background: none;
    border: 1px dashed #ccc;
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
}

.btn-add-field:hover {
    border-color: #3498db;
    color: #3498db;
}

.field-picker {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    min-width: 150px;
}

.field-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
}

.field-option:hover {
    background: #f5f5f5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 50px;
}

/* Stipulation */
.stip-row {
    display: flex;
    gap: 6px;
}

.stip-select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.stip-length {
    width: 60px;
    text-align: center;
}

/* Conditions (minor, rarely used) */
.conditions-minor {
    margin-bottom: 12px;
}



.conditions-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.condition-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #e8f4fc;
    border: 1px solid #b8d4ec;
    border-radius: 3px;
    font-size: 0.75rem;
}

.condition-tag button {
    padding: 0;
    width: 14px;
    height: 14px;
    font-size: 12px;
    line-height: 1;
    background: transparent;
    color: #666;
    border: none;
    cursor: pointer;
}

.condition-tag button:hover {
    color: #e74c3c;
}

.btn-link-small {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    color: #666;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 10px;
    margin-top: 6px;
}

.btn-link-small:hover {
    background: #e0e0e0;
    border-color: #bbb;
}

/* Options */
.options-inline {
    display: flex;
    gap: 16px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.option-item input {
    width: auto;
    margin: 0;
}

/* Solve Section */
.solve-section {
    padding-top: 12px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.solve-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.solve-options-numeric {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.option-item-numeric {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.option-item-numeric input {
    width: 70px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

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

.pool-select,
.worker-select,
.backend-select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.worker-select.worker-running {
    border-color: #27ae60;
    background: linear-gradient(to right, #e8f5e9 0%, white 10%);
}

.worker-select.worker-stopped {
    border-color: #e67e22;
    background: linear-gradient(to right, #fff3e0 0%, white 10%);
}

.worker-select.worker-starting {
    border-color: #3498db;
    background: linear-gradient(to right, #e3f2fd 0%, white 10%);
}

.backend-select {
    max-width: 100px;
}

.btn-quick-solve {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-quick-solve:hover:not(:disabled) {
    background: #2980b9;
}

.btn-quick-solve:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.solve-divider {
    color: #888;
    font-size: 0.8rem;
}

.btn-solve {
    padding: 8px 16px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-solve:hover:not(:disabled) {
    background: #219a52;
}

.btn-solve:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.preview-toggle {
    margin-top: 8px;
}

.btn-link {
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
    text-decoration: underline;
}

.btn-link:hover {
    color: #2980b9;
}

.input-preview {
    margin-top: 8px;
    padding: 10px;
    background: #1a1a2e;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    color: #a0ffa0;
}

.input-preview pre {
    margin: 0;
    white-space: pre-wrap;
}

.solve-progress {
    margin-top: 8px;
    padding: 8px;
    background: #1a1a2e;
    color: #a0ffa0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    max-height: 100px;
    overflow-y: auto;
}

.solve-progress pre {
    margin: 0;
    white-space: pre-wrap;
}

/* Solution Section */
.solution-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #ddd;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.status-sound {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-unsound {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.status-unknown {
    background: #e2e3e5;
    color: #383d41;
}

.status-badge.status-error {
    background: #f8d7da;
    color: #721c24;
}

.status-date {
    font-size: 0.75rem;
    color: #888;
}

.solution-text {
    margin-top: 8px;
}

.solution-inline {
    margin-top: 8px;
}

.solution-pre {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    margin: 4px 0 0 0;
}

/* Solve History */
.solve-history {
    margin-top: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.history-header:hover {
    background: #eee;
}

.history-count {
    color: #666;
    font-weight: normal;
}

.history-toggle {
    margin-left: auto;
    color: #888;
    font-size: 0.7rem;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 10px 12px;
    border-top: 1px solid #eee;
}

.history-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.history-status {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-sound, .status-sound { background: #d4edda; color: #155724; }
.badge-cooked, .status-cooked { background: #f8d7da; color: #721c24; }
.badge-no-solution, .status-no-solution { background: #fff3cd; color: #856404; }
.badge-pending, .status-pending { background: #e2e3e5; color: #383d41; }
.badge-running, .status-running { background: #cce5ff; color: #004085; }
.badge-error, .status-error { background: #f8d7da; color: #721c24; }
.badge-unknown, .status-unknown { background: #e2e3e5; color: #383d41; }

.history-date {
    color: #888;
    font-size: 0.75rem;
}

.history-stip {
    color: #666;
    font-size: 0.8rem;
    font-family: monospace;
}

.history-item-details {
    margin-top: 4px;
}

.history-notes {
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

.history-output {
    margin-top: 6px;
}

.history-output summary {
    font-size: 0.75rem;
    color: #888;
    cursor: pointer;
}

.history-output summary:hover {
    color: #3498db;
}

.history-output pre {
    background: #f9f9f9;
    padding: 8px;
    margin-top: 4px;
    border-radius: 3px;
    font-size: 0.75rem;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}

.latest-result {
    margin-top: 8px;
}

/* Clone button */
.btn-secondary {
    padding: 6px 12px;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    background: #e0e0e0;
    border-color: #bbb;
}

.btn-secondary:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Editor Footer */
.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f0f0f0;
    border-top: 1px solid #ddd;
    font-size: 0.8rem;
    flex-shrink: 0; /* Don't let footer shrink */
}

.footer-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sync indicators */
.sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.85rem;
    margin-right: 8px;
}

.sync-indicator .sync-icon {
    font-size: 1rem;
}

.sync-indicator.syncing {
    color: #3498db;
}

.sync-indicator.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

.sync-indicator.synced {
    color: #27ae60;
}

.sync-indicator.pending {
    color: #f39c12;
}

.sync-indicator.error {
    color: #e74c3c;
    cursor: pointer;
}

.sync-indicator.error:hover {
    text-decoration: underline;
}

.dirty-indicator {
    color: #e67e22;
    font-weight: 500;
}

.saved-indicator {
    color: #27ae60;
}

.footer-actions {
    display: flex;
    gap: 8px;
}

.btn-save {
    padding: 6px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-save:hover:not(:disabled) {
    background: #2980b9;
}

.btn-save:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.btn-warning {
    padding: 6px 12px;
    background: #f39c12;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-danger {
    padding: 6px 12px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Responsive */
@media (max-width: 800px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .problem-list-panel {
        max-height: 150px;
    }
    
    .editor-layout {
        grid-template-columns: 1fr;
    }
    
    .board-area {
        width: 100%;
        align-items: center;
    }
}

/* Debug page styles (keep for debug.html) */
.debug-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.debug-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.debug-section h2 {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.pool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 12px;
}

.pool-card {
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 12px;
}

.pool-card h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.pool-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 0.8rem;
}

.pool-stat {
    text-align: center;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
}

.pool-stat-value {
    font-size: 1.2rem;
    font-weight: 600;
}

.pool-stat-label {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 2px;
}

.pool-stat-state {
    font-size: 0.65rem;
    color: #aaa;
    text-transform: capitalize;
}

.pool-stat-state.state-active {
    color: #27ae60;
    font-weight: 600;
}

/* ============================================
   Import Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin: 0 0 20px 0;
    font-size: 1.25rem;
}

.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
}

.drop-zone:hover {
    border-color: #999;
    background: #f5f5f5;
}

.drop-zone.drag-over {
    border-color: #0066cc;
    background: #e8f4fc;
}

.drop-zone.has-file {
    border-style: solid;
    border-color: #28a745;
    background: #e8f8ec;
}

.drop-zone-content {
    pointer-events: none;
}

.drop-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.drop-zone p {
    margin: 4px 0;
    color: #666;
}

.drop-hint {
    font-size: 0.85rem;
    color: #999;
}

.file-icon {
    font-size: 36px;
    color: #28a745;
    margin-bottom: 8px;
}

.file-name {
    font-weight: 600;
    color: #333;
}

.file-size {
    font-size: 0.85rem;
    color: #666;
}

.import-options {
    margin-top: 20px;
}

.import-options label {
    display: block;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 6px;
}

.collection-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

.collection-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.import-hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: 6px;
}

.import-hint.warning {
    color: #e74c3c;
    font-weight: 500;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.import-progress {
    margin-top: 20px;
    text-align: center;
}

.progress-bar {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: #0066cc;
    animation: progress-pulse 1.5s ease-in-out infinite;
}

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

.modal-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-secondary {
    padding: 10px 20px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #999;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    padding: 10px 20px;
    border: none;
    background: #0066cc;
    color: white;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: #0052a3;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Success Toast */
.success-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
}

.success-toast button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.success-toast button:hover {
    opacity: 1;
}

/* ============================================
   Pawn Promotion Popup
   ============================================ */
.promotion-popup {
    position: fixed;
    z-index: 1100;  /* Above solver modal */
    background: white;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    gap: 2px;
}

.promotion-piece {
    width: 40px;
    height: 40px;
    font-size: 32px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.promotion-piece:hover {
    border-color: #0066cc;
    background: #e8f4fc;
}

.promotion-piece.white {
    color: #333;
}

.promotion-piece.black {
    color: #222;
}

/* ============================================
   Header Solve Button
   ============================================ */
.btn-header-solve {
    padding: 8px 16px;
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-header-solve:hover {
    background: #8e44ad;
}

/* ============================================
   Solver Modal
   ============================================ */
.solver-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.solver-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.solver-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.solver-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #2c3e50;
}

.solver-modal-header .btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.solver-modal-header .btn-close:hover {
    color: #333;
}

.solver-modal-content {
    display: flex;
    gap: 24px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.solver-modal-board {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.solver-modal-options {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 280px;
}

.solver-link-info {
    padding: 8px 12px;
    background: #e8f4fc;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #2980b9;
}

.solver-submit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    margin-top: auto;
    flex-wrap: wrap;
}

.node-type-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
}

.node-type-toggle input[type="checkbox"] {
    cursor: pointer;
}

.node-type-toggle:hover {
    color: #333;
}

/* ============================================
   Solution Recorder Modal
   ============================================ */
.recorder-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.recorder-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 850px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.recorder-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.recorder-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #2c3e50;
}

.recorder-stip {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2980b9;
}

.recorder-modal-header .btn-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.recorder-modal-header .btn-close:hover {
    color: #333;
}

.recorder-modal-content {
    display: flex;
    gap: 24px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.recorder-modal-board {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.recorder-board .chess-board {
    --square-size: 45px;
    --board-width: calc(8 * var(--square-size));
}

.recorder-nav-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.recorder-nav-controls .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.recorder-nav-controls .btn-icon:hover:not(:disabled) {
    background: #e8e8e8;
}

.recorder-nav-controls .btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.recorder-position {
    font-size: 0.9rem;
    color: #666;
    min-width: 50px;
    text-align: center;
}

.btn-test-from-here {
    margin-left: 12px;
    background: #27ae60;
    color: white;
    border-color: #1e8449;
}

.btn-test-from-here:hover:not(:disabled) {
    background: #1e8449;
}

.btn-test-from-here:disabled {
    background: #bdc3c7;
    border-color: #95a5a6;
    color: #7f8c8d;
}

.recorder-instructions {
    text-align: center;
    font-size: 0.85rem;
    color: #888;
}

.recorder-modal-moves {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 280px;
}

.recorder-lines-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recorder-lines-section label {
    font-size: 0.85rem;
    color: #666;
}

.recorder-lines-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.line-tab {
    padding: 4px 12px;
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.line-tab:hover {
    background: #e8e8e8;
}

.line-tab.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.line-tab-add {
    background: #e8f4fc;
    border-color: #3498db;
    color: #3498db;
    font-weight: bold;
}

.line-tab-add:hover {
    background: #d0e8f7;
}

.recorder-import-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recorder-import-section label {
    font-size: 0.85rem;
    color: #666;
}

.recorder-import-text {
    height: 60px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: none;
}

.recorder-import-section .btn-small {
    align-self: flex-start;
}

.recorder-moves-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-height: 100px;
}

.recorder-moves-list label {
    font-size: 0.85rem;
    color: #666;
}

.moves-scroll {
    flex: 1;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 8px;
    overflow-y: auto;
    background: #fafafa;
    min-height: 80px;
    max-height: 180px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 4px;
}

.move-item {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.85rem;
    cursor: pointer;
}

.move-item:hover {
    background: #e8f4fc;
    border-color: #3498db;
}

.move-item.current {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.move-num {
    color: #888;
    margin-right: 2px;
}

.move-item.current .move-num {
    color: rgba(255, 255, 255, 0.8);
}

.moves-empty {
    color: #999;
    font-style: italic;
    font-size: 0.85rem;
}

.recorder-output-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recorder-output-section label {
    font-size: 0.85rem;
    color: #666;
}

.recorder-output-text {
    height: 50px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: none;
    background: #f8f9fa;
}

.recorder-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.recorder-actions-spacer {
    flex: 1;
}

.recorder-actions .btn-danger {
    background: #e74c3c;
    color: white;
    border-color: #c0392b;
}

.recorder-actions .btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.recorder-actions .btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.recorder-actions .btn-primary:hover {
    background: #2980b9;
}

/* ============================================
   Tests Tab - Split Layout
   ============================================ */
.tests-tab {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tests-split-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.tests-list-panel {
    width: 350px;
    min-width: 280px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tests-list-panel .tests-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.tests-list-panel .tests-header h2 {
    margin: 0 0 8px 0;
    font-size: 1rem;
}

.tests-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.test-list-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.test-list-item:hover {
    background: #f5f5f5;
}

.test-list-item.selected {
    background: #e8f4fc;
    border-left: 3px solid #3498db;
}

.test-list-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.test-list-meta {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: #888;
}

.linked-badge {
    background: #d4edda;
    color: #155724;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
}

.test-stip {
    font-family: monospace;
    font-size: 0.85rem;
    color: #333;
}

/* Test Detail Panel */
.test-detail-panel {
    flex: 1;
    background: #fafbfc;
    overflow-y: auto;
    padding: 20px;
}

.test-detail-panel.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

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

.test-detail-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.test-detail-actions-top {
    display: flex;
    gap: 8px;
}

.test-detail-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.test-board-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.test-diagram-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 0.85rem;
    width: calc(32px * 8);  /* Match mini-board: 8 squares × 32px */
    margin-left: 14px;  /* Align with board (past rank labels) */
}

.test-diagram-footer .piece-count {
    color: #555;
}

.test-stip-display {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Mini board for test detail (read-only) */
.mini-board {
    --square-size: 32px;
    --label-width: 14px;
    --board-width: calc(var(--square-size) * 8);
    pointer-events: none;
}

.mini-board .board-square {
    cursor: default;
}

.mini-board .board-square:hover {
    outline: none;
}

.mini-board .piece {
    cursor: default;
}

.mini-board .rank-label,
.mini-board .file-label {
    font-size: 0.6rem;
}

.mini-board .file-labels {
    height: var(--label-width);
}

/* Test linked compositions */
.test-linked ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.test-linked li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.test-linked a {
    color: #3498db;
    text-decoration: none;
}

.test-linked a:hover {
    text-decoration: underline;
}

/* Loading spinner small */
.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.output-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    color: #3498db;
    font-size: 0.75rem;
}

/* Status badges */
.status-completed { background: #d4edda; color: #155724; }
.status-pending { background: #fff3cd; color: #856404; }
.status-queued { background: #fff3cd; color: #856404; }
.status-running { background: #cce5ff; color: #004085; }
.status-error { background: #f8d7da; color: #721c24; }
.status-timeout { background: #fff3cd; color: #856404; }
.status-no-solution { background: #e2e3e5; color: #383d41; }
.status-preempted { background: #f8d7da; color: #721c24; }

/* Test type badges (Quick vs Cloud) */
.test-type-badge {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
}
.test-type-badge.type-quick { background: #e7f5ff; color: #1971c2; }
.test-type-badge.type-batch { background: #f3f0ff; color: #7048e8; }

/* Test metadata info in detail panel */
.test-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}
.test-meta-info .test-type-label {
    font-weight: 600;
    color: #495057;
}

/* Responsive adjustments for tests split layout */
@media (max-width: 900px) {
    .tests-split-layout {
        flex-direction: column;
    }
    
    .tests-list-panel {
        width: 100%;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .solver-modal-content {
        flex-direction: column;
    }
    
    .solver-modal-board {
        align-items: center;
    }
}

/* ============================================
   WORKERS TAB
   ============================================ */

.workers-tab {
    padding: 20px;
    max-width: 100%;
    margin: 0;
}

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

.workers-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 500;
}

.workers-header-actions {
    display: flex;
    gap: 8px;
}

.btn-refresh {
    padding: 8px 16px;
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.btn-refresh:hover:not(:disabled) {
    background: #e4e6e9;
}

.btn-copy-debug {
    padding: 8px 12px;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-copy-debug:hover {
    background: #ffe0b2;
}

.workers-error {
    background: #ffebee;
    border: 1px solid #ef9a9a;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 16px;
}

.workers-error pre {
    margin: 8px 0 0 0;
    white-space: pre-wrap;
    font-size: 0.85rem;
    color: #c62828;
}

.workers-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.worker-row {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.worker-row.worker-running {
    border-color: #27ae60;
}

.worker-row.worker-deallocated {
    border-color: #bdc3c7;
}

.worker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.worker-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.worker-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #bdc3c7;
}

.worker-status-dot.running {
    background: #27ae60;
}

.worker-status-dot.deallocated {
    background: #95a5a6;
}

.worker-status-dot.starting {
    background: #f39c12;
    animation: pulse 1s infinite;
}

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

.worker-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.worker-cost {
    color: #666;
    font-size: 0.85rem;
}

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

.worker-status-text {
    font-size: 0.8rem;
    color: #666;
    text-transform: capitalize;
}

.btn-worker-start,
.btn-worker-stop {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-worker-start {
    background: #27ae60;
    color: white;
}

.btn-worker-start:hover:not(:disabled) {
    background: #219a52;
}

.btn-worker-start:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.btn-worker-stop {
    background: #e74c3c;
    color: white;
}

.btn-worker-stop:hover {
    background: #c0392b;
}

.worker-jobs {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 16px;
    min-height: 80px;
    background: #fafafa;
    overflow-x: auto;
}

.worker-jobs.drag-over {
    background: #e8f5e9;
}

.no-jobs {
    color: #999;
    font-style: italic;
    padding: 20px;
    width: 100%;
    text-align: center;
}

.job-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 14px;
    min-width: 200px;
    max-width: 250px;
    flex: 0 0 auto;
    cursor: default;
    transition: box-shadow 0.15s, transform 0.15s;
}

.job-card[draggable="true"] {
    cursor: grab;
}

.job-card[draggable="true"]:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.job-card.job-running {
    border-color: #3498db;
    border-left: 3px solid #3498db;
}

.job-card.job-pending {
    border-color: #f39c12;
    border-left: 3px solid #f39c12;
}

.job-card.job-completed {
    border-color: #27ae60;
    border-left: 3px solid #27ae60;
}

.job-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.job-status-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
}

.job-status-badge.running {
    background: #e3f2fd;
    color: #1976d2;
}

.job-status-badge.pending {
    background: #fff3e0;
    color: #f57c00;
}

.job-status-badge.completed {
    background: #e8f5e9;
    color: #388e3c;
}

.job-name {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-card-meta {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 8px;
}

.job-card-actions {
    display: flex;
    gap: 6px;
}

.btn-job-cancel,
.btn-job-view {
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    cursor: pointer;
}

.btn-job-cancel:hover {
    background: #fee;
    border-color: #e74c3c;
    color: #e74c3c;
}

.btn-job-view:hover {
    background: #f0f2f5;
}

.no-workers {
    text-align: center;
    padding: 40px;
    color: #666;
}

.worker-badge {
    background: #f39c12;
}
