/*
  Covex-Board -- app styles.

  Layout and components. Colour, type, spacing, elevation and motion all come
  from design-tokens.css; nothing here hardcodes a hex.

  Two rules the rest of the file follows:

  1. Structure is shown with tone and shadow, not outlines. A surface sits on
     a slightly different surface and casts a soft shadow; only genuinely
     tabular divisions keep a hairline. The usual failure mode for a tool like
     this is nesting four outlined boxes inside each other, which is what
     makes a board read as clutter rather than as cards on a table.

  2. Motion is short and small. The view is rebuilt from scratch on every
     filter change, so anything still animating when the next render lands
     reads as a flicker instead of feedback. Nothing runs longer than 240ms.
     No element is ever hidden by its own base style -- only by a keyframe's
     `from` frame -- so if an animation is unsupported or disabled the
     content is still there. The drawer's exit also has to finish inside the
     180ms hide timer in app.js, so its transition uses --dur, not --dur-slow.
*/

@keyframes rise {
  from { opacity: 0.72; transform: translateY(5px); }
}

/* No opacity in this one: the parent .board is already fading in, and two
   opacity animations on the same pixels multiply into a muddy flash. */
@keyframes slide-up {
  from { transform: translateY(8px); }
}

@keyframes grow-x {
  from { transform: scaleX(0); }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.985); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
}

@keyframes soft-pulse {
  50% { opacity: 0.55; }
}

/* ---- shell ---------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  background: var(--rail-bg);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-3) var(--space-3);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}

.brand-text {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.rail-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rail-label {
  padding: 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.project-list,
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-btn,
.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  min-height: 34px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}

.project-btn:hover,
.nav-btn:hover {
  background: var(--surface-raised);
}

.project-btn[aria-current="true"],
.nav-btn[aria-current="page"] {
  background: var(--surface-raised);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.project-key {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  color: var(--text-muted);
  flex: none;
}

.project-btn[aria-current="true"] .project-key {
  background: transparent;
  color: var(--accent);
}

.project-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.nav-btn[aria-current="page"] .nav-btn-count {
  color: var(--accent);
}

/* The bottom-left panel: project summary, theme switch, keyboard hints. This
   wrapper is what pins the cluster to the foot of the rail -- the .rail-foot
   blocks inside it no longer carry the auto margin themselves. */
.rail-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.rail-foot {
  padding: 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.7;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

/* ---- topbar --------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
}

.topbar-heading {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}

.topbar-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.012em;
  white-space: nowrap;
}

.topbar-sub {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.topbar-spacer {
  flex: 1;
  min-width: var(--space-3);
}

.spacer {
  flex: 1;
  min-width: 0;
}

.search {
  position: relative;
  width: 260px;
  max-width: 100%;
}

.search .input {
  padding-left: 32px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: grid;
  place-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-group .input {
  width: auto;
  min-width: 116px;
}

/* ---- view ----------------------------------------------------------- */

.view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--space-5);
}

/* One entry animation per render, on the view's container. */
.view > * {
  animation: rise var(--dur) var(--ease-out) backwards;
}

.view-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.view-head h2 {
  font-size: var(--text-lg);
}

.view-head .mono {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---- cards, chips, marks ------------------------------------------- */

.type-mark {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: none;
}

.ticket-key {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  white-space: nowrap;
}

.prio {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--priority-medium);
}

.prio-highest { color: var(--priority-highest); }
.prio-high    { color: var(--priority-high); }
.prio-medium  { color: var(--priority-medium); }
.prio-low     { color: var(--priority-low); }

.avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-tint);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.avatar-empty {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border-strong);
  color: var(--text-muted);
}

.points {
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-tint);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text);
}

.label-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  color: var(--text-muted);
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  flex: none;
  background: currentColor;
}

/* "In progress" is the one lane on a board that is genuinely live, so its dot
   is the one thing that moves. Columns carry data-status (set in board.js)
   because the dot takes its colour from an inline style, which leaves no
   class to select on. */
.column[data-status="in_progress"] .status-dot {
  animation: soft-pulse 2.4s var(--ease) infinite;
}

.due {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.due-overdue {
  color: var(--danger);
}

/* ---- board ---------------------------------------------------------- */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: var(--space-4);
  align-items: start;
}

/* Columns slide up while the board itself fades, which gives a cascade
   without stacking two opacity animations on the same pixels. */
.column {
  display: flex;
  flex-direction: column;
  animation: slide-up var(--dur) var(--ease-out) backwards;
}

.column:nth-child(1) { animation-delay: 0ms; }
.column:nth-child(2) { animation-delay: 35ms; }
.column:nth-child(3) { animation-delay: 70ms; }
.column:nth-child(4) { animation-delay: 105ms; }
.column:nth-child(n+5) { animation-delay: 140ms; }

.column-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-1) var(--space-3);
}

.column-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.column-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* The trough is the drop target and the only thing drawing the column, which
   is one box instead of the old bordered column wrapping a second padded
   list. */
.cards {
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-height: 132px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  transition: background-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

.cards.drop-active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cards.drop-active .column-empty {
  visibility: hidden;
}

.column-empty {
  padding: var(--space-5) var(--space-3);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.ticket {
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3);
  cursor: grab;
  transition: transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              opacity var(--dur) var(--ease);
}

.ticket:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.ticket:active {
  cursor: grabbing;
  transform: translateY(0) scale(0.99);
}

.ticket[data-dragging="true"] {
  opacity: 0.4;
  transform: scale(0.97) rotate(-0.5deg);
  box-shadow: none;
}

.ticket-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ticket-title {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}

.ticket-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  min-height: 20px;
}

.ticket-labels {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  min-width: 0;
}

.ticket-foot-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drop-line {
  height: 2px;
  margin: 1px 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  list-style: none;
}

/* ---- backlog -------------------------------------------------------- */

.backlog {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 1180px;
}

.sprint-block,
.backlog-block {
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.sprint-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  flex-wrap: wrap;
}

.sprint-head.drop-active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.sprint-name {
  font-size: var(--text-base);
  font-weight: 600;
}

.sprint-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.sprint-head-spacer {
  flex: 1;
  min-width: var(--space-3);
}

.sprint-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sprint-goal {
  padding: 0 var(--space-4) var(--space-3);
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.sprint-bar {
  height: 4px;
  background: var(--surface-sunken);
}

.sprint-bar-fill {
  height: 100%;
  background: var(--status-done);
  transform-origin: left center;
  animation: grow-x var(--dur-slow) var(--ease-out) backwards;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: 16px 72px minmax(0, 1fr) 116px 132px 44px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  cursor: grab;
  font-size: var(--text-sm);
  transition: background-color var(--dur) var(--ease);
}

.row-empty {
  grid-column: 1 / -1;
  cursor: default;
}

.row-owner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.row-owner-name {
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.row[data-dragging="true"] {
  opacity: 0.4;
}

.row-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-dim {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ---- list view ------------------------------------------------------ */

.table {
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-row {
  display: grid;
  grid-template-columns: 16px 76px minmax(0, 1fr) 124px 104px 140px 64px 96px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  transition: background-color var(--dur) var(--ease);
}

.table-row:first-child {
  border-top: 0;
}

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

.table-head {
  display: grid;
  grid-template-columns: 16px 76px minmax(0, 1fr) 124px 104px 140px 64px 96px;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-tint);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---- reports -------------------------------------------------------- */

.reports {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 1180px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

.stat {
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
}

.panel {
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.panel-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.bar-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 76px;
  align-items: center;
  gap: var(--space-3);
  padding: 4px 0;
  font-size: var(--text-xs);
}

.bar-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-tint);
  overflow: hidden;
}

/* scaleX rather than width, so the inline percentage the JS sets stays
   authoritative and the bar still animates up from nothing. */
.bar-fill {
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  animation: grow-x var(--dur-slow) var(--ease-out) backwards;
}

.bar-value {
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  width: 100%;
}

.recent-item:first-child {
  border-top: 0;
}

.recent-item:hover .recent-title {
  color: var(--accent);
}

.recent-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
}

/* ---- drawer --------------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

.scrim.open {
  opacity: 1;
  pointer-events: auto;
}

/* Exit must complete inside the 180ms hide timer in app.js. */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(820px, 96vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  transform: translateX(101%);
  transition: transform var(--dur) var(--ease-out);
}

.drawer.open {
  transform: none;
}

.drawer[hidden] {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}

.drawer-head-spacer {
  flex: 1;
}

.drawer-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: var(--space-6);
  align-items: start;
  padding: var(--space-6) var(--space-5);
  overflow-y: auto;
}

.drawer-main {
  min-width: 0;
}

.drawer-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-left: var(--space-5);
  border-left: 1px solid var(--border);
}

.title-input {
  display: block;
  width: 100%;
  padding: var(--space-2);
  margin-left: calc(var(--space-2) * -1);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.012em;
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}

.title-input:hover {
  border-color: var(--border-strong);
}

.title-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-raised);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.section-label {
  margin: var(--space-5) 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.description-body {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  min-height: 44px;
  padding: var(--space-2) 0;
}

.comment {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
}

.comment:first-of-type {
  border-top: 0;
}

.comment-body {
  min-width: 0;
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: 2px;
}

.comment-author {
  font-size: var(--text-sm);
  font-weight: 600;
}

.comment-time,
.activity-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.comment-text {
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre-wrap;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.activity-item {
  display: flex;
  gap: var(--space-2);
  padding: 4px 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.activity-item:first-child {
  border-top: 0;
}

.activity-strong {
  color: var(--text);
}

.comments,
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drawer-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.field-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.field-meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

/* ---- modal ---------------------------------------------------------- */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: start center;
  padding: 7vh var(--space-4) var(--space-6);
  background: var(--scrim);
  overflow-y: auto;
}

.modal-layer[hidden] {
  display: none;
}

.modal {
  width: min(620px, 100%);
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in var(--dur) var(--ease-out) backwards;
}

.modal-head {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.modal-body {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-error {
  color: var(--danger);
  font-size: var(--text-sm);
}

/* ---- toasts + empty ------------------------------------------------- */

.toast-stack {
  position: fixed;
  left: var(--space-5);
  bottom: var(--space-5);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
}

/* Inverted on purpose: a toast has to be readable over whatever it covers. */
.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--surface);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease-out) backwards;
}

.toast-error {
  background: var(--danger);
  color: var(--danger-contrast);
}

.empty {
  max-width: 54ch;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5);
  border-radius: var(--radius);
  background: var(--surface-tint);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.empty-title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.empty > p:last-child {
  margin-bottom: 0;
}

.skeleton {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  animation: soft-pulse 1.5s var(--ease) infinite;
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  color: var(--text-muted);
}

/* ---- theme switch --------------------------------------------------- */

.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--surface-tint);
  box-shadow: inset 0 0 0 1px var(--border);
}

.theme-btn {
  padding: var(--space-1) var(--space-2);
  min-height: 24px;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* In the rail the switch is a segmented control spanning the column, so Light
   / Dark / System share the width evenly instead of hugging their labels. */
.rail-footer .theme-switch {
  display: flex;
  width: 100%;
}

.rail-footer .theme-btn {
  flex: 1;
  min-height: 28px;
}

/* ---- narrow --------------------------------------------------------- */

@media (max-width: 1040px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    width: var(--rail-width);
    transform: translateX(-101%);
    transition: transform var(--dur) var(--ease-out);
  }

  .app.rail-open .rail {
    transform: none;
  }

  .drawer-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .drawer-side {
    padding-left: 0;
    border-left: 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
  }

  .table-row,
  .table-head {
    grid-template-columns: 16px 72px minmax(0, 1fr) 116px 96px 132px;
  }

  .table-row > .col-optional,
  .table-head > .col-optional {
    display: none;
  }
}

@media (min-width: 1041px) {
  .rail-toggle {
    display: none;
  }
}

/* ---- sign-in page ----------------------------------------------------
   The door in front of the workspace. One card, one job: it should read as a
   door, not as a landing page -- no hero, no gradient, nothing to scroll. */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-5);
  background: var(--surface-sunken);
}

.auth-card {
  width: min(400px, 100%);
  padding: var(--space-6);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.auth-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-lede {
  margin: 0 0 var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: var(--space-4);
}

.auth-submit {
  width: 100%;
  justify-content: center;
}

.auth-foot {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.auth-foot .mono {
  font-family: var(--font-mono);
}

/* ---- who you are signed in as --------------------------------------- */

.account-block {
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.account-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  min-width: 0;
}

.account-id {
  min-width: 0;
}

.account-name {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-meta {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.account-block .btn {
  justify-content: flex-start;
}

/* ---- accounts modal -------------------------------------------------- */

.modal-wide {
  width: min(760px, 100%);
}

.user-list {
  overflow-x: auto;
}

.user-loading {
  margin: 0;
  padding: var(--space-3) var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.user-table th {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

.user-table td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

.user-table .mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.user-table tr:last-child td {
  border-bottom: 0;
}

/* A switched-off account stays listed -- its name is still on old issues. */
.user-table tr.is-off td:not(:last-child) {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.user-actions {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
}

/* Where a generated password appears, once. */
.form-note {
  margin: 0;
  padding: var(--space-3);
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  word-break: break-word;
}
