/* ===== CSS 변수 (Stone 색상) ===== */
:root {
    --bg-primary: #f5f5f4;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fafaf9;
    --bg-hover: #e7e5e4;
    --border-color: #d6d3d1;
    --border-light: #e7e5e4;
    --text-primary: #1c1917;
    --text-secondary: #44403c;
    --text-muted: #78716c;
    --accent-color: #007bff;
    --success-color: #16a34a;
    --note-bg: #f7f5f0;
    --note-border: #dcd7cd;
    --note-text: #5c5855;
    --read-accent: #4a5d4e;
    --read-bg: #dfe7e2;
}

:root.dark {
    --bg-primary: #1c1917;
    --bg-secondary: #1c1917;
    --bg-tertiary: #292524;
    --bg-hover: #44403c;
    --border-color: #44403c;
    --border-light: #373330;
    --text-primary: #e7e5e4;
    --text-secondary: #d6d3d1;
    --text-muted: #a8a29e;
    --accent-color: #60a5fa;
    --success-color: #4ade80;
    --note-bg: #2b2624; 
    --note-border: #57534e;
    --note-text: #d6d3d1;
    --read-accent: #8ba895;
    --read-bg: #2c332e;
}

* {
    box-sizing: border-box;
}

/* ===== 헤더 (바 형태) ===== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 55px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr minmax(0, 540px) 1fr;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.logo i {
    font-size: 1.3rem;
}

/* 전체 제목 입력칸 */
#novel-title {
    box-sizing: border-box;
    width: 100%;
    max-width: 540px;
    padding: 10px 15px;
    font-size: 18px;
    font-weight: bold;
    color: var(--text-primary);
    border: none;
    border-bottom: 2px solid transparent;
    outline: none;
    background-color: transparent;
    transition: border-color 0.2s;
}

#novel-title:focus {
    border-bottom-color: var(--accent-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-self: end;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn i {
    font-size: 1.1rem;
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

/* [읽기 모드 스타일] 헤더 아이콘 버튼 */
.icon-btn.reading-mode {
    color: var(--read-bg);
    background-color: var(--read-accent);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* 헤더 드롭다운 */
.header-dropdown {
    position: relative;
}

.header-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 1001;
}

.header-dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item i {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* 햄버거 - 기본적으로 숨김 */
.hamburger-btn {
    display: none;
}

.mobile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 160px;
    z-index: 1001;
}

.mobile-menu.hidden {
    display: none;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.mobile-menu-item:hover {
    background: var(--bg-hover);
}

.mobile-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* 768px 이하 */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }
    
    /* 저장 버튼 외 숨김 */
    .header-right .header-btn:not(#btn-save),
    .header-right .header-dropdown,
    .header-right .header-divider,
    .header-right .icon-btn:not(.hamburger-btn) {
        display: none;
    }
    
    /* 도움말 버튼도 숨김 */
    #btn-help {
        display: none;
    }

    .focus-mode .hamburger-btn {
        display: none;
    }
    
    .focus-mode #btn-focus {
        display: flex !important;
    }
}

/* ===== 기본 레이아웃 설정 ===== */
body {
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 75px 20px 20px 20px;
    font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    height: 100dvh;
    overflow: hidden;
    color: var(--text-primary);
}

.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 0;
}

/* 동기화 상태 표시 */
.sync-status {
    font-size: 13px;
    color: var(--text-muted);
}

.sync-status.synced {
    color: var(--success-color);
}

#novel-title::placeholder {
    color: var(--text-muted);
}

/* 에디터 래퍼 */
.editor-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    min-height: 0;
}

/* YouTube 패널 (왼쪽 끝) */
.youtube-panel {
    position: fixed;
    left: 20px;
    top: 75px;
    width: 320px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    box-sizing: border-box;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
}

.panel-input {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    outline: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.panel-input:focus {
    border-color: var(--accent-color);
}

.panel-input::placeholder {
    color: var(--text-muted);
}

.radio-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.radio-label i {
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
}

.radio-label .ph-youtube-logo {
    color: #ff0000;
}

.radio-label .ph-music-notes {
    color: var(--accent-color);
}

.panel-toggle-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.panel-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.youtube-content {
    padding: 0 10px 10px 10px;
}

.youtube-content.hidden {
    display: none;
}

.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 15px;
    height: 15px;
    cursor: nesw-resize;
    background: linear-gradient(-45deg, var(--text-muted) 50%, transparent 50%);
}

.resize-handle:hover {
    background: linear-gradient(-45deg, var(--accent-color) 50%, transparent 50%);
}

.youtube-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

#youtube-iframe {
    width: 100%;
    height: 100%;
}

/* 편집 영역 (중앙 고정 540px) */
.editor-area {
    flex: 1;
    width: 100%;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 본문 에디터 */
#novel-editor {
    flex: 1;
    height: auto !important;
    width: 100%;
    padding: 20px;
    font-size: 18px;
    line-height: 1.8;
    border: 1px solid var(--border-color);
    border-radius: 0 0 4px 4px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    resize: none;
    outline: none;
    overflow-y: auto;
    word-break: break-all;
    box-sizing: border-box;
    transition: all 0.2s;
}

#novel-editor:focus {
    border-color: var(--accent-color);
}

#novel-editor::placeholder {
    color: var(--text-muted);
}

/* 섹션 헤더 및 컨트롤 */
.section-header {
    display: flex;
    align-items: stretch;
}

#section-title {
    flex: 1;
    padding: 12px 15px;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 4px 0 0 0; /* 오른쪽 위 라운드 제거 */
    outline: none;
    background-color: var(--bg-tertiary);
    box-sizing: border-box;
    transition: border-color 0.2s;
    min-width: 0; /* Flexbox 축소 문제 방지 */
}

#section-title:focus {
    border-color: var(--accent-color);
    background-color: var(--bg-secondary);
    z-index: 1; /* 포커스 시 테두리 위로 */
}

/* 버튼 그룹 래퍼 */
.section-controls {
    display: flex;
}

/* 컨트롤 버튼 공통 스타일 */
.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-left: none; /* 왼쪽 테두리는 앞 요소와 공유 */
    background-color: var(--bg-tertiary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    white-space: nowrap;
}

.control-btn:last-child {
    border-radius: 0 4px 0 0; /* 마지막 버튼만 둥글게 */
}

.control-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.control-btn i {
    font-size: 1.1em;
}

/* 읽기 모드 활성화 스타일 */
.control-btn.reading-mode {
    background-color: var(--bg-secondary);
    color: var(--accent-color);
    border-bottom: 1px solid var(--bg-secondary); /* 아래 터주기 */
}

/* 노트 타입 스타일 */
.editor-area.note-mode .control-btn {
    background-color: var(--note-bg);
    border-color: var(--note-border);
    color: var(--note-text);
}

.editor-area.note-mode #section-title {
    background-color: var(--note-bg);
    border-color: var(--note-border);
}

/* 노트 타입일 때 편집 영역 스타일 */
.editor-area.note-mode #novel-editor {
    border-color: var(--note-border);
    background-color: var(--note-bg);
}

/* 섹션 사이드바 (오른쪽 끝) */
.section-sidebar {
    position: fixed;
    right: 20px;
    top: 75px;
    width: 200px;
    display: flex;
    flex-direction: column;
}

.section-list {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow-y: auto;
    max-height: 60vh;
}

.section-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: default;
    border-bottom: 1px solid var(--border-light);
    border-left: 3px solid transparent;
    transition: background 0.15s;
}

.section-item.dragging {
    opacity: 0.5;
    background: var(--bg-hover);
}

.section-item:last-child {
    border-bottom: none;
}

.section-item:hover {
    background: var(--bg-hover);
}

.section-item.active {
    background: var(--bg-hover);
    border-left-color: var(--accent-color);
}

/* 노트 타입 섹션 스타일 */
.section-item.note-type {
    background: var(--note-bg);
}

.section-item.note-type.active {
    background: var(--note-bg);
    border-left-color: var(--note-border);
}

.section-item.note-type:hover {
    background: var(--note-bg);
}

.section-label {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.drag-handle {
    flex-shrink: 0;
    width: 16px;
    color: var(--text-muted);
    font-size: 10px;
    cursor: grab;
    user-select: none;
    opacity: 0.5;
    transition: opacity 0.15s;
    margin-right: 4px;
}

.section-item:hover .drag-handle {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

.section-delete-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    flex-shrink: 0;
}

.section-delete-btn:hover {
    background: #ffebee;
    color: #d32f2f;
}

.add-section-btn {
    width: 100%;             /* 가로 꽉 차게 */
    margin-top: 10px;
    padding: 12px;           /* 터치 영역 확보 */
    
    background: transparent; /* 배경 투명하게 (눈부심 방지) */
    border: 1px dashed var(--border-color); /* 점선 테두리 */
    border-radius: 6px;
    
    color: var(--text-muted); /* 회색 글씨 (눈 편안함) */
    font-size: 14px;
    font-weight: 500;
    
    cursor: pointer;
    transition: all 0.2s;
    
    /* 아이콘과 텍스트 정렬 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.add-section-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background-color: var(--bg-hover);
    border-style: solid; /* 호버 시 실선으로 바뀌며 "누를 수 있음" 강조 (선택사항) */
}

/* 마크다운 미리보기 */
.hidden {
    display: none !important;
}

.markdown-preview {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0 0 4px 4px;
    background-color: var(--bg-secondary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.preview-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    
    background: var(--read-bg); 
    color: var(--read-accent);
    
    padding: 8px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--note-border);
    
    position: sticky;
    top: 0;
}

#preview-content {
    padding: 20px;
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
}

#preview-content h1,
#preview-content h2,
#preview-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

#preview-content h1:first-child,
#preview-content h2:first-child,
#preview-content h3:first-child {
    margin-top: 0;
}

#preview-content p {
    margin-bottom: 1em;
}

#preview-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

#preview-content pre {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
}

#preview-content blockquote {
    border-left: 4px solid var(--border-color);
    margin: 1em 0;
    padding-left: 15px;
    color: var(--text-secondary);
}

#preview-content ul,
#preview-content ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

#preview-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* 선택 영역 이동 */
.move-text-wrapper {
    position: relative;
    margin-top: 10px;
}

.move-text-wrapper button {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
}

.move-text-wrapper button:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.move-text-wrapper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.move-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

.move-option {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
    color: var(--text-primary);
}

.move-option:last-child {
    border-bottom: none;
}

.move-option:hover {
    background: var(--bg-hover);
}

.move-option.new-section {
    color: var(--success-color);
    font-weight: bold;
}

/* 상태바 (에디터 바로 아래) */
.status-bar {
    width: 100%;
    margin-top: 8px;
    background-color: transparent;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    font-size: 13px;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 목표 글자수 토글 버튼 */
.goal-toggle-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.goal-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.goal-toggle-btn.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* 목표 표시 영역 */
.goal-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.goal-display.hidden {
    display: none;
}

/* 프로그레스 바 */
.goal-progress-bar {
    width: 100px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.goal-progress-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.goal-progress-fill.complete {
    background: var(--success-color);
}

/* 목표 텍스트 */
.goal-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 목표 수정 버튼 */
.goal-edit-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.goal-edit-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 목표 입력 영역 */
.goal-input-area {
    display: flex;
    align-items: center;
    gap: 4px;
}

.goal-input-area.hidden {
    display: none;
}

.goal-input {
    width: 70px;
    height: 26px;
    padding: 0 8px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
}

.goal-input:focus {
    border-color: var(--accent-color);
}

.goal-input-suffix {
    font-size: 12px;
    color: var(--text-muted);
}

.goal-input-btn {
    padding: 4px 8px;
    font-size: 11px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.goal-input-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.goal-input-btn.cancel {
    color: var(--text-muted);
}

.status-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-toggle-btn {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.status-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.char-count-display {
    font-weight: 600;
    color: var(--text-primary);
}

/* 링크 컨트롤 */
.link-controls {
    width: 100%;
    max-width: 540px;
    margin-top: 15px;
    padding: 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
}

.link-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.link-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.link-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
}

/* 링크 박스 */
.link-box {
    width: 100%;
    max-width: 540px;
    margin-top: 10px;
    padding: 12px 15px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    font-size: 14px;
}

.link-box span {
    white-space: nowrap;
    color: var(--text-secondary);
}

.link-box input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-width: 0;
}

/* Import/Export 버튼 */
#file-input, #section-file-input { display: none; }

/* 도움말 모달 */
.help-modal-content {
    max-height: 80vh;
    width: 90%;
    max-width: 500px;
}

.help-modal-body {
    overflow-y: auto;
    max-height: 60vh;
}

.help-section {
    margin-bottom: 24px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.help-section p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.shortcut-list {
    font-size: 14px;
    color: var(--text-secondary);
}

.shortcut-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-action-btn {
    padding: 12px 15px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.modal-action-btn:hover {
    background: var(--bg-hover);
}

/* 모달 필드 (라벨 + 셀렉트) */
.modal-field {
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-field label {
    width: 50px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.modal-field select {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.modal-field select:focus {
    border-color: var(--accent-color);
}

/* 포맷 설명 텍스트 */
.modal-field-desc {
    margin-left: 65px;
    margin-top: -5px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* 모달 제출 버튼 */
.modal-submit-btn {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    background: var(--success-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-submit-btn:hover {
    opacity: 0.9;
}

/* 드래그 앤 드롭 활성화 */
.drag-active .editor-area {
    outline: 3px dashed var(--accent-color);
    outline-offset: -3px;
    background-color: var(--bg-hover);
}

/* 토스트 알림 */
#toast {
    visibility: hidden;
    min-width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 5px;
    padding: 10px;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    z-index: 100;
}

#toast.show {
    visibility: visible;
    animation: fadein 0.5s, fadeout 0.5s 1.5s;
}

@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* 반응형 (모바일) */
@media (max-width: 1020px) {
    .editor-wrapper {
        flex-direction: column; 
        align-items: center;
        gap: 20px;
    }

    .youtube-panel {
        position: static;
        width: 100%;
        max-width: 540px;
        margin-bottom: 15px;
        order: 1;
    }

    .section-sidebar {
        width: calc(50vw - 310px);
        max-width: 540px;
    }
}

@media (max-width: 1293px) {
    .header-btn span {
        display: none;
    }
}

@media (max-width: 1057px) {
    .logo span {
        display: none;
    }
}

@media (max-width: 768px) {
    .editor-wrapper {
        flex-direction: column;
        align-items: center;
    }
    
    .editor-area {
        width: 100%;
        max-width: 540px;
    }
    
    .section-sidebar {
        position: static;
        width: 100%;
        max-width: 540px;
        margin-top: 15px;
    }
    
    .section-list {
        max-height: 30vh;
    }

    .youtube-panel { display: none; }

    .logo { display: none; }
}

/* 포커스 모드 */
.focus-mode .header-left { visibility: hidden; }
.focus-mode .header-right > *:not(#btn-focus) { visibility: hidden; }
.focus-mode .header-divider { display: none; }
.focus-mode .youtube-panel { display: none; }
.focus-mode .section-sidebar { display: none; }
.focus-mode .status-bar { display: none; }
