:root {
  --bg: #0d0f14;
  --panel: #161923;
  --ink: #e8e6f0;
  --dim: #8b8ba0;
  --accent: #ff7a59;
  --accent2: #6fd6ff;
  --border: #2a2e3d;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding: 0 1rem 3rem;
}

header {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 0 1rem;
  text-align: center;
}

h1 {
  font-size: 2.4rem;
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}
h1 .tag { color: var(--accent); }

.tagline { color: var(--ink); margin: 0.2rem 0; }
.credit { color: var(--dim); font-size: 0.85rem; margin: 0.4rem 0 0; }
.credit a { color: var(--accent2); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

main {
  max-width: 900px;
  margin: 2rem auto;
}

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.slot-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.slot-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}
.slot-tab.active {
  color: var(--bg);
  background: var(--accent2);
  border-color: var(--accent2);
}
.optional-tag { font-size: 0.7rem; opacity: 0.7; }

.chart-caption { color: var(--dim); font-size: 0.85rem; margin: 0 0 0.6rem; }

.chart-scroll { overflow-x: auto; }

table.chart {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}
table.chart th, table.chart td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  text-align: center;
  min-width: 3.2rem;
}
table.chart th {
  color: var(--dim);
  font-weight: 500;
  font-size: 0.78rem;
  white-space: nowrap;
}
table.chart th.row-label { text-align: right; white-space: nowrap; }
table.chart td.empty-cell { background: repeating-linear-gradient(45deg, transparent, transparent 5px, #1c202c 5px, #1c202c 6px); }

.symbol {
  display: inline-block;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 1.15rem;
}
.symbol:hover { background: #22273a; }
/* onset and coda share one consonant chart, so both can be marked on the
   same chart at once — fill for onset, ring for coda, so a symbol picked
   for both (e.g. the same nasal as onset and coda) shows both cues. */
.symbol.selected-onset, .symbol.selected-nucleus {
  background: var(--accent);
  color: #1a0e08;
  font-weight: 700;
}
.symbol.selected-coda {
  box-shadow: 0 0 0 2px var(--accent2) inset;
  font-weight: 700;
}
.symbol.voiced, .symbol.rounded { color: var(--accent2); }
.symbol.selected-onset.voiced, .symbol.selected-onset.rounded,
.symbol.selected-nucleus.voiced, .symbol.selected-nucleus.rounded { color: #06232b; }

.nasal-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  color: var(--dim);
  font-size: 0.9rem;
  cursor: pointer;
}

#result {
  text-align: center;
}
.ipa-display {
  font-size: 2.2rem;
  letter-spacing: 0.02em;
}
.roman-display {
  color: var(--accent2);
  font-size: 1.1rem;
  margin-top: 0.2rem;
}
.gloss {
  color: var(--ink);
  margin-top: 0.8rem;
  font-style: italic;
  min-height: 1.4em;
}
.result-controls {
  margin-top: 1.2rem;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #1a0e08;
  cursor: pointer;
  font-weight: 600;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost-btn {
  background: transparent;
  color: var(--dim);
  font-weight: 500;
}
button.ghost-btn:hover { color: var(--ink); border-color: var(--accent2); }

#word-builder h2 { margin-top: 0; font-size: 1.1rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.word-display {
  font-size: 1.6rem;
  margin-bottom: 0.6rem;
  word-break: break-word;
}
.word-gloss-line {
  color: var(--dim);
  font-size: 0.9rem;
  padding: 0.15rem 0;
}
.word-controls { margin: 0.8rem 0; }

#share-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}
#share-bar[hidden] { display: none; }
.share-btn {
  display: inline-block;
  background: var(--accent2);
  color: #06232b;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

footer {
  max-width: 720px;
  margin: 2rem auto 0;
  color: var(--dim);
  font-size: 0.85rem;
  text-align: center;
}
footer a { color: var(--accent2); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  h1 { font-size: 1.9rem; }
  table.chart { font-size: 0.8rem; }
  table.chart th, table.chart td { padding: 0.25rem 0.35rem; min-width: 2.4rem; }
}
