.language-page {
  min-height: 100vh;
  padding: 30px;
  background: #111827;
  color: #f9fafb;
  font-family: Arial, sans-serif;
}

.language-page h1 {
  font-size: 42px;
  margin-bottom: 10px;
}

.intro {
  max-width: 850px;
  color: #d1d5db;
  font-size: 18px;
}

section {
  margin-top: 35px;
}

.tree-node {
  margin-left: 24px;
  border-left: 2px solid #374151;
  padding-left: 18px;
}

.node-card {
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
  cursor: pointer;
  max-width: 520px;
}

.node-card:hover {
  background: #273449;
}

.node-card h3 {
  margin: 0;
  color: #facc15;
}

.date {
  color: #93c5fd;
  font-size: 14px;
}

.children {
  margin-left: 22px;
}

/* Functional rule for the tap-to-collapse behavior in languages.js */
.children.collapsed {
  display: none;
}

/* Living Fossils of PIE */
.fossil-words {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 22px;
}

.fossil-chip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 999px;
  padding: 10px 16px;
  color: #f9fafb;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fossil-chip:hover {
  background: #273449;
}

.fossil-chip .fc-root {
  color: #facc15;
  font-weight: bold;
  font-size: 17px;
}

.fossil-chip .fc-meaning {
  color: #93c5fd;
  font-size: 13px;
}

.fossil-chip.active {
  background: #facc15;
  border-color: #facc15;
}

.fossil-chip.active .fc-root { color: #111827; }
.fossil-chip.active .fc-meaning { color: #4b3a04; }

.fossil-tree {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 16px;
  padding: 24px;
  max-width: 760px;
}

.fossil-head {
  text-align: center;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px dashed #4b5563;
}

.fossil-root {
  display: block;
  font-size: 40px;
  font-weight: bold;
  color: #facc15;
}

.fossil-meaning {
  display: block;
  margin-top: 4px;
  color: #93c5fd;
  font-size: 18px;
}

.fossil-branches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.fossil-branch {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  opacity: 0;
  animation: fossil-in 0.45s ease forwards;
}

.fossil-word {
  display: block;
  font-size: 22px;
  color: #f9fafb;
}

.fossil-lang {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@keyframes fossil-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* Other Language Families */
.family-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 22px;
}

.family-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 14px;
  padding: 10px 16px;
  color: #f9fafb;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.family-chip:hover {
  background: #273449;
}

.family-chip:focus-visible {
  outline: 2px solid #facc15;
  outline-offset: 2px;
}

.family-chip .fmc-name {
  font-weight: bold;
  font-size: 16px;
}

.family-chip .fmc-speakers {
  color: #93c5fd;
  font-size: 12px;
}

.family-chip.active {
  background: #facc15;
  border-color: #facc15;
}

.family-chip.active .fmc-name { color: #111827; }
.family-chip.active .fmc-speakers { color: #4b3a04; }

.family-detail {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 16px;
  padding: 24px;
  max-width: 760px;
}

.fd-head {
  text-align: center;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px dashed #4b5563;
}

.fd-greeting {
  display: block;
  font-size: 36px;
  font-weight: bold;
  color: #facc15;
}

.fd-greeting-lang {
  display: block;
  margin-top: 4px;
  color: #9ca3af;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fd-name {
  margin: 0 0 12px;
  color: #f9fafb;
  font-size: 24px;
}

.fd-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.fd-tag {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 8px 14px;
  color: #e5e7eb;
  font-size: 15px;
}

.fd-tag-label {
  color: #93c5fd;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fd-note {
  color: #d1d5db;
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.fd-langs-label {
  display: block;
  color: #93c5fd;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

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

.fd-lang {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  color: #f9fafb;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #1f2937;
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: 12px;
  border: 1px solid #374151;
  text-align: left;
}

th {
  background: #374151;
  color: #facc15;
}

td {
  color: #e5e7eb;
}

/* ---- Section nav ---- */
.lang-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 4px;
}
.lang-nav a {
  background: #1f2937;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.lang-nav a:hover {
  background: #273449;
  border-color: #facc15;
  color: #facc15;
}

/* ---- PIE Word Explorer ---- */
.pie-explorer { max-width: 900px; }
.pie-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 12px;
}
.pie-form input {
  flex: 1 1 280px;
  background: #0f172a;
  border: 1px solid #4b5563;
  color: #f9fafb;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
}
.pie-form input:focus {
  outline: none;
  border-color: #facc15;
}
.pie-form button,
.lang-ai-form button {
  background: #facc15;
  color: #111827;
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
}
.pie-form button:hover,
.lang-ai-form button:hover { background: #fde047; }
.pie-form button:disabled,
.lang-ai-form button:disabled { opacity: 0.6; cursor: default; }

.pie-examples,
.lang-ai-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.pie-ex-chip,
.lang-ai-chip {
  background: #1f2937;
  border: 1px solid #374151;
  color: #cbd5e1;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pie-ex-chip:hover,
.lang-ai-chip:hover {
  background: #273449;
  border-color: #93c5fd;
  color: #fff;
}

.pie-msg { color: #d1d5db; font-size: 16px; }
.pie-loading::after {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 8px;
  border: 2px solid #475569;
  border-top-color: #facc15;
  border-radius: 50%;
  vertical-align: -2px;
  animation: pie-spin 0.7s linear infinite;
}
@keyframes pie-spin { to { transform: rotate(360deg); } }

.pie-root-card {
  background: linear-gradient(145deg, #1e293b, #312e1a);
  border: 2px solid #facc15;
  border-radius: 16px;
  padding: 20px 24px;
  margin: 8px 0 16px;
  text-align: center;
  max-width: 520px;
}
.pie-root-card.not-ie {
  background: #1f2937;
  border-color: #6b7280;
}
.pie-root-label {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  color: #93c5fd;
  margin-bottom: 6px;
}
.pie-root-form {
  font-size: 38px;
  font-weight: bold;
  color: #facc15;
  line-height: 1.1;
}
.pie-root-gloss {
  font-size: 18px;
  color: #e5e7eb;
  font-style: italic;
  margin-top: 4px;
}

.pie-reveal-btn {
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  margin: 4px 0 18px;
  transition: background 0.15s;
}
.pie-reveal-btn:hover { background: #2563eb; }

.pie-tree { display: flex; flex-direction: column; gap: 14px; }

.pie-node {
  border-left: 3px solid #475569;
  padding-left: 16px;
  opacity: 0;
  transform: translateY(10px);
}
.pie-tree.revealed .pie-node {
  opacity: 1;
  transform: none;
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.pie-node-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0;
}
.pie-stage { color: #93c5fd; font-weight: bold; font-size: 15px; }
.pie-node-form {
  display: inline;
  color: #fcd34d;
  font-size: 18px;
  margin: 0;
}
.pie-children { margin-left: 14px; }

.pie-modern {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px;
}
.pie-leaf {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  min-width: 72px;
  opacity: 0;
  transform: translateY(10px);
}
.pie-tree.revealed .pie-leaf {
  opacity: 1;
  transform: none;
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.pie-leaf-word { color: #f9fafb; font-size: 16px; font-weight: bold; }
.pie-leaf-lang { color: #94a3b8; font-size: 12px; margin-top: 2px; }

.pie-note {
  color: #cbd5e1;
  font-size: 15px;
  max-width: 640px;
  margin-top: 8px;
  line-height: 1.5;
}

/* ---- Ask About Languages ---- */
.lang-ai { max-width: 800px; }
.lang-ai-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 12px;
}
.lang-ai-form input {
  flex: 1 1 280px;
  background: #0f172a;
  border: 1px solid #4b5563;
  color: #f9fafb;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
}
.lang-ai-form input:focus { outline: none; border-color: #facc15; }
.lang-ai-answer {
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 14px;
  padding: 16px 18px;
  color: #e5e7eb;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 460px;
  overflow-y: auto;
}
.lang-ai-answer.hidden { display: none; }
.ai-loading { color: #94a3b8; font-style: italic; }
