@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --grey-1: #404040;
  --grey-2: #737373;
  --grey-3: #a3a3a3;
  --rule: #e5e5e5;
  --field: #d4d4d4;
  --hover: #f5f5f5;
  --attn: #ff4f00;
  --attn-tint: #fff6f2;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: 32px;
  --tap: 40px;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

code,
pre,
.c-out,
.c-params,
.c-mem,
.c-idx,
.numeral,
.in {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter) 48px;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey-2);
}

.sub {
  font-size: 12px;
  color: var(--grey-2);
}

h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Masthead ---------- */

.masthead {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  align-items: end;
  padding: 48px 0 24px;
  border-bottom: 1px solid var(--ink);
}
.masthead h1 {
  grid-column: span 5;
  margin: 0;
  font-size: 72px;
  line-height: 0.9;
  font-weight: 600;
  letter-spacing: -0.045em;
}
.masthead .lede {
  grid-column: 7 / span 6;
  margin: 0;
  color: var(--grey-1);
  font-size: 15px;
  max-width: 44ch;
}

/* ---------- Buttons ---------- */

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover {
  background: var(--hover);
}
.btn[aria-pressed='true'],
.btn-solid {
  background: var(--ink);
  color: var(--bg);
}
.btn-solid:hover {
  background: var(--grey-1);
}
.btn.is-copied {
  background: var(--bg);
  color: var(--ink);
}
.btn-add {
  border-color: var(--field);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-add:hover {
  border-color: var(--ink);
}
.btn-add .plus {
  font-family: var(--mono);
  color: var(--grey-2);
}

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

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}

/* ---------- Totals ---------- */

.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--rule);
}
.total {
  padding: 24px 24px 24px 0;
  min-width: 0;
}
.total + .total {
  padding-left: 24px;
  border-left: 1px solid var(--rule);
}
.numeral {
  display: block;
  margin: 8px 0 6px;
  font-size: 44px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub.attn {
  color: var(--attn);
}

/* ---------- Model table ---------- */

.model {
  margin-top: 32px;
}

.thead,
.row {
  display: grid;
  grid-template-columns: 40px 160px minmax(0, 1fr) 128px 96px 96px 132px;
  column-gap: 16px;
  align-items: center;
}

.thead {
  padding: 8px 0;
  border-bottom: 1px solid var(--ink);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey-2);
}
.thead .num,
.c-params,
.c-mem {
  text-align: right;
}

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

.row {
  position: relative;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.row-input {
  background: #fafafa;
  padding-left: 0;
}

.c-idx {
  color: var(--grey-2);
  font-size: 13px;
  padding-left: 8px;
}
.c-type {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.type-name {
  font-weight: 600;
}
.inferred {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--grey-2);
}
.c-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  min-width: 0;
}
.none {
  color: var(--grey-3);
  font-size: 13px;
}
.c-out {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.c-params,
.c-mem {
  font-size: 14px;
}
.c-mem {
  color: var(--grey-1);
}
.c-ctrl {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}
.c-msg {
  grid-column: 2 / -1;
}
.c-msg:empty {
  display: none;
}

/* fields */
.f {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--field);
  height: var(--tap);
  background: var(--bg);
}
.f:focus-within {
  border-color: var(--ink);
}
.f-label {
  padding: 0 4px 0 8px;
  font-size: 12px;
  color: var(--grey-2);
  white-space: nowrap;
  user-select: none;
}
.in {
  width: 5ch;
  height: 100%;
  padding: 0 8px 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.in-pair {
  width: 6ch;
}
.in::placeholder {
  color: var(--grey-3);
}
.row-input .in {
  width: 6ch;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--tap);
  padding: 0 10px;
  border: 1px solid var(--field);
  border-radius: 0;
  background: var(--bg);
  font-size: 12px;
  color: var(--grey-2);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.toggle .box {
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
}
.toggle[aria-pressed='true'] {
  color: var(--ink);
}
.toggle[aria-pressed='true'] .box {
  background: var(--ink);
}

.icon {
  width: var(--tap);
  height: var(--tap);
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.icon:hover:not(:disabled) {
  border-color: var(--field);
}
.icon:disabled {
  color: var(--grey-3);
  cursor: default;
}

/* statuses */
.row.is-error,
.row.is-warn {
  background: var(--attn-tint);
}
.row.is-error::before,
.row.is-warn::before {
  content: '';
  position: absolute;
  left: 0;
  top: -1px;
  bottom: -1px;
  width: 3px;
  background: var(--attn);
}
.row.is-error .c-out,
.row.is-warn .c-out,
.row.is-error .c-idx,
.row.is-warn .c-idx {
  color: var(--attn);
}
.row.is-blocked .c-out,
.row.is-blocked .c-params,
.row.is-blocked .c-mem,
.row.is-blocked .type-name {
  color: var(--grey-3);
}

.msg {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 4px;
  padding: 8px 0 2px;
  font-size: 13px;
  color: var(--attn);
}
.msg-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  align-self: start;
  border: 1px solid var(--attn);
}
.msg-error .msg-tag {
  background: var(--attn);
  color: var(--bg);
}
.msg-text {
  color: var(--ink);
}
.msg-formula {
  grid-column: 2;
  font-size: 13px;
  color: var(--attn);
  overflow-wrap: anywhere;
}

.empty {
  margin: 0;
  padding: 24px 0;
  color: var(--grey-2);
  border-bottom: 1px solid var(--rule);
}

/* ---------- Add ---------- */

.add {
  padding: 20px 0 32px;
  border-bottom: 1px solid var(--rule);
}

/* ---------- Code ---------- */

.code {
  padding: 32px 0;
  border-bottom: 1px solid var(--rule);
}
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 16px;
}
pre {
  margin: 0;
  padding: 20px;
  border: 1px solid var(--rule);
  background: #fafafa;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* ---------- Notes ---------- */

.notes {
  padding: 32px 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
}
.notes h2 {
  grid-column: span 3;
}
.notes dl {
  grid-column: 4 / -1;
  margin: 0;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  border-top: 1px solid var(--rule);
}
.notes dt,
.notes dd {
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.notes dt {
  font-weight: 600;
  padding-right: 16px;
}
.notes dd {
  color: var(--grey-1);
}
.notes code {
  font-size: 13px;
  color: var(--ink);
}
.notes > .sub {
  grid-column: 4 / -1;
  margin: 16px 0 0;
  font-size: 13px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 16px;
  border-top: 1px solid var(--ink);
  font-size: 12px;
  color: var(--grey-2);
}

/* ---------- Medium ---------- */

@media (max-width: 1000px) {
  .totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .total:nth-child(3) {
    padding-left: 0;
    border-left: 0;
  }
  .total:nth-child(n + 3) {
    border-top: 1px solid var(--rule);
  }
  .thead,
  .row {
    grid-template-columns: 32px 130px minmax(0, 1fr) 104px 80px 84px 128px;
    column-gap: 12px;
  }
}

/* ---------- Mobile: stacked cards ---------- */

@media (max-width: 639px) {
  :root {
    --gutter: 16px;
  }
  body {
    font-size: 15px;
  }
  .masthead {
    display: block;
    padding: 28px 0 16px;
  }
  .masthead h1 {
    font-size: 52px;
  }
  .masthead .lede {
    margin-top: 12px;
    font-size: 14px;
  }
  .toolbar {
    display: block;
    padding: 16px 0;
  }
  .toolbar .group + .group {
    margin-top: 16px;
  }
  .totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .total {
    padding: 16px 12px 16px 0;
  }
  .total + .total {
    padding-left: 12px;
  }
  .total:nth-child(3) {
    padding-left: 0;
  }
  .numeral {
    font-size: 30px;
  }
  .model {
    margin-top: 20px;
  }
  .thead {
    display: none;
  }
  .layers {
    border-top: 1px solid var(--ink);
  }
  .row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      'type type type'
      'fields fields fields'
      'out params mem'
      'msg msg msg';
    row-gap: 10px;
    column-gap: 8px;
    padding: 14px 0 14px 12px;
  }
  .row-input {
    border-top: 1px solid var(--ink);
  }
  .c-idx {
    position: absolute;
    top: 14px;
    left: 0;
    padding: 0;
    display: none;
  }
  .c-type {
    grid-area: type;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
  }
  .c-fields {
    grid-area: fields;
  }
  .c-out {
    grid-area: out;
  }
  .c-params {
    grid-area: params;
  }
  .c-mem {
    grid-area: mem;
  }
  .c-ctrl {
    position: absolute;
    top: 6px;
    right: 0;
  }
  .c-ctrl .icon {
    flex: none;
  }
  .c-type {
    padding-right: 140px;
    min-height: 32px;
  }
  .c-msg {
    grid-area: msg;
  }
  .c-out,
  .c-params,
  .c-mem {
    text-align: left;
    font-size: 14px;
  }
  .c-out::before,
  .c-params::before,
  .c-mem::before {
    content: attr(data-label);
    display: block;
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--grey-2);
    margin-bottom: 2px;
  }
  .in {
    font-size: 16px; /* prevents iOS focus zoom */
    width: 4.5ch;
  }
  .in-pair {
    width: 5ch;
  }
  .row-input .in {
    width: 5ch;
  }
  .f,
  .toggle {
    height: 44px;
  }
  .icon {
    width: 44px;
    height: 44px;
  }
  .add .btn-add {
    flex: 1 1 calc(50% - 8px);
    justify-content: flex-start;
  }
  .notes {
    display: block;
  }
  .notes dl {
    margin-top: 16px;
    grid-template-columns: minmax(0, 1fr);
  }
  .notes dt {
    padding-bottom: 0;
    border-bottom: 0;
  }
  .notes dd {
    padding-top: 4px;
  }
  .notes > .sub {
    margin-top: 16px;
  }
  pre {
    padding: 14px;
    font-size: 12px;
  }
}
