@font-face {
  font-family: "Luhn Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/noto-sans-sc-ui.woff2") format("woff2");
}

@font-face {
  font-family: "Luhn Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-500.woff2") format("woff2");
}

@font-face {
  font-family: "Luhn Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-600.woff2") format("woff2");
}

@font-face {
  font-family: "Luhn Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-700.woff2") format("woff2");
}

:root {
  --canvas: #f5f7fa;
  --paper: #ffffff;
  --paper-subtle: #fbfcfd;
  --ink: #161a1d;
  --ink-soft: #32383d;
  --muted: #687179;
  --line: #dce1e5;
  --line-strong: #b8c0c7;
  --signal: #e24a3b;
  --signal-dark: #a92d24;
  --success: #18765b;
  --success-dark: #105b45;
  --success-soft: #eaf5f1;
  --warning: #9a5c12;
  --warning-soft: #fff6e8;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --focus: #1769e0;
  --radius: 5px;
  --font-display: "Luhn Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --font-sans: "Luhn Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --font-mono: "Luhn Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  font-synthesis: none;
  line-height: 1.5;
  background: var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 1px 0 rgb(22 26 29 / 2%);
  backdrop-filter: blur(12px);
}

.topbar__inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand__mark {
  position: relative;
  width: 34px;
  height: 34px;
  overflow: hidden;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 4px;
  color: #ffffff;
  background: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.brand__mark::after {
  position: absolute;
  right: -3px;
  bottom: 5px;
  width: 16px;
  height: 3px;
  background: var(--signal);
  content: "";
  transform: rotate(-42deg);
}

.brand__name {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 18px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.local-badge::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 12%, transparent);
  content: "";
}

.language-control {
  height: 34px;
  padding: 2px;
  display: grid;
  grid-template-columns: repeat(2, 38px);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--canvas);
}

.language-button {
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.language-button.is-active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1px 3px rgb(22 26 29 / 10%);
}

main {
  padding: 0 0 24px;
}

.workspace-band {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.workspace {
  width: min(1240px, calc(100% - 40px));
  min-height: calc(100vh - 109px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
}

.controls,
.results {
  min-width: 0;
  padding: 42px 40px 48px;
}

.controls {
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.results {
  background: var(--paper-subtle);
}

.section-heading,
.results-toolbar > div {
  min-width: 0;
}

.section-heading p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: 27px;
}

.section-heading h1 {
  display: flex;
  flex-wrap: wrap;
}

.section-heading h1 > span {
  white-space: nowrap;
}

html[lang="en"] .section-heading h1 {
  column-gap: 0.22em;
}

h2 {
  font-size: 22px;
}

.mode-tabs {
  margin: 26px 0 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.mode-tab {
  min-height: 43px;
  margin-bottom: -1px;
  padding: 8px 6px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.is-active {
  border-bottom-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
}

.field-group label,
.select-field label,
.format-field legend {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.number-input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper);
}

.number-input {
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.number-input::placeholder {
  color: #949ca2;
}

.number-input:hover,
select:hover {
  border-color: #8f999f;
}

.number-input:focus,
select:focus {
  border-color: var(--focus);
  outline: 3px solid color-mix(in srgb, var(--focus) 14%, transparent);
}

.number-input[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.field-error {
  min-height: 21px;
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.metrics {
  margin: 14px 0 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}

.metrics > div {
  min-width: 0;
  padding: 11px 8px 12px;
  text-align: left;
}

.metrics > div + div {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.metrics dt {
  color: var(--muted);
  font-size: 11px;
}

.metrics dd {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-row {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

select {
  padding: 8px 34px 8px 11px;
}

.format-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  height: 48px;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
}

.segmented label {
  position: relative;
  min-width: 0;
  margin: 0;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.segmented input:checked + span {
  color: var(--ink);
  background: var(--paper);
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(22 26 29 / 10%);
}

.segmented input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 600;
}

.primary-button {
  width: 100%;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  color: #ffffff;
  background: var(--ink);
}

.primary-button:hover {
  border-color: #30363a;
  background: #30363a;
}

.primary-button:active {
  transform: translateY(1px);
}

.secondary-button {
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  background: var(--paper);
  font-size: 13px;
}

.secondary-button:hover:not(:disabled) {
  border-color: #808a91;
  color: var(--ink);
  background: var(--canvas);
}

.secondary-button:disabled {
  color: #9aa2a8;
  background: #f2f4f5;
  opacity: 0.72;
}

.results-toolbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.export-button {
  min-width: 48px;
  padding-inline: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.result-status {
  min-height: 42px;
  margin-top: 18px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-block: 1px solid var(--line);
  color: var(--muted);
  background: var(--paper);
  font-size: 13px;
}

.status-message {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.status-timing {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8d969c;
}

.result-status.is-success {
  border-color: #c1ddd3;
  color: var(--success-dark);
  background: var(--success-soft);
  box-shadow: inset 3px 0 0 var(--success);
}

.result-status.is-success .status-dot {
  background: var(--success);
}

.result-status.is-empty {
  border-color: #ead6b8;
  color: #77460d;
  background: var(--warning-soft);
  box-shadow: inset 3px 0 0 var(--warning);
}

.result-status.is-empty .status-dot {
  background: var(--warning);
}

.result-list {
  max-height: calc(100vh - 248px);
  margin: 15px 0 0;
  padding: 0 5px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  column-gap: 24px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  list-style: none;
  border-top: 1px solid var(--line);
}

.result-list li {
  min-width: 0;
  border-bottom: 1px solid var(--line);
}

.result-row {
  --row-background: var(--paper-subtle);
  width: 100%;
  min-height: 54px;
  padding: 9px 7px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: var(--row-background);
  text-align: left;
}

.result-row:hover,
.result-row:focus-visible {
  --row-background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
}

.result-number {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
  white-space: pre-wrap;
}

.result-number__wildcard {
  padding: 0;
  color: var(--signal-dark);
  background: transparent;
  font-weight: 700;
}

.copy-action {
  width: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  opacity: 0.42;
}

.result-row:hover .copy-action,
.result-row:focus-visible .copy-action {
  color: var(--ink);
  opacity: 1;
}

.copy-glyph {
  position: relative;
  width: 14px;
  height: 15px;
  display: inline-block;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.copy-glyph::before {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 9px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  background: var(--row-background, var(--paper));
  content: "";
  transform: translate(-3px, -3px);
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
}

.empty-state__sample {
  margin-bottom: 12px;
  color: #a2a9ae;
  font-family: var(--font-mono);
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.empty-state__sample mark {
  padding: 0;
  color: var(--signal-dark);
  background: transparent;
  font-weight: 700;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

.check-output {
  margin-top: 25px;
  border-top: 1px solid var(--line);
}

.check-output > div,
.copy-result {
  min-height: 72px;
  padding: 13px 4px;
}

.check-output > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.check-output > div strong {
  color: var(--signal-dark);
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.output-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.copy-result {
  --row-background: var(--paper);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--row-background);
  text-align: left;
}

.copy-result:hover {
  --row-background: var(--canvas);
  background: var(--row-background);
}

.copy-result strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.copy-result .copy-action {
  width: auto;
  display: inline-flex;
  gap: 7px;
  color: var(--ink-soft);
  opacity: 1;
  font-size: 13px;
  font-weight: 600;
}

.guide-band {
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}

.guide {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 40px 46px;
  display: grid;
  grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
  gap: 34px 56px;
}

.guide__heading h2,
.guide__boundary h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.35;
}

.guide__heading h2 {
  font-size: 21px;
}

.guide__heading p,
.guide__boundary p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.guide__facts {
  margin: 0;
  border-top: 1px solid var(--line);
}

.guide__facts > div {
  padding: 15px 0 16px;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 22px;
  border-bottom: 1px solid var(--line);
}

.guide__facts dt {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.guide__facts dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.guide__boundary {
  grid-column: 1 / -1;
  padding-top: 18px;
  display: grid;
  grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
  gap: 56px;
  border-top: 1px solid var(--line-strong);
}

.guide__boundary h3 {
  font-size: 15px;
}

.guide__boundary p {
  margin: 0;
}

.footnote {
  width: min(1240px, calc(100% - 40px));
  margin: 16px auto 0;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border: 1px solid #b8d8cc;
  border-radius: var(--radius);
  color: var(--success-dark);
  background: var(--paper);
  box-shadow: 0 10px 30px rgb(22 26 29 / 16%);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 7px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

[hidden] {
  display: none !important;
}

noscript {
  display: block;
  padding: 16px;
  color: var(--danger);
  text-align: center;
}

.not-found-page {
  display: grid;
  place-items: center;
}

.not-found {
  width: min(520px, calc(100% - 40px));
  padding: 48px 0;
}

.not-found__brand {
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.not-found__code {
  margin: 56px 0 10px;
  color: var(--signal-dark);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.not-found h1 {
  font-size: 30px;
}

.not-found > p:not(.not-found__code) {
  margin: 16px 0 28px;
  color: var(--muted);
  line-height: 1.8;
}

.not-found__link {
  color: var(--ink);
  font-weight: 600;
  text-underline-offset: 4px;
}

.language-entry-page {
  display: grid;
  place-items: center;
}

.language-entry {
  width: min(460px, calc(100% - 40px));
  padding: 48px 0;
}

.language-entry h1 {
  margin: 56px 0 26px;
  font-size: 27px;
}

.language-entry h1 span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
}

.language-entry__choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.language-entry__choices a {
  min-height: 58px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.language-entry__choices a + a {
  border-left: 1px solid var(--line);
}

.language-entry__choices a:hover {
  background: var(--paper);
}

.language-entry noscript {
  padding: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

@media (max-width: 899px) {
  .workspace {
    width: min(760px, calc(100% - 32px));
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
  }

  .controls,
  .results {
    padding: 36px 28px 40px;
  }

  .controls {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .result-list {
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .empty-state {
    min-height: 240px;
  }

  .guide {
    width: min(760px, calc(100% - 32px));
    padding: 36px 28px 40px;
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .guide__boundary {
    grid-column: auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}

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

@media (max-width: 520px) {
  .topbar__inner,
  .workspace,
  .guide,
  .footnote {
    width: calc(100% - 24px);
  }

  .topbar__inner {
    min-height: 58px;
  }

  .brand__mark {
    width: 31px;
    height: 31px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .local-badge {
    display: none;
  }

  .language-control {
    grid-template-columns: repeat(2, 36px);
  }

  .controls,
  .results {
    padding: 30px 12px 34px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  .mode-tabs {
    margin-top: 22px;
  }

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

  .results-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 14px;
  }

  .result-actions {
    justify-content: flex-start;
  }

  .secondary-button {
    min-width: 44px;
    padding-inline: 10px;
  }

  .result-status {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .status-timing {
    padding-left: 16px;
    white-space: normal;
  }

  .result-list {
    padding-right: 0;
  }

  .result-row {
    padding-inline: 5px;
    gap: 7px;
  }

  .result-number {
    font-size: 14.5px;
  }

  .guide {
    padding: 30px 12px 34px;
  }

  .guide__facts > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .copy-action {
    min-height: 44px;
    opacity: 0.62;
  }
}

@media (hover: none) {
  .result-row .copy-action {
    opacity: 0.62;
  }
}

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