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

/* ---- Theme variables ----
   Dark:  bg #000000, text #000000 (as specified in the request).
          Muted/secondary tones use white-opacity accents so the toggle,
          hints, translations, and grammar tip stay findable in the void.
   Light: bg #ffffff, text #000000.
*/
:root[data-theme="dark"] {
  --bg: #000000;
  --text: #000000;
  --star: #ffffff;          /* French word — the star (bright in dark) */
  --muted-1: rgba(255, 255, 255, 0.6);
  --muted-2: rgba(255, 255, 255, 0.5);
  --muted-3: rgba(255, 255, 255, 0.3);
  --muted-4: rgba(255, 255, 255, 0.22);
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);
  --glow: rgba(255, 255, 255, 0.65);
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --text: #000000;
  --star: #000000;
  --muted-1: rgba(0, 0, 0, 0.65);
  --muted-2: rgba(0, 0, 0, 0.5);
  --muted-3: rgba(0, 0, 0, 0.4);
  --muted-4: rgba(0, 0, 0, 0.35);
  --line: rgba(0, 0, 0, 0.1);
  --line-soft: rgba(0, 0, 0, 0.06);
  --glow: rgba(0, 0, 0, 0.35);
}

html, body {
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.5s ease, color 0.5s ease;
}

.screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
}

/* Theme toggle — top right, understated */
.theme-toggle {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 10;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--muted-3);
  padding: 0.4rem 0.55rem;
  transition: color 0.3s ease;
  user-select: none;
}

.theme-toggle:hover {
  color: var(--star);
}

.content {
  width: 100%;
  max-width: 760px;
}

.legend {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 1fr;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.legend-item {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-3);
}

.legend-item.rtl {
  direction: rtl;
  text-align: right;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.7rem;
}

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

.word-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 1fr;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.7rem 0;
  opacity: 0;
  transform: translateY(8px);
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cell {
  font-family: "Newsreader", Georgia, serif;
  cursor: pointer;
  transition: color 0.25s ease, transform 0.15s ease, text-shadow 0.25s ease;
  border-radius: 4px;
  user-select: none;
  outline: none;
}

.cell:hover {
  color: var(--star);
}

.cell:focus-visible {
  box-shadow: 0 0 0 1px var(--muted-3);
}

.cell.speaking {
  color: var(--star);
  text-shadow: 0 0 14px var(--glow);
  transform: translateY(-1px);
}

.cell-fr {
  font-size: 1.45rem;
  font-weight: 400;
  color: var(--star);
  letter-spacing: 0.01em;
}

.cell-en {
  font-size: 1rem;
  font-style: italic;
  color: var(--muted-2);
}

.cell-fa,
.cell-ckb {
  font-size: 1.15rem;
  color: var(--muted-1);
}

.cell.rtl {
  direction: rtl;
  text-align: right;
}

.hint {
  margin-top: 2.4rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--muted-4);
  text-align: center;
  font-style: italic;
}

/* Grammar tip — a gentle aside beneath the words */
.grammar {
  margin: 2.2rem auto 0;
  max-width: 640px;
  text-align: center;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  opacity: 0;
  transform: translateY(8px);
  animation: rise 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
</parameter>

.grammar-label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-3);
  margin-bottom: 0.7rem;
}

.grammar-text {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--muted-1);
  text-align: left;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.grammar-text:last-child {
  border-bottom: none;
}

.grammar-text.rtl {
  direction: rtl;
  text-align: right;
}

.grammar-lang {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-style: normal;
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-3);
  margin-bottom: 0.35rem;
}

.grammar-text.rtl .grammar-lang {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72rem;
}

.grammar-fa,
.grammar-ckb {
  font-style: normal;
  font-family: "Newsreader", Georgia, serif;
}

.grammar-body {
  display: block;
}
</parameter>

.meta {
  margin-top: 1.8rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--muted-3);
  text-align: center;
}

.footer {
  margin-top: 1.25rem;
  text-align: center;
}

.footer a {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--muted-4);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: var(--muted-1);
}

@media (max-width: 640px) {
  .screen {
    padding: 2.6rem 1rem 2rem;
  }
  .theme-toggle {
    top: 0.7rem;
    right: 0.7rem;
    font-size: 0.62rem;
  }
  .legend,
  .word-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.9rem;
  }
  .legend {
    padding-bottom: 0.6rem;
  }
  .legend-item {
    font-size: 0.55rem;
  }
  .legend-item.rtl {
    font-size: 0.62rem;
  }
  .word-row {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .cell-fr {
    font-size: 1.25rem;
  }
  .cell-en {
    font-size: 0.9rem;
  }
  .cell-fa,
  .cell-ckb {
    font-size: 1.05rem;
  }
  .grammar-text {
    font-size: 0.92rem;
    line-height: 1.65;
  }
  .grammar-lang {
    font-size: 0.52rem;
  }
}
</parameter>