/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* necropsy. Design tokens and layout follow urashyl.dev. */

:root {
  color-scheme: light;
  --bg: #eef0eb;
  --surface: #f7f8f4;
  --surface-2: #e4e8e1;
  --ink: #18201b;
  --ink-soft: #36403a;
  --muted: #5d6a62;
  --rule: #d3d9d0;
  --rule-strong: #b3bcb1;
  --accent: #2b5e4f;
  --accent-ink: #f4f7f3;
  --accent-soft: rgba(43, 94, 79, 0.1);
  --up: #2c7a4b;
  --warn: #9a6812;
  --down: #b2442a;

  /* code highlighting */
  --hl-comment: #5d6a62;
  --hl-string: #8a4f0c;
  --hl-number: #1b6a85;
  --hl-keyword: #7a3a9a;
  --hl-function: #2b5e4f;
  --hl-var: #9a3b2a;

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2rem;

  --radius: 10px;
  --wrap: 62rem;
  --gutter: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141916;
    --surface: #1a201c;
    --surface-2: #222a25;
    --ink: #e2e8e2;
    --ink-soft: #c3ccc5;
    --muted: #93a098;
    --rule: #2a332d;
    --rule-strong: #3d4840;
    --accent: #8fc7af;
    --accent-ink: #11201a;
    --accent-soft: rgba(143, 199, 175, 0.12);
    --up: #6fc492;
    --warn: #e0b35a;
    --down: #ec8467;
    --hl-comment: #93a098;
    --hl-string: #e0b35a;
    --hl-number: #7fc3dc;
    --hl-keyword: #c9a3e6;
    --hl-function: #8fc7af;
    --hl-var: #ec9a85;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141916;
  --surface: #1a201c;
  --surface-2: #222a25;
  --ink: #e2e8e2;
  --ink-soft: #c3ccc5;
  --muted: #93a098;
  --rule: #2a332d;
  --rule-strong: #3d4840;
  --accent: #8fc7af;
  --accent-ink: #11201a;
  --accent-soft: rgba(143, 199, 175, 0.12);
  --up: #6fc492;
  --warn: #e0b35a;
  --down: #ec8467;
  --hl-comment: #93a098;
  --hl-string: #e0b35a;
  --hl-number: #7fc3dc;
  --hl-keyword: #c9a3e6;
  --hl-function: #8fc7af;
  --hl-var: #ec9a85;
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-3);
  letter-spacing: -0.022em;
}

h2 {
  font-size: var(--step-1);
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.86em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.tabular {
  font-variant-numeric: lining-nums tabular-nums;
}

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

.err-text {
  color: var(--down);
}

.icon {
  flex: none;
  vertical-align: -0.15em;
}

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

/* Header */

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-block: 1.25rem;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.45em;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.streak {
  margin-right: 0.5rem;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: var(--step--1);
  text-decoration: none;
  white-space: nowrap;
}

.streak:hover {
  background: var(--surface-2);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn[aria-current="page"] {
  background: var(--surface-2);
  color: var(--ink);
}

a.icon-btn {
  text-decoration: none;
}

@media (max-width: 640px) {
  /* Three rows, so nothing has to fit beside anything else: the brand with the
     streak and theme button, then the navigation, then the account links. The tools
     wrapper steps aside (display: contents) so its children can be placed in them. */
  .header-inner {
    flex-wrap: wrap;
    gap: 0.6rem 0.75rem;
  }

  .header-tools {
    display: contents;
  }

  .site-name {
    order: 1;
    margin-right: auto;
  }

  .streak {
    order: 2;
    margin-right: 0;
  }

  .header-tools .icon-btn {
    order: 3;
  }

  .site-nav {
    order: 4;
    flex-wrap: wrap;
    width: 100%;
    margin-left: 0;
    gap: 0.4rem 1.25rem;
  }

  .user-link {
    order: 5;
    margin-right: 0.5rem;
  }

  /* Leave room beside a long name for the Admin link. */
  .site-header .user-name {
    max-width: calc(100% - 6.5rem);
  }
}

/* On the narrowest phones the logo alone stands for the name, so the streak and the
   two buttons still fit on the first row. */
@media (max-width: 340px) {
  .site-name span {
    display: none;
  }
}

/* Footer */

.site-footer {
  margin-top: 5rem;
  padding-block: 1.5rem 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--step--1);
}

.footer-inner {
  display: flex;
  gap: 1.5rem;
}

/* Buttons and small controls */

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  filter: brightness(1.08);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
  filter: none;
}

.button-quiet {
  border-color: var(--rule-strong);
  background: transparent;
  color: var(--ink);
}

.button-quiet:hover {
  filter: none;
  background: var(--surface-2);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--step--1);
  font-weight: 550;
  line-height: 1.5;
}

.diff {
  display: inline-flex;
  gap: 0.2rem;
  vertical-align: 0.05em;
}

.diff .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--rule-strong);
}

.diff .dot.on {
  background: var(--accent);
  box-shadow: none;
}

/* Page heads */

.page-head {
  padding-block: clamp(2rem, 5vw, 3.5rem) 0.5rem;
}

.page-head h1 {
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
}

.page-lead {
  margin-top: 0.9rem;
  color: var(--ink-soft);
  font-size: var(--step-1);
}

.crumb {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.section-tight {
  padding-block: 1.5rem 0;
}

/* Archive list */

.work-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--rule);
}

.work-row {
  border-top: 1px solid var(--rule);
}

.work-link {
  display: grid;
  grid-template-columns: 16rem 1fr auto;
  gap: 0.25rem 2rem;
  align-items: baseline;
  padding: 1.1rem 0.75rem;
  margin-inline: -0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
}

.work-link:hover {
  background: var(--surface);
}

.work-link:hover .work-name {
  color: var(--accent);
}

.work-name {
  font-size: var(--step-1);
}

.work-name .num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.work-desc {
  color: var(--ink-soft);
}

.work-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: var(--step--1);
  white-space: nowrap;
}

.solved-mark {
  color: var(--up);
}

@media (max-width: 720px) {
  .work-link {
    grid-template-columns: 1fr auto;
  }

  .work-desc {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .work-meta {
    grid-row: 1;
    grid-column: 2;
  }
}

/* Puzzle layout */

.case-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 4rem;
  padding-top: 1.5rem;
}

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

.puzzle-main > * + * {
  margin-top: 1.75rem;
}

.case-side {
  position: sticky;
  top: 1.5rem;
  align-self: start;
}

@media (max-width: 860px) {
  .case-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .case-side {
    position: static;
    order: -1;
  }

  .case-side .facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.5rem;
  }
}

.facts {
  margin: 0;
}

.facts > div {
  padding-block: 0.7rem;
  border-top: 1px solid var(--rule);
}

.facts > div:last-child {
  border-bottom: 1px solid var(--rule);
}

.facts dt {
  color: var(--muted);
  font-size: var(--step--1);
}

.facts dd {
  margin: 0.1rem 0 0;
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* Prose (brief, explainer, format page) */

.prose {
  max-width: 42rem;
}

.prose > * + * {
  margin-top: 1rem;
}

.prose h2 {
  margin-top: 2.5rem;
  font-size: var(--step-2);
}

.prose h3 {
  margin-top: 2rem;
  font-size: var(--step-1);
}

.prose ul,
.prose ol {
  padding-left: 1.2rem;
}

.prose li + li {
  margin-top: 0.5rem;
}

.prose li::marker {
  color: var(--muted);
}

.prose pre {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  background: none;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.prose th,
.prose td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.prose th {
  color: var(--muted);
  font-weight: 550;
}

.prose.doc {
  max-width: 46rem;
}

.prose.doc h2:first-child {
  display: none;
}

/* Code excerpt */

.codefile {
  margin-inline: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.codefile-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--step--1);
}

.codefile-head a {
  color: var(--muted);
  font-family: var(--font);
}

.codefile-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  overflow-x: auto;
  padding-block: 0.8rem;
}

.codefile pre {
  margin: 0;
  line-height: 1.6;
}

.gutter {
  padding-inline: 1rem 0.9rem;
  border-right: 1px solid var(--rule);
  color: var(--muted);
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
}

.code {
  padding-inline: 1rem;
  min-width: max-content;
}

.codefile-bin {
  padding: 1rem;
  color: var(--muted);
}

/* Token colors, see markdown.rs for the class prefix */

.hl .s-comment {
  color: var(--hl-comment);
  font-style: italic;
}

.hl .s-string {
  color: var(--hl-string);
}

.hl .s-constant.s-numeric,
.hl .s-constant.s-language {
  color: var(--hl-number);
}

.hl .s-keyword,
.hl .s-storage {
  color: var(--hl-keyword);
}

.hl .s-entity.s-name.s-function,
.hl .s-support.s-function,
.hl .s-support.s-class {
  color: var(--hl-function);
}

.hl .s-variable.s-parameter,
.hl .s-variable.s-other.s-readwrite {
  color: var(--hl-var);
}

/* Answer form */

.answer-form label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.answer-row {
  display: flex;
  gap: 0.6rem;
}

.answer-row input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.answer-row input:read-only {
  color: var(--muted);
}

.answer-msg {
  min-height: 1.6em;
  margin-top: 0.6rem;
  color: var(--ink-soft);
}

/* Hints */

.hint-list {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}

.hint-list li + li {
  margin-top: 0.4rem;
}

/* Explainer */

.explainer {
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.explainer h2 {
  margin-bottom: 1rem;
  font-size: var(--step-2);
}

/* Pager */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--step--1);
}

.pager a {
  text-decoration: none;
}

.pager a:hover {
  color: var(--ink);
}

/* Header account links */

.user-link {
  margin-right: 0.75rem;
  color: var(--muted);
  font-size: var(--step--1);
  text-decoration: none;
  white-space: nowrap;
}

/* A long username is cut short with an ellipsis (its full text is the title), so it
   cannot push the header wider than the screen. */
.user-name {
  display: inline-block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.user-link:hover,
.user-link[aria-current="page"] {
  color: var(--ink);
}

/* Account forms */

.auth {
  max-width: 26rem;
}

.auth > * + * {
  margin-top: 1rem;
}

.auth h2 {
  margin-top: 2.5rem;
  font-size: var(--step-1);
}

.field + .field {
  margin-top: 1rem;
}

.field label,
.inline-form label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.field-hint {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.auth form > .button {
  margin-top: 1.25rem;
}

.auth-links {
  color: var(--muted);
  font-size: var(--step--1);
}

.form-error,
.form-ok {
  padding: 0.65rem 0.9rem;
  border-left: 3px solid var(--down);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
}

.form-ok {
  border-left-color: var(--up);
}

.button-danger {
  border-color: var(--down);
  background: transparent;
  color: var(--down);
}

.button-danger:hover {
  filter: none;
  background: var(--surface-2);
}

/* Admin */

.admin-h {
  margin: 2.5rem 0 0.75rem;
  font-size: var(--step-1);
}

.admin-h:first-of-type {
  margin-top: 0;
}

.admin-facts {
  max-width: 26rem;
}

.mfa-alt {
  max-width: 26rem;
  margin-top: 1rem;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.table th,
.table td {
  padding: 0.6rem 1rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-weight: 550;
}

.row-actions {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.row-actions form {
  margin: 0;
}

.auth form.logout {
  margin-top: 2.5rem;
}

/* Learn and archive lists */

.work-desc .date {
  font-variant-numeric: tabular-nums;
}

.after-list {
  margin-top: 1.25rem;
}

/* A short hint above the puzzle */

.notice {
  padding: 0.65rem 0.9rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  color: var(--ink-soft);
}

/* ---- live instances ---- */
.live-panel {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.live-panel h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.live-captcha:not(:empty) { margin: 0.8rem 0 1rem; }
.live-url { font-family: var(--mono); font-size: 0.95rem; word-break: break-all; }
.live-log-box summary { cursor: pointer; color: var(--muted); }
.live-log {
  margin: 0.5rem 0 0;
  max-height: 16rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Two-step verification */

.account h3 {
  margin: 1.25rem 0 0.25rem;
  font-size: var(--step-0);
}

.qr {
  display: inline-block;
  margin: 0.5rem 0 1rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: #fff;
  line-height: 0;
}

.qr svg {
  width: 11rem;
  height: 11rem;
}

.totp-secret {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--mono);
  letter-spacing: 0.08em;
  word-break: break-all;
  user-select: all;
}

.recovery-codes {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--step-0);
  line-height: 1.9;
  user-select: all;
}

.mfa-alt {
  margin-top: 0.75rem;
}

/* Search */

.card-view {
  max-width: 40rem;
  line-height: 0;
}

.card-view svg {
  width: 100%;
  height: auto;
  border-radius: 14px;
}

.card-actions {
  margin-top: 1.25rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  max-width: 32rem;
}

.search-form input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list a {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
}

.tag-list a:hover {
  background: var(--surface-2);
}

.tag-links a {
  color: inherit;
}

/* ---- workspace (docs/toolkit.md) ---- */

.wrap-wide {
  width: 100%;
  max-width: calc(82rem + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.workspace-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.ws-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 2.5rem;
  padding-top: 1rem;
}

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

.ws-side {
  position: sticky;
  top: 1rem;
  align-self: start;
  min-width: 0;
}

.ws-side > * + * {
  margin-top: 1.5rem;
}

@media (max-width: 960px) {
  .ws-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .ws-side {
    position: static;
  }
}

.ws-brief {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.ws-brief summary {
  cursor: pointer;
  font-weight: 600;
}

.ws-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--rule-strong);
}

.ws-tab {
  padding: 0.5rem 0.85rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.ws-tab[aria-selected="true"] {
  border-color: var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  margin-bottom: -1px;
}

.ws-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.ws-pane {
  padding: 1rem 0;
  min-width: 0;
}

.ws-pane > * + * {
  margin-top: 0.85rem;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.tool-row input[type="text"],
.tool-row input[type="number"],
.tool-row select,
.console-form textarea,
.nb-cell textarea,
.block-line input {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--step--1);
  min-width: 0;
  max-width: 100%;
}

.tool-row input[type="text"] {
  flex: 1 1 12rem;
}

.tool-row input[type="number"] {
  width: 5rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--step--1);
}

.tool-msg {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: var(--step--1);
}

.tool-msg.err-text {
  color: var(--down);
}

.cli {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: var(--step--1);
  overflow-wrap: anywhere;
}

.cli code {
  background: none;
  padding: 0;
}

.cli-label {
  color: var(--muted);
}

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

.file-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.file-item > a {
  font-family: var(--mono);
}

.file-view {
  margin-top: 1rem;
}

.file-view-name {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.file-download {
  text-decoration: none;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-top: 0.25rem;
}

.table-scroll {
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.packet-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.packet-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
}

.packet-table th,
.packet-table td {
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
}

.packet-table tbody tr {
  cursor: pointer;
  border-top: 1px solid var(--rule);
}

.packet-table tbody tr:hover,
.packet-table tbody tr:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.packet-table tbody tr.selected {
  background: var(--accent);
  color: var(--accent-ink);
}

.pcap-detail > * + * {
  margin-top: 0.75rem;
}

.proto-tree {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-x: auto;
}

.proto-tree ul {
  margin: 0;
  padding-left: 1.1rem;
  list-style: none;
}

.proto-tree > ul {
  padding-left: 0;
}

.proto-tree summary {
  cursor: pointer;
}

.tree-filter {
  font-size: 0.75rem;
}

.stream-view,
.raw-view,
.hex-view,
.nb-out {
  margin: 0;
  padding: 0.75rem;
  max-height: 24rem;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hex-view {
  white-space: pre;
  overflow-wrap: normal;
}

.raw-view:empty::before {
  content: "Nothing yet.";
  color: var(--muted);
}

.console-out h3 {
  margin: 1rem 0 0.35rem;
  font-size: var(--step--1);
  color: var(--muted);
  font-weight: 600;
}

.console-form {
  display: grid;
  gap: 0.5rem;
}

.console-form label {
  font-size: var(--step--1);
  color: var(--muted);
}

.console-form textarea,
.nb-cell textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.5;
}

.console-form textarea:read-only {
  background: var(--surface-2);
}

.block-builder {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
}

.block-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: var(--step--1);
}

.block-added {
  padding-left: 1.25rem;
}

.block-fixed {
  overflow-wrap: anywhere;
  min-width: 0;
}

.block-line input {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.decoder-iframe {
  display: block;
  width: 100%;
  height: min(75vh, 46rem);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
}

.notebook {
  display: grid;
  gap: 1rem;
}

.nb-cell {
  display: grid;
  gap: 0.4rem;
}

/* ---- learn (docs/learn.md) ---- */

.path-form fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

.path-form legend {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.path-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
}

.path-option {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.path-option span {
  color: var(--muted);
  font-size: var(--step--1);
}

.path-option[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}

.path-option[aria-pressed="true"] strong::after {
  content: " (chosen)";
  color: var(--accent);
  font-weight: 500;
}

.path-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tier {
  margin-top: 2rem;
}

.tier h2 {
  font-size: var(--step-1);
}

.module-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.module-link {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: baseline;
  padding: 0.8rem 0.75rem;
  margin-inline: -0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}

.module-link:hover {
  background: var(--surface);
}

.module-link:hover .module-title {
  color: var(--accent);
}

.module-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.module-text {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.module-title {
  font-size: var(--step-1);
}

.module-summary {
  color: var(--ink-soft);
}

.passed-mark {
  color: var(--up);
  font-size: var(--step--1);
  font-weight: 600;
}

@media (max-width: 520px) {
  .module-link {
    grid-template-columns: 1.5rem minmax(0, 1fr);
  }

  .passed-mark {
    grid-column: 2;
  }
}

.learn-module .learn-section {
  margin-top: 2.5rem;
  max-width: 46rem;
}

.learn-section h3 {
  margin-top: 1.5rem;
}

.path-switch {
  margin: 0.25rem 0 1rem;
}

.checkpoint {
  display: grid;
  gap: 1.25rem;
}

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

.question input,
.question textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--step--1);
  width: 100%;
}

.checkpoint .button {
  justify-self: start;
}

.ok-text {
  color: var(--up);
}

.learn-practice-head {
  margin-top: 2.5rem;
}

/* The text the Share button sends, as it will look. */
.share-preview {
  flex-basis: 100%;
  margin: 0 0 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.discuss {
  font-weight: 600;
}

/* ---- leaderboards ---------------------------------------------------------- */

.board-tabs {
  display: flex;
  gap: 1.25rem;
  margin: 0.75rem 0 1rem;
}

.board-tabs a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.board-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.board-pick select {
  max-width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--step--1);
}

.board th,
.board td {
  padding-right: 0.75rem;
}

.board td.num,
.board th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board td.player {
  min-width: 10ch;
  white-space: normal;
  overflow-wrap: anywhere;
}

.ranked-notice {
  margin-bottom: 0.75rem;
}

.board-hidden td {
  color: var(--muted);
  text-decoration: line-through;
}

.board-hidden td:last-child {
  text-decoration: none;
}

.board .inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

.board .inline-form input {
  width: 9rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
