/* Swarm — screen layer. tokens.css holds the world; this holds the rooms.
   Nothing here invents a value: every colour, size, radius and gap is a token from
   tokens.css, because DESIGN.md's spacing rhythm (4 8 16 24 32 48 72) and its 1px/2px
   /3px radius vocabulary are the whole reason the interface reads as one piece of
   stock rather than a dashboard. A 12px gap or a 6px radius in here is a bug. */

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 var(--s-3); }
@media (max-width: 820px) { .wrap { padding: 0 var(--s-2); } }

/* ------------------------------------------------------------- the bundle cover */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-2); padding-top: var(--s-2);
  border-bottom: 1px solid var(--hairline);
}
.mark {
  display: flex; align-items: baseline; gap: var(--s-1);
  font-size: var(--t-20); font-weight: 800; letter-spacing: -0.01em;
  color: var(--text); padding-bottom: var(--s-2);
}
.mark__seal {
  font-family: var(--font-mono); font-size: var(--t-11); font-weight: 700;
  letter-spacing: 0.08em; padding: 2px 6px; border-radius: var(--r-xs);
  background: var(--gold); color: var(--on-gold); transform: translateY(-2px);
}
.topbar__right {
  display: flex; align-items: center; gap: var(--s-1); padding-bottom: var(--s-1);
}
/* At phone width the name and workspace wrap onto two lines and crowd the seal, and
   neither is information the person needs while working — they know who they are.
   The theme control stays, because that one is a choice. */
@media (max-width: 560px) { #whoami { display: none; } }

/* The divider tab: the system's one curved form, top corners only, sitting flush on
   the stock it indexes. Used for navigation because that is literally what a tab
   index is for. */
.tab, .sw-nav__tab {
  font-family: var(--font-mono); font-size: var(--t-11);
  text-transform: uppercase; letter-spacing: 0.14em;
  background: var(--sunken); color: var(--muted);
  border: 1px solid var(--hairline); border-bottom: none;
  border-radius: var(--r-tab);
  padding: 5px 10px 6px;
}
.sw-nav {
  display: flex; gap: var(--s-0); overflow-x: auto;
  padding: var(--s-2) 0 0 var(--s-1);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--s-3);
  scrollbar-width: none;
}
.sw-nav::-webkit-scrollbar { display: none; }
.sw-nav__tab {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; text-decoration: none; white-space: nowrap;
  margin-bottom: -1px; cursor: pointer;
}
.sw-nav__tab:hover { color: var(--text); }
.sw-nav__tab[aria-current="page"] {
  background: var(--surface); color: var(--text); border-bottom: 1px solid var(--surface);
}
.sw-nav__n {
  font-size: var(--t-11); font-weight: 700; letter-spacing: 0.04em;
  color: var(--muted);
}
.sw-nav__tab[aria-current="page"] .sw-nav__n { color: var(--text); }

/* --------------------------------------------------------------------- headings */
.page { padding-bottom: var(--s-6); }
.page__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-3);
}
.page__head h1 { margin: 0; }          /* one Display element per screen */
.page__asof {
  font-family: var(--font-mono); font-size: var(--t-12); color: var(--faint);
}
.hero { padding: var(--s-5) 0 var(--s-4); max-width: 660px; }
.hero h1 { margin-bottom: var(--s-2); }
.hero p { font-size: var(--t-18); color: var(--muted); margin: 0 0 var(--s-3); }

.grid { display: grid; gap: var(--s-2); grid-template-columns: repeat(3, 1fr); padding-bottom: var(--s-5); }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }
.card-title { font-family: var(--font-ui); font-size: var(--t-16); font-weight: 700; color: var(--text); margin: 0 0 var(--s-1); }
.card-body { color: var(--muted); font-size: var(--t-14); margin: 0; }

.state { display: none; }
.state--on { display: block; }

/* ---------------------------------------------------------------------- banners */
.banner {
  border: 1px solid var(--risk); background: var(--surface);
  border-radius: var(--r-sm); padding: var(--s-2); margin: var(--s-3) 0;
  font-size: var(--t-14); color: var(--text);
  display: flex; gap: var(--s-1); align-items: flex-start;
}
/* An author `display` rule beats the UA rule for [hidden] (I-012), so an empty
   banner renders on every clean load unless this is said explicitly. */
.banner[hidden] { display: none; }
.banner__mark { font-family: var(--font-mono); font-weight: 700; color: var(--risk); flex: none; }
.banner--ok { border-color: var(--ok); }
.banner--ok .banner__mark { color: var(--ok); }

/* --------------------------------------------------------------------- sections */
.sw-section { margin-bottom: var(--s-4); }
.sw-section__tabs { display: flex; padding-left: var(--s-2); }
.sw-section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-1);
  background: var(--surface);
  border: 1px solid var(--hairline); border-bottom: none;
  border-top-left-radius: 0;
}
.sw-section__head h2 { font-size: var(--t-18); font-weight: 700; }
.sw-section__note { font-size: var(--t-13); color: var(--muted); }
.sw-section__body {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 0 var(--r-sm) var(--r-sm) var(--r-sm);
  padding: 0 var(--s-2);
}

/* ------------------------------------------------- the ruled index: a bundle row */
.sw-row {
  display: grid;
  grid-template-columns: 132px 96px 1fr auto;
  gap: var(--s-2); align-items: baseline;
  padding: 11px 0; border-bottom: 1px solid var(--hairline);
  font-size: var(--t-14); text-decoration: none; color: inherit;
}
.sw-row:last-child { border-bottom: 0; }
.sw-row:hover { background: var(--sunken); }
.sw-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.sw-row__code {
  font-family: var(--font-mono); font-size: var(--t-13); color: var(--muted);
}
.sw-row__title { color: var(--text); font-weight: 600; }
.sw-row__where { color: var(--muted); font-size: var(--t-13); }
.sw-row__right {
  display: flex; align-items: baseline; gap: var(--s-2); justify-self: end;
  font-family: var(--font-mono); font-size: var(--t-13); color: var(--muted);
  white-space: nowrap;
}
.sw-row__date--late { color: var(--risk); font-weight: 700; }
.sw-row__who { font-family: var(--font-ui); font-size: var(--t-13); }

@media (max-width: 820px) {
  .sw-row {
    grid-template-columns: 1fr; gap: var(--s-0);
    padding: var(--s-2) 0;
  }
  .sw-row__right { justify-self: start; }
}

/* Status: a mark, then a label, then a colour — in that order of importance, so the
   interface still works in greyscale and for a colour-blind reader. */
.sw-status { display: inline-flex; align-items: baseline; gap: 6px; font-size: var(--t-13); font-weight: 600; }
.sw-status__mark { font-family: var(--font-mono); font-size: var(--t-12); font-weight: 700; }

/* The inference marker. A derived item never looks like a stated one. */
.sw-derived {
  display: inline-flex; align-items: baseline; gap: 5px;
  font-family: var(--font-mono); font-size: var(--t-11);
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}
.sw-derived__ref { color: var(--gold-ink); }

/* ---------------------------------------------------------- detail: the meta grid */
.sw-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; }
@media (max-width: 560px) { .sw-meta { grid-template-columns: 1fr; } }
.sw-meta__row {
  display: flex; justify-content: space-between; gap: var(--s-2);
  padding: 11px var(--s-2) 11px 0; border-bottom: 1px solid var(--hairline);
  font-size: var(--t-14);
}
.sw-meta__row dt { color: var(--muted); margin: 0; }
.sw-meta__row dd { margin: 0; color: var(--text); font-family: var(--font-mono); font-size: var(--t-13); text-align: right; }
.sw-meta__row dd.is-ui { font-family: var(--font-ui); }

.row {
  display: flex; justify-content: space-between; gap: var(--s-2);
  padding: 11px 0; border-bottom: 1px solid var(--hairline); font-size: var(--t-14);
}
.row:last-child { border-bottom: 0; }
.row dt { color: var(--muted); margin: 0; }
.row dd { margin: 0; color: var(--text); font-family: var(--font-mono); font-size: var(--t-13); }

/* -------------------------------------------------------------------- the detail */
.detail__head { margin-bottom: var(--s-3); }
.detail__codeline {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin-bottom: var(--s-1);
}
.detail__code { font-family: var(--font-mono); font-size: var(--t-13); color: var(--muted); }
.detail__title { font-size: var(--t-28); font-weight: 800; line-height: 1.15; letter-spacing: -0.015em; }
.detail__body { color: var(--body); max-width: 70ch; margin: var(--s-2) 0 0; }
.detail__cols { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }

.sw-block {
  border: 1px solid var(--risk); background: var(--surface);
  border-radius: var(--r-sm); padding: var(--s-2); margin: var(--s-2) 0;
  display: flex; gap: var(--s-1); align-items: flex-start; font-size: var(--t-14);
}
.sw-block__mark { font-family: var(--font-mono); font-weight: 700; color: var(--risk); flex: none; }
.sw-block__since { display: block; font-family: var(--font-mono); font-size: var(--t-12); color: var(--muted); margin-top: var(--s-0); }

.sw-list { list-style: none; margin: 0; padding: 0; }
.sw-list__item {
  padding: 11px 0; border-bottom: 1px solid var(--hairline); font-size: var(--t-14);
}
.sw-list__item:last-child { border-bottom: 0; }
.sw-list__meta { font-family: var(--font-mono); font-size: var(--t-12); color: var(--muted); }

.sw-check { display: flex; align-items: center; gap: var(--s-1); min-height: 36px; cursor: pointer; }
.sw-check input { width: 16px; height: 16px; accent-color: var(--gold-ink); margin: 0; flex: none; }
.sw-check--done span { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------------- the actions */
.sw-actions { display: flex; flex-wrap: wrap; gap: var(--s-1); margin: var(--s-2) 0; }
.sw-field { display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: center; margin: var(--s-2) 0; }
.sw-label--inline { flex: none; }

.sw-input, .sw-select, .sw-textarea {
  font-family: var(--font-ui); font-size: var(--t-14); color: var(--text);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 0 var(--s-1); min-height: 44px;
}
.sw-textarea { padding: var(--s-1); min-height: 72px; line-height: 1.5; width: 100%; resize: vertical; }
.sw-input:focus-visible, .sw-select:focus-visible, .sw-textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
.sw-input--grow { flex: 1 1 220px; min-width: 0; }

.sw-filters {
  display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: center;
  padding-bottom: var(--s-2); margin-bottom: var(--s-2);
  border-bottom: 1px solid var(--hairline);
}
.sw-chip--button { cursor: pointer; min-height: 36px; padding: 0 var(--s-1); font-family: var(--font-ui); }

.sw-count {
  font-family: var(--font-mono); font-size: var(--t-12); color: var(--muted);
}

footer { border-top: 1px solid var(--hairline); padding: var(--s-3) 0; color: var(--faint); font-size: var(--t-13); }
footer a { color: var(--faint); }

/* The toast genuinely floats, so it is one of the three things in this product
   allowed a shadow. It carries NO border: a 1px edge plus a wide diffuse shadow is a
   recurring generated-UI signature, and Impeccable is right that a thing should commit
   to one or the other. The tonal step from board to page is the second signal, as it
   is everywhere else here.
   A refusal is marked and labelled rather than outlined, which is the Status rule
   (mark, then label, then colour) applied to a message instead of a row. */
.sw-toast {
  position: fixed; left: 50%; bottom: var(--s-3); transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-panel);
  padding: var(--s-1) var(--s-2); font-size: var(--t-14);
  max-width: calc(100vw - var(--s-4)); z-index: 20;
  display: flex; align-items: baseline; gap: var(--s-1);
}
.sw-toast[hidden] { display: none; }
.sw-toast__mark {
  font-family: var(--font-mono); font-weight: 700; color: var(--risk); flex: none;
}
