/* ═══════════════════════════════════════════
   Three-Body Problem — Layout & Styling
   ═══════════════════════════════════════════ */

.tb-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    color: #e2e8f0;
}

/* ── Header ─────────────────────────────── */
.tb-header {
    margin-bottom: 0.75rem;
}
.tb-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.tb-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}
.tb-subtitle {
    font-size: 0.85rem;
    color: #94a3b8;
    margin: 0 0 0 2.25rem;
}

/* ── Tabs ────────────────────────────────── */
.tb-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #334155;
    padding-bottom: 0.5rem;
}
.tb-tab {
    background: transparent;
    border: 1px solid #475569;
    border-radius: 6px 6px 0 0;
    color: #94a3b8;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.tb-tab:hover {
    color: #e2e8f0;
    background: #1e293b;
}
.tb-tab.active {
    color: #fbbf24;
    border-color: #fbbf24;
    background: #1e293b;
}
.tb-tab-num {
    font-weight: 700;
    margin-right: 0.25rem;
}

/* ── Main Layout ─────────────────────────── */
.tb-main {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* ── Controls Panel ──────────────────────── */
.tb-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.tb-scenario-controls {
    display: contents;
}
.tb-scenario-desc {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.45;
    margin: 0;
    padding: 0.4rem 0.5rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    border-left: 3px solid #fbbf24;
}
.tb-control-group {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem;
}
.tb-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.tb-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.75rem;
    color: #cbd5e1;
    margin-bottom: 0.15rem;
}
.tb-value {
    color: #fbbf24;
    font-family: monospace;
    font-size: 0.7rem;
}
.tb-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #475569;
    border-radius: 2px;
    outline: none;
    margin-bottom: 0.4rem;
    cursor: pointer;
}
.tb-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fbbf24;
    cursor: pointer;
}
.tb-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fbbf24;
    border: none;
    cursor: pointer;
}

/* ── Buttons ─────────────────────────────── */
.tb-btn {
    background: #334155;
    border: 1px solid #475569;
    border-radius: 6px;
    color: #e2e8f0;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.tb-btn:hover {
    background: #475569;
    color: #fff;
}
.tb-btn.active {
    background: #fbbf24;
    color: #1e293b;
    border-color: #fbbf24;
}
.tb-btn-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
}
.tb-btn-row {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.4rem;
}
.tb-center-btns {
    flex-wrap: wrap;
}

/* ── Presets ──────────────────────────────── */
.tb-preset-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.tb-preset {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #94a3b8;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.7rem;
    text-align: left;
    transition: all 0.15s;
}
.tb-preset:hover {
    background: #1e293b;
    color: #fbbf24;
    border-color: #fbbf24;
}

/* ── Checkboxes & Radios ─────────────────── */
.tb-check, .tb-radio {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: #cbd5e1;
    cursor: pointer;
    margin-bottom: 0.15rem;
}
.tb-check input[type="checkbox"],
.tb-radio input[type="radio"] {
    accent-color: #fbbf24;
    cursor: pointer;
}

/* ── Canvas Wrapper & Zoom ────────────────── */
.tb-canvas-wrap {
    position: relative;
    flex-shrink: 0;
}
.tb-zoom-btns {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 2;
}

/* ── Canvas Area ─────────────────────────── */
.tb-canvas-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.tb-canvas-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

/* ── Quick-Reference Tips ────────────────── */
.tb-tips {
    flex: 1;
    min-width: 150px;
    max-width: 220px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    font-size: 0.7rem;
    line-height: 1.5;
    color: #94a3b8;
    align-self: stretch;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
}
.tb-tips-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 0.35rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.tb-tips-title:not(:first-child) {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid #334155;
}
.tb-tip {
    margin-bottom: 0.25rem;
    color: #cbd5e1;
    font-size: 0.68rem;
    line-height: 1.45;
}
.tb-tip kbd {
    display: inline-block;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 3px;
    padding: 0 0.3rem;
    font-size: 0.62rem;
    font-family: monospace;
    color: #fbbf24;
    min-width: 1.4em;
    text-align: center;
    margin-right: 0.2rem;
}
.tb-tip i {
    color: #64748b;
    width: 1em;
    text-align: center;
    margin-right: 0.15rem;
}
.tb-tip b {
    color: #fbbf24;
    font-weight: 600;
}
#tbCanvas {
    height: calc(100vh - 260px);
    aspect-ratio: 1;
    max-width: 100%;
    background: #0a0e1a;
    border-radius: 8px;
    border: 1px solid #334155;
    cursor: crosshair;
    touch-action: none;
}

/* ── Info Bar ────────────────────────────── */
.tb-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-top: none;
    border-radius: 0 0 8px 8px;
    font-size: 0.75rem;
}
.tb-info-item {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.tb-info-label {
    color: #64748b;
    font-style: italic;
}
.tb-info-val {
    color: #e2e8f0;
    font-family: monospace;
    font-size: 0.75rem;
}

/* ── Eccentricity Panel ─────────────────── */
.tb-ecc-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}
#eccChart {
    background: #0f172a;
    border-radius: 4px;
    border: 1px solid #334155;
    width: 100%;
    height: 120px;
}

/* ── How to Use ──────────────────────────── */
.tb-howto {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-top: 0.5rem;
}
.tb-howto summary {
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}
.tb-howto-content {
    margin-top: 0.5rem;
}
.tb-howto-content p {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

/* ── Hidden utility ──────────────────────── */
.hidden {
    display: none !important;
}

/* ══════════════════════════════════════════
   Responsive: tablet/mobile
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
    .tb-tips {
        display: none;
    }
}

@media (max-width: 768px) {
    .tb-main {
        grid-template-columns: 1fr;
    }
    .tb-canvas-area {
        order: -1;
    }
    .tb-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .tb-playback-group {
        order: -1;
        grid-column: 1 / -1;
    }
    .tb-tabs {
        flex-wrap: wrap;
    }
    #tbCanvas {
        height: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .tb-container {
        padding: 0.5rem;
    }
    .tb-title {
        font-size: 1.15rem;
    }
    .tb-subtitle {
        font-size: 0.75rem;
        margin-left: 0;
    }
    .tb-controls {
        grid-template-columns: 1fr;
    }
    .tb-tab {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }
    /* Larger touch targets for sliders */
    .tb-slider {
        height: 8px;
        margin-bottom: 0.5rem;
    }
    .tb-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    .tb-slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
    /* Larger touch targets for buttons */
    .tb-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    .tb-btn-sm {
        padding: 0.35rem 0.5rem;
        min-height: 36px;
    }
    .tb-preset {
        padding: 0.45rem 0.6rem;
        font-size: 0.75rem;
    }
    .tb-check, .tb-radio {
        padding: 0.2rem 0;
        font-size: 0.8rem;
    }
    .tb-scenario-desc {
        font-size: 0.7rem;
    }
    .tb-info-bar {
        gap: 0.4rem 0.6rem;
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }
    .tb-info-item {
        min-width: 0;
    }
    .tb-howto summary {
        font-size: 0.8rem;
    }
    .tb-howto-content p {
        font-size: 0.75rem;
    }
    #eccChart {
        height: 80px;
    }
}

/* ══════════════════════════════════════════
   Night Mode (red-tinted)
   ══════════════════════════════════════════ */
body[data-theme="night"] .tb-container {
    color: #fca5a5;
}
body[data-theme="night"] .tb-title {
    color: #fca5a5;
}
body[data-theme="night"] .tb-subtitle {
    color: #b47070;
}
body[data-theme="night"] .tb-tab {
    color: #b47070;
    border-color: #7f1d1d;
}
body[data-theme="night"] .tb-tab:hover {
    color: #fca5a5;
    background: #7f1d1d;
}
body[data-theme="night"] .tb-tab.active {
    color: #ef4444;
    border-color: #ef4444;
    background: #7f1d1d;
}
body[data-theme="night"] .tb-control-group,
body[data-theme="night"] .tb-ecc-panel,
body[data-theme="night"] .tb-howto,
body[data-theme="night"] .tb-info-bar,
body[data-theme="night"] .tb-tips {
    background: #7f1d1d;
    border-color: #991b1b;
}
body[data-theme="night"] .tb-tips-title {
    color: #b47070;
    border-top-color: #991b1b;
}
body[data-theme="night"] .tb-tip {
    color: #fca5a5;
}
body[data-theme="night"] .tb-tip kbd {
    background: #991b1b;
    border-color: #b91c1c;
    color: #ef4444;
}
body[data-theme="night"] .tb-tip i {
    color: #b47070;
}
body[data-theme="night"] .tb-tip b {
    color: #ef4444;
}
body[data-theme="night"] .tb-btn {
    background: #991b1b;
    border-color: #b91c1c;
    color: #fca5a5;
}
body[data-theme="night"] .tb-btn:hover {
    background: #b91c1c;
    color: #fef2f2;
}
body[data-theme="night"] .tb-btn.active {
    background: #ef4444;
    color: #450a0a;
    border-color: #ef4444;
}
body[data-theme="night"] .tb-slider {
    background: #991b1b;
}
body[data-theme="night"] .tb-slider::-webkit-slider-thumb {
    background: #ef4444;
}
body[data-theme="night"] .tb-slider::-moz-range-thumb {
    background: #ef4444;
}
body[data-theme="night"] .tb-preset {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #b47070;
}
body[data-theme="night"] .tb-preset:hover {
    background: #7f1d1d;
    color: #ef4444;
    border-color: #ef4444;
}
body[data-theme="night"] .tb-value {
    color: #ef4444;
}
body[data-theme="night"] .tb-label,
body[data-theme="night"] .tb-check,
body[data-theme="night"] .tb-radio,
body[data-theme="night"] .tb-info-val {
    color: #fca5a5;
}
body[data-theme="night"] .tb-info-label,
body[data-theme="night"] .tb-group-title {
    color: #b47070;
}
body[data-theme="night"] .tb-scenario-desc {
    color: #fca5a5;
    background: #7f1d1d;
    border-color: #991b1b;
    border-left-color: #ef4444;
}
body[data-theme="night"] #tbCanvas {
    background: #1a0505;
    border-color: #7f1d1d;
}
body[data-theme="night"] #eccChart {
    background: #450a0a;
    border-color: #7f1d1d;
}
body[data-theme="night"] .tb-check input[type="checkbox"],
body[data-theme="night"] .tb-radio input[type="radio"] {
    accent-color: #ef4444;
}
body[data-theme="night"] .tb-howto summary {
    color: #b47070;
}
body[data-theme="night"] .tb-howto-content p {
    color: #fca5a5;
}
