:root {
    --background: #f8f6fc;
    --foreground: #211a2e;
    --card: #ffffff;
    --card-foreground: #211a2e;
    --primary: #6d28d9;
    --primary-foreground: #ffffff;
    --secondary: #efe9fa;
    --secondary-foreground: #2f2249;
    --muted: #f1edf8;
    --muted-foreground: #6c6379;
    --accent: #0d9488;
    --accent-foreground: #ffffff;
    --success: #1f8a5f;
    --success-soft: #e6f6ee;
    --warning: #9a5b00;
    --warning-soft: #fff3d9;
    --destructive: #b23b52;
    --destructive-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: 820px;
    --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-foreground: #201040;
        --secondary: #2c2242;
        --secondary-foreground: #f1edf9;
        --muted: #251e38;
        --muted-foreground: #b5abc4;
        --accent: #2dd4bf;
        --accent-foreground: #06302b;
        --success: #7bd6ab;
        --success-soft: #1b3327;
        --warning: #efc46c;
        --warning-soft: #392f1a;
        --destructive: #f2909f;
        --destructive-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: 10;
    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; }
.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: 12px; background: var(--primary); color: var(--primary-foreground);
    font-size: 1.25rem; 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: 14px; white-space: nowrap; }
.header-actions form { margin: 0; }
.header-actions a, .link-button, .text-button {
    border: 0; padding: 4px 0; background: transparent; color: var(--muted-foreground);
    font-size: .84rem; font-weight: 650; cursor: pointer; text-decoration: none;
}
.header-actions a: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);
    text-decoration: none;
}

.page-shell { max-width: var(--max-width); margin: 0 auto; padding: 34px 22px 64px; }
.workspace { display: flex; flex-direction: column; gap: 18px; }
.flow-rail {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 4px; padding: 0; list-style: none; color: var(--muted-foreground);
    font-size: .78rem; font-weight: 650;
}
.flow-rail li { position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; }
.flow-rail li:not(:last-child)::after {
    content: ""; height: 1px; flex: 1; min-width: 12px; margin-right: 8px; background: var(--border);
}
.flow-rail span {
    display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto;
    border: 1px solid var(--border); border-radius: 999px; background: var(--card);
    font-variant-numeric: tabular-nums;
}
.flow-rail .is-current { color: var(--foreground); }
.flow-rail .is-current span { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }

.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);
}
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-number {
    margin: 0 0 4px; color: var(--muted-foreground); font-size: .72rem;
    font-weight: 750; letter-spacing: .08em; text-transform: uppercase;
}
.badge, .state {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
    padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--secondary); color: var(--secondary-foreground);
    font-size: .72rem; font-weight: 650; line-height: 1.3; white-space: nowrap;
}
.badge.estimate { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.badge.muted { color: var(--muted-foreground); }

.notice {
    display: flex; flex-direction: column; gap: 3px; margin-bottom: 18px; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--card);
}
.notice span { color: var(--muted-foreground); }
.notice-warning { color: var(--warning); background: var(--warning-soft); }
.notice-error { color: var(--destructive); background: var(--destructive-soft); }
.setup-notice span { color: inherit; }

.drop-zone {
    min-height: 190px; padding: 28px 20px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    border: 1.5px dashed var(--input); border-radius: 12px; background: var(--muted);
    text-align: center; cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.drop-zone:hover, .drop-zone.is-dragging, .drop-zone:focus-visible, .drop-zone:focus-within {
    border-color: var(--primary); background: var(--secondary); transform: translateY(-1px);
}
.drop-zone.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }
.drop-zone span { color: var(--muted-foreground); font-size: .85rem; }
.drop-mark {
    display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 4px;
    border-radius: 14px; background: var(--card); color: var(--primary); border: 1px solid var(--border);
    font-size: .78rem; font-weight: 800; letter-spacing: .04em;
}
.native-file-input {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.file-picker-button { display: inline-flex; pointer-events: none; }
.file-picker-help { margin: 10px 0 0; color: var(--muted-foreground); font-size: .78rem; text-align: center; }

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 9px;
    background: var(--secondary); color: var(--secondary-foreground);
    font-weight: 700; cursor: pointer;
    transition: background-color .15s ease, transform .15s ease, opacity .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { background: var(--primary); color: var(--primary-foreground); }
.button.primary:hover:not(:disabled) { filter: brightness(.94); }
.button.secondary { border-color: var(--border); background: var(--card); color: var(--foreground); }
.button.danger { border-color: var(--destructive); background: transparent; color: var(--destructive); }
.button.large { min-height: 48px; padding-inline: 24px; }
.text-button { color: var(--primary); }

.file-summary { margin-top: 18px; }
.file-name-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.file-name-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metrics-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
    margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--border);
}
.metrics-grid > div { min-width: 0; padding: 12px 13px; background: var(--card); }
.metrics-grid dt { color: var(--muted-foreground); font-size: .75rem; font-weight: 600; }
.metrics-grid dd {
    min-width: 0; margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 750; font-variant-numeric: tabular-nums;
}

.option-settings, .advanced-settings, .privacy-disclosure {
    border: 1px solid var(--border); border-radius: 10px; background: var(--card);
}
.option-settings + .advanced-settings { margin-top: 10px; }
.option-settings summary, .advanced-settings summary, .privacy-disclosure summary, .support-table > summary {
    padding: 13px 15px; cursor: pointer; font-weight: 700; list-style-position: inside;
}
.option-settings summary span, .advanced-settings summary span { float: right; color: var(--muted-foreground); font-size: .78rem; font-weight: 550; }
.option-settings__content, .advanced-settings > .form-grid { padding: 4px 15px 16px; }
.advanced-settings.is-preparing { border-color: var(--warning); }
.advanced-settings.is-preparing summary::after { content: " · 준비 중"; color: var(--warning); font-size: .78rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span, .field > label { font-size: .8rem; font-weight: 700; }
.field input, .field select, .field textarea, .login-form input {
    min-width: 0; width: 100%; padding: 10px 11px; border: 1px solid var(--input);
    border-radius: 8px; background: var(--card); color: var(--foreground);
}
.field input, .field select, .login-form input { min-height: 42px; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:disabled { opacity: .65; cursor: not-allowed; }
.field-with-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.field-with-action .button { white-space: nowrap; }
.field-help, .fine-print { color: var(--muted-foreground); font-size: .79rem; }
.full-field { grid-column: 1 / -1; }
.checkbox-field { flex-direction: row; align-items: center; padding-top: 25px; }
.checkbox-field input { width: 18px; min-height: 18px; height: 18px; }

.research-progress {
    display: flex; flex-direction: column; gap: 8px; padding: 11px 12px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--muted);
}
.research-progress-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: .78rem; }
.research-progress-meta strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.research-progress-time { color: var(--muted-foreground); white-space: nowrap; }
.research-progress-time b { margin-left: 4px; color: var(--foreground); font-variant-numeric: tabular-nums; }
.research-progress-track { position: relative; height: 7px; overflow: hidden; border-radius: 999px; background: var(--border); }
.research-progress-track span { position: absolute; inset-block: 0; left: 0; width: 36%; border-radius: inherit; background: var(--primary); transform: translateX(-120%); }
.research-progress.is-running .research-progress-track span { animation: research-progress-sweep 1.25s ease-in-out infinite; }
.research-progress.is-success { border-color: var(--success); }
.research-progress.is-success .research-progress-track span { width: 100%; transform: none; background: var(--success); }
.research-progress.is-error { border-color: var(--destructive); }
.research-progress.is-error .research-progress-track span { width: 100%; transform: none; background: var(--destructive); opacity: .75; }
@keyframes research-progress-sweep { 0% { transform: translateX(-120%); } 55% { transform: translateX(120%); } 100% { transform: translateX(300%); } }
.research-status { min-height: 1.4em; color: var(--muted-foreground); font-size: .8rem; font-weight: 650; }
.research-status.pending { color: var(--warning); }
.research-status.success { color: var(--success); }
.research-status.error { color: var(--destructive); }

.estimate-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.estimate-grid > div:first-child { display: none; }
.privacy-disclosure { margin-top: 14px; background: var(--muted); }
.privacy-disclosure p { margin: 0; padding: 0 15px 12px; color: var(--muted-foreground); font-size: .8rem; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 20px; }
.estimate-panel .action-row .primary { flex: 1 1 220px; }

.progress-percent { font-size: 1.55rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: var(--border); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .18s ease; }
.progress-status { margin: 11px 0 16px; font-weight: 700; }
.progress-primary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.progress-details-control { display: flex; justify-content: flex-end; margin-top: 8px; }
.progress-details-toggle { min-height: 36px; }
.progress-details-grid { margin-top: 8px; }

.result-panel { border-color: color-mix(in srgb, var(--success) 42%, var(--border)); }
.result-icon {
    float: left; display: grid; place-items: center; width: 46px; height: 46px; margin: 0 14px 12px 0;
    border-radius: 999px; background: var(--success); color: #fff; font-size: 1.35rem; font-weight: 800;
}
.result-grid { clear: both; margin-top: 20px; }
.error-panel { border-color: color-mix(in srgb, var(--destructive) 42%, var(--border)); }
.manual-resolution-panel { border-color: color-mix(in srgb, var(--warning) 42%, var(--border)); }
.error-details { display: grid; margin: 18px 0 0; }
.error-details div { display: grid; grid-template-columns: minmax(90px, 130px) minmax(0, 1fr); gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.error-details dt { color: var(--muted-foreground); font-weight: 650; }
.error-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.source-preview { max-height: 180px; margin: 0; overflow: auto; white-space: pre-wrap; font: inherit; }

.support-table { margin-top: 18px; padding: 0; box-shadow: none; background: transparent; }
.support-table > summary { color: var(--muted-foreground); font-size: .82rem; }
.support-table__content { padding: 8px 22px 22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 650px; border-collapse: collapse; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted-foreground); font-size: .78rem; font-weight: 650; }
.state.supported { color: var(--success); background: var(--success-soft); }
.state.unverified { color: var(--warning); background: var(--warning-soft); }
.state.unsupported { color: var(--muted-foreground); }

.login-panel { max-width: 560px; margin: 30px auto; }
.login-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; margin-top: 20px; }
.login-form label { grid-column: 1 / -1; font-weight: 700; }
.site-footer { padding: 24px 22px 38px; color: var(--muted-foreground); text-align: center; font-size: .8rem; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.is-hidden { display: none !important; }

@media (max-width: 720px) {
    .masthead {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        gap: 10px;
    }
    .brand-lockup {
        display: flex;
        align-items: center;
        gap: 10px;
        flex: 1 1 auto;
        min-width: 0;
    }
    .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;
    }
    .page-shell { padding: 24px 13px 48px; }
    .panel { padding: 19px 15px; border-radius: 12px; }
    .flow-rail { font-size: .7rem; }
    .flow-rail li:not(:last-child)::after { min-width: 5px; }
    .section-heading { display: grid; gap: 9px; }
    .form-grid, .compact-grid, .metrics-grid, .estimate-grid, .progress-primary-grid { grid-template-columns: 1fr; }
    .estimate-grid > div:first-child { display: block; }
    .field-with-action { grid-template-columns: 1fr; }
    .field-with-action .button { width: 100%; }
    .checkbox-field { padding-top: 0; }
    .option-settings summary span, .advanced-settings summary span { float: none; margin-left: 5px; }
    .research-progress-meta { align-items: flex-start; flex-direction: column; gap: 3px; }
    .drop-zone { min-height: 170px; padding-inline: 14px; }
    .file-name-row { align-items: flex-start; }
    .action-row { align-items: stretch; flex-direction: column; }
    .action-row .button { width: 100%; }
    .estimate-panel .action-row .primary { flex-basis: auto; }
    .error-details div { grid-template-columns: 1fr; gap: 2px; }
    .login-form { grid-template-columns: 1fr; }
}

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


@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
    .research-progress.is-running .research-progress-track span { animation: none !important; width: 100%; transform: none; opacity: .55; }
}
