:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #fafafa;
  --border: #ddd;
  --accent: #2a6cb0;
  --error: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #eaeaea;
    --bg: #16181c;
    --border: #333;
    --accent: #6ea8dd;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

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

.brand { font-weight: 600; }

nav a {
  margin-left: 1rem;
  color: var(--accent);
  text-decoration: none;
}

main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 360px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.form input,
.form textarea,
.form select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
}

.form-wide { max-width: 640px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0;
}

fieldset legend {
  padding: 0 0.4rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}

button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  width: fit-content;
}

button.danger {
  background: var(--error);
}

table.totals th { width: 60%; font-weight: 500; }
table.totals tr.totals-highlight th,
table.totals tr.totals-highlight td { font-weight: 700; }

.hint { color: #888; font-size: 0.9rem; }

.table-scroll { overflow-x: auto; }

.quality-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}
.quality-good { background: #1e7d34; }
.quality-limited { background: #b8860b; }
.quality-poor { background: var(--error); }
.quality-none { background: #888; }

.comp-excluded { opacity: 0.5; }

.nowrap { white-space: nowrap; }

.comps-toolbar { display: flex; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; }

.comp-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.comp-card-media { flex-shrink: 0; width: 140px; }
.comp-thumb-lg { width: 140px; height: 140px; object-fit: contain; }

.comp-card-body { flex: 1; min-width: 0; }

.comp-title-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  resize: vertical;
  font-family: inherit;
}

.comp-condition-label {
  display: block;
  font-size: 0.85rem;
  color: #888;
  margin: 0.5rem 0;
}
.comp-condition-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  margin-top: 0.2rem;
}

.comp-title-display {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.comp-field-label { color: #888; font-size: 0.85rem; margin-right: 0.3rem; }

.comp-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin: 0.75rem 0;
}
.comp-card-fields label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: #888; }
.comp-card-fields input { width: 130px; }

.comp-card-included { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.4rem; }

.comp-card-actions { margin-top: 0.6rem; display: flex; gap: 0.5rem; }

pre {
  background: rgba(127, 127, 127, 0.1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.8rem;
  max-width: 100%;
}

details summary { cursor: pointer; color: var(--accent); }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.error { color: var(--error); }
.notice { color: var(--accent); }
.empty-state { color: #888; }
