/*
 * 색맹 친화적 컬러셋 (Cloud Dancer 기반)
 * - Class A (label=1): Teal (#008080 계열) + 원형(⬤)
 * - Class B (label=0): Amber (#D4740A 계열) + 삼각형(▲)
 * - 배경 그라데이션: Teal/Amber 톤
 * - 가중치(+): Steel Blue | 가중치(-): Warm Coral
 */
:root {
    --color-bg: #F2F0EB;            /* Cloud Dancer (Warm White) */
    --color-bg-alt: #E8E6E1;
    --color-text: #3A3A3A;
    --color-text-light: #6B6B6B;

    --color-primary: #4A7C8A;       /* Teal Blue */
    --color-primary-hover: #3B6570;
    --color-accent: #D4740A;        /* Amber */
    --color-accent-hover: #B8630A;

    --color-class-a: #008B8B;       /* 색맹 친화: Teal (class 1) */
    --color-class-b: #D4740A;       /* 색맹 친화: Amber (class 0) */

    --color-weight-pos: #4A7C8A;    /* 양의 가중치 */
    --color-weight-neg: #C75B39;    /* 음의 가중치 */

    --color-panel: #FFFFFF;
    --color-border: #D5D3CE;

    --color-danger: #C75B39;
    --color-danger-hover: #A44A2E;
    --color-success: #5A9E6F;
    --color-info: #B8860B;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.65;
}

/* === Layout === */
.app-container {
    max-width: 1440px; margin: 0 auto; padding: 16px;
    display: flex; flex-direction: column; height: 100vh;
}

header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 24px; background: var(--color-panel);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
header h1 { font-size: 1.4rem; font-weight: 700; color: var(--color-primary); letter-spacing: -0.02em; }

.student-info { display: flex; gap: 8px; }
.student-info input {
    padding: 9px 14px; border: 1px solid var(--color-border);
    border-radius: 8px; font-family: inherit; font-size: 0.9rem;
    outline: none; transition: border 0.25s;
}
.student-info input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(74,124,138,0.15); }

.main-content { display: flex; gap: 16px; flex: 1; overflow: hidden; }

/* === Left Panel === */
.simulator-panel {
    flex: 1.15; display: flex; flex-direction: column; gap: 12px;
    overflow-y: auto; padding-right: 4px;
}

.canvas-wrapper {
    background: var(--color-panel); border-radius: var(--radius);
    box-shadow: var(--shadow-md); padding: 16px;
    display: flex; justify-content: center; align-items: center;
    position: relative;
}

#mainCanvas { border-radius: 10px; cursor: crosshair; }

/* 범례 (Legend) */
.canvas-legend {
    position: absolute; top: 20px; right: 24px;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(4px);
    padding: 8px 12px; border-radius: 8px; font-size: 0.78rem;
    border: 1px solid var(--color-border); line-height: 1.8;
}
.canvas-legend .legend-item { display: flex; align-items: center; gap: 6px; }
.legend-circle { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-triangle { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid; display: inline-block; }

.controls-card {
    background: var(--color-panel); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-md);
}

.play-controls { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

button {
    padding: 10px 18px; border: none; border-radius: 8px;
    font-family: inherit; font-weight: 600; font-size: 0.88rem;
    cursor: pointer; transition: all 0.2s ease; color: white;
}
.btn-primary { background: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); }

.btn-secondary { background: #8A9BAE; }
.btn-secondary:hover { background: #6F8296; }

.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-hover); }

.btn-info { background: var(--color-info); }
.btn-info:hover { background: #9A7209; }

.btn-submit {
    background: linear-gradient(135deg, var(--color-primary), #5A9E6F);
    font-size: 1rem; padding: 14px;
}
.btn-submit:hover { opacity: 0.92; transform: translateY(-1px); }

.hyperparams {
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: center; font-size: 0.88rem;
}
.hyperparams label { display: flex; align-items: center; gap: 5px; font-weight: 500; }
.hyperparams input[type="number"], .hyperparams select {
    width: 72px; padding: 6px 8px; border: 1px solid var(--color-border);
    border-radius: 6px; outline: none; font-size: 0.88rem;
}
.hyperparams input[type="number"]:focus, .hyperparams select:focus {
    border-color: var(--color-primary);
}
fieldset {
    border: 1px solid var(--color-border); border-radius: 8px;
    padding: 4px 10px; display: flex; gap: 10px; align-items: center;
}
legend { font-size: 0.78rem; color: var(--color-text-light); padding: 0 4px; }

/* === Network Diagram (TF Playground 스타일) === */
.network-diagram-card {
    background: var(--color-panel); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-md);
}

.network-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.network-header h3 { font-size: 1rem; flex: 1; }

.badge-pos, .badge-neg {
    padding: 3px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700;
}
.badge-pos { background: rgba(74,124,138,0.12); color: var(--color-weight-pos); }
.badge-neg { background: rgba(199,91,57,0.12); color: var(--color-weight-neg); }

.network-container {
    position: relative; display: flex; justify-content: space-between;
    align-items: stretch; min-height: 170px; background: var(--color-bg-alt);
    border-radius: 10px; padding: 18px 36px; border: 1px solid var(--color-border);
}

#networkSvg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1; pointer-events: none;
}

.network-layer {
    display: flex; flex-direction: column; justify-content: space-around;
    z-index: 2; gap: 8px;
}

/* 둥근 사각형 노드 (TF Playground 방식) */
.node {
    width: 52px; height: 52px; border-radius: 10px;
    background: white; border: 2px solid var(--color-border);
    position: relative; display: flex; align-items: center;
    justify-content: center; box-shadow: var(--shadow-sm);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.node:hover { transform: scale(1.12); border-color: var(--color-primary); box-shadow: var(--shadow-md); z-index: 10;}
.node canvas {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; border-radius: 8px;
}
.node span.label {
    position: absolute; bottom: -22px; font-size: 0.72rem; font-weight: 600;
    color: var(--color-text); white-space: nowrap; background: rgba(255,255,255,0.92);
    padding: 1px 6px; border-radius: 4px;
}

/* === Right Panel: Wizard === */
.evaluation-panel { flex: 0.85; }

.wizard-container {
    display: flex; flex-direction: column; height: 100%;
    background: var(--color-panel); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); overflow: hidden;
}

.wizard-header {
    padding: 20px 24px 16px; border-bottom: 1px solid var(--color-border);
    background: #FAFAF8;
}
.wizard-progress {
    height: 5px; background: var(--color-bg-alt); border-radius: 3px;
    margin-bottom: 12px; overflow: hidden;
}
.progress-bar {
    height: 100%; border-radius: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-success));
    transition: width 0.4s ease;
}
.wizard-header h2 { font-size: 1.2rem; margin: 0; letter-spacing: -0.01em; }

.steps-wrapper { flex: 1; position: relative; overflow: hidden; }

.step-card {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    padding: 24px; opacity: 0; visibility: hidden;
    transform: translateX(60px);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow-y: auto;
}
.step-card.active { opacity: 1; visibility: visible; transform: translateX(0); }
.step-card.prev { transform: translateX(-60px); }

.q-box {
    margin-bottom: 18px; background: var(--color-bg);
    padding: 16px; border-radius: 10px; border: 1px solid var(--color-border);
}
.q-box label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.92rem; line-height: 1.6; }
.q-box input[type="number"], .q-box textarea {
    width: 100%; padding: 11px 14px; border: 1px solid var(--color-border);
    border-radius: 8px; font-family: inherit; font-size: 0.92rem;
    resize: vertical; outline: none; transition: border 0.25s;
}
.q-box input[type="number"]:focus, .q-box textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74,124,138,0.12);
}

.q-box .math-eq {
    font-size: 1rem; padding: 6px 0; color: var(--color-text);
}

.metrics { display: flex; gap: 12px; margin-bottom: 18px; }
.metric-box {
    flex: 1; background: rgba(74,124,138,0.06); padding: 14px;
    border-radius: 10px; text-align: center; font-size: 0.85rem;
    border: 1px solid rgba(74,124,138,0.15);
}
.metric-box strong {
    font-size: 1.35rem; color: var(--color-primary);
    display: block; margin-top: 4px; font-weight: 700;
}

.wizard-controls {
    padding: 16px 24px; border-top: 1px solid var(--color-border);
    display: flex; justify-content: space-between; background: #FAFAF8;
}

/* Loss Tutorial 오버레이 */
.loss-tutorial-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(58,58,58,0.65); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 20; border-radius: 10px;
}
.loss-tutorial-card {
    background: white; border-radius: 12px; padding: 24px;
    max-width: 360px; box-shadow: var(--shadow-lg);
    font-size: 0.9rem; line-height: 1.7;
}
.loss-tutorial-card h4 { margin-bottom: 12px; color: var(--color-primary); }
.loss-tutorial-card .loss-item {
    background: var(--color-bg); padding: 10px; border-radius: 8px;
    margin-bottom: 8px; border-left: 3px solid var(--color-accent);
}
.loss-tutorial-card .loss-total {
    text-align: center; font-weight: 700; font-size: 1.05rem;
    padding-top: 8px; border-top: 1px solid var(--color-border);
    color: var(--color-primary);
}

/* 스크롤바 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
/* 아코디언 스타일 (손실함수 유도) */
.theory-accordion {
    margin-bottom: 12px; border: 1px solid var(--color-border);
    border-radius: var(--radius); background: #FAFAF8; overflow: hidden;
}
.theory-accordion summary {
    padding: 12px 16px; font-weight: 600; cursor: pointer;
    background: rgba(0,0,0,0.02); outline: none; list-style: none;
    color: var(--color-text); font-size: 0.95rem; display: flex; align-items: center;
}
.theory-accordion summary::-webkit-details-marker { display: none; }
.theory-accordion summary::after {
    content: "▼"; margin-left: auto; font-size: 0.8rem; transition: transform 0.2s;
}
.theory-accordion[open] summary::after { transform: rotate(180deg); }
.accordion-content {
    padding: 16px; font-size: 0.9rem; line-height: 1.6;
    border-top: 1px solid var(--color-border); background: #fff;
}


/* 슬라이더 */
input[type="range"] {
    -webkit-appearance: none; height: 6px; border-radius: 3px;
    background: var(--color-border); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--color-primary); cursor: pointer;
}

/* 레이어별 노드 수 입력 */
.layer-node-input {
    display: flex; align-items: center; gap: 3px;
    font-size: 0.8rem; background: var(--color-bg); padding: 3px 8px;
    border-radius: 6px; border: 1px solid var(--color-border);
}
.layer-node-input input {
    width: 40px; padding: 2px 4px; border: 1px solid var(--color-border);
    border-radius: 4px; text-align: center; font-size: 0.8rem;
}

/* 컨트롤 잠금 오버레이 */
.controls-lock {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(242,240,235,0.85); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; color: var(--color-text-light); font-size: 0.9rem;
    border-radius: var(--radius); z-index: 5;
}
.hyperparams { position: relative; }

/* 시작 전 블로킹 오버레이 */
.start-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 50; display: flex; align-items: center; justify-content: center;
    background: rgba(242, 240, 235, 0.5);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius);
}
.start-overlay-card {
    background: white; border-radius: 16px; padding: 40px 48px;
    box-shadow: var(--shadow-lg); text-align: center; max-width: 420px;
    animation: fadeInUp 0.5s ease;
}
.start-overlay-card h2 {
    font-size: 1.4rem; color: var(--color-primary); margin-bottom: 12px;
}
.start-overlay-card p { margin: 8px 0; line-height: 1.6; }

.main-content { position: relative; }
.main-content.blurred > section { filter: blur(6px); pointer-events: none; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
