:root {
  --background: #f8f6fb;
  --foreground: #201a2b;
  --card: #ffffff;
  --card-foreground: #201a2b;
  --primary: #5b3fa0;
  --primary-foreground: #ffffff;
  --secondary: #efeaf7;
  --secondary-foreground: #3a2d52;
  --muted: #f2eff8;
  --muted-foreground: #6f647f;
  --accent: #d9822b;
  --teal: #0d9488;
  --teal-soft: #ccfbf1;
  --success: #28785e;
  --success-soft: #e8f5ef;
  --warning: #956200;
  --warning-soft: #fff5d9;
  --destructive: #b43b45;
  --destructive-soft: #fff0f1;
  --border: #e2dcee;
  --input: #d2c7e3;
  --ring: #7c52c4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(45, 30, 70, .05), 0 12px 36px rgba(45, 30, 70, .08);
  --max-width: 820px;
  --sans: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #16121f;
    --foreground: #ece7f5;
    --card: #1e1830;
    --card-foreground: #ece7f5;
    --primary: #b79ce8;
    --primary-foreground: #1f1233;
    --secondary: #2a2140;
    --secondary-foreground: #ece7f5;
    --muted: #241c38;
    --muted-foreground: #ac9fc4;
    --success: #7bc2a5;
    --success-soft: #1b342b;
    --teal: #2dd4bf;
    --teal-soft: #134e4a;
    --warning: #efc46c;
    --warning-soft: #392f1a;
    --destructive: #f08b92;
    --destructive-soft: #402327;
    --border: #3a2f52;
    --input: #4a3d68;
    --ring: #c9b3ef;
    --shadow: 0 14px 36px rgba(0, 0, 0, .35);
  }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--foreground); background: var(--background); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: .18em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }

.skip-link { position: fixed; left: 16px; top: -100px; z-index: 20; padding: 10px 14px; border-radius: 8px; background: var(--foreground); color: var(--background); }
.skip-link:focus { top: 16px; }
.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 { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 11px; background: var(--teal-soft); color: var(--teal); font-size: 1.2rem; line-height: 1; text-decoration: none; transition: transform .15s ease; }
.brand-mark:hover { transform: scale(1.05); }
.brand-copy { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 4px; }
h1 { margin: 0; font-size: 1.1rem; line-height: 1.25; letter-spacing: -.02em; }
.subtitle { margin: 0; color: var(--muted-foreground); font-size: .82rem; }
.home-button { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--secondary); color: var(--secondary-foreground); font-size: .84rem; font-weight: 700; text-decoration: none; white-space: nowrap; transition: border-color .15s, color .15s, transform .15s; }
.home-button:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

.page-shell { max-width: var(--max-width); min-height: calc(100vh - 150px); 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)); width: 100%; max-width: 560px; margin: 0 auto 22px; padding: 0; list-style: none; color: var(--muted-foreground); font-size: .78rem; font-weight: 650; }
.flow-step { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; text-align: center; }
.flow-step:not(:last-child)::after { content: ""; position: absolute; z-index: 0; height: 1px; left: 50%; right: -50%; background: var(--border); }
.flow-number { position: relative; z-index: 1; 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-label { position: relative; z-index: 1; padding: 0 4px; background: var(--background); white-space: nowrap; }
.flow-step.is-current { color: var(--foreground); }
.flow-step.is-current .flow-number { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.flow-step.is-done .flow-number { border-color: var(--primary); color: transparent; }
.flow-step.is-done .flow-number::after { content: "✓"; position: absolute; color: var(--primary); font-weight: 800; }

.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: 22px; }
.section-number { margin: 0 0 4px; color: var(--muted-foreground); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.55rem); line-height: 1.3; letter-spacing: -.025em; }
h3 { margin: 0 0 5px; font-size: .9rem; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; 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.good { color: var(--success); background: var(--success-soft); border-color: transparent; }
.result-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.field + .field { margin-top: 20px; }
.field label { display: block; margin-bottom: 7px; font-size: .82rem; font-weight: 700; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.field-label-row > span { color: var(--muted-foreground); font: .72rem var(--mono); }
select, textarea { width: 100%; border: 1px solid var(--input); border-radius: 10px; background: var(--card); color: var(--foreground); transition: border-color .15s, box-shadow .15s; }
select { min-height: 46px; padding: 0 42px 0 13px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%), linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 265px; padding: 15px; resize: vertical; font: .88rem/1.65 var(--mono); }
#sourceText { background: var(--muted); }
#resultText { min-height: 310px; background: var(--muted); }
select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--secondary); outline: none; }
.field-help { margin: 8px 0 0; color: var(--muted-foreground); font-size: .78rem; }
.encoding-field { max-width: 300px; margin-bottom: 20px; }
.drop-zone { min-height: 210px; padding: 30px 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, background-color .15s, transform .15s, opacity .15s; }
.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:not(.button):not(.drop-mark) { color: var(--muted-foreground); font-size: .84rem; }
.drop-mark { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: 15px; background: var(--card); color: var(--primary); font: 800 .78rem var(--mono); letter-spacing: .05em; }
.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 { margin-top: 7px; pointer-events: none; }
.picker-help { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted-foreground); font-size: .75rem; }
.sample-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; color: var(--muted-foreground); font-size: .8rem; }
.sample-row > span { margin-right: 2px; font-weight: 650; }

.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: transform .15s, filter .15s, opacity .15s; }
.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(.95); }
.button.secondary { border-color: var(--border); background: var(--card); color: var(--foreground); }
.button.large { min-height: 48px; padding-inline: 22px; }
.button.small { min-height: 34px; padding: 0 12px; font-size: .78rem; }
.text-button { border: 0; padding: 3px 0; background: transparent; color: var(--primary); font-size: .84rem; font-weight: 700; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.action-row { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.fine-print { flex: 1; margin: 0; color: var(--muted-foreground); font-size: .77rem; }

.notice { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.notice > div { display: flex; flex-direction: column; gap: 2px; }
.notice > div > span { color: var(--muted-foreground); font-size: .82rem; }
.notice-success { color: var(--success); background: var(--success-soft); border-color: transparent; }
.notice-warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.notice-error { color: var(--destructive); background: var(--destructive-soft); border-color: transparent; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 7px; border-radius: 50%; background: currentColor; }
.result-panel { scroll-margin-top: 20px; }
.result-actions { flex-wrap: wrap; }
.reset-button { margin-right: auto; color: var(--muted-foreground); }

.queue-panel { scroll-margin-top: 20px; }
.progress-panel { margin-bottom: 18px; padding: 14px 16px; border-radius: 10px; background: var(--muted); }
.progress-label { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 9px; font-size: .82rem; }
.progress-label span { color: var(--muted-foreground); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--border); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .18s ease; }
.queue-list { overflow: hidden; border: 1px solid var(--border); border-radius: 11px; }
.queue-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--border); background: var(--card); }
.queue-row:first-child { border-top: 0; }
.queue-row-error { background: var(--destructive-soft); }
.queue-number { color: var(--muted-foreground); font: .72rem var(--mono); font-variant-numeric: tabular-nums; }
.queue-body { min-width: 0; }
.queue-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.queue-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; color: var(--muted-foreground); font-size: .74rem; }
.queue-output, .queue-error { display: block; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.queue-output { color: var(--success); }
.queue-error { color: var(--destructive); white-space: normal; }
.state { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; font-size: .69rem; font-weight: 700; }
.state.supported { color: var(--success); background: var(--success-soft); }
.state.failed { color: var(--destructive); background: var(--destructive-soft); }
.compact-heading { margin-bottom: 16px; }
.result-actions-panel .action-row { margin-top: 0; }
.result-actions-panel .text-button { margin-right: auto; color: var(--muted-foreground); }

.support-panel { padding: 0; overflow: hidden; box-shadow: none; }
.support-panel summary { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; font-weight: 750; cursor: pointer; list-style: none; }
.support-panel summary::-webkit-details-marker { display: none; }
.support-panel[open] summary { border-bottom: 1px solid var(--border); }
.support-panel[open] summary span { transform: rotate(45deg); }
.support-panel summary span { color: var(--primary); font-size: 1.2rem; transition: transform .15s; }
.support-content { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; padding: 22px; }
.support-content p { margin: 0; color: var(--muted-foreground); font-size: .82rem; }
.site-footer { padding: 0 22px 32px; color: var(--muted-foreground); text-align: center; font-size: .78rem; }
.site-footer p { margin: 0; }

@media (max-width: 640px) {
  .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;
  }
  .brand-copy h1, h1 {
    font-size: 1.05rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }
  .brand-copy .subtitle, .subtitle {
    display: none !important;
  }
  .home-button {
    padding: 6px 12px;
    font-size: 0.82rem;
    gap: 4px;
    min-height: 32px;
    flex-shrink: 0;
  }
  .page-shell { padding: 26px 16px 48px; }
  .flow-rail { font-size: .7rem; }
  .flow-step { gap: 5px; }
  .flow-label { padding-inline: 2px; }
  .section-heading, .action-row { align-items: stretch; flex-direction: column; }
  .section-heading .badge { align-self: flex-start; }
  .result-badges { justify-content: flex-start; }
  .button { width: 100%; }
  .reset-button { align-self: center; margin: 0 auto; order: 3; }
  .support-content { grid-template-columns: 1fr; }
  textarea { min-height: 230px; }
  .encoding-field { max-width: none; }
  .picker-help { flex-direction: column; gap: 2px; }
  .queue-row { grid-template-columns: 1.7rem minmax(0, 1fr); }
  .queue-row .button { grid-column: 2; width: auto; justify-self: start; }
  .result-actions-panel .text-button { order: 2; margin: 0 auto; }
}

@media (max-width: 380px) {
  .brand-copy h1, h1 {
    font-size: 0.95rem;
  }
  .home-button {
    padding: 5px 10px;
    font-size: 0.78rem;
  }
}

