:root {
  --color-primary: #2c5282;
  --color-secondary: #4299e1;
  --color-bg: #ffffff;
  --color-bg-alt: #f7fafc;
  --color-border: #e2e8f0;
  --color-text: #1a202c;
  --color-text-muted: #718096;
  --color-accent: #ed8936;
  --max-width: 800px;
  --border-radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg-alt);
}

#search-container {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-box {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus {
  border-color: var(--color-secondary);
}

.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-height: 400px;
  overflow-y: auto;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}

.search-result-item:hover {
  background: var(--color-bg-alt);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-term {
  font-weight: 600;
  color: var(--color-primary);
}

.search-result-type {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-result-def {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-results {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
  background: var(--color-bg);
  min-height: calc(100vh - 4rem);
}

.loading,
.error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

.error {
  color: #e53e3e;
}

.home-header {
  text-align: center;
  margin-bottom: 3rem;
}

.home-header h1 {
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.header-logo {
  max-width: 600px;
  width: 100%;
  height: auto;
  margin: 0 auto 1rem;
  display: block;
}

.tagline {
  font-size: 1.125rem;
  color: var(--color-text-muted);
}

.random-term-section {
  text-align: center;
  margin-bottom: 3rem;
}

.random-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.random-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.random-term-preview {
  margin-top: 1rem;
}

.featured-section,
.browse-section {
  margin-bottom: 3rem;
}

.featured-section h2,
.browse-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.term-card {
  display: block;
  padding: 1rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
}

.term-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.term-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.term-card-term {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
}

.term-card-type {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.term-card-preview {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.alphabet-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.filter-btn {
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: var(--color-border);
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.letter-group {
  margin-bottom: 2rem;
}

.letter-heading {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  color: var(--color-secondary);
  text-decoration: none;
  font-size: 0.875rem;
}

.back-link:hover {
  text-decoration: underline;
}

.term-article {
  max-width: 700px;
}

.term-header {
  margin-bottom: 2rem;
}

.headword {
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.term-type {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.definition-rail {
  position: relative;
  padding-left: 3rem;
  margin-bottom: 2rem;
}

.definition-rail::before {
  content: '';
  position: absolute;
  left: 1.25rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--color-border);
}

.definition-item {
  position: relative;
  margin-bottom: 2rem;
}

.definition-number {
  position: absolute;
  left: -3rem;
  top: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 1;
}

.definition-content {
  padding-left: 1rem;
}

.definition-text {
  font-size: 1.125rem;
  line-height: 1.8;
}

.definition-intro {
  font-size: 1.125rem;
  line-height: 1.8;
  margin-bottom: 0.5rem;
}

.definition-subbullets {
  list-style: none;
  padding-left: 1rem;
}

.definition-subbullets li {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.other-forms-section,
.see-also-section,
.examples-section,
.history-section {
  margin-bottom: 2rem;
}

.other-forms-section h3,
.see-also-section h3,
.examples-section h3,
.history-section h3 {
  font-size: 1.25rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  font-size: 0.875rem;
  color: var(--color-text);
}

.pill-link {
  text-decoration: none;
  transition: all 0.2s;
}

.pill-link:hover {
  background: var(--color-secondary);
  color: white;
  border-color: var(--color-secondary);
}

/* Auto-linked terms in definitions, history, and examples */
.term-link {
  color: var(--color-secondary);
  text-decoration: none;
  border-bottom: 1px dotted var(--color-secondary);
  transition: all 0.2s;
  padding-bottom: 1px;
}

.term-link:hover {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  border-bottom-style: solid;
}

.history-box {
  padding: 1rem;
  background: var(--color-bg-alt);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--border-radius);
  font-style: italic;
  color: var(--color-text-muted);
}

.examples-list {
  list-style: none;
}

.example {
  padding: 0.75rem 1rem;
  background: var(--color-bg-alt);
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
  font-style: italic;
}

.term-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin-top: 2rem;
}

.term-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.not-found-view {
  text-align: center;
  padding: 3rem 1rem;
}

.not-found-view h1 {
  font-size: 4rem;
  color: var(--color-text-muted);
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: background 0.2s;
}

.btn:hover {
  background: var(--color-secondary);
}

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 2px solid var(--color-border);
  text-align: center;
}

.footer-nav {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-nav a {
  color: var(--color-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.page-content {
  max-width: 700px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 2.5rem;
  color: var(--color-primary);
}

.about-section,
.contribute-section {
  margin-bottom: 2rem;
}

.about-section h2,
.contribute-section h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.about-section p,
.contribute-section p {
  margin-bottom: 1rem;
  line-height: 1.8;
}

.contribute-steps {
  padding-left: 1.5rem;
  margin: 1.5rem 0;
}

.contribute-steps li {
  margin-bottom: 1rem;
  line-height: 1.8;
}

.spreadsheet-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-secondary);
  color: white;
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: background 0.2s;
}

.spreadsheet-link:hover {
  background: var(--color-primary);
}

.field-guide {
  background: var(--color-bg-alt);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 1rem 0;
}

.field-item {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.field-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.field-item strong {
  color: var(--color-primary);
}

.guidelines-list {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.guidelines-list li {
  margin-bottom: 0.5rem;
  line-height: 1.8;
}

@media (max-width: 768px) {
  .home-header h1 {
    font-size: 2rem;
  }

  .headword {
    font-size: 2rem;
  }

  .definition-rail {
    padding-left: 0;
  }

  .definition-rail::before {
    display: none;
  }

  .definition-number {
    position: static;
    display: inline-flex;
    margin-right: 0.5rem;
    width: 2rem;
    height: 2rem;
  }

  .definition-content {
    padding-left: 0;
  }

  .term-grid {
    grid-template-columns: 1fr;
  }
}
