:root {
  --bg: #e7e9ec;
  --panel: #fbfbfc;
  --ink: #1c1d21;
  --muted: #4c5058;
  --line: #d5d8de;
  --danger: #8f2d2d;
  --danger-bg: #f8ecec;
  --radius: 10px;
  --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 16px;
}
::selection { background: #cfd3da; color: var(--ink); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--ink);
  color: #fff;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  z-index: 2;
}
.skip:focus { top: 0.75rem; }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: #e4e7ec;
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

.page {
  width: min(880px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.75rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
  min-height: 44px;
}
.brand img { display: block; }

.site-nav,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
}
.site-nav a,
.site-footer a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.site-nav a:hover,
.site-footer a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.28em;
}

h1 {
  margin: 0 0 0.45rem;
  font-size: 1.7rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
  font-weight: 650;
}

.lede {
  margin: 0 0 1rem;
  max-width: 38rem;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 0.95rem 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  min-height: 44px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.tab:hover { color: var(--ink); }

.actions { display: flex; gap: 0.4rem; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  min-height: 44px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
}
.btn.primary {
  background: var(--ink);
  color: #fbfbfc;
}
.btn.primary:hover { background: #000; }
.btn.ghost { border-color: var(--line); background: transparent; }
.btn.ghost:hover { background: #f4f5f7; }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

textarea,
.url-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink);
  background: #fff;
  caret-color: var(--ink);
}
textarea { min-height: 220px; resize: vertical; }
textarea::placeholder,
.url-row input::placeholder { color: #6e6c67; }

.pane.is-hidden { display: none; }

.url-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}
.url-row input { flex: 1; min-width: 0; }
.url-row .btn { flex: 0 0 auto; }

.help {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.help a { color: var(--ink); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 220px;
  border: 1px dashed #c5c9d1;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  padding: 1.25rem;
  text-align: center;
}
.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--ink);
  background: #f4f5f7;
}
.dropzone input { display: none; }
.drop-title { font-weight: 650; }
.drop-sub { color: var(--muted); font-size: 0.92rem; }
.drop-file {
  color: var(--ink);
  font-size: 0.9rem;
  margin-top: 0.35rem;
  word-break: break-all;
}

.convert-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 0.9rem;
}
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.error {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #efd0d0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.result { margin-top: 1.1rem; }
.result-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.result h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}
.meta { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 420px;
  background: #fff;
  scrollbar-color: #c5c9d1 transparent;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #f4f5f7;
  font-weight: 650;
  z-index: 1;
}
tbody tr:hover td { background: #f4f5f7; }

.notes {
  margin-top: 1.5rem;
}
.notes h2 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}
.notes ol { margin: 0; padding-left: 1.2rem; }
.notes li { margin-bottom: 0.3rem; }
.notes a { color: var(--ink); }

.prose { max-width: 66ch; }
.prose p,
.lede,
.help,
.notes li { text-wrap: pretty; }
.prose h1 { margin-bottom: 0.35rem; }
.prose h2 {
  margin: 1.4rem 0 0.35rem;
  font-size: 1.05rem;
}
.prose p,
.prose li { margin: 0.55rem 0; }
.prose ul,
.prose ol { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.prose a { color: var(--ink); }
.updated {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer {
  margin-top: 2.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { margin: 0.35rem 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  .page { width: min(100% - 1.25rem, 880px); padding-top: 0.85rem; }
  .site-header { align-items: flex-start; }
  h1 { font-size: 1.45rem; }
  .panel { padding: 0.75rem; }
  textarea, .dropzone { min-height: 180px; }
  .url-row { flex-direction: column; }
  .url-row .btn,
  .convert-bar .btn.primary,
  .result-head .btn.primary { width: 100%; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
}
