:root {
  --ink: #17272b;
  --muted: #5c6e70;
  --paper: #f4f7f6;
  --panel: #ffffff;
  --signal: #176b62;
  --signal-dark: #0f4f49;
  --caution: #8a5a16;
  --caution-paper: #fff6e5;
  --line: #c8d4d2;
  --line-strong: #8da4a1;
  --danger: #8c2f38;
  --focus: #0b61a4;
  --display: "Bahnschrift SemiCondensed", "Arial Narrow", sans-serif;
  --body: "Segoe UI", system-ui, sans-serif;
  --utility: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body);
  line-height: 1.55;
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 7.5rem / 100% 4rem
      no-repeat,
    var(--paper);
}

a {
  color: var(--signal-dark);
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--panel);
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 5rem;
  padding: 1rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  background: rgb(244 247 246 / 92%);
}

.wordmark {
  display: inline-grid;
  color: var(--ink);
  line-height: 1;
  text-decoration: none;
}

.wordmark__system {
  font-family: var(--display);
  font-size: 1.05rem;
  font-stretch: condensed;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.wordmark__surface,
.eyebrow,
.operator__label {
  font-family: var(--utility);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.wordmark__surface {
  margin-top: 0.4rem;
  color: var(--muted);
}

.operator {
  display: grid;
  min-width: 0;
  max-width: 100%;
  text-align: right;
  overflow-wrap: anywhere;
}

.operator-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.operator strong {
  overflow-wrap: anywhere;
}

.operator__label {
  color: var(--muted);
}

.primary-nav {
  position: relative;
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.5rem clamp(1rem, 4vw, 4rem);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: thin;
}

.primary-nav a {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
  color: var(--ink);
  background: #e6efed;
}

.primary-nav a[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--signal);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.9fr) minmax(22rem, 1.1fr);
  width: min(68rem, calc(100% - 2rem));
  margin: clamp(2rem, 8vh, 6rem) auto;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.gate-copy {
  padding: clamp(2rem, 6vw, 4.75rem);
  border-right: 1px solid var(--line);
  background: #e9efed;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--signal-dark);
  font-weight: 700;
}

h1,
h2 {
  font-family: var(--display);
  font-weight: 650;
  line-height: 1.08;
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.35rem, 5vw, 4.75rem);
  letter-spacing: -0.035em;
}

.gate-copy__summary {
  max-width: 34rem;
  margin: 1.5rem 0 2.75rem;
  color: var(--muted);
}

.event-rail {
  position: relative;
  display: grid;
  gap: 1.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-rail::before {
  position: absolute;
  top: 0.7rem;
  bottom: 0.7rem;
  left: 0.35rem;
  width: 1px;
  content: "";
  background: var(--line-strong);
}

.event-rail li {
  position: relative;
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.75rem;
  align-items: start;
}

.event-rail__node {
  z-index: 1;
  width: 0.75rem;
  height: 0.75rem;
  margin-top: 0.35rem;
  border: 2px solid var(--signal);
  background: var(--panel);
}

.event-rail strong,
.event-rail small {
  display: block;
}

.event-rail small {
  margin-top: 0.15rem;
  color: var(--muted);
}

.auth-panel {
  align-self: center;
  padding: clamp(2rem, 6vw, 4.75rem);
}

.auth-form {
  display: grid;
  gap: 1.15rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-weight: 650;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  color: var(--ink);
  background: var(--panel);
  font: inherit;
}

.filter-bar,
.shell__boundary > form[method="get"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.filter-bar .field,
.shell__boundary > form[method="get"] .field {
  flex: 1 1 12rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--signal);
  border-radius: 0;
  color: #fff;
  background: var(--signal);
  font: 650 1rem/1 var(--body);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button:hover {
  border-color: var(--signal-dark);
  background: var(--signal-dark);
}

.button--secondary,
.button--quiet,
.button--link {
  color: var(--signal-dark);
  background: transparent;
}

.button--quiet {
  border-color: var(--line-strong);
}

.button--secondary:hover,
.button--quiet:hover,
.button--link:hover {
  color: #fff;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 120ms ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.error-summary {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--danger);
  background: #fff0f1;
}

.error-summary p {
  margin: 0.25rem 0 0;
}

.shell,
.error-page {
  width: min(68rem, calc(100% - 2rem));
  margin: clamp(2rem, 7vh, 5rem) auto;
}

.shell {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(2rem, 7vw, 6rem);
}

.shell h1 {
  max-width: 14ch;
}

.shell__intro p:last-child {
  max-width: 44rem;
  color: var(--muted);
}

.shell__boundary {
  padding: 1.25rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.shell__boundary h2 {
  margin-top: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.summary-grid div {
  min-height: 7.5rem;
  padding: 1rem;
  background: var(--panel);
}

.summary-grid dt {
  color: var(--muted);
  font-family: var(--utility);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-grid dd {
  margin: 1rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  font-weight: 650;
  line-height: 1;
  overflow-wrap: anywhere;
}

.boundary-list {
  margin: 0;
}

.boundary-list div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.boundary-list dt {
  color: var(--muted);
}

.boundary-list dd {
  margin: 0;
  font-family: var(--utility);
  font-size: 0.8rem;
}

.status {
  display: inline-flex;
  gap: 0.4rem;
  align-items: baseline;
  color: var(--ink);
  font-family: var(--utility);
  font-size: 0.78rem;
  font-weight: 700;
}

.status [aria-hidden="true"] {
  color: var(--signal);
}

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

.review-list {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.review-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.review-item__select,
.review-item__detail {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
}

.review-item__select {
  gap: 0.65rem;
  overflow-wrap: anywhere;
}

.review-item__select input {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
}

.review-item__detail {
  padding: 0.5rem;
}

.review-body {
  min-width: 0;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.challenge-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  scrollbar-width: thin;
}

table {
  width: 100%;
  min-width: 48rem;
  border-collapse: collapse;
  background: var(--panel);
}

th,
td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  background: #edf2f1;
  font-family: var(--utility);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:last-child > * {
  border-bottom: 0;
}

td form {
  min-width: 13rem;
}

.shell__boundary > nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
  margin-top: 1rem;
}

.shell__boundary > nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem;
}

.logout-form {
  grid-column: 1 / -1;
}

.error-page {
  max-width: 40rem;
  padding: clamp(2rem, 6vw, 4rem);
  border-left: 5px solid var(--danger);
  background: var(--panel);
}

.error-page h1 {
  font-size: clamp(2.2rem, 6vw, 4rem);
}

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

@media (max-width: 760px) {
  body {
    background: var(--paper);
  }

  .masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-items: flex-start;
    min-height: auto;
  }

  .operator-actions {
    display: flex;
    justify-content: space-between;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .operator {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .operator strong {
    overflow-wrap: anywhere;
  }

  .logout-form {
    flex: 0 0 auto;
  }

  .primary-nav {
    padding-right: 3rem;
    -webkit-mask-image: linear-gradient(
      to right,
      #000 calc(100% - 2.5rem),
      transparent
    );
    mask-image: linear-gradient(
      to right,
      #000 calc(100% - 2.5rem),
      transparent
    );
  }

  .auth-layout {
    grid-template-columns: 1fr;
    width: min(100% - 1rem, 34rem);
    margin: 0.5rem auto 2rem;
  }

  .gate-copy {
    padding: 2rem 1.25rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-panel {
    padding: 2rem 1.25rem;
  }

  h1 {
    font-size: clamp(2.35rem, 13vw, 3.75rem);
  }

  .event-rail {
    gap: 1rem;
  }

  .shell {
    grid-template-columns: 1fr;
    width: min(100% - 1rem, 68rem);
    margin-top: 1.5rem;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .review-item {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .shell__boundary {
    padding: 1rem;
  }

  .filter-bar,
  .shell__boundary > form[method="get"] {
    display: grid;
    align-items: stretch;
  }

  .filter-bar .button,
  .shell__boundary > form[method="get"] .button {
    width: 100%;
  }
}

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