:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --accent-lr: #38bdf8;
    --accent-rl: #f43f5e;
    --accent-success: #10b981;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-main: 'Outfit', 'Noto Sans KR', sans-serif;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 85% 85%, rgba(56, 189, 248, 0.12) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
}

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

.logo .icon {
    font-size: 1.8rem;
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-lr);
    box-shadow: 0 0 10px var(--accent-lr);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* Main Layout Grid */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
}

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

/* Visualizer Card */
.visualizer-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.click-hint {
    font-size: 0.85rem;
    color: var(--accent-lr);
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 380px;
    background: #020617;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    cursor: pointer;
}

#simCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Click Interaction Overlay */
.interaction-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.click-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: rgba(30, 41, 59, 0.9);
    border: 2px solid var(--accent-rl);
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.4);
    padding: 16px 28px;
    border-radius: var(--radius-lg);
    color: #fff;
    font-weight: 600;
    animation: bounce 1.5s infinite;
}

.pointer-anim {
    font-size: 2rem;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Readouts Grid */
.readouts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.readout-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.readout-item.Highlight {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

.readout-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.readout-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-lr);
}

.readout-value.diff {
    color: var(--accent-success);
}

.readout-value small {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
}

/* Sidebar Layout */
.sidebar-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-card, .chart-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-card h3, .chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.toggle-group {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.toggle-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-lr);
    cursor: pointer;
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.btn {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Chart Section */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-legend {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.legend-box {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-item.lr .legend-box {
    background: var(--accent-lr);
}

.legend-item.rl .legend-box {
    background: var(--accent-rl);
}

.chart-wrapper {
    width: 100%;
    height: 180px;
    background: #020617;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#chartCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.chart-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    background: rgba(15, 23, 42, 0.5);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-success);
}
