:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --surface-2: #f0f2f1;
  --text: #16201d;
  --muted: #5b6863;
  --border: #dde3e0;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #e3f3f1;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --risky: #b45309;
  --risky-soft: #fdf3e3;
  --invalid: #b91c1c;
  --invalid-soft: #fdecec;
  --code-bg: #f0f2f1;
  --shadow: 0 1px 2px rgb(16 24 22 / 6%), 0 8px 24px rgb(16 24 22 / 6%);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --surface: #151d1a;
    --surface-2: #1b2521;
    --text: #e6ece9;
    --muted: #9aa8a2;
    --border: #2a3632;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123430;
    --ok: #4ade80;
    --ok-soft: #12291b;
    --risky: #fbbf24;
    --risky-soft: #2e2410;
    --invalid: #f87171;
    --invalid-soft: #331616;
    --code-bg: #1b2521;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px / 1.6 var(--font);
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-strong);
}

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

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header and footer */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand img {
  width: 26px;
  height: 26px;
}

.nav {
  display: flex;
  gap: 20px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

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

.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  padding-top: 24px;
  padding-bottom: 32px;
}

/* Hero and checker */
.hero {
  padding: 64px 0 24px;
  text-align: center;
}

.hero h1 {
  margin: 0 auto 12px;
  max-width: 18ch;
  font-size: clamp(32px, 6vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0 auto;
  max-width: 56ch;
  color: var(--muted);
  font-size: 18px;
}

.checker {
  max-width: 640px;
  margin: 32px auto 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.checker label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.field {
  display: flex;
  gap: 8px;
}

.field input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 0;
}

.button {
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .button {
    color: #04201d;
  }
}

.button:hover {
  background: var(--accent-strong);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Result */
.result {
  margin-top: 20px;
}

.result:empty {
  display: none;
}

.verdict {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-2);
}

.verdict[data-tone="ok"] {
  background: var(--ok-soft);
}

.verdict[data-tone="risky"] {
  background: var(--risky-soft);
}

.verdict[data-tone="invalid"] {
  background: var(--invalid-soft);
}

.verdict-score {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid currentcolor;
  font-weight: 700;
  font-size: 18px;
}

.verdict[data-tone="ok"] .verdict-score,
.verdict[data-tone="ok"] h2 {
  color: var(--ok);
}

.verdict[data-tone="risky"] .verdict-score,
.verdict[data-tone="risky"] h2 {
  color: var(--risky);
}

.verdict[data-tone="invalid"] .verdict-score,
.verdict[data-tone="invalid"] h2 {
  color: var(--invalid);
}

.verdict h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.verdict p {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.suggestion {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
}

.suggestion button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.reasons {
  margin: 14px 0 0;
  padding-left: 20px;
}

.reasons li + li {
  margin-top: 4px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.facts div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.facts dt {
  color: var(--muted);
  font-size: 13px;
}

.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.error {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--invalid-soft);
  color: var(--text);
}

/* Feature grid */
.section {
  padding-top: 64px;
}

.section h2 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.015em;
}

.section > .wrap > p {
  margin: 0 0 24px;
  max-width: 64ch;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.callout {
  padding: 20px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
}

.callout p {
  margin: 0;
}

.callout p + p {
  margin-top: 8px;
}

/* Docs */
.docs {
  padding-top: 48px;
}

.docs h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 40px);
  letter-spacing: -0.02em;
}

.docs h2 {
  margin: 48px 0 12px;
  padding-top: 8px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.docs h3 {
  margin: 28px 0 8px;
  font-size: 18px;
}

.docs .lead {
  margin: 0;
  max-width: 64ch;
  color: var(--muted);
  font-size: 18px;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.toc a:hover {
  border-color: var(--accent);
}

code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--code-bg);
  font: 0.9em / 1.5 var(--mono);
  overflow-wrap: anywhere;
}

pre {
  margin: 12px 0;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
}

pre code {
  padding: 0;
  background: none;
  font-size: 13.5px;
  overflow-wrap: normal;
}

.table-wrap {
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

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

th {
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

td:first-child {
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-risky {
  background: var(--risky-soft);
  color: var(--risky);
}

.pill-invalid {
  background: var(--invalid-soft);
  color: var(--invalid);
}

/* 404 */
.not-found {
  padding: 96px 0;
  text-align: center;
}

@media (max-width: 520px) {
  .field {
    flex-direction: column;
  }

  .field input {
    flex: none;
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .hero {
    padding-top: 40px;
  }

  .nav {
    gap: 14px;
  }
}

/* Account */
.account {
  padding-top: 48px;
}

.narrow {
  max-width: 720px;
}

.account h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -0.02em;
}

.account h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.account .lead {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 17px;
  overflow-wrap: anywhere;
}

.panel {
  margin-top: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel > p {
  margin: 0 0 8px;
}

.panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.status {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface-2);
}

.status[hidden] {
  display: none;
}

.account-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.button-quiet {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.button-quiet:hover {
  background: var(--border);
}

.button-danger {
  background: var(--invalid);
}

.button-danger:hover {
  background: var(--invalid);
  filter: brightness(0.9);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.danger .link-button,
td .link-button {
  color: var(--invalid);
}

.usage-line {
  margin: 0 0 10px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.meter-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.meter-fill[data-full="true"] {
  background: var(--invalid);
}

.usage-days .hint {
  margin-top: 10px;
}

.new-key {
  margin: 12px 0;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
}

.new-key p {
  margin: 0 0 10px;
}

.new-key input {
  font-family: var(--mono);
  font-size: 14px;
}

.create-key {
  margin-top: 12px;
}

.create-key input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

td.actions {
  text-align: right;
}

td code {
  white-space: nowrap;
  overflow-wrap: normal;
}

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

@media (max-width: 520px) {
  /* Keep name, key and revoke on one line; the date is the least needed column. */
  .keys-table th:nth-child(3),
  .keys-table td:nth-child(3) {
    display: none;
  }

  .create-key input {
    flex: none;
    width: 100%;
  }
}

@media (max-width: 420px) {
  /* The logo already links to the checker. */
  .nav a[href="/"] {
    display: none;
  }
}

/* Admin dashboard */
.admin .wrap {
  max-width: 1100px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-label,
.stat-detail {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-value {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 6px 0 0;
  border-radius: 3px;
  vertical-align: baseline;
}

.legend-site {
  margin-left: 14px;
}

.legend-key,
.seg-key {
  background: var(--accent);
}

.legend-site,
.seg-site {
  background: var(--risky);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
}

.chart-small .chart-bars {
  height: 100px;
}

.bar-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
}

.bar {
  display: flex;
  flex: 1;
  flex-direction: column-reverse;
  justify-content: flex-start;
  border-radius: 3px 3px 0 0;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-seg {
  flex: none;
}

.bar-total {
  min-height: 1.1em;
  color: var(--muted);
  font-size: 0.65rem;
  text-align: center;
  overflow: hidden;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head input {
  min-width: 0;
  padding: 8px 12px;
  color: var(--text);
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.count {
  color: var(--muted);
  font-weight: 400;
}

.admin-table th,
.admin-table td {
  white-space: nowrap;
}

.admin-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table tr.at-limit td {
  background: var(--risky-soft);
}

.sort {
  padding: 0;
  color: inherit;
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

th[aria-sort="ascending"] .sort::after {
  content: " ▲";
}

th[aria-sort="descending"] .sort::after {
  content: " ▼";
}

@media (max-width: 520px) {
  .chart-bars {
    gap: 1px;
  }

  .bar-total {
    display: none;
  }
}
