:root {
    --bg-body:             #0e1018;
    --bg-sidebar:          #161a26;
    --bg-card:             #1e2334;
    --bg-input:            #11141f;
    --border-main:         #2b3147;
    --border-strong:       #394264;
    --text-main:           #eef2f8;
    --text-muted:          #9aa6bd;
    --text-label:          #cdd6e6;
    --accent:              #3b82f6;
    --accent-strong:       #2563eb;
    --accent-soft:         rgba(59, 130, 246, 0.14);
    --success:             #10b981;
    --danger:              #ef4444;
    --warn:                #f59e0b;
    --btn-secondary:       #2c3450;
    --btn-secondary-hover: #3a456a;
    --shadow-card:         0 1px 3px rgba(0,0,0,0.22);
    --sidebar-w:  296px;
    --card-pad:   12px;
    --radius:     10px;
    --fs-title:   15.5px;
    --fs-sub:     11.5px;
    --fs-trigger: 11px;
    --fs-label:   12px;
    --fs-input:   13px;
    --fs-hint:    11px;
    --fs-mono:    11.5px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    display: flex;
    height: 100dvh;
}

/* ─── SIDEBAR ───────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-main);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.sidebar-inner {
    padding: 14px 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ─── HEADER ────────────────────────────────────── */
.sim-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 4px;
}
.sim-logo {
    width: 38px; height: 38px;
    border-radius: 9px;
    background: var(--accent-soft);
    border: 1.5px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
}
.sim-title    { font-size: var(--fs-title); font-weight: 700; line-height: 1.25; }
.sim-subtitle { font-size: var(--fs-sub); color: var(--text-muted); margin-top: 2px; }

/* ─── CARDS ─────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.card-trigger {
    width: 100%; background: none; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px var(--card-pad);
    color: var(--text-muted);
    font-size: var(--fs-trigger); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.07em;
    transition: color 0.15s; font-family: inherit;
}
.card-trigger:hover { color: var(--text-main); }
.card-chevron { font-size: 10px; transition: transform 0.2s; }
.card.is-expanded .card-chevron { transform: rotate(180deg); }
.card-body { display: none; padding: 0 var(--card-pad) var(--card-pad); }
.card.is-expanded .card-body { display: block; }
.card-body-static {
    padding: 0 var(--card-pad) var(--card-pad);
    display: flex; flex-direction: column; gap: 6px;
}
.atom-card-label {
    padding: 8px var(--card-pad) 2px;
    font-size: var(--fs-trigger); font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em;
}

/* ─── MODE SELECT ───────────────────────────────── */
.mode-card { padding: 10px var(--card-pad); }
select {
    width: 100%; padding: 6px 8px;
    background: var(--bg-input); color: var(--text-main);
    border: 1px solid var(--border-strong); border-radius: 6px;
    font-family: inherit; font-size: var(--fs-input); cursor: pointer; outline: none;
}
select:focus { border-color: var(--accent); }

/* ─── SLIDER ────────────────────────────────────── */
.slider-row { display: flex; align-items: center; gap: 8px; }
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 4px;
    background: var(--border-strong); border-radius: 2px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--accent); border: 2px solid var(--accent-strong);
    cursor: pointer; transition: background 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { background: var(--accent-strong); }
input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }
input[type="range"]:disabled::-webkit-slider-thumb { cursor: not-allowed; }

.slider-meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; margin-top: 2px; color: var(--text-muted);
}

/* ─── SLIDER MARKS ──────────────────────────────── */
.slider-marks { position: relative; height: 16px; margin-top: 1px; }
.slider-mark {
    position: absolute; top: 0; transform: translateX(-50%);
    font-size: 9px; color: var(--text-muted); white-space: nowrap;
}
.slider-mark::before {
    content: ''; position: absolute; top: -5px; left: 50%;
    width: 1px; height: 4px; background: var(--border-strong);
}

/* ─── TRAJECTORY LABELS ─────────────────────────── */
.traj-label {
    font-weight: 600; font-size: 10px; padding: 2px 6px;
    border-radius: 4px; background: var(--bg-input); border: 1px solid var(--border-strong);
}
.traj-suborbital  { color: #f97316; border-color: #7c3a0e; }
.traj-circular    { color: var(--success); border-color: #065f46; }
.traj-elliptical  { color: var(--accent); border-color: #1e40af; }
.traj-escape      { color: #a78bfa; border-color: #4c1d95; }

/* ─── STATUS BOX ────────────────────────────────── */
.status-box {
    background: var(--bg-input); border: 1px solid var(--border-main);
    border-radius: 7px; padding: 7px 9px;
    font-size: var(--fs-mono); font-family: 'Consolas', 'Fira Mono', monospace;
    line-height: 1.8; color: var(--text-label); min-height: 60px;
}
.ui-empty { color: var(--text-muted); font-style: italic; font-size: 11px; }

/* ─── BUTTONS ───────────────────────────────────── */
button {
    background: var(--btn-secondary); color: var(--text-label);
    border: 1px solid var(--border-main); border-radius: 7px;
    padding: 6px 10px; font-family: inherit; font-size: 11.5px; font-weight: 600;
    cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) {
    background: var(--btn-secondary-hover); color: var(--text-main); border-color: var(--border-strong);
}
button:disabled { opacity: 0.28; cursor: not-allowed; }

/* Fondo un tono más oscuro que el acento para que el texto blanco se lea bien (contraste 4,5:1) */
.btn-primary { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; color: #fff; }

.btn-group        { display: flex; gap: 5px; }
.btn-group button { flex: 1; font-size: 10.5px; padding: 5px 3px; }

.reset-row        { display: flex; }
.reset-row button { width: 100%; }

/* ─── PRESET BUTTONS ────────────────────────────── */
.preset-row { display: flex; gap: 5px; }
.preset-row button {
    flex: 1; font-size: 9.5px; padding: 4px 2px;
    border-radius: 5px; font-weight: 700; letter-spacing: 0.02em;
}
.btn-preset-circ { color: var(--success); border-color: #065f46; background: rgba(16,185,129,0.08); }
.btn-preset-circ:hover:not(:disabled) { background: rgba(16,185,129,0.18); color: var(--success); }
.btn-preset-esc  { color: #a78bfa; border-color: #4c1d95; background: rgba(167,139,250,0.08); }
.btn-preset-esc:hover:not(:disabled)  { background: rgba(167,139,250,0.18); color: #a78bfa; }

/* ─── SPEED ROW ─────────────────────────────────── */
.speed-row {
    display: flex; align-items: center; gap: 6px;
    font-size: 10.5px; color: var(--text-muted);
}
.speed-row .btn-group { flex: 1; }
.speed-row button { font-size: 10px; padding: 4px 2px; }
.speed-btn-active { background: var(--border-strong) !important; color: var(--text-main) !important; }

/* ─── INFO SECTION ──────────────────────────────── */
.info-section p {
    font-size: var(--fs-hint); color: var(--text-muted); line-height: 1.65; margin-bottom: 6px;
}
.info-section p:last-child { margin-bottom: 0; }
.info-section b  { color: var(--text-label); }
.info-section em { color: var(--accent); font-style: normal; }

/* ─── SHORTCUTS HINT ────────────────────────────── */
.kbd-hint {
    font-size: 9.5px; color: var(--text-muted);
    line-height: 1.7; padding: 4px 0 0;
}
.kbd { display: inline-block; background: var(--bg-input); border: 1px solid var(--border-strong);
    border-radius: 3px; padding: 0 4px; font-family: monospace; font-size: 9px; color: var(--text-label); }

/* ─── CANVAS HOLDER ─────────────────────────────── */
#canvas-holder {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
    padding: 14px; background: var(--bg-body); overflow: hidden;
}
#sim-frame {
    flex: 1; min-height: 0; position: relative; background: #050a14;
    border-radius: 14px; overflow: hidden;
    border: 1px solid var(--border-strong);
    box-shadow: 0 0 0 1px rgba(59,130,246,0.06), 0 4px 24px rgba(0,0,0,0.45);
}
/* El lienzo ocupa el ancho del marco; si es más estrecho que el tamaño lógico
   mínimo (640 px, ver frameCanvasSize en sketch.js) se escala visualmente. */
#sim-frame canvas { display: block; width: 100% !important; height: auto !important; }

/* ─── PLANET LEGEND ─────────────────────────────── */
.planet-legend { display: flex; flex-direction: column; gap: 3px; }
.planet-row {
    display: flex; align-items: center; gap: 7px;
    font-size: 10.5px; color: var(--text-muted); padding: 2px 0;
    cursor: pointer; border-radius: 4px; padding: 3px 4px;
    transition: background 0.12s;
}
.planet-row:hover { background: rgba(255,255,255,0.04); }
.planet-row.active { color: var(--text-main); background: rgba(255,255,255,0.07); }
.planet-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.planet-name { flex: 1; font-weight: 500; }
.planet-stat { font-size: 9.5px; color: var(--text-muted); font-family: monospace; }

/* ─── PANTALLAS ESTRECHAS (móvil, tablet en vertical) ───
   La simulación pasa arriba a todo el ancho, con proporción 4:3, y los
   controles debajo. En ordenador no cambia nada. */
@media (max-width: 960px) {
    html, body { height: auto; overflow: auto; }
    body { flex-direction: column; height: auto; }
    #canvas-holder { order: -1; padding: 10px; overflow: visible; }
    #sim-frame { flex: none; aspect-ratio: 4 / 3; }
    .sidebar { width: 100%; overflow: visible; border-right: none; border-top: 1px solid var(--border-main); }
}
