/* 나의 이야기 — 웹앱 CSS */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4a6741;
    --primary-light: #6b8f5e;
    --primary-dark: #35502e;
    --bg: #faf9f6;
    --bg-card: #ffffff;
    --text: #2c2c2c;
    --text-light: #666;
    --border: #e0ddd5;
    --danger: #c0392b;
    --success: #27ae60;
    --warning: #f39c12;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

html { font-size: 18px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: var(--bg); color: var(--text);
    line-height: 1.7; min-height: 100vh;
    display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── 헤더 ── */
.site-header {
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    padding: 0.7rem 1.5rem; position: sticky; top: 0; z-index: 100;
}
.header-inner {
    max-width: 1000px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.header-nav { display: flex; gap: 1rem; }
.header-nav a { font-size: 0.88rem; }

/* ── 메인 ── */
.main-wrap {
    max-width: 1000px; width: 100%; margin: 0 auto;
    padding: 2rem 1.5rem; flex: 1;
}
.site-footer {
    text-align: center; padding: 1.2rem;
    color: var(--text-light); font-size: 0.78rem;
    border-top: 1px solid var(--border);
}

/* ── 공통 컴포넌트 ── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-light); }
.empty-state p { margin-bottom: 1rem; }

.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.2rem; color: var(--primary-dark); }
.page-subtitle { font-size: 0.9rem; color: var(--text-light); margin-bottom: 1.5rem; }
.page-narrow { max-width: 500px; margin: 0 auto; }
.page-header-row { display: flex; justify-content: space-between; align-items: center; }

.hint { display: block; margin-top: 0.3rem; font-size: 0.8rem; color: var(--text-light); }

/* ── 폼 ── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-weight: 600; font-size: 0.88rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.65rem 0.85rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 1rem; font-family: inherit; line-height: 1.5; background: var(--bg-card);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,103,65,0.15);
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* ── 버튼 ── */
.btn {
    display: inline-block; padding: 0.6rem 1.3rem; border: none;
    border-radius: var(--radius); font-size: 0.92rem; font-family: inherit;
    cursor: pointer; transition: background 0.2s; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d0cdc5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; color: #fff; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.82rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── 히어로 ── */
.hero {
    text-align: center; padding: 3.5rem 1rem 3rem;
    background: linear-gradient(135deg, #f0f5ed 0%, #e8efe5 50%, #faf9f6 100%);
    border-radius: 16px; margin-bottom: 2.5rem;
}
.hero-badge {
    display: inline-block; padding: 0.3rem 1rem; border-radius: 20px;
    background: rgba(74,103,65,0.12); color: var(--primary); font-size: 0.82rem;
    font-weight: 600; margin-bottom: 1.2rem;
}
.hero h1 { font-size: 2.2rem; color: var(--primary-dark); margin-bottom: 1rem; line-height: 1.4; }
.hero-desc { font-size: 1.05rem; color: var(--text-light); margin-bottom: 2rem; line-height: 1.7; }
.hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

/* ── 섹션 공통 ── */
.section { padding: 2.5rem 0; }
.section-alt {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 2.5rem 1.5rem; margin: 1rem 0;
}
.section-title { font-size: 1.4rem; font-weight: 700; text-align: center; color: var(--primary-dark); margin-bottom: 0.5rem; }
.section-desc { font-size: 0.95rem; color: var(--text-light); text-align: center; margin-bottom: 2rem; }

/* ── 3단계 ── */
.steps { display: flex; align-items: flex-start; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.step-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 1.5rem; text-align: center; flex: 1; min-width: 200px; max-width: 280px;
    box-shadow: var(--shadow); transition: transform 0.2s;
}
.step-card:hover { transform: translateY(-3px); }
.step-icon {
    width: 48px; height: 48px; border-radius: 50%; background: var(--primary);
    color: #fff; font-size: 1.3rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem;
}
.step-card h3 { font-size: 1.05rem; color: var(--primary-dark); margin-bottom: 0.5rem; }
.step-card p { font-size: 0.85rem; color: var(--text-light); line-height: 1.6; }
.step-arrow {
    font-size: 1.5rem; color: var(--primary-light); align-self: center;
    padding-top: 1rem;
}

/* ── 7챕터 카드 ── */
.chapter-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
}
.ch-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    padding: 1.1rem; text-align: center; transition: transform 0.2s, box-shadow 0.2s;
}
.ch-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.ch-num {
    display: inline-block; font-size: 0.72rem; font-weight: 700; color: var(--primary);
    background: rgba(74,103,65,0.1); padding: 0.15rem 0.6rem; border-radius: 10px;
    margin-bottom: 0.5rem;
}
.ch-card h4 { font-size: 0.95rem; color: var(--text); margin-bottom: 0.3rem; }
.ch-card p { font-size: 0.78rem; color: var(--text-light); }

/* ── 왜 우리인가 ── */
.why-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
}
.why-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 1.5rem; text-align: center; box-shadow: var(--shadow);
}
.why-icon { font-size: 1.8rem; margin-bottom: 0.8rem; }
.why-card h4 { font-size: 1rem; color: var(--primary-dark); margin-bottom: 0.4rem; }
.why-card p { font-size: 0.85rem; color: var(--text-light); line-height: 1.6; }

/* ── CTA ── */
.cta-section {
    text-align: center; padding: 2.5rem 1.5rem; margin-top: 1.5rem;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-radius: 12px; color: #fff;
}
.cta-section h2 { font-size: 1.35rem; margin-bottom: 0.6rem; color: #fff; }
.cta-section p { font-size: 0.95rem; opacity: 0.9; margin-bottom: 1.5rem; }
.cta-section .btn-primary { background: #fff; color: var(--primary-dark); }
.cta-section .btn-primary:hover { background: #f0f0f0; }
.cta-section .btn-secondary { background: rgba(255,255,255,0.2); color: #fff; border: 1px solid rgba(255,255,255,0.4); }
.cta-section .btn-secondary:hover { background: rgba(255,255,255,0.3); }

/* ── 구조 선택 카드 ── */
.structure-options { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.structure-card {
    flex: 1; min-width: 140px; padding: 0.8rem; border: 2px solid var(--border);
    border-radius: var(--radius); cursor: pointer; text-align: center;
    transition: all 0.2s; background: var(--bg);
}
.structure-card:hover { border-color: var(--primary-light); }
.structure-card.selected { border-color: var(--primary); background: rgba(74,103,65,0.06); }
.structure-title { display: block; font-weight: 700; font-size: 0.95rem; color: var(--primary-dark); margin-bottom: 0.2rem; }
.structure-desc { display: block; font-size: 0.78rem; color: var(--text-light); }

/* ── 프로젝트 목록 ── */
.project-list { display: grid; gap: 0.8rem; }
.project-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.3rem;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: var(--shadow);
}
.project-card h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.meta, .sub { font-size: 0.8rem; color: var(--text-light); }
.actions { display: flex; gap: 0.5rem; }

/* ── 챕터 그리드 ── */
.chapter-grid { display: grid; gap: 0.6rem; }
.chapter-row {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.9rem 1.1rem;
    display: flex; justify-content: space-between; align-items: center;
}
.chapter-info h4 { font-size: 0.95rem; margin-bottom: 0.15rem; }
.chapter-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── 뱃지 ── */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-not-started { background: #f5f5f5; color: #999; }
.badge-interviewing { background: #fff3e0; color: #e65100; }
.badge-writing { background: #e3f2fd; color: #1565c0; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }

/* ── 프로그레스 바 ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 0.6rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }

/* ── 로딩 ── */
.loading { display: none; text-align: center; padding: 1.5rem; color: var(--text-light); }
.loading.active { display: block; }
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 0.6rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 인터뷰 채팅 ── */
.interview-container { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 400px; }
.interview-header {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.7rem 1rem; margin-bottom: 0.5rem;
    flex-shrink: 0;
}
.interview-header h2 { font-size: 1.05rem; margin-bottom: 0.15rem; }

.chat-messages {
    flex: 1; min-height: 0; overflow-y: auto; padding: 0.8rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 0.5rem;
    display: flex; flex-direction: column; gap: 0.7rem;
}
.message {
    max-width: 80%; padding: 0.7rem 1rem; border-radius: 12px;
    font-size: 0.92rem; line-height: 1.6; word-break: break-word;
}
.message-assistant {
    align-self: flex-start; background: #f0ede6; border-bottom-left-radius: 4px;
    position: relative;
}
.message-assistant .msg-text { margin-right: 1.8rem; }
.btn-speak {
    position: absolute; top: 0.5rem; right: 0.5rem;
    background: none; border: none; cursor: pointer;
    color: #aaa; padding: 4px; border-radius: 50%;
    transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.btn-speak:hover { color: var(--primary); background: rgba(74,103,65,0.1); }
.btn-speak.active { color: var(--primary); animation: speak-pulse 1s ease-in-out infinite; }
@keyframes speak-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
#autoSpeakBtn.active { background: var(--primary); color: #fff; }
.message-user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.message-system { align-self: center; background: #e3f2fd; color: #1565c0; font-size: 0.82rem; max-width: 90%; text-align: center; }

.chat-input { display: flex; gap: 0.5rem; flex-shrink: 0; }
/* 입력창 + 트레이싱 ghost text */
.input-wrap {
    flex: 1; position: relative;
}
.ghost-text {
    display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    padding: 0.7rem 0.9rem;
    font-size: 1rem; font-family: inherit; line-height: 1.5;
    color: #c0b8a8; pointer-events: none;
    white-space: pre-wrap; overflow: hidden;
    z-index: 1;
}
.chat-input textarea {
    width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 1rem; font-family: inherit;
    resize: none; min-height: 48px; max-height: 120px; line-height: 1.5;
    background: transparent; position: relative; z-index: 2;
}
.chat-input textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,103,65,0.15); }
.chat-input .btn { align-self: flex-end; min-width: 70px; }

.chat-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; flex-shrink: 0; }

.typing-indicator {
    display: none; align-self: flex-start; padding: 0.5rem 0.9rem;
    background: #f0ede6; border-radius: 12px; font-size: 0.82rem; color: var(--text-light);
}
.typing-indicator.active { display: block; }

/* ── 음성 입력 ── */
.btn-mic {
    align-self: flex-end; min-width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: 50%; color: var(--text-light);
    padding: 0; cursor: pointer; transition: all 0.2s;
}
.btn-mic:hover { border-color: var(--primary); color: var(--primary); }
.btn-mic.recording {
    background: #fee; border-color: #e53935; color: #e53935;
    animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.3); }
    50% { box-shadow: 0 0 0 10px rgba(229,57,53,0); }
}
.voice-status {
    display: none; padding: 0.5rem 0.8rem; margin-top: 0.3rem;
    font-size: 0.85rem; color: #e53935; text-align: center;
    background: #fff5f5; border: 1px solid #ffcdd2; border-radius: var(--radius);
    align-items: center; justify-content: center; gap: 0.5rem;
    flex-shrink: 0;
}
.voice-status.active { display: flex; }
.voice-dot {
    display: inline-block; width: 10px; height: 10px; min-width: 10px;
    background: #e53935; border-radius: 50%;
    animation: voice-blink 1s ease-in-out infinite;
}
@keyframes voice-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.7); }
}

/* ── 에디터 ── */
.editor-container { display: grid; grid-template-columns: 1fr 300px; gap: 1.2rem; align-items: start; }
.editor-main {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.3rem;
}
.manuscript-content {
    min-height: 280px; padding: 1rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 1rem; line-height: 1.9;
    white-space: pre-wrap; background: #fefefe;
}
.manuscript-content:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,103,65,0.15); }
.editor-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

.editor-sidebar { display: flex; flex-direction: column; gap: 0.8rem; }
.sidebar-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem;
}
.sidebar-card h4 { font-size: 0.9rem; margin-bottom: 0.6rem; color: var(--primary-dark); }
.info-text { font-size: 0.82rem; color: var(--text-light); }
.info-text p { margin-bottom: 0.2rem; }

.version-list { list-style: none; font-size: 0.82rem; }
.version-list li { padding: 0.3rem 0; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; }
.version-list li:last-child { border-bottom: none; }
.version-current { font-weight: 700; color: var(--primary); }
.ver-date { color: var(--text-light); font-size: 0.78rem; }

/* ── Harness 평가 ── */
.eval-box {
    background: #f8f7f4; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.8rem; font-size: 0.85rem;
}
.eval-row { display: flex; justify-content: space-between; padding: 0.25rem 0; border-bottom: 1px solid #eee; }
.eval-row:last-of-type { border-bottom: none; }
.eval-score { font-weight: 700; }
.eval-pass { color: var(--success); }
.eval-fail { color: var(--danger); }
.eval-verdict { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 2px solid var(--border); font-weight: 700; font-size: 0.95rem; }
.verdict-approved { color: var(--success); }
.verdict-revision { color: var(--warning); }
.eval-detail { margin-top: 0.5rem; font-size: 0.8rem; color: var(--text-light); }

/* ── 미리보기 / 전체 보기 ── */
.preview-container {
    max-width: 700px; margin: 0 auto; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 2.5rem; box-shadow: var(--shadow);
}
.preview-title { font-size: 1.3rem; text-align: center; margin-bottom: 0.3rem; color: var(--primary-dark); }
.preview-subtitle { text-align: center; font-size: 0.88rem; color: var(--text-light); margin-bottom: 1.5rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--border); }
.preview-body { font-size: 1.02rem; line-height: 2; white-space: pre-wrap; }
.full-section { margin-bottom: 2.5rem; }

/* ── 내보내기 ── */
.export-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1rem; }
.export-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.3rem; text-align: center;
}
.export-card h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.export-card p { font-size: 0.82rem; color: var(--text-light); margin-bottom: 0.8rem; }

/* ── 진행 상태 (멈춤/계속) ── */
.process-status { text-align: center; }
.process-buttons {
    display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.8rem;
}
.paused-msg {
    margin-top: 0.6rem; padding: 0.5rem 1rem;
    background: #fff8e1; border: 1px solid #ffe082;
    border-radius: var(--radius); font-size: 0.88rem; color: #f57f17;
}

/* ── 다음 챕터 네비게이션 ── */
.next-nav {
    display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap;
    padding: 1rem; margin-top: 0.8rem;
    background: linear-gradient(135deg, #f0f5ed, #e8efe5);
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    flex-shrink: 0;
    animation: navSlideIn 0.3s ease;
}
.next-nav .btn { font-size: 0.95rem; padding: 0.7rem 1.5rem; }
@keyframes navSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── 소스 자료 페이지 ── */
.source-toolbar {
    display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
    margin-bottom: 1.2rem;
}
.source-stat {
    font-size: 0.82rem; color: var(--text-light); margin-left: auto;
}
.source-empty {
    text-align: center; padding: 3rem 1.5rem;
    background: var(--bg-card); border: 2px dashed var(--border);
    border-radius: 12px; color: var(--text-light);
}
.source-empty p { margin-bottom: 0.5rem; }
.source-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.8rem;
}
.source-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 1rem; box-shadow: var(--shadow);
    transition: transform 0.15s;
    cursor: default;
}
.source-card:hover { transform: translateY(-2px); }
.source-card-head {
    display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem;
}
.source-icon { font-size: 1.2rem; }
.source-title {
    flex: 1; font-weight: 600; font-size: 0.92rem; color: var(--primary-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.source-del {
    background: none; border: none; cursor: pointer; font-size: 1.3rem;
    color: #ccc; padding: 0 4px; line-height: 1;
}
.source-del:hover { color: var(--danger); }
.source-preview {
    font-size: 0.82rem; color: var(--text-light); line-height: 1.5;
    max-height: 3.6em; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.source-meta {
    margin-top: 0.5rem; font-size: 0.75rem; color: #bbb;
}

/* ── 소스 채팅창 ── */
.source-chat {
    margin-top: 1.5rem; border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden; background: var(--bg-card);
    box-shadow: var(--shadow);
}
.source-chat-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.8rem 1.2rem; background: var(--primary-dark); color: #fff;
    cursor: pointer; font-size: 0.95rem; font-weight: 600;
    user-select: none;
}
.source-chat-toggle { font-size: 0.8rem; }
.source-chat-body {
    display: none; flex-direction: column;
}
.source-chat-body.open { display: flex; }
.source-chat-messages {
    height: 300px; overflow-y: auto; padding: 0.8rem;
    display: flex; flex-direction: column; gap: 0.6rem;
    background: #faf9f6;
}
.source-chat-messages .message { max-width: 85%; font-size: 0.9rem; }
.source-chat-messages .message-user {
    align-self: flex-end; background: var(--primary); color: #fff;
    padding: 0.6rem 0.9rem; border-radius: 12px; border-bottom-right-radius: 4px;
}
.source-chat-messages .message-assistant {
    align-self: flex-start; background: #f0ede6;
    padding: 0.6rem 0.9rem; border-radius: 12px; border-bottom-left-radius: 4px;
}
.source-chat-messages .message-system {
    align-self: center; background: #fce4ec; color: #c62828;
    padding: 0.4rem 0.8rem; border-radius: 8px; font-size: 0.82rem;
}
.src-typing { color: var(--text-light); font-style: italic; }
.source-chat-input {
    display: flex; gap: 0.4rem; padding: 0.6rem 0.8rem;
    border-top: 1px solid var(--border); background: var(--bg-card);
}
.source-chat-input input {
    flex: 1; padding: 0.5rem 0.8rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.92rem; font-family: inherit;
}
.source-chat-input input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74,103,65,0.15);
}

/* ── 모달 ── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-box {
    background: var(--bg-card); border-radius: 12px; padding: 1.8rem;
    max-width: 600px; width: 100%; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.modal-box h3 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--primary-dark); }
.modal-box textarea { min-height: 200px; }

/* ── 책 읽기 뷰어 ── */
.reader { max-width: 750px; margin: 0 auto; }
.reader-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.8rem;
}
.reader-title { font-size: 1.1rem; font-weight: 700; color: var(--primary-dark); }
.reader-page { font-size: 0.85rem; color: var(--text-light); }

.reader-nav-top { margin-bottom: 1rem; }
.reader-toc {
    width: 100%; padding: 0.5rem 0.8rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.92rem; font-family: inherit;
    background: var(--bg-card);
}

.reader-body {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 2.5rem 2rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    min-height: 400px;
}
.reader-chapter-title {
    font-size: 1.3rem; font-weight: 700; text-align: center;
    color: var(--primary-dark); margin-bottom: 0.3rem;
}
.reader-chapter-sub {
    text-align: center; font-size: 0.88rem; color: var(--text-light);
    margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}
.reader-content {
    font-size: 1.05rem; line-height: 2; white-space: pre-wrap;
}

.reader-nav {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 1.2rem; padding: 0.5rem 0;
}
.reader-prev, .reader-next { min-width: 100px; }

@media (max-width: 768px) {
    .reader-body { padding: 1.5rem 1rem; }
    .reader-content { font-size: 1rem; }
}

/* ── 삽화 생성 ── */
.illust-panel {
    margin-top: 1.2rem; padding: 1.5rem;
    background: #faf5ff; border: 1px solid #e0d4f0;
    border-radius: 12px;
}
.illust-panel h4 { color: #6b3fa0; margin-bottom: 0.4rem; }

.scene-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.scene-item {
    padding: 0.6rem 0.8rem; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer; font-size: 0.88rem;
    transition: all 0.15s;
}
.scene-item:hover { border-color: #8e6bb8; background: #f5f0fa; }
.scene-item.selected { border-color: #8e6bb8; background: #ede4f7; font-weight: 600; }

.illust-result { margin-top: 1rem; text-align: center; }
.illust-image {
    max-width: 100%; max-height: 500px; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15); margin-bottom: 1rem;
}
.illust-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.illust-prompt {
    margin-top: 0.8rem; font-size: 0.78rem; color: var(--text-light);
    padding: 0.5rem; background: #f5f5f5; border-radius: var(--radius);
}
.illust-fallback {
    padding: 1.2rem; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); text-align: left;
}
.illust-fallback h4 { margin-bottom: 0.3rem; }
.illust-links {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.6rem; margin-top: 1rem;
}
.illust-link-card {
    display: flex; flex-direction: column; padding: 0.8rem;
    background: #f5f0fa; border: 1px solid #e0d4f0; border-radius: var(--radius);
    text-align: center; text-decoration: none; transition: all 0.15s;
}
.illust-link-card:hover { border-color: #8e6bb8; transform: translateY(-2px); }
.illust-link-card strong { font-size: 0.92rem; color: #6b3fa0; margin-bottom: 0.2rem; }
.illust-link-card span { font-size: 0.78rem; color: var(--text-light); }
.illust-prompt-box {
    padding: 0.8rem; background: #f8f7f4; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.88rem; line-height: 1.6;
    margin-top: 0.5rem; font-family: monospace; word-break: break-all;
}

/* ── 보안 안내 ── */
.security-guide {
    margin-top: 2rem; padding: 1.5rem;
    background: #fefcf7; border: 1px solid #e8e0d0;
    border-radius: 12px;
}
.security-guide h3 {
    font-size: 1.15rem; color: var(--primary-dark);
    margin-bottom: 0.4rem;
}
.security-guide > p {
    font-size: 0.9rem; color: var(--text-light);
    margin-bottom: 1.2rem; line-height: 1.6;
}
.security-items { display: flex; flex-direction: column; gap: 1rem; }
.security-item {
    display: flex; gap: 0.8rem; align-items: flex-start;
}
.security-icon {
    min-width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; margin-top: 2px;
}
.security-item h4 {
    font-size: 0.95rem; margin-bottom: 0.2rem; color: var(--text);
}
.security-item p {
    font-size: 0.85rem; color: var(--text-light); line-height: 1.6;
}
.security-item a { text-decoration: underline; }

/* ── 반응형 ── */
@media (max-width: 768px) {
    html { font-size: 16px; }
    .header-inner { flex-direction: column; gap: 0.4rem; }
    .main-wrap { padding: 1rem; }
    .project-card, .chapter-row { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
    .editor-container { grid-template-columns: 1fr; }
    .message { max-width: 90%; }
    .hero h1 { font-size: 1.6rem; }
    .hero { padding: 2rem 1rem; }
    .steps { flex-direction: column; align-items: center; }
    .step-arrow { transform: rotate(90deg); padding: 0; }
    .step-card { max-width: 100%; }
    .section-alt { padding: 1.5rem 1rem; }
    .cta-section { padding: 2rem 1rem; }
    .preview-container { padding: 1.5rem; }
    .page-header-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
