:root {
  color-scheme: light dark;
  --border: #ccc;
  --muted: #666;
  --accent: #2a5d8f;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0 1.5rem 2rem;
  max-width: 1000px;
  margin-inline: auto;
}

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

h1 {
  font-size: 1.3rem;
  margin: 0;
}

button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

#app {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

#search-box {
  width: 100%;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
}

#search-count {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.4rem 0;
}

#search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

#search-results li {
  border-bottom: 1px solid var(--border);
}

#search-results li:last-child {
  border-bottom: none;
}

#search-results button {
  all: unset;
  display: block;
  width: 100%;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}

#search-results button:hover,
#search-results button:focus-visible {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

#search-results .years {
  color: var(--muted);
  font-size: 0.85rem;
}

#detail-panel {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.5rem;
}

#detail-panel .placeholder {
  color: var(--muted);
}

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

.field-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.field-list li {
  padding: 0.2rem 0;
}

.field-list .label {
  color: var(--muted);
  display: inline-block;
  min-width: 6rem;
}

.relation-group h3 {
  font-size: 0.95rem;
  margin: 1rem 0 0.3rem;
}

.relation-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.relation-group a {
  color: var(--accent);
  text-decoration: none;
}

.relation-group a:hover {
  text-decoration: underline;
}

form.edit-form label {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

form.edit-form input,
form.edit-form textarea {
  width: 100%;
  padding: 0.4rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
}

form.edit-form .actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.error {
  color: #b00020;
}
