* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  background: #f7f6f3;
  color: #1a1a1a;
}

main {
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.5rem 1rem calc(6rem + env(safe-area-inset-bottom));
}

h1 {
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

.top-nav {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.top-nav a {
  color: #777;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid transparent;
}

.top-nav a.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

#category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.chip {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid #cfcac0;
  border-radius: 999px;
  background: #fff;
  color: inherit;
  cursor: pointer;
}

.chip.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

#results-status {
  font-size: 0.85rem;
  color: #777;
  margin: 0.5rem 0;
}

#results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-item {
  background: #fff;
  border: 1px solid #e6e2d9;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
}

.result-item:hover,
.result-item:focus-visible {
  border-color: #b8b2a4;
}

.result-hero {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.result-text {
  margin: 0;
  font-weight: 500;
}

.result-text-secondary {
  margin-top: 0.3rem;
  font-weight: 400;
  color: #666;
  font-size: 0.92rem;
}

.result-swiss {
  margin: 0.25rem 0 0;
  font-style: italic;
  color: #777;
  font-size: 0.9rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: #eee9dd;
  color: #4a4a4a;
}

.badge-tag {
  background: #dbe9e0;
  color: #2b5940;
}

#detail-back {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border: 1px solid #cfcac0;
  border-radius: 0.6rem;
  background: #fff;
  color: inherit;
  cursor: pointer;
  margin-bottom: 1rem;
}

.detail-hero {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.detail-status {
  font-size: 0.85rem;
  color: #9a6b00;
  margin: 0.4rem 0 0;
}

.badge-clickable {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.detail-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #999;
  margin: 1.25rem 0 0.5rem;
}

.token-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.token-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #e6e2d9;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
}

.token-row:hover,
.token-row:focus-visible {
  border-color: #b8b2a4;
}

.token-surface {
  font-weight: 600;
}

.token-meta {
  font-size: 0.8rem;
  color: #777;
  text-align: right;
}

textarea,
input[type="text"] {
  width: 100%;
  font-size: 1rem;
  padding: 0.75rem;
  border: 1px solid #cfcac0;
  border-radius: 0.5rem;
  background: #fff;
  color: inherit;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

#typo-warning {
  min-height: 1.1rem;
  font-size: 0.82rem;
  color: #9a6b00;
  margin: 0.4rem 0 0;
}

details {
  margin-top: 0.75rem;
}

details summary {
  cursor: pointer;
  color: #555;
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

details input {
  margin-top: 0.5rem;
}

#feedback {
  min-height: 1.5rem;
  font-size: 0.9rem;
  margin: 0.75rem 0 0;
}

#feedback[data-state="ok"] {
  color: #1a7f37;
}

#feedback[data-state="error"] {
  color: #b3261e;
}

#submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #f7f6f3 60%, transparent);
}

#submit-button {
  display: block;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem;
  border: none;
  border-radius: 0.75rem;
  background: #1a1a1a;
  color: #fff;
  cursor: pointer;
}

#submit-button:active {
  opacity: 0.85;
}

#submit-button:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (prefers-color-scheme: dark) {
  html, body {
    background: #17181a;
    color: #ececec;
  }

  textarea,
  input[type="text"] {
    background: #232427;
    border-color: #3a3b3e;
  }

  details summary {
    color: #a8a8a8;
  }

  .top-nav a {
    color: #999;
  }

  .top-nav a.active {
    color: #ececec;
    border-bottom-color: #ececec;
  }

  .chip {
    background: #232427;
    border-color: #3a3b3e;
  }

  .chip.active {
    background: #ececec;
    color: #17181a;
    border-color: #ececec;
  }

  #results-status {
    color: #999;
  }

  .result-item {
    background: #232427;
    border-color: #3a3b3e;
  }

  .result-item:hover,
  .result-item:focus-visible {
    border-color: #55565a;
  }

  .result-swiss {
    color: #999;
  }

  .result-text-secondary {
    color: #a8a8a8;
  }

  .badge {
    background: #2f302f;
    color: #d8d8d8;
  }

  .badge-tag {
    background: #223a2c;
    color: #a6d9ba;
  }

  #detail-back {
    background: #232427;
    border-color: #3a3b3e;
    color: inherit;
  }

  .detail-status,
  #typo-warning {
    color: #d9a441;
  }

  .detail-section-label {
    color: #888;
  }

  .token-row {
    background: #232427;
    border-color: #3a3b3e;
  }

  .token-row:hover,
  .token-row:focus-visible {
    border-color: #55565a;
  }

  .token-meta {
    color: #999;
  }

  #submit-bar {
    background: linear-gradient(to top, #17181a 60%, transparent);
  }

  #submit-button {
    background: #ececec;
    color: #17181a;
  }
}
