:root {
  --ink: #1b1b1b;
  --paper: #ffffff;
  --accent: #0b5394;
  --accent-ink: #ffffff;
  --border: #595959;
  --error: #b3261e;
  --muted-bg: #f1f3f4;
  --focus: #0b5394;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  line-height: 1.55;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

h1 { font-size: 1.7rem; line-height: 1.25; margin: 0.5rem 0 0.25rem; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; }
.tagline { margin-top: 0; }

a { color: var(--accent); }
a:focus-visible, button:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar { display: flex; justify-content: flex-end; }

.field { margin: 1rem 0; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
textarea {
  width: 100%;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
}
textarea[readonly] { background: var(--muted-bg); }

.actions { display: flex; gap: 0.75rem; margin: 1rem 0; }
button {
  font: inherit;
  padding: 0.5rem 1.2rem;
  border-radius: 4px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button.secondary { background: var(--paper); color: var(--accent); }

#status { min-height: 1.5em; font-weight: 600; }

#error-summary {
  border: 2px solid var(--error);
  border-radius: 4px;
  padding: 0.6rem 1rem;
  margin: 1rem 0;
}
#error-summary h2 { color: var(--error); margin-top: 0.2rem; }
.err-context { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }

details {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 1rem;
  margin: 1rem 0;
}
summary { cursor: pointer; font-weight: 600; }

.trees { display: block; }
.trees ul { margin: 0.2rem 0 0.2rem 1.1rem; padding-left: 0.9rem; }
.trees li { overflow-wrap: anywhere; margin: 0.15rem 0; }
.where-note { font-style: italic; }

footer { margin-top: 2.5rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }

@media (max-width: 40rem) {
  main { padding: 0.75rem 0.75rem 2rem; }
  .actions { flex-wrap: wrap; }
}
