/*
  ============================================================================================================
  [ Credits & License ]
  
  - Project:    도로랜드 정보국 훈련소
  - Creator:    XYLO
  - Powered by: DORO Inc.
  - Version:    1.3.3 (2026.04.29.)
  - Source:     https://github.com/xylito/doroland-smart-guide
  - License:    CC BY-SA 4.0 (상업적 이용 가능 / 동일 조건 변경 허락 / 저작자 표시)
  
  이 저작물은 공공데이터를 활용한 웹 개발 교육용 실습 자료로 제작되었습니다.
  미래의 훌륭한 웹 마스터가 될 여러분을 응원합니다!
  ============================================================================================================
*/

        .header-controls {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .color-picker-container, .status-badge {
            background: var(--badge-bg, rgba(0,0,0,0.1));
            border: 1px solid var(--primary);
            color: var(--primary);
            padding: 0 12px;
            height: 30px;
            box-sizing: border-box;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .status-badge {
            animation: pulse 2s infinite;
            line-height: normal;
            margin-left: 5px;
        }
        
        .color-picker-container {
            gap: 6px;
        }
        
        .color-picker-container label {
            cursor: pointer;
            font-size: 0.85rem;
        }

        #color-picker {
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            border: none;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            cursor: pointer;
            padding: 0;
            background: none;
        }
        
        #color-picker::-webkit-color-swatch-wrapper {
            padding: 0;
        }
        
        #color-picker::-webkit-color-swatch {
            border: 2px solid rgba(255, 255, 255, 0.5);
            border-radius: 50%;
        }

        #hex-value {
            font-family: monospace;
            font-size: 0.85rem;
            color: var(--primary);
            background: var(--hex-bg, rgba(0,0,0,0.1));
            padding: 2px 6px;
            border-radius: 4px;
            user-select: all;
            letter-spacing: 1px;
        }

body {
            font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
            background-color: var(--bg-dark);
            background-image: 
                radial-gradient(circle at 10% 20%, var(--radial-1) 0%, transparent 20%),
                radial-gradient(circle at 90% 80%, var(--radial-2) 0%, transparent 20%);
            transition: background-color 0.4s ease, color 0.4s ease;
            color: var(--text-main);
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            word-break: keep-all;
            overflow-wrap: break-word;
        }

        header {
            position: sticky;
            top: 0;
            padding: 15px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: var(--header-bg);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--header-border);
            transition: background 0.4s ease, border-color 0.4s ease;
            z-index: 90;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: 900;
            color: var(--text-main);
            display: flex;
            align-items: center;
            gap: 10px;
            line-height: 1;
        }

        .logo span {
            color: var(--primary);
            text-shadow: 0 0 10px var(--primary-glow);
        }

        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 var(--primary-glow); }
            70% { box-shadow: 0 0 0 10px transparent; }
            100% { box-shadow: 0 0 0 0 transparent; }
        }

        .main-container {
            display: flex;
            flex: 1;
            padding: 20px;
            gap: 20px;
            height: calc(100vh - 105px);
            box-sizing: border-box;
        }

        .panel {
            background-color: var(--panel-bg);
            border: 1px solid var(--panel-border);
            border-radius: 16px;
            display: flex;
            flex-direction: column;
            box-shadow: 0 10px 30px var(--panel-shadow);
            overflow: hidden;
            transition: transform 0.2s, box-shadow 0.2s, background-color 0.4s ease, border-color 0.4s ease;
            scroll-margin-top: 100px;
        }

        .panel-header {
            padding: 15px 20px;
            background: var(--panel-header-bg);
            border-bottom: 1px solid var(--panel-header-border);
            font-weight: bold;
            color: var(--primary);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        /* Columns Layout */
        .scenario-col { flex: 1.2; min-width: 300px; }
        .editor-col { flex: 1.5; min-width: 300px; }
        .preview-col { flex: 1.5; min-width: 300px; }

        /* Scenario Content */
        .scenario-content {
            padding: 20px;
            overflow-y: auto;
            flex: 1;
        }

        .dictionary-box {
            background: var(--dict-bg);
            border: 1px solid var(--dict-border);
            border-radius: 8px;
            margin-bottom: 25px;
            overflow: hidden;
        }

        .dictionary-box summary {
            padding: 15px;
            background: var(--dict-summary-bg);
            cursor: pointer;
            color: var(--primary);
            outline: none;
            user-select: none;
            font-size: 1.05rem;
        }
        
        .dictionary-box summary:hover {
            background: var(--dict-summary-hover);
        }

        .dict-content {
            padding: 15px;
            font-size: 0.9rem;
            color: var(--dict-text);
            line-height: 1.6;
            max-height: 400px;
            overflow-y: auto;
        }

        .dict-content h4 {
            color: var(--accent);
            margin: 15px 0 10px 0;
            border-bottom: 1px dashed var(--dict-divider);
            padding-bottom: 5px;
        }
        
        .dict-content h4:first-child { margin-top: 0; }

        .dict-content ul {
            padding-left: 20px;
            margin: 0 0 15px 0;
        }

        .dict-content li {
            margin-bottom: 8px;
        }

        .dict-content i {
            color: #94a3b8;
            font-size: 0.85rem;
        }

        .intro-box {
            background: linear-gradient(135deg, var(--intro-gradient), rgba(0, 0, 0, 0));
            border-left: 4px solid var(--primary);
            padding: 15px;
            border-radius: 0 8px 8px 0;
            margin-bottom: 25px;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .agent-avatar {
            width: 90px;
            height: auto;
            max-height: 120px;
            object-fit: contain;
            filter: drop-shadow(0 0 8px var(--primary-glow));
        }

        .intro-text {
            line-height: 1.6;
            font-size: 0.95rem;
            flex: 1;
        }

        .mission-card {
            background: var(--mission-bg);
            border: 1px solid var(--mission-border);
            border-radius: 10px;
            padding: 15px;
            margin-bottom: 15px;
            position: relative;
        }

        .mission-step {
            position: absolute;
            top: -10px;
            left: 15px;
            background: var(--accent);
            color: #000;
            font-weight: 900;
            padding: 2px 10px;
            border-radius: 12px;
            font-size: 0.8rem;
        }

        .mission-card h3 {
            margin: 10px 0 5px 0;
            font-size: 1.1rem;
            color: var(--mission-title);
        }

        .mission-card p {
            font-size: 0.9rem;
            color: var(--text-muted);
            margin-bottom: 10px;
            line-height: 1.5;
        }

        .code-wrapper {
            position: relative;
            margin-top: 5px;
        }

        .copy-btn {
            position: absolute;
            top: 5px;
            right: 5px;
            background: var(--panel-bg);
            border: 1px solid var(--panel-border);
            border-radius: 4px;
            padding: 4px;
            cursor: pointer;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
            font-size: 14px;
            box-shadow: 0 2px 5px var(--panel-shadow);
            color: var(--text-main);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 5;
        }

        .code-wrapper:hover .copy-btn {
            opacity: 1;
            visibility: visible;
        }

        .copy-btn:hover {
            transform: scale(1.05);
            background: var(--bg-dark);
        }

        .copy-btn:active {
            transform: scale(0.95);
        }

        .mission-card code {
            display: block;
            white-space: pre-wrap;
            word-break: keep-all;      /* 한글 단어 중간 줄바꿈 방지 */
            overflow-wrap: break-word; /* 긴 코드/URL은 여전히 줄바꿈 허용 */
            overflow-x: auto;
            padding: 10px;
            line-height: 1.4;
        }

        code {
            background: var(--code-bg);
            color: var(--primary);
            padding: 3px 8px;
            border-radius: 4px;
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.9rem;
        }

        .tag-hint {
            display: inline-block;
            margin-top: 5px;
            background: var(--tag-hint-bg);
            color: var(--accent);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: bold;
        }

        /* Editor */
        .editor-container {
            flex: 1;
            position: relative;
            padding: 15px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .CodeMirror {
            width: 100%;
            flex: 1;
            height: 0;
            font-family: 'Courier New', Courier, monospace;
            font-size: 16px;
            border: 1px solid var(--editor-border);
            border-radius: 8px;
            line-height: 1.5;
        }

        .CodeMirror-focused {
            border-color: var(--primary);
            box-shadow: 0 0 10px var(--primary-glow);
        }
        
        .cm-highlight-html {
            background-color: rgba(249, 115, 22, 0.15) !important;
            outline: 1px solid rgba(249, 115, 22, 0.5);
        }
        
        .cm-highlight-css {
            background-color: rgba(56, 189, 248, 0.15) !important;
            outline: 1px solid rgba(56, 189, 248, 0.5);
        }
        
        .cm-highlight-js {
            background-color: rgba(234, 179, 8, 0.15) !important;
            outline: 1px solid rgba(234, 179, 8, 0.5);
        }

        /* Preview */
        .preview-container {
            flex: 1;
            background: #fff; /* White background for preview */
            position: relative;
        }

        iframe {
            width: 100%;
            height: 100%;
            border: none;
            position: absolute;
            top: 0;
            left: 0;
        }

        /* ---------- Global Styles ---------- */
        html {
            scroll-behavior: smooth;
        }

        /* Scrollbar styling */
        ::-webkit-scrollbar { width: 8px; }
        ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
        ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: var(--primary); }

        /* Codewhisper Hint Styles */
        .whisper-hint {
            color: var(--accent) !important;
            font-weight: bold;
            border-left: 3px solid var(--accent);
            padding-left: 8px !important;
        }
        .CodeMirror-hints {
            border: 1px solid var(--primary);
            background: var(--panel-bg) !important;
            box-shadow: 0 4px 15px var(--panel-shadow);
            border-radius: 8px;
            padding: 5px 0;
            z-index: 200;
        }
        .CodeMirror-hint {
            color: var(--text-main);
            padding: 4px 12px !important;
            border-radius: 4px;
            margin: 0 4px;
        }
        .CodeMirror-hint-active {
            background-color: var(--primary) !important;
            color: #fff !important;
        }

        @media (max-width: 1024px) {
            .main-container { flex-direction: column; height: auto; overflow-y: auto;}
            .panel { min-height: 400px; }
            body { overflow: auto; height: auto; }
            header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
                padding: 15px 20px;
            }
            .logo {
                flex-wrap: wrap;
                font-size: 1.2rem;
            }
            .header-controls {
                width: 100%;
                justify-content: flex-end;
            }
            .CodeMirror {
                height: 350px !important;
                flex: none;
            }
            .editor-container {
                overflow: visible;
                display: block;
            }
            .preview-container {
                height: 350px;
                flex: none;
                display: block;
            }
        }
        
        /* Hide mobile nav on desktop by default */
        .mobile-nav {
            display: none;
        }

        @media (max-width: 1024px) {
            .mobile-nav {
                display: flex;
                position: fixed;
                bottom: 70px;
                right: 20px;
                gap: 8px;
                z-index: 1000;
            }
            .nav-btn {
                background: rgba(248, 250, 252, 0.9);
                border: 1px solid rgba(226, 232, 240, 0.6);
                color: #334155;
                padding: 8px 16px;
                border-radius: 20px;
                font-size: 0.9rem;
                font-weight: bold;
                cursor: pointer;
                display: flex;
                align-items: center;
                gap: 5px;
                transition: all 0.3s ease;
                user-select: none;
                text-decoration: none;
                font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
            }
            .nav-btn:hover, .nav-btn:active {
                background: rgba(248, 250, 252, 1);
                transform: scale(1.05);
            }
        }



        @media (min-width: 1025px) and (max-width: 1536px) {
            .main-container {
                display: grid;
                grid-template-columns: 1fr 1fr;
                grid-template-rows: 1fr 1fr;
                gap: 20px;
            }
            .scenario-col {
                grid-column: 1 / 2;
                grid-row: 1 / 3;
                min-width: unset;
                height: 100%;
            }
            .editor-col {
                grid-column: 2 / 3;
                grid-row: 1 / 2;
                min-width: unset;
            }
            .preview-col {
                grid-column: 2 / 3;
                grid-row: 2 / 3;
                min-width: unset;
            }
            .intro-box {
                flex-direction: column;
                align-items: center;
                text-align: center;
            }
        }
    
        .ui-footer {
            text-align: center;
            font-size: 0.75rem;
            color: var(--text-muted);
            padding: 8px 0;
            line-height: 1.4;
            background: var(--bg-dark);
            border-top: 1px solid var(--footer-border);
            z-index: 10;
        }
        .ui-footer a {
            color: var(--primary);
            text-decoration: none;
        }
        .ui-footer a:hover {
            text-decoration: underline;
        }

        /* Header Controls */
        .header-controls {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            align-items: center;
        }
        .portal-btn {
            background: rgba(248, 250, 252, 0.9);
            border: 1px solid rgba(226, 232, 240, 0.6);
            color: #334155;
            padding: 5px 12px;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            transition: all 0.3s ease;
            user-select: none;
            text-decoration: none;
            font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
        }
        .portal-btn:hover {
            background: rgba(248, 250, 252, 1);
            transform: scale(1.05);
        }
        [data-theme="light"] .portal-btn {
            background: rgba(15, 23, 42, 0.85);
            border: 1px solid #1e293b;
            color: #f8fafc;
        }
        [data-theme="light"] .portal-btn:hover {
            background: rgba(15, 23, 42, 0.95);
        }

        /* Theme Toggle */
        .theme-toggle {
            background: rgba(248, 250, 252, 0.9);
            border: 1px solid rgba(226, 232, 240, 0.6);
            color: #334155;
            padding: 5px 12px;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            transition: all 0.3s ease;
            user-select: none;
            font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
        }
        .theme-toggle:hover {
            background: rgba(248, 250, 252, 1);
            transform: scale(1.05);
        }
        .theme-toggle .toggle-icon {
            font-size: 0.85rem;
            transition: transform 0.4s ease;
            transform: rotate(180deg);
        }
        [data-theme="light"] .theme-toggle {
            background: rgba(15, 23, 42, 0.85);
            border: 1px solid #1e293b;
            color: #f8fafc;
        }
        [data-theme="light"] .theme-toggle:hover {
            background: rgba(15, 23, 42, 0.95);
        }
        [data-theme="light"] .theme-toggle .toggle-icon {
            transform: rotate(0deg);
        }
    
/* Agent Switch Navigation */
.agent-switch-nav {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 1000;
}

.agent-switch-btn {
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.6);
    color: #334155;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    user-select: none;
    text-decoration: none;
    font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.agent-switch-btn:hover, .agent-switch-btn:active {
    background: rgba(248, 250, 252, 1);
    transform: scale(1.05);
}

.agent-switch-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}


/* Table Styles */
.attr-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.85rem;
    background: var(--panel-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px var(--panel-shadow);
}

.attr-table th, .attr-table td {
    padding: 10px 15px;
    border: 1px solid var(--mission-border);
    text-align: left;
}

.attr-table th {
    background: var(--panel-header-bg);
    color: var(--primary);
    font-weight: bold;
}

.attr-table td code {
    background: none;
    padding: 0;
    color: var(--text-main);
    font-weight: bold;
}
