/* ==========================================================================
   H-R도표 & 별의 진화 시뮬레이션 - 100vh 뷰포트 고정 (전체 스크롤 차단) 스타일
   ========================================================================== */

@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+KR:wght@300;400;500;700;900&family=Outfit:wght@400;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --bg-dark: #070913;
    --bg-gradient: radial-gradient(circle at top left, #08090f, #101422 65%, #05060b);
    --panel-bg: rgba(12, 16, 28, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary: #00f2fe;
    --accent: #22d3ee;
    --accent-glow: rgba(34, 211, 238, 0.35);
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #a855f7;
    --text-main: #f0f4f8;
    --text-muted: #8892a4;
    
    --font-family: 'Noto Sans KR', 'Inter', sans-serif;
    --font-heading: 'Outfit', 'Noto Sans KR', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-gradient);
    color: var(--text-main);
    font-family: var(--font-family);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.app-container {
    width: 100%;
    max-width: 1650px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

/* 1. APP HEADER BAR */
.app-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-family);
    font-size: 0.85rem;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.back-btn {
    border-color: rgba(255, 255, 255, 0.15);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.title-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pulse-dot {
    width: 9px;
    height: 9px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow);
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 242, 254, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 242, 254, 0);
    }
}

.title-container h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
}

/* 탭 메뉴 */
.sim-tab-menu {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 0.85rem;
    white-space: nowrap;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--primary);
    color: #050711;
    font-weight: 800;
    box-shadow: 0 0 14px rgba(0, 242, 254, 0.4);
}

.principle-btn {
    background: rgba(0, 242, 254, 0.08);
    color: var(--primary);
    border-color: rgba(0, 242, 254, 0.3);
    padding: 8px 28px;
    min-width: 130px;
    justify-content: center;
    font-weight: 600;
}

.principle-btn:hover {
    background: rgba(0, 242, 254, 0.18);
    border-color: rgba(0, 242, 254, 0.5);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* 2. MAIN CONTENT */
main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-content {
    display: none;
    height: 100%;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    min-height: 0;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
}

.search-box input {
    background: none;
    border: none;
    color: var(--text-main);
    outline: none;
    font-size: 12px;
    width: 100%;
}

.select-control {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

/* 3. LAYOUT GRIDS & CARDS */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 10px;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.badge {
    background: rgba(0, 242, 254, 0.15);
    color: var(--primary);
    border: 1px solid rgba(0, 242, 254, 0.3);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
}

.canvas-box {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: rgba(5, 7, 15, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 4. CONTROLS BAR */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(15, 23, 42, 0.5);
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    margin-top: 10px;
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #00f2fe, #0284c7);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    cursor: pointer;
}

.val-badge {
    background: rgba(245, 158, 11, 0.18);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.4);
    font-weight: 700;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 6px;
}

/* 5. SIDE PROP GRID & PRESETS */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.info-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 10px;
    border-radius: 8px;
}

.info-key {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.info-val {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
}

.desc-box {
    margin-top: 10px;
    background: rgba(0, 242, 254, 0.08);
    border-left: 3px solid var(--primary);
    padding: 10px 12px;
    border-radius: 0 8px 8px 0;
    font-size: 11px;
    line-height: 1.5;
    color: #cbd5e1;
}

/* 별 선택 그리드가 빈 공간을 전적으로 채우도록 flex: 1 및 스크롤바 커스텀 스타일링 */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 8px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

/* 커스텀 다크 시안 스크롤바 */
.presets-grid::-webkit-scrollbar {
    width: 6px;
}
.presets-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}
.presets-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 254, 0.35);
    border-radius: 4px;
}
.presets-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 254, 0.7);
}

.preset-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px;
    border-radius: 8px;
    font-size: 11px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.preset-chip:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: var(--primary);
    color: #ffffff;
}

/* 6. MODAL DIALOG */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    width: 90%;
    max-width: 760px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-body {
    font-size: 12.5px;
    line-height: 1.6;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-body h3 {
    color: var(--accent-amber);
    font-size: 14px;
    margin-bottom: 4px;
}

/* ==========================================================================
   Mobile Optimization Suite (Smartphones, Tablets, Touch Devices)
   Harmonized 100% with All Science Simulation Suite Standards
   ========================================================================== */

@media (max-width: 840px) {
    html, body {
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    body {
        padding: 6px;
        align-items: flex-start;
    }

    .app-container {
        width: 100vw;
        max-width: 100%;
        height: auto !important;
        min-height: 100vh;
        padding: 8px;
        gap: 8px;
        overflow: visible !important;
    }

    .app-header {
        padding: 10px 12px;
        border-radius: 12px;
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .header-left {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .title-container h1 {
        font-size: 1.05rem;
        font-weight: 800;
    }

    .sim-tab-menu {
        width: 100%;
        display: flex;
        background: rgba(0, 0, 0, 0.5);
        border: 1px solid var(--panel-border);
        border-radius: 10px;
        padding: 4px;
        box-sizing: border-box;
    }

    .nav-tab, .tab-btn {
        flex: 1;
        justify-content: center;
        text-align: center;
        padding: 9px 12px;
        font-size: 0.85rem;
        font-weight: 600;
        border-radius: 8px;
        color: var(--text-muted);
        background: transparent;
        border: 1px solid transparent;
        touch-action: manipulation;
    }

    .nav-tab.active, .tab-btn.active {
        background: #00f2fe;
        color: #000000;
        font-weight: 800;
        border: 1px solid #00f2fe;
        box-shadow: 0 0 16px var(--accent-glow);
    }

    .header-right {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .principle-btn {
        width: 100%;
        min-width: 100%;
        justify-content: center;
        padding: 9px 20px;
        font-weight: 700;
    }

    /* Main & Layout Cards */
    main,
    .tab-content,
    .tab-content.active,
    .grid-2col,
    .card {
        height: auto !important;
        min-height: min-content !important;
        overflow: visible !important;
        flex: none !important;
    }

    .grid-2col {
        grid-template-columns: 1fr;
        gap: 12px;
        width: 100%;
    }

    .card {
        padding: 12px;
        border-radius: 12px;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px;
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }

    .canvas-box {
        height: 340px !important;
        min-height: 280px !important;
        flex: none !important;
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .info-item {
        padding: 6px 8px;
    }

    .info-key { font-size: 9px; }
    .info-val { font-size: 11px; }

    .presets-grid {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        max-height: 220px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .preset-chip {
        min-height: 44px;
        padding: 6px 4px;
        touch-action: manipulation;
    }

    /* Modal Mobile Optimization */
    .modal-card {
        width: 95%;
        max-height: 88vh;
        overflow-y: auto;
        padding: 18px;
        border-radius: 16px;
    }
}
