@layer components {
  .nav-link {
    @apply px-3 py-2 rounded-xl text-ash hover:text-ivory hover:bg-surface-hover transition-all duration-200;
  }
  .btn-primary {
    @apply inline-flex items-center justify-center bg-brass hover:bg-gold text-canvas font-bold rounded-xl px-6 py-3 transition-all duration-200 shadow-md shadow-brass/10 hover:shadow-brass/20 active:scale-[0.98] hover:-translate-y-0.5;
  }
  .btn-secondary {
    @apply inline-flex items-center justify-center bg-surface hover:bg-surface-hover text-ivory border border-border font-semibold rounded-xl px-6 py-3 transition-all duration-200 hover:-translate-y-0.5;
  }
  .btn-agri {
    @apply inline-flex items-center justify-center bg-agri hover:bg-[#6A9E60] text-white font-bold rounded-xl px-6 py-3 transition-all duration-200 hover:-translate-y-0.5;
  }
  .card {
    @apply bg-surface/90 backdrop-blur-md border border-border rounded-2xl p-6 shadow-xl relative overflow-hidden hover:border-brass/50 transition-colors duration-300;
  }
  .badge {
    @apply text-xs font-medium uppercase tracking-wider text-brass;
  }
  .mod-badge {
    @apply bg-canvas text-brass border border-border text-xs font-mono px-3 py-1 rounded-full;
  }
}

.wiki-prose {
  color: #B3A598;
  line-height: 1.75;
}
.wiki-prose h1,
.wiki-prose h2,
.wiki-prose h3 {
  color: #F4EFEA;
  font-family: Cinzel, serif;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}
.wiki-prose h2 { color: #E5A93C; }
.wiki-prose a { color: #E5A93C; text-decoration: underline; }
.wiki-prose code {
  font-family: "JetBrains Mono", monospace;
  background: #1E1A17;
  border: 1px solid #4A3E35;
  border-radius: 0.5rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.875em;
  color: #F4C463;
}
.wiki-prose pre {
  background: #1E1A17;
  border: 1px solid #4A3E35;
  border-radius: 1rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.wiki-prose pre code {
  border: none;
  padding: 0;
  background: transparent;
}
.wiki-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.wiki-prose th,
.wiki-prose td {
  border: 1px solid #4A3E35;
  padding: 0.5rem 0.75rem;
}
.wiki-prose th {
  background: #1E1A17;
  color: #E5A93C;
}
.wiki-prose ul,
.wiki-prose ol {
  padding-left: 1.25rem;
  margin: 0.75rem 0;
}
.wiki-prose li { margin: 0.25rem 0; }
.wiki-prose blockquote {
  border-left: 3px solid #E5A93C;
  padding-left: 1rem;
  color: #7A6E63;
  margin: 1rem 0;
}
.wiki-prose img {
  border-radius: 1rem;
  border: 1px solid #4A3E35;
  max-width: 100%;
}
.wiki-prose del { color: #7A6E63; }

/* Fallback utility classes when @apply is unavailable (Tailwind CDN) */
.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  color: #B3A598;
  transition: all 0.2s;
}
.nav-link:hover {
  color: #F4EFEA;
  background: #362F29;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #E5A93C;
  color: #1E1A17;
  font-weight: 700;
  border-radius: 0.75rem;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(229, 169, 60, 0.1);
}
.btn-primary:hover {
  background: #F4C463;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(229, 169, 60, 0.2);
}
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2A2420;
  color: #F4EFEA;
  border: 1px solid #4A3E35;
  font-weight: 600;
  border-radius: 0.75rem;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: #362F29;
  transform: translateY(-2px);
}
.btn-agri {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #5B8C51;
  color: #fff;
  font-weight: 700;
  border-radius: 0.75rem;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s;
}
.btn-agri:hover {
  background: #6A9E60;
  transform: translateY(-2px);
}
.card {
  background: rgba(42, 36, 32, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid #4A3E35;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}
.card:hover { border-color: rgba(229, 169, 60, 0.5); }
.badge {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #E5A93C;
}
.mod-badge {
  background: #1E1A17;
  color: #E5A93C;
  border: 1px solid #4A3E35;
  font-size: 0.75rem;
  font-family: "JetBrains Mono", monospace;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
}

/* Profile chip in header */
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(42, 36, 32, 0.95);
  border: 1px solid #4A3E35;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  color: #F4EFEA;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s ease-in-out;
}
.profile-chip:hover {
  border-color: rgba(229, 169, 60, 0.5);
  background: #362F29;
  transform: translateY(-1px);
}
.profile-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  object-fit: cover;
  border: 1px solid #4A3E35;
  flex-shrink: 0;
}
.profile-chip-avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1E1A17;
  color: #E5A93C;
}
.profile-chip-label {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.25rem;
}
.logout-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-left: 0.25rem;
  border-radius: 0.75rem;
  border: 1px solid #4A3E35;
  background: #2A2420;
  color: #B3A598;
  transition: all 0.2s ease-in-out;
}
.logout-icon-btn:hover {
  color: #F4EFEA;
  border-color: rgba(200, 109, 59, 0.6);
  background: #362F29;
  transform: translateY(-1px);
}

/* Floating toasts — no layout shift under header */
.toast-stack {
  position: fixed;
  top: 5.5rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(24rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: rgba(42, 36, 32, 0.96);
  border: 1px solid rgba(229, 169, 60, 0.35);
  color: #B3A598;
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.toast--success { border-color: rgba(91, 140, 81, 0.5); }
.toast--error { border-color: rgba(200, 109, 59, 0.55); }
.toast--fade {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}
.toast-close {
  flex-shrink: 0;
  color: #7A6E63;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.toast-close:hover { color: #F4EFEA; }

/* GitDocs-style wiki */
.wiki-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 72rem;
  margin: 0 auto;
  min-height: 70vh;
}
@media (min-width: 900px) {
  .wiki-layout {
    grid-template-columns: 260px 1fr;
  }
}
.wiki-sidebar {
  border-right: 1px solid #4A3E35;
  background: rgba(42, 36, 32, 0.45);
  padding: 1.25rem 0.75rem 2rem;
}
@media (max-width: 899px) {
  .wiki-sidebar {
    border-right: none;
    border-bottom: 1px solid #4A3E35;
    max-height: 40vh;
    overflow-y: auto;
  }
}
.wiki-sidebar-home {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  color: #B3A598;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
}
.wiki-sidebar-home:hover,
.wiki-sidebar-home.is-active {
  background: #362F29;
  color: #E5A93C;
}
.wiki-tree-category {
  margin-bottom: 0.75rem;
}
.wiki-tree-category-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.65rem;
  color: #F4EFEA;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.wiki-tree-category-link:hover {
  background: #362F29;
}
.wiki-tree-category-link.is-active {
  background: rgba(229, 169, 60, 0.12);
  color: #E5A93C;
}
.wiki-tree-sections {
  margin: 0.2rem 0 0.35rem 0.35rem;
  padding-left: 0.35rem;
  border-left: 1px solid #4A3E35;
}
.wiki-tree-section {
  margin-bottom: 0.35rem;
}
.wiki-tree-section-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.65rem;
  color: #F4EFEA;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
}
.wiki-tree-section-link:hover {
  background: #362F29;
}
.wiki-tree-section-link.is-active {
  background: rgba(229, 169, 60, 0.12);
  color: #E5A93C;
}
.wiki-tree-articles {
  list-style: none;
  margin: 0.15rem 0 0.5rem 0.85rem;
  padding: 0 0 0 0.75rem;
  border-left: 1px solid #4A3E35;
}
.wiki-tree-article {
  display: block;
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  color: #B3A598;
  font-size: 0.8125rem;
  transition: all 0.2s;
}
.wiki-tree-article:hover {
  color: #F4EFEA;
  background: rgba(54, 47, 41, 0.7);
}
.wiki-tree-article.is-active {
  color: #F4C463;
  background: rgba(229, 169, 60, 0.1);
  border-left: 2px solid #E5A93C;
  margin-left: -1px;
}
.wiki-tree-empty {
  color: #7A6E63;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
}
.wiki-content {
  padding: 1.5rem 1.25rem 3rem;
}
@media (min-width: 900px) {
  .wiki-content {
    padding: 2rem 2.5rem 4rem;
  }
}

/* Faction media */
.faction-logo {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  object-fit: cover;
  border: 1px solid #4A3E35;
  background: #1E1A17;
}
.faction-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.faction-gallery-item {
  position: relative;
  border-radius: 0.85rem;
  overflow: hidden;
  border: 1px solid #4A3E35;
  aspect-ratio: 4 / 3;
  background: #1E1A17;
}
.faction-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.faction-gallery-item:hover img {
  transform: scale(1.04);
}

/* Guide steps */
.guide-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: start;
}
.guide-step-num {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: rgba(229, 169, 60, 0.15);
  border: 1px solid rgba(229, 169, 60, 0.4);
  color: #E5A93C;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signature-box {
  font-family: "JetBrains Mono", monospace;
  background: #1E1A17;
  border: 1px dashed #E5A93C;
  border-radius: 0.85rem;
  padding: 1rem 1.15rem;
  color: #F4C463;
  word-break: break-all;
  font-size: 0.875rem;
}
