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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.header-actions {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 언어 전환: 한글 | English */
.lang-switcher {
    display: inline-flex;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.4);
}
.lang-switcher-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.lang-switcher-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}
.lang-switcher-btn.active {
    background: rgba(255, 255, 255, 0.95);
    color: #4c1d95;
}

/* 헤더(보라 그라데이션) 위에서 잘 보이는 버튼 */
.btn-header {
    background: rgba(255, 255, 255, 0.95);
    color: #4c1d95;
    text-decoration: none;
}
.btn-header:hover {
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(255, 255, 255, 0.25);
}

/* 어디서든 가이드로 이동 가능한 고정 버튼 */
.floating-guide {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1500;
    padding: 12px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: #4c1d95;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}
.floating-guide:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
}
@media (max-width: 480px) {
    .floating-guide {
        right: 12px;
        bottom: 12px;
        padding: 10px 12px;
        font-size: 13px;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 30px;
}

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

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 그리드 셀 안에서만 차지하도록, 다른 영역을 덮지 않음 */
.preview-section {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-area {
    min-height: 120px;
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.button-group .btn {
    position: relative;
    z-index: 2;
}

.section-header h2 {
    font-size: 1.5em;
    color: #333;
    font-weight: 600;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    transform: none;
    box-shadow: none;
}

.btn-secondary:disabled,
.btn-secondary[disabled] {
    background: #e8e8e8;
    color: #999;
}

/* 미리보기 내 이미지: 썸네일 + 호버 시 복사하기 */
.preview-image-wrap {
    display: block;
    width: 100%;
    position: relative;
    margin: 8px 0;
}

/* 가로 100%, 세로는 비율에 맞게 자동 */
.preview-image-thumb {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

/* 미리보기 이미지 플레이스홀더 (미매칭 시) – JS에서 인라인 스타일로도 적용 */
.preview-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 140px;
    padding: 20px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    color: #64748b;
    font-size: 13px;
    box-sizing: border-box;
}

.preview-image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.preview-image-wrap:hover .preview-image-overlay {
    opacity: 1;
}

.preview-image-copy-btn {
    font-size: 12px;
    padding: 6px 12px;
}

textarea {
    width: 100%;
    min-height: 500px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s ease;
    white-space: pre-wrap; /* 줄바꿈과 공백 보존 (Markdown 하드 브레이크 지원) */
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

#htmlOutput {
    background: #f8f9fa;
    color: #333;
}

/* File Tree Styles */
.file-tree {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.file-tree h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #667eea;
    font-weight: 600;
}

#fileTreeContent {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.file-tree-item {
    padding: 3px 0;
    padding-left: 20px;
    position: relative;
}

.file-tree-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 12px;
    height: 12px;
    transform: translateY(-50%);
}

.file-tree-item.md-file::before {
    content: '📄';
}

.file-tree-item.image-file::before {
    content: '🖼️';
}

.file-tree-item.folder::before {
    content: '📁';
}

.file-tree-item:hover {
    background: #e8e8e8;
    border-radius: 4px;
}

.file-tree-path {
    color: #666;
    word-break: break-all;
}

.file-tree-size {
    color: #999;
    font-size: 11px;
    margin-left: 10px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.close:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-body h1,
.modal-body h2,
.modal-body h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #333;
}

.modal-body p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.modal-body code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.modal-body pre {
    background: #f4f4f4;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 15px;
}

.modal-body pre code {
    background: none;
    padding: 0;
}

.modal-body ul,
.modal-body ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body li {
    margin-bottom: 5px;
}

.modal-body blockquote {
    border-left: 4px solid #667eea;
    padding-left: 15px;
    margin: 15px 0;
    color: #666;
    font-style: italic;
}

.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 15px 0;
    transition: all 0.3s ease;
}

.modal-body img[src^="data:image"] {
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
}

.modal-body img[src^="data:image"]:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.modal-body img[src^="data:image"]:active {
    transform: scale(0.98);
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.modal-body table th,
.modal-body table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.modal-body table th {
    background-color: #f4f4f4;
    font-weight: 600;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 2000;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: #4caf50;
}

.toast.error {
    background: #f44336;
}

/* Help Button */
.help-button {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.close-help {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-help:hover {
    transform: scale(1.2);
}

