:root {
  --paper: #f7f4ec;
  --panel: #fbf9f3;
  --line: #e2dbcb;
  --line-strong: #cfc6b2;
  --ink: #1a1f1c;
  --muted: #585f59;
  --faint: #8f958e;
  --sage: #c9d6c3;
  --forest: #0f6b4c;
  --forest-dark: #0b5139;
  --free-bg: #e3eddd;
  --free-line: #bbd1b3;
  --free-ink: #22533a;
  --held-bg: #f7e6bc;
  --held-line: #ddba6a;
  --held-ink: #674508;
  --held-btn: #fff8e6;
  --busy-bg: #f0dcd3;
  --busy-line: #d8ae9d;
  --busy-ink: #7a3726;
  --danger-bg: #f7e3de;
  --danger-line: #e0aba0;
  --danger-ink: #8e2f20;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --asset-col: 168px;
  --slot-col: 88px;
  --ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--forest);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

button,
input,
select {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ——— Top nav ——— */

.topnav {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  height: 3rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (min-width: 1024px) {
  .topnav-inner {
    padding: 0 2rem;
  }
}

.brand-mark {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 2px;
}

.brand-mark:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.brand-mark span {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

.topnav-links {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}

.topnav-links a {
  color: var(--muted);
  text-decoration: none;
  border-radius: 2px;
  text-underline-offset: 4px;
}

.topnav-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.topnav-links a[aria-current="page"] {
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--forest);
  text-decoration-thickness: 2px;
}

.topnav-links a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ——— Shell / landing ——— */

.shell-landing {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 7rem;
}

.shell-board {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (min-width: 1024px) {
  .shell-landing,
  .shell-board {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.hero {
  padding-top: 3rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.hero p {
  margin: 1rem 0 0;
  max-width: 36rem;
  font-size: 1.0625rem;
  line-height: 1.625;
  color: var(--muted);
}

.pack-grid {
  display: grid;
  gap: 1.25rem;
  margin-top: 3.5rem;
}

@media (min-width: 768px) {
  .pack-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.seed-card {
  display: flex;
  flex-direction: column;
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
}

.seed-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.seed-card h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chip-mono {
  flex-shrink: 0;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.seed-card .tagline {
  margin: 0.375rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.asset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.asset-chips li {
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--sage);
  border-radius: 999px;
  background: var(--free-bg);
  font-size: 0.75rem;
  color: var(--free-ink);
}

.seed-meta {
  margin: 0.75rem 0 0;
  font-size: 0.78125rem;
  color: var(--muted);
}

.seed-card form {
  margin-top: auto;
  padding-top: 2rem;
}

.open-existing {
  margin-top: 2rem;
}

.open-existing a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--forest);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--forest) 40%, transparent);
  text-underline-offset: 4px;
  border-radius: 2px;
}

.open-existing a:hover {
  text-decoration-color: var(--forest);
}

.open-existing a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ——— Buttons ——— */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.5rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, color 150ms, opacity 150ms;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-forest {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--paper);
}

.btn-forest:hover:not(:disabled) {
  background: var(--forest-dark);
  border-color: var(--forest-dark);
}

.btn-ink {
  height: 2rem;
  padding: 0 0.75rem;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-size: 0.8125rem;
  border-radius: 5px;
}

.btn-ink:hover:not(:disabled) {
  background: var(--forest-dark);
  border-color: var(--forest-dark);
}

.btn-icon {
  width: 0.875rem;
  height: 0.875rem;
}

.htmx-indicator {
  display: none;
  font-size: 0.75rem;
  color: var(--muted);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

.spin {
  animation: spin 0.7s linear infinite;
}

.htmx-request .spin-on-request {
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ——— Banners ——— */

.banner-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.banner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
}

.banner-ok {
  border-color: var(--free-line);
  background: var(--free-bg);
  color: var(--free-ink);
}

.banner-err {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.banner p {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.banner-icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

/* ——— Day board header ——— */

.board-header {
  padding: 1.5rem 0 1.25rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78125rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 2px;
}

.back-link:hover {
  color: var(--ink);
}

.back-link:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.board-header h1 {
  margin: 0.5rem 0 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.board-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.board-meta .mono {
  font-family: var(--mono);
}

.control-sticky {
  position: sticky;
  top: 0;
  z-index: 30;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(6px);
}

.control-sticky-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.625rem 1.5rem;
}

@media (min-width: 1024px) {
  .control-sticky-inner {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.field input,
.field select {
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.8125rem;
}

.field input.mono,
.field select.mono {
  font-family: var(--mono);
}

.field input:focus-visible,
.field select:focus-visible {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--forest) 35%, transparent);
}

.field-narrow {
  width: 4rem;
}

.field-tz {
  width: 7rem;
}

.board-main {
  padding: 1rem 0 4rem;
}

.grid-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.grid-chrome h2 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  border: 1px solid;
}

.swatch-free {
  background: var(--free-bg);
  border-color: var(--free-line);
}

.swatch-held {
  background: var(--held-bg);
  border-color: var(--held-line);
}

.swatch-busy {
  background: var(--busy-bg);
  border-color: var(--busy-line);
}

.footnote {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ——— Slot grid ——— */

.grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--panel);
  transition: opacity 200ms;
}

.htmx-request .grid-wrap {
  opacity: 0.5;
}

.slot-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: calc(var(--asset-col) + 14 * var(--slot-col));
}

.slot-grid caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.slot-grid th,
.slot-grid td {
  border: 0;
  padding: 0;
  vertical-align: top;
}

.slot-grid thead th {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.25rem;
  font-size: 0.71875rem;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--muted);
  text-align: left;
  background: var(--panel);
}

.slot-grid thead th.asset-col {
  position: sticky;
  left: 0;
  z-index: 20;
  width: var(--asset-col);
  min-width: var(--asset-col);
  padding: 0.5rem 0.75rem;
  border-right: 1px solid var(--line);
  font-family: var(--font);
}

.slot-grid tbody tr {
  border-bottom: 1px solid var(--line);
}

.slot-grid tbody tr:last-child {
  border-bottom: 0;
}

.slot-grid tbody th.asset-col {
  position: sticky;
  left: 0;
  z-index: 10;
  width: var(--asset-col);
  min-width: var(--asset-col);
  padding: 0.75rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  vertical-align: middle;
  font-weight: 500;
}

.asset-label {
  display: block;
  font-size: 0.84375rem;
  color: var(--ink);
}

.asset-id {
  display: block;
  margin-top: 0.125rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--faint);
}

.slot-grid tbody td {
  height: 72px;
  padding: 0.25rem;
  width: var(--slot-col);
  min-width: var(--slot-col);
}

.slot-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.8125rem;
  color: var(--faint);
}

/* Free cell */

.slot-free-form {
  height: 100%;
}

.slot-free {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--free-line);
  border-radius: 4px;
  background: var(--free-bg);
  color: var(--free-ink);
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}

.slot-free:hover,
.slot-free:focus-visible {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--paper);
  outline: none;
}

.slot-free .idle {
  font-size: 0.75rem;
  font-weight: 500;
}

.slot-free .hover {
  display: none;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.slot-free:hover .idle,
.slot-free:focus-visible .idle {
  display: none;
}

.slot-free:hover .hover,
.slot-free:focus-visible .hover {
  display: flex;
}

.slot-free .hover strong {
  font-size: 0.75rem;
  font-weight: 600;
}

.slot-free .hover span {
  font-family: var(--mono);
  font-size: 0.65625rem;
}

/* Held / busy cells */

.slot-held,
.slot-busy {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.25rem 0.375rem;
  border-radius: 4px;
  border: 1px solid;
}

.slot-held {
  border-color: var(--held-line);
  background: var(--held-bg);
  color: var(--held-ink);
}

.slot-busy {
  border-color: var(--busy-line);
  background: var(--busy-bg);
  color: var(--busy-ink);
}

.slot-busy.noshow {
  border-style: dashed;
  background: color-mix(in srgb, var(--busy-bg) 60%, transparent);
}

.slot-state {
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1.2;
}

.slot-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.65625rem;
  line-height: 1.2;
}

.slot-held form {
  margin-top: auto;
}

.btn-confirm {
  width: 100%;
  height: 1.25rem;
  padding: 0;
  border: 1px solid var(--held-line);
  border-radius: 3px;
  background: var(--held-btn);
  color: var(--held-ink);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}

.btn-confirm:hover,
.btn-confirm:focus-visible {
  background: var(--held-ink);
  border-color: var(--held-ink);
  color: var(--paper);
  outline: none;
}

.muted {
  color: var(--muted);
  font-size: 0.8125rem;
}

.empty-grid {
  margin: 0;
  padding: 1.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
