@font-face {
  font-family: "Gmarket Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/GmarketSans-Medium.ttf") format("truetype");
}

:root {
  --forest: #2f4f46;
  --forest-hover: #3b6258;
  --gold: #c7a76c;
  --gold-light: #d8c197;
  --background: #f8f7f4;
  --card: #ffffff;
  --text: #2a2a2a;
  --muted: #666666;
  --line: #ded7cb;
  --success: #4f8a5b;
  --error: #c96a6a;
  --processing: #a2752c;
  --font-brand: "Hahmlet", Georgia, "Times New Roman", serif;
  --font-ui: "Pretendard Variable", Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; background: var(--background); }
body { margin: 0; color: var(--text); background: var(--background); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible, a:focus-visible { outline: 3px solid rgba(199, 167, 108, .55); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.brand-header { display: flex; width: min(calc(100% - 40px), 1020px); align-items: flex-end; justify-content: space-between; gap: 18px; margin: 0 auto; padding: 22px 0 14px; }
.brand-copy .eyebrow { margin: 0 0 4px; color: var(--gold); font-size: .75rem; font-weight: 800; letter-spacing: .15em; }
.brand-copy h1 { margin: 0; color: var(--forest); font-family: var(--font-brand); font-size: clamp(1.85rem, 3vw, 2.2rem); font-weight: 700; line-height: 1.05; letter-spacing: -.035em; }
.brand-copy h1 span { color: var(--gold); }
.brand-copy > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: .9rem; }
.privacy-badge { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; margin: 0; padding: 5px 9px; border: 1px solid rgba(79,138,91,.28); border-radius: 999px; color: var(--forest); background: rgba(255,255,255,.74); font-size: .76rem; font-weight: 600; }
.privacy-badge span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(79,138,91,.12); }
.header-actions { display: flex; align-items: center; gap: 7px; }
.logout-button { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--forest); background: #fff; font-size: .76rem; font-weight: 700; cursor: pointer; }
.logout-button:hover { border-color: var(--forest); }
.template-notice { margin: 8px 0 0; padding: 7px 10px; border-radius: 7px; color: #775718; background: #fff5dc; font-size: .8rem; font-weight: 650; }

.shell { width: min(calc(100% - 40px), 1020px); margin: 0 auto; }
#convertForm { display: grid; gap: 9px; }
.work-card { padding: 15px 17px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); box-shadow: 0 5px 17px rgba(47,79,70,.05); }
.section-heading { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.step-number { display: grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; border-radius: 7px; color: #fff; background: var(--forest); font-family: var(--font-brand); font-size: .86rem; font-weight: 700; }
.section-heading h2 { margin: 0; color: var(--forest); font-size: .95rem; line-height: 1.25; }
.section-heading p { margin: 1px 0 0; color: var(--muted); font-size: .81rem; }
.field-label { display: block; margin-bottom: 5px; color: var(--text); font-size: .82rem; font-weight: 700; }

.template-row { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 6px 9px; }
.template-row .field-label { grid-column: 1 / -1; }
.template-actions { display: flex; flex-wrap: nowrap; gap: 5px; }
select, .password-field { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #fff; }
select { width: 100%; padding: 0 36px 0 11px; cursor: pointer; }
select:focus, .password-field:focus-within { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(47,79,70,.1); }
select:disabled { color: #918b82; cursor: wait; background: #f6f4ef; }
.secondary-button { min-height: 40px; padding: 0 11px; border: 1px solid var(--gold-light); border-radius: 8px; color: var(--forest); background: #fff; font-family: "Gmarket Sans", var(--font-ui); font-size: .84rem; font-weight: 600; letter-spacing: -.01em; }
.secondary-button span { display: inline-block; margin-left: 5px; padding: 2px 6px; border-radius: 999px; color: var(--muted); background: #efede8; font-size: .7rem; }
.secondary-button:disabled { cursor: not-allowed; opacity: .72; }
.danger-button { color: #9f2f2f; border-color: #d9aaa3; }

.drop-zone { display: grid; min-height: 118px; place-items: center; align-content: center; gap: 3px; padding: 13px; border: 1px dashed var(--gold); border-radius: 9px; color: var(--muted); background: #fbfaf7; text-align: center; transition: border-color .15s ease, background-color .15s ease; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--forest); background: #f1f5f3; }
.drop-zone strong { color: var(--forest); font-size: .92rem; }
.drop-zone > span { font-size: .8rem; }
.file-button { min-height: 38px; margin-top: 3px; padding: 7px 14px; border: 1px solid var(--gold-light); border-radius: 7px; color: var(--forest); background: #fff; font-family: "Gmarket Sans", var(--font-ui); font-size: .84rem; font-weight: 600; letter-spacing: -.01em; cursor: pointer; }
.file-button:hover { border-color: var(--forest); }
.file-info { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid rgba(79,138,91,.35); border-radius: 8px; background: #f5f8f6; }
.file-mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 7px; color: #fff; background: var(--success); font-size: .66rem; font-weight: 800; }
.file-info strong { display: block; overflow: hidden; color: var(--forest); text-overflow: ellipsis; white-space: nowrap; }
.file-info p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.file-info button { min-height: 36px; padding: 0 9px; border: 0; border-radius: 7px; color: var(--error); background: transparent; font-size: .84rem; font-weight: 700; cursor: pointer; }
.file-info button:hover { background: #fff0ed; }

.password-field { display: flex; overflow: hidden; }
.password-field input { width: 100%; min-width: 0; padding: 0 11px; border: 0; outline: 0; color: var(--text); background: transparent; }
.password-field button { min-width: 58px; border: 0; border-left: 1px solid var(--line); color: var(--forest); background: #fff; font-size: .82rem; font-weight: 700; cursor: pointer; }
.password-field button:hover { background: #f6f9f7; }
.security-note { margin: 5px 1px 0; color: var(--muted); font-size: .76rem; }

.action-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 13px; border: 1px solid var(--gold-light); border-radius: 10px; background: #efebe3; }
.message { min-width: 0; color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.message.is-error { color: var(--error); font-weight: 650; }
.message.is-processing { color: var(--processing); font-weight: 650; }
.primary-button, .download-button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; border: 1px solid var(--forest); border-radius: 8px; color: #fff; background: var(--forest); font-family: "Gmarket Sans", var(--font-ui); font-size: .88rem; font-weight: 600; letter-spacing: -.01em; text-decoration: none; cursor: pointer; transition: background-color .15s ease, transform .15s ease; }
.primary-button { min-width: 154px; gap: 8px; padding: 0 18px; }
.primary-button:hover:not(:disabled), .download-button:hover { background: var(--forest-hover); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .76; }
.spinner { display: none; width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }
.primary-button.is-processing .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-section { margin-top: 12px; padding: 13px 16px; border: 1px solid rgba(79,138,91,.38); border-radius: 12px; background: var(--card); box-shadow: 0 7px 22px rgba(47,79,70,.07); }
.result-header { display: flex; align-items: center; gap: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.success-mark { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 50%; color: #fff; background: var(--success); font-size: 1.05rem; font-weight: 800; }
.result-kicker { margin: 0 0 2px; color: var(--success); font-size: .75rem; font-weight: 800; letter-spacing: .08em; }
.result-header h2 { margin: 0; color: var(--forest); font-family: var(--font-brand); font-size: 1.12rem; }
.result-header > div:last-child > p:last-child { max-width: 760px; overflow: hidden; margin: 2px 0 0; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.report-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.report-grid article { min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fbfaf7; }
.report-grid h3 { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 650; }
.report-grid p { margin: 3px 0 0; color: var(--forest); font-variant-numeric: tabular-nums; }
.report-grid strong { font-family: var(--font-brand); font-size: 1.28rem; }
.download-button { width: 100%; min-height: 38px; margin-top: 9px; padding: 0 18px; }
footer { padding: 16px 20px 22px; color: #89847d; font-size: .72rem; text-align: center; }

.login-page { min-height: 100vh; background: radial-gradient(circle at top, #fffdf7 0, var(--background) 58%); }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(100%, 410px); padding: 30px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 18px 55px rgba(47,79,70,.1); }
.login-card .eyebrow { margin: 0 0 6px; color: var(--gold); font-size: .75rem; font-weight: 800; letter-spacing: .15em; }
.login-card h1 { margin: 0; color: var(--forest); font-family: var(--font-brand); font-size: 2.1rem; line-height: 1.1; letter-spacing: -.035em; }
.login-card h1 span { color: var(--gold); }
.login-intro { margin: 8px 0 20px; color: var(--muted); }
.remember-row { display: flex; width: fit-content; align-items: center; gap: 8px; margin: 14px 0; color: var(--text); font-size: .9rem; cursor: pointer; }
.remember-row input { width: 18px; height: 18px; accent-color: var(--forest); }
.login-message { min-height: 24px; margin: 2px 0 8px; color: var(--error); font-size: .86rem; font-weight: 650; }
.login-button { width: 100%; }
.login-privacy { display: flex; align-items: flex-start; gap: 8px; margin: 16px 0 0; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.login-privacy span { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 5px; border-radius: 50%; background: var(--success); }

@media (min-width: 760px) {
  #convertForm { grid-template-columns: 1fr 1fr; }
  #convertForm .work-card:first-child, #convertForm .action-panel { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .brand-header, .shell { width: min(calc(100% - 24px), 1040px); }
  .brand-header { align-items: flex-start; padding: 24px 0 17px; }
  .brand-copy h1 { font-size: 2rem; }
  .brand-copy > p:last-child { font-size: .88rem; }
  .privacy-badge { padding: 7px 9px; font-size: .72rem; }
  .header-actions { align-items: flex-end; flex-direction: column; }
  .work-card { padding: 18px; }
  .template-row { grid-template-columns: 1fr; }
  .template-actions { flex-wrap: wrap; }
  select, .password-field, .secondary-button { min-height: 44px; }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-grid article, .report-grid article:nth-child(n+4) { grid-column: auto; }
  .report-grid article:last-child { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .brand-header { display: block; }
  .privacy-badge { width: fit-content; margin-top: 13px; }
  .header-actions { width: 100%; align-items: flex-start; }
  .privacy-badge { margin-top: 13px; }
  .login-shell { padding: 14px; }
  .login-card { padding: 27px 20px; border-radius: 14px; }
  .template-row { grid-template-columns: 1fr; }
  .template-row .field-label { grid-column: auto; }
  .secondary-button { width: 100%; }
  .drop-zone { min-height: 154px; padding: 18px 12px; }
  .file-button, .primary-button, .download-button { width: 100%; min-height: 50px; }
  .file-info { grid-template-columns: auto minmax(0, 1fr); }
  .file-info button { grid-column: 1 / -1; width: 100%; }
  .action-panel { align-items: stretch; flex-direction: column; gap: 12px; }
  .result-section { padding: 19px 16px; }
  .result-header { align-items: flex-start; }
  .result-header > div:last-child { min-width: 0; }
  .report-grid article { padding: 13px 11px; }
  .report-grid strong { font-size: 1.35rem; }
}

@media (max-width: 350px) {
  .brand-copy > p:last-child { font-size: .82rem; }
  .work-card { padding: 15px 13px; }
  .section-heading { gap: 10px; }
  .report-grid { grid-template-columns: 1fr; }
  .report-grid article, .report-grid article:nth-child(n+4), .report-grid article:last-child { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; }
}

.settings-dialog { width: min(860px, calc(100% - 24px)); max-height: calc(100vh - 20px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--card); box-shadow: 0 24px 70px rgba(20,35,30,.25); }
.settings-dialog::backdrop { background: rgba(20,35,30,.48); }
.settings-dialog form { padding: 16px; }
.settings-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.settings-header h2 { margin: 1px 0 2px; color: var(--forest); font-family: var(--font-brand); font-size: 1.25rem; }
.settings-header p { margin: 0; color: var(--muted); }
.dialog-close { border: 0; color: var(--muted); background: transparent; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.settings-section { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.settings-section h3 { margin: 0 0 2px; color: var(--forest); font-size: .92rem; }
.settings-help { margin: 0 0 7px; color: var(--muted); font-size: .78rem; }
.check-row { display: flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 700; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--forest); }
.column-grid { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(210px, 2fr) 120px; gap: 4px; margin-top: 4px; }
.column-grid-header { color: var(--muted); font-size: .72rem; font-weight: 700; }
.column-grid input, .column-grid select, .conditional-fields input { width: 100%; min-height: 34px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: #fff; font-size: .84rem; }
.conditional-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; margin-top: 8px; }
.conditional-fields label { color: var(--muted); font-size: .74rem; font-weight: 700; }
.conditional-fields input { display: block; margin-top: 2px; font-size: .84rem; }
.conditional-fields[hidden] { display: none; }
.extra-column[hidden] { display: none; }
.column-toggle { width: 100%; margin-top: 8px; }
.settings-message { min-height: 18px; margin: 8px 0 0; color: var(--error); font-size: .8rem; }
.settings-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 5px; }
.settings-actions button { min-width: 96px; min-height: 38px; padding: 0 14px; }

@media (max-width: 650px) {
  .settings-dialog form { padding: 16px 12px; }
  .settings-section { padding: 12px 10px; }
  .column-grid { grid-template-columns: 1fr; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .column-grid input, .column-grid select, .conditional-fields input { min-height: 44px; }
  .column-grid-header { display: none; }
  .conditional-fields { grid-template-columns: 1fr; }
  .template-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .settings-actions button { min-height: 44px; }
}

@media (min-width: 651px) and (max-width: 700px) {
  .column-grid input, .column-grid select, .conditional-fields input,
  .settings-actions button { min-height: 44px; }
}
