/* 폰트 메트릭 보정 — 웹폰트 로드 전 fallback과 크기 차이를 최소화해 FOUT 레이아웃 흔들림 방지 */
@font-face {
    font-family: "Outfit Fallback";
    src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
    size-adjust: 97%;
    ascent-override: 95%;
    descent-override: 22%;
    line-gap-override: 0%;
}
@font-face {
    font-family: "Noto Sans KR Fallback";
    src:
        local("Apple SD Gothic Neo"), local("Malgun Gothic"),
        local("sans-serif");
    size-adjust: 100%;
    ascent-override: 97%;
    descent-override: 20%;
    line-gap-override: 0%;
}

/* 폰트 로딩: @import 제거 → HTML의 preconnect + <link rel="stylesheet"> 방식으로 이동
   Google Fonts URL에 display=swap 파라미터 포함 → font-display: swap 자동 적용 */

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

:root {
    --font-main:
        "Outfit", "Outfit Fallback", "Noto Sans KR", "Noto Sans KR Fallback",
        sans-serif;
    --bg: #f7f8fc;
    --surface: #ffffff;
    --surface-2: #f0f3fa;
    --border: #e4e9f2;
    --border-2: #d0d8eb;
    --accent: #4f80ff;
    --accent-2: #7ba4ff;
    --accent-bg: #eef3ff;
    --text-1: #111827;
    --text-2: #4b5563;
    --success: #10b981;
    --warn-text: #92400e;
    --warn-bg: #fffbeb;
    --warn-border: #fcd34d;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:
        0 4px 16px rgba(79, 128, 255, 0.1), 0 1px 4px rgba(0, 0, 0, 0.05);
    --shadow-lg:
        0 12px 40px rgba(79, 128, 255, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

html {
    scroll-behavior: smooth;
}

/* 스크린리더 전용 숨김 텍스트 */
.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;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text-1);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Topbar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand {
    text-decoration: none;
    color: var(--text-1);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand::before {
    content: "";
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 7px;
    display: inline-block;
    flex-shrink: 0;
}
.site-nav {
    margin-left: auto;
}
.nav-list {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 2px;
}
.nav-item a,
.sub-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition:
        color 0.15s,
        background 0.15s;
    white-space: nowrap;
}
.nav-item a:hover,
.sub-toggle:hover {
    color: var(--accent);
    background: var(--accent-bg);
}
.nav-toggle {
    margin-left: auto;
    display: none;
    width: 40px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: border-color 0.15s;
}
.nav-toggle:hover {
    border-color: var(--border-2);
}
.nav-toggle-bar {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text-1);
    border-radius: 2px;
}
.has-sub {
    position: relative;
}
.sub-menu {
    list-style: none;
    padding: 6px;
    padding-top: 12px; /* 시각적 간격 — top은 100%에 붙어 hover 끊김 방지 */
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: transparent; /* wrapper는 투명 */
    border: none;
    box-shadow: none;
    display: none;
}
/* 실제 메뉴 박스는 내부 ul::before 대신 inner wrapper 처리 */
.sub-menu::before {
    content: "";
    position: absolute;
    top: 12px; /* padding-top 만큼 아래 */
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: -1;
}
@media (min-width: 1025px) {
    .has-sub:hover .sub-menu {
        display: block;
    }
}
.sub-menu a {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition:
        color 0.15s,
        background 0.15s;
}
.sub-menu a:hover {
    color: var(--accent);
    background: var(--accent-bg);
}

/* ── Main wrap ── */
.wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 36px 20px 0;
}

/* ── Hero ── */
.hero {
    margin-bottom: 28px;
    padding: 40px 0 8px;
}
.hero h1 {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.15;
    background: linear-gradient(120deg, var(--text-1) 30%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.lead {
    margin: 14px 0 18px;
    color: var(--text-2);
    font-size: 16px;
    line-height: 1.7;
    max-width: 560px;
}
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.badges span {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ── Panel ── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
}
.row {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.row label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
}
.ml {
    margin-left: 6px;
}
.row select {
    padding: 8px 30px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-1);
    font-size: 14px;
    font-family: var(--font-main);
    font-weight: 500;
    cursor: pointer;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 128, 255, 0.15);
}

/* Drop zone */
.drop {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    background: var(--surface-2);
    cursor: pointer;
    transition:
        border-color 0.2s,
        background 0.2s;
}
.drop:hover,
.drop:focus-within,
.drop--over {
    border-color: var(--accent-2);
    background: var(--accent-bg);
}
/* 드래그 진입 시 더 강조 */
.drop--over {
    border-color: var(--accent);
    border-style: solid;
}
.drop::before {
    content: "";
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    background: var(--surface);
    border-radius: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234F80FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
    box-shadow: var(--shadow-sm);
}
.drop .muted {
    color: var(--text-2);
    font-size: 15px;
    line-height: 1.6;
}
.drop .muted strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
}
.drop input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Buttons */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.actions button {
    padding: 10px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-1);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}
.actions button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
    box-shadow: none;
}
.actions button:first-child {
    background: linear-gradient(135deg, var(--accent), #6b9dff);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(79, 128, 255, 0.3);
}
.actions button:first-child:hover:not(:disabled) {
    background: linear-gradient(135deg, #3d6df0, var(--accent));
    color: #fff;
    box-shadow: 0 4px 14px rgba(79, 128, 255, 0.4);
}
.actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Status */
.status {
    margin-top: 16px;
}
#summary {
    color: var(--text-2);
    font-size: 14px;
    text-align: center;
    padding: 6px;
}
.warn {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--warn-border);
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 14px;
    line-height: 1.5;
    display: none;
}
.warn.show {
    display: block;
}

/* File list */
.list {
    list-style: none;
    margin-top: 16px;
}
.item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 8px;
    border-top: 1px solid var(--border);
    align-items: flex-start;
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}
.item:hover {
    background: var(--surface-2);
}

.item-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item small {
    color: var(--text-2);
    font-size: 12px;
}
.item .right {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    padding-top: 2px;
}
.item a {
    text-decoration: none;
    border: 1px solid var(--accent-bg);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-bg);
    transition: all 0.15s;
    white-space: nowrap;
}
.item a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.item .tag {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    white-space: nowrap;
}
.item .tag--fail {
    background: #fff1f1;
    border-color: #fecaca;
    color: #dc2626;
}

/* 파일별 진행률 바 */
.item-progress-wrap {
    margin-top: 5px;
    height: 5px;
    width: 100%;
}
.item-progress {
    width: 100%;
    height: 5px;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border);
    display: block;
}
.item-progress::-webkit-progress-bar {
    background: var(--border);
    border-radius: 999px;
}
.item-progress::-webkit-progress-value {
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.25s ease;
}
.item-progress::-moz-progress-bar {
    background: var(--accent);
    border-radius: 999px;
}

/* 상태별 진행바 색상 */
.item--done .item-progress::-webkit-progress-value {
    background: var(--success);
}
.item--done .item-progress::-moz-progress-bar {
    background: var(--success);
}
.item--fail .item-progress::-webkit-progress-value {
    background: #ef4444;
}
.item--fail .item-progress::-moz-progress-bar {
    background: #ef4444;
}

/* 대기 상태엔 바를 흐리게 */
.item--pending .item-progress-wrap {
    opacity: 0.3;
}

/* ── Content sections ── */
.howto,
.heic-errors,
.heic-limit,
.faq {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.howto h2,
.heic-errors h2,
.heic-limit h2,
.faq h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text-1);
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.howto h3,
.heic-errors h3,
.heic-limit h3,
.faq h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    margin: 20px 0 8px;
}
.howto p,
.heic-errors p,
.heic-limit p,
.faq p {
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.7;
    margin-bottom: 8px;
}
.howto ol,
.howto ul,
.heic-limit ul {
    padding-left: 20px;
    margin: 8px 0;
}
.howto li,
.heic-limit li {
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.7;
    margin: 6px 0;
}

/* Error items */
.heic-error-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin: 12px 0;
    transition: border-color 0.15s;
}
.heic-error-item:hover {
    border-color: var(--border-2);
}
.heic-error-item h3 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: 8px;
}
.heic-error-item h3::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}
.heic-error-item p {
    margin: 6px 0;
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.65;
}

/* FAQ */
.faq h3 {
    margin: 20px 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    padding-left: 12px;
    border-left: 3px solid var(--accent);
}

/* ── Footer ── */
.footer {
    margin: 0;
    padding: 28px 0 48px;
    border-top: 1px solid var(--border);
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.footer-link {
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.footer-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}
.footer-copy {
    color: var(--text-2);
    font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .nav-toggle {
        display: inline-flex;
    }
    .site-nav {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
        display: none;
        padding: 12px 20px 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    }
    body.nav-open .site-nav {
        display: block;
    }
    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .nav-item a,
    .sub-toggle {
        width: 100%;
        border: 1px solid var(--border);
        background: var(--surface-2);
        border-radius: var(--radius-sm);
        padding: 10px 14px;
    }
    .nav-item a {
        justify-content: flex-start;
    }
    .sub-toggle {
        justify-content: space-between;
    }
    .has-sub {
        position: static;
    }
    .sub-menu {
        position: static;
        min-width: unset;
        box-shadow: none;
        border: 0;
        padding: 4px 0 0;
        margin-left: 14px;
        display: none;
        flex-direction: column;
        gap: 4px;
        border-radius: 0;
    }
    .sub-toggle[aria-expanded="true"] + .sub-menu,
    .has-sub.open .sub-menu {
        display: flex;
    }
    .sub-menu a {
        border: 1px solid var(--border);
        background: var(--surface);
        border-radius: var(--radius-sm);
        padding: 9px 14px;
    }
}

@media (max-width: 600px) {
    .wrap {
        padding: 24px 14px 0;
    }
    .panel {
        padding: 20px 16px;
    }
    .howto,
    .heic-errors,
    .heic-limit,
    .faq {
        padding: 22px 18px;
    }
    .hero {
        padding-top: 24px;
    }
    .hero h1 {
        font-size: 26px;
    }
    .drop {
        padding: 28px 16px;
    }
    .actions button {
        flex: 1;
        justify-content: center;
    }
}
