:root {
    --bg: #0a0e17;
    --bg-panel: #111827;
    --bg-panel-alt: #0f1520;
    --bg-hover: #1a2236;
    --border: #1e2a3a;
    --border-light: #2a3a52;
    --text: #e2e8f0;
    --text-dim: #8b9cc0;
    --text-muted: #4a5a78;
    --cyan: #00e5ff;
    --cyan-dim: rgba(0, 229, 255, 0.15);
    --cyan-glow: rgba(0, 229, 255, 0.3);
    --orange: #ff6d00;
    --orange-dim: rgba(255, 109, 0, 0.15);
    --orange-glow: rgba(255, 109, 0, 0.3);
    --green: #00e676;
    --red: #ff5252;
    --red-dim: rgba(255, 82, 82, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.2s ease;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-display);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== HEADER ===== */

.header {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(10, 14, 23, 0.8) 100%);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 0 6px var(--cyan-glow));
    animation: headerPulse 3s ease-in-out infinite;
}

@keyframes headerPulse {
    0%, 100% { filter: drop-shadow(0 0 6px var(--cyan-glow)); }
    50% { filter: drop-shadow(0 0 12px var(--cyan-glow)); }
}

.header h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--cyan) 0%, #a0e9ff 50%, var(--orange) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* ===== APP LAYOUT ===== */

.app-layout {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    min-height: calc(100vh - 60px);
}

/* ===== PANELS ===== */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-control {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.control-section {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

.control-section:last-child {
    border-bottom: none;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

/* ===== SELECT ===== */

.select-wrapper {
    position: relative;
    margin-bottom: 0.6rem;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-dim);
    pointer-events: none;
}

.obj-select {
    width: 100%;
    appearance: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 2rem 0.55rem 0.75rem;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--transition);
}

.obj-select:hover { border-color: var(--border-light); }
.obj-select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan-dim); }

/* ===== OBJ PROPS ===== */

.obj-props {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.prop-label {
    color: var(--text-muted);
}

.prop-value {
    color: var(--text);
    text-align: right;
    font-weight: 500;
}

.prop-value.obj1-accent { color: var(--cyan); }
.prop-value.obj2-accent { color: var(--orange); }

/* ===== CONTROLS ===== */

.control-row {
    margin-bottom: 0.85rem;
}

.control-row:last-child { margin-bottom: 0; }

.control-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    font-weight: 400;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.slider {
    flex: 1;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--cyan);
    border: 2px solid var(--bg);
    box-shadow: 0 0 8px var(--cyan-glow);
    cursor: pointer;
    transition: transform var(--transition);
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--cyan);
    border: 2px solid var(--bg);
    box-shadow: 0 0 8px var(--cyan-glow);
    cursor: pointer;
}

.slider-value {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--cyan);
    min-width: 85px;
    text-align: right;
    font-weight: 500;
}

/* ===== CHECKBOX ===== */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text);
    user-select: none;
}

.checkbox { display: none; }

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    position: relative;
}

.checkbox:checked + .checkbox-custom {
    background: var(--cyan);
    border-color: var(--cyan);
}

.checkbox:checked + .checkbox-custom::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid var(--bg);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

/* ===== NUMBER INPUT ===== */

.input-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.num-input {
    width: 80px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.6rem;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    text-align: right;
    font-weight: 500;
    transition: border-color var(--transition);
}

.num-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan-dim); }
.num-input::-webkit-inner-spin-button { opacity: 0.3; }

.input-unit {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */

.control-buttons {
    display: flex;
    gap: 0.6rem;
    flex-direction: row;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
}

.btn-primary {
    background: var(--cyan);
    color: var(--bg);
    box-shadow: 0 2px 12px var(--cyan-glow);
}

.btn-primary:hover {
    background: #33ecff;
    box-shadow: 0 4px 20px var(--cyan-glow);
    transform: translateY(-1px);
}

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

.btn-primary.running {
    background: var(--red);
    box-shadow: 0 2px 12px var(--red-dim);
}

.btn-primary.running:hover {
    background: #ff7070;
    box-shadow: 0 4px 20px var(--red-dim);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
    transform: translateY(-1px);
}

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

/* ===== TIPS ===== */

.tips-section {
    background: linear-gradient(135deg, var(--cyan-dim), transparent);
}

.tip-text {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text);
    margin-bottom: 0.6rem;
}

.btn-tip {
    background: transparent;
    color: var(--cyan);
    border: 1px solid var(--cyan-dim);
    font-size: 0.72rem;
    padding: 0.35rem 0.75rem;
    flex: 0;
}

.btn-tip:hover {
    background: var(--cyan-dim);
}

/* ===== MAIN AREA ===== */

.main-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.sim-and-data {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 1rem;
    flex: 1;
    align-items: stretch;
    min-height: 420px;
}

/* ===== SIMULATION CANVAS ===== */

.canvas-wrapper {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 380px;
    height: clamp(320px, 42vh, 560px);
}

.canvas-wrapper canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.result-banner {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.65rem 1.3rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text);
    white-space: nowrap;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 10;
}

.result-banner.visible {
    transform: translateX(-50%) translateY(0);
}

.result-banner .delta-time {
    color: var(--cyan);
    font-weight: 600;
}

/* ===== DATA PANEL ===== */

.panel-data {
    padding: 1rem;
    overflow: hidden;
}

.panel-data .section-title {
    margin-bottom: 1rem;
}

.data-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.35rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    align-items: baseline;
}

.data-header {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.2rem;
}

.data-obj1-header { color: var(--cyan); text-align: right; }
.data-obj2-header { color: var(--orange); text-align: right; }

.data-label {
    color: var(--text-muted);
    font-weight: 400;
    padding: 0.15rem 0;
}

.data-value {
    text-align: right;
    font-weight: 500;
    padding: 0.15rem 0;
    transition: color 0.15s;
}

.data-obj1 { color: var(--cyan); }
.data-obj2 { color: var(--orange); }

.data-value.landed {
    text-shadow: 0 0 8px currentColor;
}

/* ===== GRAPH ===== */

.graph-wrapper {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    height: 220px;
    position: relative;
}

.graph-title {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 2;
}

.graph-wrapper canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== VACUUM EFFECT ===== */

body.vacuum-mode .canvas-wrapper {
    border-color: rgba(0, 229, 255, 0.2);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== RESPONSIVE ===== */

@media (max-width: 1100px) {
    .sim-and-data {
        grid-template-columns: 1fr;
    }

    .panel-data {
        order: -1;
    }

    .data-grid {
        font-size: 0.75rem;
    }

    .sim-and-data {
        min-height: 360px;
    }

    .canvas-wrapper {
        min-height: 340px;
        height: clamp(300px, 38vh, 500px);
    }
}

@media (max-width: 860px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .panel-control {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .control-section {
        flex: 1;
        min-width: 200px;
        border-bottom: none;
        border-right: 1px solid var(--border);
    }

    .control-section:last-child { border-right: none; }

    .header-inner {
        flex-direction: column;
        text-align: center;
        gap: 0.3rem;
    }
}

@media (max-width: 600px) {
    html { font-size: 13px; }

    .panel-control {
        flex-direction: column;
    }

    .control-section {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .graph-wrapper { height: 180px; }
}
