* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.back-link {
  position: absolute;
  top: 2rem;
  left: 2rem;
}

.back-link a {
  font-size: 0.8rem;
  color: inherit;
  opacity: 0.35;
  text-decoration: none;
  transition: opacity 0.4s;
}

.back-link a:hover {
  opacity: 0.7;
}

.api-btn {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.45em 1.2em;
  border: 1px solid rgba(127, 127, 127, 0.25);
  border-radius: 100px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.4s, border-color 0.4s, transform 0.15s;
  font-family: inherit;
}

.api-btn:hover {
  opacity: 0.85;
  border-color: rgba(127, 127, 127, 0.5);
}

.api-btn:active {
  transform: scale(0.96);
}

#words {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2em;
  flex-wrap: wrap;
  font-size: clamp(2rem, 6vw, 3.6rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  line-height: 1.4;
  margin-bottom: 3rem;
  min-height: 5rem;
}

#words div {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeUp 0.6s ease forwards;
}

#words div:nth-child(1) { animation-delay: 0.05s; }
#words div:nth-child(2) { animation-delay: 0.15s; }
#words div:nth-child(3) { animation-delay: 0.25s; }

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.actions {
  display: flex;
  gap: 0.75rem;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.35s forwards;
}

.btn {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  padding: 0.6em 1.8em;
  border: 1px solid rgba(127, 127, 127, 0.25);
  border-radius: 100px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.4s, border-color 0.4s, transform 0.15s;
  font-family: inherit;
}

.btn:hover {
  opacity: 0.85;
  border-color: rgba(127, 127, 127, 0.5);
}

.btn:active {
  transform: scale(0.97);
}

.btn.copied {
  opacity: 1;
  border-color: rgba(127, 127, 127, 0.6);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: modalIn 0.25s ease;
}

.modal.hidden {
  display: none;
}

@keyframes modalIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(520px, calc(100vw - 3rem));
  max-height: 85vh;
  overflow-y: auto;
  background: #fafaf9;
  color: #2a2a2a;
  border-radius: 1rem;
  padding: 2rem 2rem 1.75rem;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: dark) {
  .modal-card {
    background: #1a1a1a;
    color: #e8e8e8;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  }
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.2s;
  padding: 0.25rem;
}

.modal-close:hover {
  opacity: 0.8;
}

.modal-card h2 {
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  margin: 0 0 0.4rem;
}

.modal-desc {
  font-size: 0.82rem;
  opacity: 0.5;
  margin: 0 0 1.5rem;
}

.api-block {
  margin-bottom: 1.1rem;
}

.api-block label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.4;
  margin-bottom: 0.35rem;
}

.api-url {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  padding: 0.55em 0.8em;
  border-radius: 0.5rem;
  background: rgba(127, 127, 127, 0.08);
  word-break: break-all;
}

.api-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 0;
  padding: 0.7em 0.9em;
  border-radius: 0.5rem;
  background: rgba(127, 127, 127, 0.08);
  white-space: pre-wrap;
  word-break: break-all;
}

.api-notes {
  list-style: none;
  padding: 0;
  margin: 1.2rem 0 0;
  font-size: 0.75rem;
  opacity: 0.45;
}

.api-notes li {
  padding: 0.2em 0;
}

.api-notes li::before {
  content: "·";
  margin-right: 0.6em;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #111;
    color: #e8e8e8;
  }
}

@media (prefers-color-scheme: light) {
  body {
    background: #fafaf9;
    color: #2a2a2a;
  }
}
