:root {
  color-scheme: light;
  --bg: #f3eee6;
  --bg-2: #e7e0d4;
  --surface: #fffaf3;
  --ink: #1d1914;
  --muted: #5c5348;
  --line: #ddd3c4;
  --accent: #8a4b10;
  --accent-ink: #fff8ef;
  --accent-soft: #f6e4d0;
  --good: #1c6b42;
  --bad: #8f2d2d;
  --shadow: 0 1px 0 rgba(40, 30, 15, 0.04), 0 10px 28px rgba(60, 40, 20, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #12100d;
    --bg-2: #1c1914;
    --surface: #221e18;
    --ink: #f4ecdf;
    --muted: #c3b6a4;
    --line: #3c342b;
    --accent: #e6a45a;
    --accent-ink: #24180c;
    --accent-soft: #3a2c1c;
    --good: #9ed6b4;
    --bad: #ffb4ab;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 4px;
  background-repeat: no-repeat;
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 10;
}

.skip:focus { top: 12px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 32px 8px;
}

.brand { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }

.mark {
  margin: 0;
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.04em;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

h1 { margin: 0; font-size: clamp(1.7rem, 2.4vw, 2.15rem); }
h2 { margin: 0; font-size: 1.45rem; }
h3 { margin: 0; font-size: 1.15rem; }

.lede, .hint, .meta { color: var(--muted); }
.lede { margin: 4px 0 0; max-width: 42rem; }

.nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  flex: none;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
}

.nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--bg);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 32px 72px;
}

.stack { display: flex; flex-direction: column; gap: 16px; }

.tools, .head-row, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions {
  display: grid;
  gap: 6px;
}

.actions-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.actions-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.actions button, .actions .btn { min-width: 0; padding: 7px 8px; }

.head-row { justify-content: space-between; align-items: baseline; }

.grid, .roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 14px;
}

.card, .empty, .composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card { padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card.pinned { box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.actions-wrap { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

.command, .example {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.45;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag, .count {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

button, .btn, input, textarea, select {
  font: inherit;
  color: inherit;
}

button, .btn {
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 8px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.primary, .btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}

button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

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

button.danger { color: var(--bad); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
}

textarea { min-height: 7.5rem; resize: vertical; }

.tools input[type="search"] { max-width: 320px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.lbl { font-size: 0.92rem; font-weight: 600; }

.composer { padding: 18px; display: flex; flex-direction: column; gap: 14px; max-width: 760px; }

.agents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  border: 0;
  margin: 0;
  padding: 0;
}

.agents legend { font-weight: 600; margin-bottom: 8px; }

.agents label {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  min-height: 72px;
}

.agents input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.agents label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.agents .who { font-weight: 650; }
.agents .cmd, .agents .range { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }

.n-row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: end; }
.hint { margin: 0; min-height: 1.5em; }
.error { color: var(--bad); margin: 0; min-height: 1.5em; }
.banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
}

.examples { display: flex; flex-direction: column; gap: 6px; }
.examples a {
  color: inherit;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--bg-2);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-word;
}
.examples a:hover { outline: 1px solid var(--accent); }

.empty {
  grid-column: 1 / -1;
  max-width: 28rem;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.scale { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.scale li { margin: 2px 0; }

.foot {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 999px;
  margin: 0;
  transition: opacity 0.18s linear, transform 0.18s linear;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%); }

.noscript { max-width: 40rem; margin: 1rem auto; padding: 0 16px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::placeholder { color: var(--muted); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

@media (max-width: 720px) {
  .toast {
    top: auto;
    bottom: 12px;
    left: auto;
    right: 12px;
    transform: none;
  }
  .toast.show { transform: none; }
  .top {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: column;
    align-items: stretch;
    padding: 16px 16px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .nav { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 12px; }
  .nav a { text-align: center; padding: 8px 6px; }
  main { padding: 14px 16px 48px; }
  .n-row { grid-template-columns: 1fr; }
  .tools input[type="search"] { max-width: none; flex: 1 1 100%; }
}
