* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
  line-height: 1.7;
}

.app {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 12px;
}

.app-header {
  padding: 18px 4px 10px;
}

.app-header h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.03em;
}

.app-header p {
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 14px;
}

.letter-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  padding: 10px 0;
  background: rgba(243, 244, 246, 0.96);
  backdrop-filter: blur(8px);
}

.letter-button {
  min-height: 40px;
  border: none;
  border-radius: 999px;
  background: #ffffff;
  color: #2563eb;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

.letter-button:active,
.filter-button:active,
.related-button:active,
.back-button:active {
  transform: scale(0.96);
}

.filter-area {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 16px;
}

.filter-button {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: none;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-weight: 900;
  cursor: pointer;
}

.filter-button.active {
  background: #111827;
  color: #ffffff;
}

.letter-section {
  margin: 28px 0;
}

.letter-heading {
  margin: 0 0 12px;
  padding-left: 8px;
  border-left: 6px solid #2563eb;
  font-size: 26px;
}

.term-card {
  margin: 12px 0;
  padding: 16px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  scroll-margin-top: 120px;
}

.term-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.term-name {
  margin: 0;
  font-family: Consolas, Menlo, monospace;
  font-size: 24px;
  font-weight: 900;
  color: #dc2626;
}

.category-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.term-reading {
  margin: 6px 0 0;
  color: #6b7280;
  font-size: 14px;
}

.term-block {
  margin-top: 14px;
}

.term-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 900;
}

.term-card p {
  margin: 0;
}

.code-example {
  margin: 8px 0 0;
  padding: 12px;
  overflow-x: auto;
  border-radius: 12px;
  background: #111827;
  color: #f9fafb;
  font-family: Consolas, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
}

.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.related-button {
  padding: 7px 10px;
  border: none;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-family: Consolas, Menlo, monospace;
  font-weight: 900;
  cursor: pointer;
}

.back-button {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 20;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.hidden {
  display: none;
}

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

  .letter-nav {
    grid-template-columns: repeat(7, 1fr);
  }

  .letter-button {
    min-height: 40px;
    font-size: 13px;
  }

  .term-name {
    font-size: 22px;
  }

  .term-card {
    padding: 14px;
  }
}