:root {
  --ink: #0b0d10;
  --ink-2: #3f4650;
  --muted: #6b7280;
  --line: #e6e8ec;
  --paper: #ffffff;
  --wash: #f7f8fa;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #0f766e;
  --err: #b42318;
  --r: 14px;
  --shadow: 0 1px 2px rgba(11,13,16,.04), 0 8px 24px -12px rgba(11,13,16,.18);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(920px, 100% - 40px); margin-inline: auto; }

.skip {
  position: absolute; left: -9999px;
}
.skip:focus {
  left: 12px; top: 12px; z-index: 20;
  background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px;
}

/* ---------- top bar ---------- */
.topbar { border-bottom: 1px solid var(--line); }
.topbar-in {
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 18px; height: 18px; border-radius: 6px;
  background: linear-gradient(140deg, var(--accent), #7c6cf6 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.brand-name { font-weight: 650; letter-spacing: -.015em; font-size: 15.5px; }
.pill {
  font-size: 12.5px; color: var(--ok); background: #ecfdf5;
  border: 1px solid #d1fae5; padding: 4px 10px; border-radius: 999px;
}

/* ---------- tool ---------- */
.tool { padding: 56px 0 8px; }

h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5.2vw, 44px);
  line-height: 1.1;
  letter-spacing: -.032em;
  font-weight: 700;
  text-wrap: balance;
}
.sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: clamp(15px, 2.2vw, 17px);
  max-width: 54ch;
}

.btn {
  flex: 0 0 auto;
  height: 54px;
  padding: 0 22px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:hover:not(:disabled) { background: #372ea8; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #c7c2ff; outline-offset: 2px; }

.btn.ghost {
  height: 34px; padding: 0 12px;
  font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--line); border-radius: 9px;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn.ghost:hover { background: var(--wash); }
.btn.ghost.done { color: var(--ok); border-color: #bbf7d0; background: #f0fdf4; }

.hint { margin: 10px 2px 0; font-size: 13px; color: var(--muted); }

.lang {
  display: flex; align-items: center; gap: 10px;
  margin: 0 2px 16px; font-size: 13px; color: var(--muted);
}
.lang label { font-weight: 500; white-space: nowrap; }
.lang select {
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; max-width: 200px;
}
.lang select:focus-visible { outline: 3px solid #c7c2ff; outline-offset: 1px; }
.lang-hint { font-size: 12.5px; color: #9aa1ac; }

.drop {
  display: flex; flex-direction: column; gap: 5px;
  padding: 30px 24px;
  border: 1px dashed #cfd4dd; border-radius: var(--r);
  background: var(--wash);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.drop:hover, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { box-shadow: 0 0 0 4px var(--accent-soft); }
.drop-title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.drop-sub { font-size: 13px; color: var(--muted); }
.drop[aria-busy="true"] { cursor: progress; }
.drop.has-file { border-style: solid; border-color: #bbf7d0; background: #f0fdf4; }
.drop.has-file .drop-title { color: var(--ok); }

/* ---------- status ---------- */
.status { margin-top: 26px; }
.bar { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i {
  display: block; height: 100%; width: 30%;
  background: var(--accent);
  border-radius: 999px;
  animation: slide 1.25s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}
.bar.det i {
  width: var(--p, 4%);
  animation: none;
  transition: width .25s ease;
}
.status-text { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.status-note { margin: 4px 0 0; font-size: 12.5px; color: #9aa1ac; overflow-wrap: anywhere; }
.status.err .bar i { background: var(--err); animation: none; width: 100%; }
.status.err .status-text { color: var(--err); }
.status.err .status-note { color: #9b3a30; }

/* ---------- result ---------- */
.result {
  margin-top: 26px;
  padding: 18px 20px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.result-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.result-head h2 {
  margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em;
}
.result-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--wash); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.tab {
  border: 0; background: transparent; font-family: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
}
.tab.is-on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(11,13,16,.08); }

.result-meta { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

.out {
  margin: 12px 0 0;
  padding: 18px 20px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow: auto;
  margin-inline: 0;
}
.out:focus-visible { outline: 3px solid #c7c2ff; outline-offset: 2px; }

/* ---------- prose ---------- */
.prose { padding: 64px 0 8px; max-width: 68ch; }
.prose h2 {
  margin: 40px 0 10px;
  font-size: 19px; font-weight: 650; letter-spacing: -.018em;
}
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--ink-2); }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em; background: var(--wash); padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line);
}

.faq { margin: 0; }
.faq dt { font-weight: 600; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--ink-2); }

.foot {
  border-top: 1px solid var(--line);
  margin-top: 56px; padding: 22px 0 40px;
}
.foot p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .wrap { width: calc(100% - 32px); }
  .tool { padding-top: 34px; }
  .drop { padding: 24px 18px; }
  .drop-title { font-size: 16px; }
  .result-head { align-items: flex-start; }
  .result-actions { width: 100%; align-items: center; }
  .btn.ghost { width: auto; flex: 0 0 auto; }
  .out { max-height: 340px; font-size: 13px; padding: 14px; }
  .prose { padding-top: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .bar i { transform: none; width: 100%; }
}
