:root {
    --background: #f8f6fc;
    --foreground: #211a2e;
    --card: #ffffff;
    --card-foreground: #211a2e;
    --primary: #6d28d9;
    --primary-hover: #5b21b6;
    --primary-foreground: #ffffff;
    --secondary: #efe9fa;
    --secondary-hover: #e2d7f7;
    --secondary-foreground: #2f2249;
    --muted: #f1edf8;
    --muted-foreground: #6c6379;
    --accent: #0d9488;
    --accent-foreground: #ffffff;
    --success: #1f8a5f;
    --success-soft: #e6f6ee;
    --warning: #9a5b00;
    --warning-soft: #fff3d9;
    --danger: #b23b52;
    --danger-soft: #ffeef1;
    --border: #e2d9f2;
    --input: #d4c5ec;
    --ring: #7c3aed;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(45, 25, 66, .05), 0 12px 36px rgba(45, 25, 66, .07);
    --max-width: 840px;
    --sans: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #17121f;
        --foreground: #f1edf9;
        --card: #201933;
        --card-foreground: #f1edf9;
        --primary: #b39ef2;
        --primary-hover: #c4b3f5;
        --primary-foreground: #201040;
        --secondary: #2c2242;
        --secondary-hover: #382c54;
        --secondary-foreground: #f1edf9;
        --muted: #251e38;
        --muted-foreground: #b5abc4;
        --accent: #2dd4bf;
        --accent-foreground: #06302b;
        --success: #7bd6ab;
        --success-soft: #1b3327;
        --warning: #efc46c;
        --warning-soft: #392f1a;
        --danger: #f2909f;
        --danger-soft: #3a2028;
        --border: #3b2f56;
        --input: #4b3d69;
        --ring: #c4b1f5;
        --shadow: 0 14px 36px rgba(0, 0, 0, .3);
    }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--foreground);
    background: var(--background);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: .18em; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
h1, h2, h3, p { overflow-wrap: anywhere; }

.skip-link {
    position: fixed; left: 16px; top: -100px; z-index: 100;
    padding: 10px 14px; border-radius: 8px;
    background: var(--foreground); color: var(--background);
}
.skip-link:focus { top: 16px; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }

/* 헤더 */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.masthead {
    max-width: var(--max-width); margin: 0 auto; padding: 20px 22px;
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark-link { display: inline-flex; border-radius: 12px; transition: transform .15s ease; text-decoration: none; }
.brand-mark-link:hover, .brand-mark-link:focus-visible { transform: scale(1.05); }
.brand-mark {
    flex: 0 0 auto; display: grid; place-items: center; width: 42px; height: 42px;
    border-radius: 11px; background: var(--secondary); color: var(--primary);
    font-size: 1.2rem; font-weight: 800;
}
h1 { margin: 0; font-size: 1.1rem; line-height: 1.25; letter-spacing: -.02em; }
h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.55rem); line-height: 1.3; letter-spacing: -.025em; }
.subtitle { margin: 2px 0 0; color: var(--muted-foreground); font-size: .82rem; }
.header-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.header-actions form { margin: 0; }
.header-actions a.header-link, .link-button, .text-button {
    border: 0; padding: 4px 8px; background: transparent; color: var(--muted-foreground);
    font-size: .84rem; font-weight: 650; cursor: pointer; text-decoration: none;
}
.header-actions a.header-link:hover, .link-button:hover, .text-button:hover { color: var(--foreground); text-decoration: underline; }
.header-actions a.home-button {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 34px; padding: 0 14px; border: 1px solid var(--border);
    border-radius: 999px; background: var(--card); color: var(--primary);
    font-size: .82rem; font-weight: 700; text-decoration: none;
}
.header-actions a.home-button:hover {
    border-color: var(--primary); background: var(--secondary); color: var(--primary);
}

/* 페이지 쉘 */
.page-shell { max-width: var(--max-width); margin: 0 auto; padding: 28px 22px 64px; }
.workspace { display: flex; flex-direction: column; gap: 20px; }

/* 스텝 진행률 레일 (Flow Rail) */
.flow-rail {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
    gap: 8px; margin: 0 auto 6px; padding: 0; list-style: none; color: var(--muted-foreground);
    font-size: .82rem; font-weight: 650;
}
.flow-rail li { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 0 auto; }
.flow-rail li:not(:last-child)::after {
    content: ""; width: 32px; height: 2px; flex: 0 0 auto; background: var(--border);
}
.flow-rail span {
    display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto;
    border: 1px solid var(--border); border-radius: 999px; background: var(--card);
    font-variant-numeric: tabular-nums; font-size: .82rem;
}
.flow-rail .is-current { color: var(--foreground); font-weight: 750; }
.flow-rail .is-current span { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.flow-rail .is-complete span { border-color: var(--success); background: var(--success-soft); color: var(--success); }

/* 패널 공통 */
.panel {
    min-width: 0; padding: clamp(20px, 4vw, 28px);
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow);
}
.step-section.is-hidden, .panel.is-hidden { display: none !important; }

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-heading.compact-heading { margin-bottom: 12px; }
.section-number {
    margin: 0 0 4px; color: var(--primary); font-size: .75rem;
    font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
}
.badge {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
    padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--secondary); color: var(--secondary-foreground);
    font-size: .75rem; font-weight: 650; white-space: nowrap;
}
.badge.estimate { color: var(--warning); background: var(--warning-soft); border-color: transparent; }

/* 파일 드롭존 */
.drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 200px; padding: 28px 20px; border: 2px dashed var(--border);
    border-radius: var(--radius); background: var(--muted); cursor: pointer;
    text-align: center; transition: all .2s ease;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-dragover {
    border-color: var(--primary); background: var(--secondary);
}
.drop-mark {
    display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 12px;
    border-radius: 16px; background: var(--card); color: var(--primary);
    font-size: 1.1rem; font-weight: 800; box-shadow: var(--shadow);
}
.drop-zone strong { font-size: 1.05rem; margin-bottom: 6px; }
.drop-zone span { color: var(--muted-foreground); font-size: .84rem; margin-bottom: 16px; }
.native-file-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.file-status { padding: 10px 14px; border-radius: 8px; background: var(--muted); font-size: .88rem; }
.file-summary { margin-top: 18px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.file-name-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.file-name-row strong { font-size: 1rem; word-break: break-all; }

/* 메트릭스 그리드 */
.metrics-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px;
    margin: 0; padding: 0; list-style: none;
}
.metrics-grid div { padding: 12px; border-radius: 10px; background: var(--muted); }
.metrics-grid dt { color: var(--muted-foreground); font-size: .75rem; font-weight: 600; margin-bottom: 4px; }
.metrics-grid dd { margin: 0; font-size: 1rem; font-weight: 750; font-variant-numeric: tabular-nums; word-break: break-all; }

/* AI 작품 조사 카드 */
.research-smart-card {
    padding: 20px; margin-bottom: 22px; border: 1px solid var(--border);
    border-radius: 12px; background: var(--secondary);
}
.research-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.research-icon { font-size: 1.5rem; line-height: 1; }
.research-card-header strong { display: block; font-size: .98rem; color: var(--foreground); }
.research-card-header p { margin: 2px 0 0; font-size: .82rem; color: var(--muted-foreground); }

.field-with-action { display: flex; gap: 10px; flex-wrap: wrap; }
.field-with-action input { flex: 1; min-width: 220px; }

.research-progress { margin-top: 14px; padding: 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); }
.research-progress-meta { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: 8px; }
.research-progress-track { height: 8px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.research-progress-track span { display: block; height: 100%; width: 0%; background: var(--primary); transition: width .3s ease; }
.research-status { margin-top: 10px; font-size: .84rem; color: var(--muted-foreground); }
.research-quality { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.research-quality div { padding: 8px; border-radius: 6px; background: var(--card); text-align: center; }
.research-quality dt { font-size: .7rem; color: var(--muted-foreground); }
.research-quality dd { font-size: .9rem; font-weight: 700; margin: 0; }
.research-actions { margin-top: 10px; }

.research-conflict-panel { margin-top: 16px; padding: 16px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); }
.research-conflict-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.research-conflict-heading {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}
.research-conflict-heading input[type="checkbox"] {
    width: 18px;
    min-width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    cursor: pointer;
}
.research-conflict-heading strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* 폼 요소 */
.form-grid { display: grid; gap: 16px; }
.form-grid.compact-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full-field { grid-column: 1 / -1; }
.field span { font-size: .84rem; font-weight: 650; color: var(--foreground); }
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--input);
    border-radius: 10px; background: var(--card); color: var(--card-foreground);
    transition: border-color .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ring); outline: none; }
.field.checkbox-field { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.field.checkbox-field input { width: auto; }

/* 접기/열기 (Advanced Settings) */
.advanced-settings { margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }
.advanced-settings summary {
    padding: 14px 18px; font-weight: 700; font-size: .9rem; cursor: pointer;
    color: var(--muted-foreground); user-select: none; transition: color .15s ease;
}
.advanced-settings summary:hover { color: var(--foreground); }
.advanced-settings[open] summary { border-bottom: 1px solid var(--border); color: var(--primary); }
.advanced-settings .form-grid, .advanced-settings .diagnostic-content { padding: 18px; }

/* 예상 처리량 박스 */
.estimate-summary-box { margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--muted); }
.fine-print { margin: 10px 0 0; font-size: .78rem; color: var(--muted-foreground); line-height: 1.45; }

/* 버튼 스타일 */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border: 1px solid transparent; border-radius: 10px;
    font-size: .9rem; font-weight: 700; cursor: pointer; text-decoration: none;
    transition: all .15s ease; white-space: nowrap;
}
.button.primary { background: var(--primary); color: var(--primary-foreground); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { background: var(--secondary); color: var(--secondary-foreground); border-color: var(--border); }
.button.secondary:hover { background: var(--secondary-hover); }
.button.danger { background: var(--danger); color: #fff; }
.button.large { padding: 14px 28px; font-size: 1rem; border-radius: 12px; }
.button:disabled { opacity: .5; cursor: not-allowed; }

.step-action-row, .action-row { display: flex; align-items: center; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.step-action-row { justify-content: flex-end; }

/* 진행바 (Progress) */
.progress-track { height: 12px; border-radius: 999px; background: var(--muted); overflow: hidden; margin: 16px 0 10px; }
.progress-track span { display: block; height: 100%; width: 0%; background: var(--primary); transition: width .3s ease; }
.progress-percent { font-size: 1.8rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.progress-status { font-size: .92rem; font-weight: 600; color: var(--muted-foreground); margin: 0 0 16px; }

/* 결과 패널 */
.result-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.result-icon {
    display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto;
    border-radius: 999px; background: var(--success-soft); color: var(--success);
    font-size: 1.5rem; font-weight: 800;
}

/* 알림/노티스 */
.notice { padding: 14px 18px; border-radius: 10px; margin-bottom: 20px; font-size: .88rem; }
.notice-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); }
.notice-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }

/* 푸터 */
.site-footer { max-width: var(--max-width); margin: 0 auto; padding: 24px 22px; text-align: center; color: var(--muted-foreground); font-size: .8rem; }

/* 반응형 */
@media (max-width: 640px) {
    .masthead {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 12px 16px;
    }
    .brand-lockup {
        display: flex;
        align-items: center;
        flex: 1 1 auto;
        min-width: 0;
        gap: 10px;
    }
    .brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 1.15rem;
    }
    h1 {
        font-size: 1.05rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0;
    }
    .subtitle {
        display: none !important;
    }
    .header-actions {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 6px;
        align-self: center;
    }
    .header-actions a.home-button {
        min-height: 32px;
        padding: 6px 12px;
        font-size: .82rem;
        gap: 4px;
    }
    .flow-rail { font-size: .72rem; }
    .flow-rail span { width: 22px; height: 22px; font-size: .75rem; }
    .flow-rail li:not(:last-child)::after { width: 16px; }
    .step-action-row { justify-content: stretch; }
    .step-action-row .button { flex: 1; }
    .field-with-action { flex-direction: column; }
}

@media (max-width: 380px) {
    h1 { font-size: 0.95rem; }
    .header-actions a.home-button { padding: 5px 10px; font-size: .78rem; }
}

