:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --border: #e3e1dd;
  --text: #1a1a19;
  --muted: #6b6a67;
  --accent: #0047ff;
  --accent-ink: #ffffff;
  --danger: #b4231d;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #1e1f23;
    --border: #32343a;
    --text: #e8e8e4;
    --muted: #9a9a96;
    --accent: #6f95ff;
    --accent-ink: #0d1020;
    --danger: #ff8b83;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem 1.25rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main,
.masthead,
footer {
  max-width: 60rem;
  margin: 0 auto;
}

.masthead h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 1.5rem;
  max-width: 46rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------------ forms -- */

#repo-form {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 16rem;
  min-width: 0;
}

.label {
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type='text'],
input[type='number'],
input[type='search'],
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.6rem;
  min-width: 0;
  width: 100%;
}

input[type='text'],
input[type='search'],
textarea {
  font-family: var(--mono);
  font-size: 0.87rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----------------------------------------------------------------- status -- */

#status {
  margin: 0 0 1rem;
  font-size: 0.87rem;
  color: var(--muted);
  min-height: 1.4em;
}

#status[data-kind='busy'] {
  color: var(--accent);
}

#status[data-kind='error'] {
  color: var(--danger);
}

/* ------------------------------------------------------------------- tree -- */

.panel-head {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.panel-head h2 {
  margin: 0;
}

.panel-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.panel-actions input[type='search'] {
  width: 12rem;
}

.meta {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.tree {
  max-height: 22rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
}

.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.28rem 0.6rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.row:last-child {
  border-bottom: none;
}

.row:hover {
  background: var(--surface);
}

.row .path {
  font-family: var(--mono);
  font-size: 0.83rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .cost {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.row.is-binary {
  opacity: 0.55;
  cursor: default;
}

/* ---------------------------------------------------------------- options -- */

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.toggles {
  border: none;
  padding: 0;
  margin: 0 0 0.85rem;
  display: flex;
  gap: 0.4rem 1.1rem;
  flex-wrap: wrap;
  align-items: center;
}

.toggles legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toggles label {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.89rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------- output --- */

.chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.chip {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

#output-text {
  width: 100%;
  height: 24rem;
  resize: vertical;
  white-space: pre;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.45;
}

footer {
  margin-top: 1.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

footer code {
  font-family: var(--mono);
  font-size: 0.95em;
}

@media (max-width: 34rem) {
  .panel-actions {
    width: 100%;
  }
  .panel-actions input[type='search'] {
    flex: 1;
    width: auto;
  }
}
