:root {
  --bg: #f6f7f9; --card: #fff; --fg: #15181d; --muted: #5f6672; --line: #dde1e7;
  --accent: #2563eb; --accent-fg: #fff; --err: #b42318; --warn-bg: #fff4e5; --warn: #8a4b00;
  --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #181b21; --fg: #e8eaee; --muted: #9aa1ad; --line: #2b3038;
    --accent: #4f8bff; --err: #ff8a80; --warn-bg: #2d2210; --warn: #f5c46b; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 960px; margin-inline: auto; padding-inline: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { font-size: 1.5rem; margin: 0 0 16px; } h2 { font-size: 1.2rem; margin: 0 0 12px; } h3 { font-size: 1rem; margin: 0 0 4px; }
a { color: var(--accent); }

.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  max-width: 960px; margin: 0 auto; padding: 20px 16px; }
.brand { font-weight: 800; font-size: 1.4rem; color: var(--fg); text-decoration: none; letter-spacing: -.02em; }
.brand span { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 32px; }
textarea, input, select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
textarea { width: 100%; min-height: 240px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; padding: 10px 16px; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .6; cursor: progress; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; padding-inline: 28px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

.drop { margin-top: 12px; border: 2px dashed var(--line); border-radius: 8px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--fg); }

.options { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin: 16px 0; }
.options label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; }
.options label small { font-weight: 400; color: var(--muted); }
.options label.check { flex-direction: row; align-items: center; gap: 8px; padding-bottom: 10px; }
.check input { width: 18px; height: 18px; }
.actions { display: flex; align-items: center; gap: 16px; }
progress { flex: 1; height: 8px; }

.result-grid { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; }
.result-grid canvas { width: 232px; max-width: 100%; height: auto; border-radius: 8px; background: #fff; }
.label { margin: 12px 0 4px; font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.row.between { justify-content: space-between; margin-bottom: 8px; } .row.between h2 { margin: 0; }
.file-name { flex: 1; overflow-wrap: anywhere; font-weight: 600; }
#text-wrap { margin-bottom: 24px; }

.muted { color: var(--muted); }
.error { color: var(--err); font-weight: 600; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; }
.info { padding-left: 20px; color: var(--muted); }
#gate label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin-bottom: 16px; max-width: 360px; }
.center { text-align: center; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin-bottom: 48px; }
.steps b { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); margin-bottom: 8px; }
.steps p, .features p { margin: 0; color: var(--muted); }
.features .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.features .grid > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
footer { padding-block: 32px; text-align: center; font-size: .85rem; }

@media (max-width: 600px) {
  .card { padding: 16px; }
  .result-grid { grid-template-columns: 1fr; }
  .result-grid canvas { justify-self: center; }
  .top { padding-block: 12px; }
}
