:root {
  --ink: #1a1a1a;
  --bg: #faf8f3;
  --accent: #5a2a27;
  --muted: #6b6b6b;
  --rule: #ddd8ce;
  --card: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--rule);
  background: var(--card);
}

.brand {
  font-size: 1.3rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--ink);
}
.brand em { font-style: italic; color: var(--accent); }

.topbar nav a {
  margin-left: 1.25rem;
  text-decoration: none;
}

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

h1 { margin: 0 0 0.25rem; font-size: 2rem; }
h2 { margin: 2rem 0 0.75rem; font-size: 1.3rem; border-top: 1px solid var(--rule); padding-top: 1.25rem; }
.meta { color: var(--muted); font-size: 0.9rem; }

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

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:hover { filter: brightness(0.97); }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.empty { color: var(--muted); font-style: italic; }

.project-list, .track-list, .run-list { list-style: none; padding: 0; }
.project-list li, .run-list li {
  padding: 0.75rem 0; border-bottom: 1px solid var(--rule);
}
.track-list { counter-reset: tr; padding-left: 2rem; }
.track-list li { padding: 0.5rem 0; border-bottom: 1px dotted var(--rule); list-style: decimal; display: flex; align-items: center; gap: 0.5rem; }

.project-list a, .track-list .track-link {
  text-decoration: none; color: var(--ink);
  display: flex; justify-content: space-between; align-items: baseline;
  flex: 1; min-width: 0;
}
.project-list a { display: flex; justify-content: space-between; align-items: baseline; }

.track-list .drag-handle {
  cursor: grab; user-select: none; color: var(--muted);
  padding: 0 0.25rem; font-size: 1.2rem; line-height: 1;
  opacity: 0.4; transition: opacity 0.15s;
}
.track-list .drag-handle:hover { opacity: 1; }
.track-list .drag-handle:active { cursor: grabbing; }

.track-list .track-delete-form { margin: 0; }
.track-list .track-delete {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 0.15rem 0.5rem;
  opacity: 0.4; transition: opacity 0.15s, color 0.15s;
}
.track-list .track-delete:hover { opacity: 1; color: #8a1a1a; }

.track-list .sortable-ghost { opacity: 0.3; }
.track-list .sortable-drag { opacity: 0.9; background: var(--paper, #fff); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

/* Audio version list on track detail page */
.audio-list { list-style: none; padding: 0; margin: 1rem 0; }
.audio-list li { padding: 0.6rem 0.75rem; border-bottom: 1px dotted var(--rule); }
.audio-list li.audio-selected { background: rgba(255, 215, 90, 0.08); border-left: 3px solid var(--accent); padding-left: 0.5rem; }
.audio-row-top { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.audio-row-top audio { max-width: 320px; }
.audio-row-ctrl { display: flex; align-items: center; gap: 1rem; margin-top: 0.35rem; flex-wrap: wrap; }
.audio-row-ctrl .inline-form { display: inline-flex; gap: 0.35rem; align-items: center; margin: 0; }
.audio-row-ctrl input[type="text"] { padding: 0.25rem 0.5rem; font-size: 0.85rem; min-width: 240px; }

form.wizard, form.stack { display: flex; flex-direction: column; gap: 1rem; }
form label { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--muted); }
form label input, form label textarea, form label select {
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
form label small { color: var(--muted); margin-top: 0.25rem; }
form label.inline { flex-direction: row; align-items: center; gap: 0.5rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

fieldset { border: 1px solid var(--rule); border-radius: 4px; padding: 1rem; }
legend { padding: 0 0.5rem; color: var(--muted); }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.dropzone {
  border: 2px dashed var(--rule);
  padding: 1rem;
  border-radius: 4px;
  margin-top: 0.75rem;
  background: var(--card);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.image-grid figure {
  margin: 0;
  border: 1px solid var(--rule);
  background: var(--card);
  padding: 0.5rem;
  border-radius: 4px;
}
.image-grid figure.selected { border-color: var(--accent); }
.image-grid img { width: 100%; height: auto; border-radius: 2px; }
.image-grid figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }

.crumbs { margin-top: 0; }

/* Rounds + candidates */
.round-form { margin: 1rem 0 1.5rem; max-width: 620px; }
.round-form label { font-size: 0.9rem; }
.round-form input { width: 100%; }
.round-form button { margin-top: 0.5rem; }

.rounds { display: flex; flex-direction: column; gap: 1.5rem; margin-bottom: 1.5rem; }
.round {
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  padding: 1rem 1.25rem;
}
.round header {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; margin-bottom: 0.75rem;
}
.round h3 { margin: 0; font-size: 1.1rem; font-weight: normal; }
.round h3 em { color: var(--accent); font-style: italic; }
.round .status {
  font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 3px;
  background: #eee; color: #555; text-transform: uppercase; letter-spacing: 0.03em;
}
.status-running { background: #fef3c7; color: #92400e; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-failed { background: #fecaca; color: #991b1b; }

.candidate-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem;
}
.candidate {
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.75rem;
  background: #fff; transition: border-color 0.1s, background 0.1s;
}
.candidate.selected { border-color: var(--accent); background: #fff9f7; }
.candidate label {
  display: flex; align-items: baseline; gap: 0.5rem; cursor: pointer;
  flex-direction: row; color: inherit;
}
.candidate input { margin-top: 0.2rem; }
.candidate .ctitle { font-weight: bold; font-size: 0.95rem; flex: 1; }
.candidate .ckind { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }
.candidate .cone { font-size: 0.85rem; margin: 0.5rem 0 0.25rem; color: var(--ink); }
.candidate .crat { font-size: 0.8rem; margin: 0; color: var(--muted); }

.lock-form { margin: 1.5rem 0; text-align: center; }
.lock-form button { padding: 0.7rem 1.4rem; font-size: 1rem; }

.err { color: #991b1b; background: #fff5f5; padding: 0.5rem 0.75rem; border-radius: 3px; }
