* {
  box-sizing: border-box;
}

body {
  max-width: 64rem;
  margin: 10vh auto;
  padding: 2rem;
  background: white;
  color: black;
  font: 16px monospace;
}

main {
  padding: 2rem;
  border: 4px solid black;
}

body[data-auth-page="login"] main {
  width: 100%;
  max-width: 32rem;
  margin-inline: auto;
}

body[data-auth-page="error"] main {
  width: 100%;
  max-width: 40rem;
  margin-inline: auto;
}

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

.site-footer {
  margin-top: 2rem;
  font-size: 0.875rem;
}

.license-contents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-block: 2rem;
}

#licenses-page .page-header {
  flex-wrap: wrap;
}

#licenses-page h1 {
  font-size: clamp(1.75rem, 5vw, 3rem);
}

.license-entry {
  padding-block: 1rem;
  border-top: 1px solid black;
  overflow-wrap: anywhere;
}

.license-entry summary {
  cursor: pointer;
}

.license-version {
  font-size: 0.875rem;
}

.license-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 0.875rem/1.6 monospace;
}

.toast {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  z-index: 1000;
  width: min(28rem, calc(100vw - 4rem));
  margin: 0;
  padding: 1rem;
  border: 3px solid black;
  background: black;
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateY(1rem);
  transition: opacity 120ms ease, transform 120ms ease;
  visibility: hidden;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

body[data-auth-page="terminals"] {
  max-width: 76rem;
  margin-top: 5vh;
}

body[data-auth-page="metrics"] {
  max-width: 92rem;
  margin-top: 3vh;
}

#metrics-page {
  min-height: 80vh;
}

.metric-summary,
.saturation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.metric-summary article,
.saturation-grid article {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 3px solid black;
}

.metric-summary span,
.saturation-grid article > span:first-child {
  font-weight: bold;
  text-transform: uppercase;
}

.metric-summary strong,
.saturation-grid strong {
  overflow-wrap: anywhere;
  font-size: 1.6rem;
}

.saturation-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
}

.saturation-grid .muted {
  margin: 0;
}

progress {
  width: 100%;
  height: 1rem;
  border: 2px solid black;
  border-radius: 0;
  background: white;
}

progress::-webkit-progress-bar {
  background: white;
}

progress::-webkit-progress-value {
  background: black;
}

progress::-moz-progress-bar {
  background: black;
}

.metrics-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.metrics-heading h2,
.metrics-heading p {
  margin: 0;
}

.metrics-table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
  border: 3px solid black;
}

.metrics-table {
  width: 100%;
  min-width: 70rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.metrics-table th,
.metrics-table td {
  padding: 0.8rem;
  border-right: 2px solid black;
  border-bottom: 2px solid black;
  text-align: left;
  vertical-align: top;
}

.metrics-table tr:last-child th,
.metrics-table tr:last-child td {
  border-bottom: 0;
}

.metrics-table th:last-child,
.metrics-table td:last-child {
  border-right: 0;
}

.metrics-table thead {
  background: black;
  color: white;
  text-transform: uppercase;
}

.metrics-table tbody th {
  width: 20rem;
  overflow-wrap: anywhere;
}

.metrics-table td span {
  display: block;
  white-space: nowrap;
}

.metrics-table td span + span {
  margin-top: 0.4rem;
}

.metrics-note {
  margin-top: 1.5rem;
}

#terminals-page {
  min-height: 70vh;
  border: 0;
}

.terminal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.terminal-create-card,
.terminal-card {
  position: relative;
  min-height: 11rem;
  margin: 0;
  border: 3px solid black;
  background: white;
  color: black;
}

.terminal-create-card {
  padding: 0;
}

.terminal-card:hover,
.terminal-card:focus-visible,
.terminal-card:focus-within {
  outline: 4px solid black;
  outline-offset: 4px;
}

.terminal-card::before {
  content: "•••";
  display: block;
  height: 2.5rem;
  padding: 0.25rem 0.75rem;
  border-bottom: 3px solid black;
  font-size: 1.25rem;
  letter-spacing: 0.2rem;
  text-align: left;
}

.terminal-create-card .terminal-card-name {
  padding: 1.25rem;
}

.terminal-create-button {
  width: auto;
  margin: 0;
  font-weight: bold;
}

.terminal-create-symbol {
  display: inline-block;
}

.terminal-create-button[aria-busy="true"] .terminal-create-symbol {
  animation: terminal-create-spin 700ms linear infinite;
}

@keyframes terminal-create-spin {
  to {
    transform: rotate(1turn);
  }
}

.terminal-create-button:hover,
.terminal-create-button:focus-visible {
  background: black;
  color: white;
}

.terminal-card-name {
  display: flex;
  min-height: 8.2rem;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 2.75rem 1.25rem 1.25rem;
  color: black;
  font-size: 1.2rem;
  font-weight: bold;
  overflow-wrap: anywhere;
  text-align: center;
  text-decoration: none;
}

.terminal-delete {
  position: absolute;
  top: 0.2rem;
  right: 0.35rem;
  width: auto;
  min-height: 2rem;
  margin: 0;
  padding: 0.3rem 0.55rem;
  border: 2px solid black;
  background: black;
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
  line-height: 1;
}

dialog {
  width: min(90vw, 30rem);
  padding: 2rem;
  border: 4px solid black;
  background: white;
  color: black;
  font: inherit;
}

dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

dialog h2 {
  margin-top: 0;
}

.error-code {
  margin: 0 0 0.5rem;
  font-size: 5rem;
  font-weight: bold;
  line-height: 1;
}

h1 {
  margin-top: 0;
  font-size: 3rem;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 2rem 0 0.5rem;
  font-weight: bold;
}

input,
button {
  width: 100%;
  padding: 1rem;
  border: 3px solid black;
  border-radius: 0;
  background: white;
  color: black;
  font: inherit;
}

.terminal-body {
  position: fixed;
  top: var(--terminal-viewport-top, 0px);
  right: 0;
  left: 0;
  overflow: hidden;
  max-width: none;
  margin: 0;
  padding: 1rem;
  background: white;
  color: black;
}

.terminal-body main {
  min-height: 0;
  height: calc(100vh - 2rem);
  height: calc(100dvh - 2rem);
  height: calc(var(--terminal-viewport-height, 100dvh) - 2rem);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border-color: black;
}

.terminal-header {
  flex: 0 0 auto;
}

.terminal-header .record-actions {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
  justify-content: flex-end;
  margin-left: auto;
  text-align: right;
}

.terminal-header h1 {
  max-width: 60vw;
  overflow-wrap: anywhere;
  font-size: 1.5rem;
  text-transform: none;
}

.terminal-header a {
  color: black;
}

.terminal-role {
  padding: 0.4rem 0.7rem;
  border: 2px solid currentColor;
  font-weight: bold;
  text-transform: uppercase;
}

.terminal-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  margin-top: 1rem;
  overflow: hidden;
  background: white;
  border: 3px solid black;
}

#terminal-canvas {
  display: block;
  outline: none;
  background: white;
  cursor: text;
}

.terminal-shell:focus-within {
  outline: 3px solid black;
  outline-offset: -2px;
}

.terminal-prediction {
  position: absolute;
  pointer-events: none;
  background: white;
  z-index: 2;
}

.terminal-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  opacity: 0.01;
  background: white;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  pointer-events: none;
  resize: none;
}

.terminal-body #status {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
}

.terminal-clipboard-status {
  margin: 0.5rem 0 0;
}

.terminal-keybar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(3.5rem, 1.2fr) repeat(4, minmax(0, 1fr));
  gap: 0.25rem;
  flex: 0 0 auto;
  min-width: 0;
  margin: 0.5rem 0 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  border: 0;
}

.terminal-keybar button {
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0.5rem 0.125rem;
  border: 2px solid black;
  border-radius: 0.4rem;
  background: white;
  color: black;
  font-size: 0.875rem;
  text-transform: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.terminal-keybar button:not([data-key="Control"]):active,
.terminal-keybar button[aria-pressed="true"] {
  background: black;
  color: white;
}

.terminal-keybar button:disabled {
  opacity: 0.4;
}

.terminal-keybar button:focus-visible {
  outline: 3px solid #175cd3;
  outline-offset: 2px;
}

@media (max-width: 42rem), (pointer: coarse) {
  .terminal-body {
    padding: 0;
  }

  .terminal-body main {
    height: 100dvh;
    height: var(--terminal-viewport-height, 100dvh);
    padding: 0.5rem;
    border: 0;
  }

  .terminal-keybar {
    margin: 0.5rem -0.5rem -0.5rem;
    padding: 0.5rem 0.5rem max(0.5rem, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #d0d5dd;
    background: #f2f4f7;
  }
}

select {
  width: 100%;
  padding: 1rem;
  border: 3px solid black;
  border-radius: 0;
  background: white;
  color: black;
  font: inherit;
}

section {
  margin-top: 3rem;
}

.page-header,
.form-row,
.record,
.record-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.page-header,
.record {
  justify-content: space-between;
}

.page-header h1,
.page-header p {
  margin: 0;
}

.form-row > :first-child {
  flex: 1;
}

.compact,
.form-row button,
.button-link {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}

.button-link {
  display: inline-block;
  padding: 1rem;
  background: black;
  color: white;
  font-weight: bold;
  text-decoration: none;
  text-transform: uppercase;
}

nav a:not(.button-link) {
  color: black;
  font-weight: bold;
}

.records {
  margin-top: 1rem;
  border-top: 2px solid black;
}

.record {
  padding: 1rem 0;
  border-bottom: 2px solid black;
}

.record strong,
.record .muted {
  display: block;
  overflow-wrap: anywhere;
}

.muted {
  margin-top: 0.4rem;
  color: #444;
  font-size: 0.875rem;
}

.cat-mark {
  margin: 1.5rem 0 0;
  font-weight: bold;
  letter-spacing: 0.08em;
}

@media (max-width: 42rem) {
  body {
    margin: 0;
    padding: 1rem;
  }

  main {
    padding: 1rem;
  }

  .form-row,
  .access-record {
    display: block;
  }

  .form-row button,
  .record-actions {
    width: 100%;
    margin-top: 1rem;
  }

  .record-actions button {
    flex: 1;
  }

  #terminals-page {
    padding: 0;
  }

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

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

  .metrics-heading {
    display: block;
  }

  .metrics-heading button {
    width: 100%;
    margin-top: 1rem;
  }
}

button {
  margin-top: 1rem;
  background: black;
  color: white;
  font-weight: bold;
  text-transform: uppercase;
}
