:root {
  --bg: #090909;
  --surface: #0e0e0e;
  --surface-hover: #131313;
  --text: #e8e8e8;
  --muted: #777;
  --dim: #444;
  --border: #242424;
  --accent: #9effa7;

  --mono:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;

  background: var(--bg);
  color: var(--text);

  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

.app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;

  display: flex;
  flex-direction: column;

  margin: 0;

  padding:
    clamp(18px, 1.7vw, 28px)
    clamp(24px, 4vw, 72px)
    clamp(24px, 3vw, 40px);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo,
.source {
  text-decoration: none;
}

.logo {
  font-weight: 700;
  letter-spacing: -0.04em;
}

.logo span {
  color: var(--accent);
  animation: blink 1.2s steps(1) infinite;
}

.source {
  flex: 0 0 auto;

  color: var(--muted);
  font-size: 12px;
}

.source:hover {
  color: var(--text);
}

.hero {
  width: 72vw;

  margin:
    clamp(72px, 11vh, 120px)
    auto
    clamp(40px, 5vh, 56px);

  text-align: center;
}

h1 {
  margin: 0;

  font-size: clamp(36px, 3vw, 54px);
  line-height: 1.06;
  letter-spacing: -0.055em;
  font-weight: 600;

  text-wrap: balance;
}

.hero p {
  margin: 16px 0 0;
  color: var(--muted);
}

.generator {
  width: 52vw;
  margin: 0 auto;
}

form label {
  display: block;
  margin-bottom: 8px;

  color: var(--muted);
  font-size: 13px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

input,
.input-row button {
  height: 44px;

  border: 1px solid var(--border);
  border-radius: 3px;

  background: var(--surface);
}

input {
  width: 100%;
  min-width: 0;

  padding: 0 14px;

  color: var(--text);
  outline: none;

  appearance: textfield;
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

input.invalid,
input.invalid::placeholder {
  color: #FF6B6B;
}

input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

input:focus {
  border-color: var(--dim);
}

.input-row button {
  width: 100%;
  min-width: 0;

  padding: 0 18px;

  cursor: pointer;
}

.input-row button:hover {
  background: var(--surface-hover);
  border-color: var(--dim);
}

.results {
  margin-top: 24px;
}

.results-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;

  padding:
    0
    clamp(8px, 1.5vw, 16px)
    7px;

  color: var(--muted);

  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.prefix-list {
  border-top: 1px solid var(--border);
}

.prefix-row {
  width: 100%;
  min-height: 52px;

  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 2vw, 24px);
  align-items: center;

  padding:
    0
    clamp(8px, 1.5vw, 16px);

  border: 0;
  border-bottom: 1px solid var(--border);

  background: transparent;

  text-align: left;
  cursor: pointer;
}

.prefix-row:hover {
  background: var(--surface-hover);
}

.prefix-row:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

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

.count {
  min-width: 0;
  color: var(--text);
}

.copy-state {
  color: var(--muted);
  font-size: 12px;
}

.prefix-row.copied .rank,
.prefix-row.copied .count {
  color: var(--dim);
}

.prefix-row.copied .copy-state {
  color: var(--accent);
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;

  margin-top: 12px;
}

.text-button {
  padding: 0;
  border: 0;

  background: transparent;
  color: var(--text);

  font-size: 12px;

  cursor: pointer;
}

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

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

.shortcut {
  margin: 22px 0 0;

  color: var(--muted);

  font-size: 11px;
  line-height: 1.8;
}

details {
  width: 52vw;

  margin:
    clamp(36px, 5vh, 52px)
    auto
    0;

  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

summary {
  padding: 14px 0;

  color: var(--muted);

  font-size: 13px;

  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  float: right;
}

details[open] summary::after {
  content: "−";
}

.details-content {
  padding: 0 0 16px;

  color: var(--muted);

  font-size: 12px;
}

.details-content p {
  margin: 0 0 8px;
}

.details-content p:last-child {
  margin-bottom: 0;
}

/* cleanup */

.cleanup-details {
  margin-top: 0;
  border-top: 0;
}

.cleanup-content {
  padding: 0 0 16px;
}

.cleanup-label {
  display: block;

  margin-bottom: 8px;

  color: var(--muted);

  font-size: 12px;
}

.cleanup-input {
  width: 100%;
  min-height: 96px;

  display: block;

  padding: 11px 12px;

  border: 1px solid var(--border);
  border-radius: 3px;

  background: var(--surface);
  color: var(--text);

  line-height: 1.5;

  outline: none;
  resize: vertical;
}

.cleanup-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.cleanup-input:focus {
  border-color: var(--dim);
}

.cleanup-copy-button {
  width: 100%;
  min-height: 40px;

  margin-top: 8px;
  padding: 0 14px;

  border: 1px solid var(--border);
  border-radius: 3px;

  background: var(--surface);
  color: var(--text);

  cursor: pointer;
}

.cleanup-copy-button:hover {
  background: var(--surface-hover);
  border-color: var(--dim);
}

.cleanup-copy-button.copied {
  color: var(--accent);
}

.cleanup-feedback {
  min-height: 18px;

  margin: 8px 0 0;

  color: var(--muted);

  font-size: 11px;
}

footer {
  width: 52vw;

  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 16px;

  margin: auto auto 0;
  padding-top: clamp(40px, 6vh, 72px);

  color: var(--dim);

  font-size: 12px;
  text-align: center;
}

.sr-only {
  position: absolute;

  width: 1px;
  height: 1px;

  padding: 0;
  margin: -1px;

  overflow: hidden;

  clip: rect(0, 0, 0, 0);

  white-space: nowrap;

  border: 0;
}

@keyframes blink {
  0%,
  45% {
    opacity: 1;
  }

  46%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .hero {
    width: 86vw;
  }

  .generator,
  details,
  footer {
    width: 78vw;
  }

  h1 {
    font-size: clamp(34px, 5vw, 46px);
  }
}

@media (max-width: 600px) {
  .app {
    padding: 20px 14px 26px;
  }

  .hero {
    width: 100%;

    margin: 46px 0 34px;

    text-align: left;
  }

  h1 {
    font-size: clamp(26px, 8vw, 34px);
    line-height: 1.08;
  }

  .generator,
  details,
  footer {
    width: 100%;
  }

  .input-row button {
    width: 100%;
  }

  .prefix-row {
    gap: 10px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .results-head {
    padding-left: 8px;
    padding-right: 8px;
  }

  details {
    margin-top: 28px;
  }

  .cleanup-details {
    margin-top: 0;
  }

  footer {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;

    margin-top: auto;
    padding-top: 28px;

    text-align: left;
  }

  footer span:last-child {
    text-align: right;
  }
}

@media (max-width: 360px) {
  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .source {
    font-size: 11px;
  }

  .prefix-row {
    font-size: 13px;
  }

  .copy-state {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo span {
    animation: none;
  }
}
