:root {
  --ink: #1b1b1b;
  --muted: #5c5c5c;
  --line: #d8d4cc;
  --paper: #faf8f4;
  --accent: #2a4b8d; /* Wikimedia blue */
  --error: #a02c2c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK TC",
        "Source Han Sans", "Microsoft JhengHei", sans-serif;
}

header, main, footer { max-width: 46rem; margin: 0 auto; }

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0 1rem;
  border-bottom: 1px solid var(--line);
}

h1 { margin: 0; font-size: 1.6rem; letter-spacing: .02em; }
h2 { margin: 2.5rem 0 .5rem; font-size: 1.1rem; }

.langs button {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  padding: .2rem .5rem;
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
  border-radius: 3px;
}
.langs button[aria-current="true"] { color: var(--accent); border-color: var(--line); background: #fff; }

.lede { margin: 1.5rem 0; color: var(--muted); }

form { margin: 1.5rem 0; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .35rem; }

input[type="text"] {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; gap: .6rem; margin-top: .75rem; }

.row button {
  font: inherit;
  padding: .5rem 1rem;
  border-radius: 3px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.row button#check { background: #fff; color: var(--accent); }

.row button:disabled {
  cursor: not-allowed;
  opacity: .45;
  border-color: var(--line);
  background: var(--line);
  color: var(--muted);
}
.row button#check:disabled { background: transparent; }

#busy {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 1rem 0;
  padding: .8rem 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: .95rem;
}
#busy[hidden] { display: none; }
.elapsed { color: var(--muted); font-variant-numeric: tabular-nums; }

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -.15em;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  /* No spin; pulse the ring instead. */
  .spinner { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .3; } }
}

.options { margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.options summary { cursor: pointer; }
.options label { display: block; margin: .5rem 0 0; color: var(--ink); }
.options input { margin-right: .4rem; }

#result {
  margin: 1rem 0;
  padding: .8rem 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: .95rem;
}
#result.error, .error { color: var(--error); }
#result a.go { color: var(--accent); }

table.quality { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .9rem; }
table.quality th, table.quality td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.quality th { color: var(--muted); font-weight: 600; }

pre {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: .8rem;
  overflow-x: auto;
  font-size: .85rem;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

ul { padding-left: 1.2rem; }
li { margin: .3rem 0; }
.note { color: var(--muted); font-size: .9rem; }

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .85rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e6e1;
    --muted: #a5a09a;
    --line: #3a3833;
    --paper: #171614;
    --accent: #7fa6ef;
    --error: #e88;
  }
  input[type="text"], pre, #result, #busy, table.quality th { background: #201f1c; }
  .langs button[aria-current="true"] { background: #201f1c; }
  .row button#check { background: #201f1c; }
}
