:root {
  color-scheme: light dark;
  --background: #111111;
  --foreground: #eeeeee;
  --muted: #9e9e9e;
  --panel: #1c1c1c;
  --border: #393939;
  --accent: #d6b46d;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.site-header {
  margin-bottom: 2rem;
}

.brand {
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header p,
.hint,
.muted {
  color: var(--muted);
}

.site-header .about {
  white-space: pre-line;
  margin-bottom: 0;
}

.panel,
.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.search-form {
  display: grid;
  gap: 1rem;
}

label,
legend {
  font-weight: 650;
}

input[type="text"],
input[name="value"] {
  box-sizing: border-box;
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--foreground);
  font-size: 1.1rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.corpus-list {
  display: grid;
  gap: 0.5rem;
}

button {
  justify-self: start;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #111111;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.7rem 1rem;
}

.value-panel {
  margin-top: 1rem;
}

.value-panel p {
  margin: 0;
}

.value-number {
  color: var(--accent);
  font-size: 1.3rem;
}

.value-expression {
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.search-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.collate-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.value-header,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.result-header {
  justify-content: flex-start;
  gap: 0.5rem;
}

.result-header h2 {
  margin: 0;
}

#toggle-all-results {
  flex: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
}

.result-fold {
  flex: none;
  justify-self: start;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 0.1rem 0.25rem;
}

.result-body {
  margin-top: 0.5rem;
}

.results {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.result-card h2 {
  margin-top: 0;
}

.error {
  color: #ff8f8f;
}

.metadata {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1rem;
}

.metadata dt {
  color: var(--muted);
}

.tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.selection-count {
  margin: 0;
}

#clear-all {
  justify-self: end;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
}

.tree,
.tree-children {
  list-style: none;
  margin: 0.5rem 0 0;
  padding-left: 0;
}

.tree-children {
  padding-left: 1.5rem;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.fold {
  justify-self: start;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.15rem 0.35rem;
  line-height: 1;
}

.tree-toggle,
.tree-file label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 550;
}

.tree-file label {
  font-weight: 400;
}

.tree-file input[type="checkbox"] {
  flex: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.72);
}

.overlay[hidden] {
  display: none;
}

.overlay-panel {
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.overlay-header h2 {
  margin: 0;
}

.help-text {
  margin: 1rem 0 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--foreground);
}
