/* ========================================================================
   Ertius Tables CSS - Conjugation table styles for conjuguer.ertius.org
   Version: 0.1.0
   Extracted from /Users/rob/src/conjuguer2/static/style.css
   ======================================================================== */

/* ========================================================================
   OKLCH Color Overrides (more precise than hex in base.css)
   ======================================================================== */
:root {
  /* Override base colors with OKLCH for perceptual uniformity */
  --color-bg: oklch(100% 0 0);
  --color-text: oklch(27% 0 0);
  --color-text-muted: oklch(48% 0 0);
  --color-text-subtle: oklch(67% 0 0);
  --color-text-faint: oklch(84% 0 0);
  --color-primary: oklch(0% 0 0);
  --color-primary-inverse: oklch(100% 0 0);
  --color-border: var(--color-primary);
  --color-bg-hover: oklch(94% 0 0);
  --color-bg-subtle: oklch(97% 0 0);

  /* Match highlighting colors - 24 light tints for background grouping
     Ordered to maximize visual distinction between consecutive colors:
     - Alternating complementary hues (0°, 180°, 90°, 270°, etc.)
     - Alternating lightness (88% darker, 96% lighter) for additional distinction
     Chroma 0.15-0.18 for visible saturation, hues spaced 60°+ apart */
  --match-a: oklch(88% 0.15 0); /* red - dark */
  --match-b: oklch(94% 0.18 180); /* cyan - light */
  --match-c: oklch(88% 0.15 60); /* orange - dark */
  --match-d: oklch(94% 0.18 300); /* magenta - light */
  --match-e: oklch(88% 0.15 120); /* green - dark */
  --match-f: oklch(94% 0.18 30); /* peach - light */
  --match-g: oklch(88% 0.15 240); /* blue - dark */
  --match-h: oklch(94% 0.18 90); /* yellow - light */
  --match-i: oklch(88% 0.15 330); /* pink - dark */
  --match-j: oklch(94% 0.18 150); /* mint - light */
  --match-k: oklch(88% 0.15 210); /* teal - dark */
  --match-l: oklch(94% 0.18 270); /* violet - light */
  --match-m: oklch(88% 0.15 45); /* gold - dark */
  --match-n: oklch(94% 0.18 225); /* sky - light */
  --match-o: oklch(88% 0.15 165); /* seafoam - dark */
  --match-p: oklch(94% 0.18 345); /* rose - light */
  --match-q: oklch(88% 0.15 285); /* purple - dark */
  --match-r: oklch(94% 0.18 105); /* lime - light */
  --match-s: oklch(88% 0.15 15); /* coral - dark */
  --match-t: oklch(94% 0.18 195); /* aqua - light */
  --match-u: oklch(88% 0.15 75); /* amber - dark */
  --match-v: oklch(94% 0.18 255); /* indigo - light */
  --match-w: oklch(88% 0.15 135); /* spring - dark */
  --match-x: oklch(94% 0.18 315); /* fuchsia - light */

  /* Stem coloring - perceptually equal brightness */
  --stem-green: oklch(50% 0.16 145);
  --stem-blue: oklch(50% 0.16 250);
  --stem-red: oklch(50% 0.18 27);

  /* Stem category backgrounds - pale tints for light mode */
  --stem-base-bg: oklch(95% 0.05 240); /* pale blue */
  --stem-grave-bg: oklch(95% 0.06 30); /* pale red-orange */
  --stem-softc-bg: oklch(95% 0.06 290); /* pale magenta */
  --stem-modified-bg: oklch(95% 0.05 60); /* pale amber */
  --stem-future-bg: oklch(95% 0.05 140); /* pale green */

  /* Stem underline colors */
  --stem-base-underline: oklch(50% 0.2 240); /* bright blue */
  --stem-grave-underline: oklch(55% 0.25 25); /* bright red */
  --stem-softc-underline: oklch(55% 0.22 290); /* bright magenta */
  --stem-modified-underline: oklch(55% 0.2 60); /* bright orange */
  --stem-future-underline: oklch(50% 0.18 140); /* bright green */

  /* Font sizes for tables */
  --font-size-base: 14px;
  --font-size-small: 0.85rem;
  --font-size-smaller: 0.8rem;
  --font-size-tiny: 0.75rem;
  --font-size-h1: 1.5rem;
  --font-size-mobile: 11px;
  --font-size-mobile-ipa: 9px;

  /* Cell padding */
  --cell-padding: 0.25rem 0.5rem;
  --cell-padding-mobile: 0.2rem 0.3rem;

  /* Additional spacing */
  --space-xs: 0.15rem;
}

/* Override base font size for conjugation site */
body {
  font-size: var(--font-size-base);
  line-height: 1.4;
  max-width: 100%;
  padding: 0;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-sm);
}

h1 {
  text-align: center;
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-h1);
}

/* ========================================================================
   Dark Mode Toggle Button
   ======================================================================== */
/* Conjugate button - subtle outlined style */
.conjugate-button {
  background: transparent;
  border: 1px solid var(--color-border);
}

.conjugate-button:hover {
  background: var(--color-bg-hover);
}

.conjugate-button:focus-visible {
  outline: 2px solid var(--color-border);
  outline-offset: 2px;
}

form header .theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5em;
  background: transparent;
  border: none;
  border-left: 5px solid var(--color-border);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

form header .theme-toggle:hover {
  opacity: 1;
}

form header .theme-toggle:focus-visible {
  outline: 2px solid var(--color-border);
  outline-offset: -2px;
}

form header .theme-toggle svg {
  display: block;
}

/* Show sun in dark mode, moon in light mode */
:root .theme-icon-dark {
  display: none;
}

:root.dark .theme-icon-light {
  display: none;
}

:root.dark .theme-icon-dark {
  display: inline;
}

/* ========================================================================
   Header Override for Search Form (form wraps header and main)
   ======================================================================== */
form {
  display: block;
}

form header {
  max-width: calc(900px - 2 * var(--space-lg));
  margin: var(--space-md) auto var(--space-md);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
  border: 5px solid var(--color-border);
}

form header .search-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
}

form header input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 0.5em;
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
}

form header button {
  border: none;
  border-left: 5px solid var(--color-border);
  border-right: 5px solid var(--color-border);
  border-radius: 0;
  background: none;
  padding: 0.5em;
  font-weight: bold;
  margin: 0;
  white-space: nowrap;
}

form header button:hover {
  background: var(--color-border);
  color: var(--color-bg);
}

form header .checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-sm);
  margin: 0 0 0 auto;
  padding: 0 var(--space-sm);
  border: none;
  min-width: 0; /* Reset fieldset default min-width: min-content */
}

/* ========================================================================
   Definition & Supporting Info
   ======================================================================== */
.definition {
  text-align: center;
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-sm);
}

.definition .sep {
  color: var(--color-text-subtle);
  margin: 0 var(--space-sm);
  font-style: normal;
}

.verb-type {
  font-style: normal;
  font-size: var(--font-size-small);
}

.def-lang-toggle {
  display: inline-block;
  padding: 0 var(--space-xs);
  margin-left: var(--space-sm);
  font-size: var(--font-size-tiny);
  font-style: normal;
  font-weight: bold;
  border: 1px solid var(--color-border-light);
  border-radius: 2px;
  background: var(--color-bg-lightest);
  color: var(--color-text-muted);
  cursor: pointer;
  vertical-align: middle;
}

.def-lang-toggle:hover {
  background: var(--color-border-light);
  color: var(--color-text);
}

/* ========================================================================
   Checkboxes (now in header)
   ======================================================================== */
.checkbox {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  white-space: nowrap;
}

.checkbox input[type="checkbox"] {
  cursor: pointer;
}

.checkbox input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-border);
  outline-offset: 2px;
}

.checkbox:has(input:disabled) {
  color: var(--color-text-subtle);
  cursor: not-allowed;
  text-decoration: line-through;
}

.checkbox:has(input:disabled) input {
  cursor: not-allowed;
}

/* ========================================================================
   Autocomplete Suggestions
   ======================================================================== */
.search-wrapper {
  position: relative;
  display: inline-block;
  flex: 1;
  min-width: 80px;
}

.search-wrapper input {
  width: 100%;
  padding-right: 1.75rem;
}

.clear-input {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--color-text-subtle);
  cursor: pointer;
  padding: 0 0.25rem;
}

.clear-input:hover {
  color: var(--color-text);
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}

.suggestions:empty {
  display: none;
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.suggestion-list li {
  padding-left: 0;
}

.suggestion-list li::before {
  content: none;
}

.suggestion-list li button {
  width: 100%;
  padding: 0.35rem var(--space-md);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

.suggestion-list li button:hover,
.suggestion-list li button:focus,
.suggestion-list li button.active {
  background: var(--color-bg-hover);
}

/* ========================================================================
   Single Match Indicator
   ======================================================================== */
.single-match {
  display: flex;
  align-items: center;
  padding: 0.35rem var(--space-md);
}

.single-match .match-check {
  color: var(--color-text-subtle);
  margin-right: var(--space-sm);
}

.single-match button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.single-match button:hover {
  text-decoration: underline;
}

/* ========================================================================
   Disambiguation Panel
   ======================================================================== */
.disambiguation {
  padding: var(--space-md);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.disambiguation p {
  margin: 0 0 var(--space-sm) 0;
}

.disambiguation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: var(--space-md);
}

.disambiguation-list li::before {
  content: none;
}

.disambiguation-list a {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-text);
}

.disambiguation-list a:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-text);
}

/* ========================================================================
   Conjugation Tables
   ======================================================================== */
.conjugation-tables {
  display: grid;
  gap: var(--space-xs);
}

.conjugation-tables table {
  border-collapse: collapse;
  width: 100%;
  border: 1px solid var(--color-border);
  table-layout: fixed;
}

.conjugation-tables .col-person {
  width: 6ch;
}

.conjugation-tables caption {
  text-align: left;
  font-weight: bold;
  padding: 0.3rem var(--space-md);
  border: 1px solid var(--color-border);
  border-bottom: none;
  background: var(--color-primary);
  color: var(--color-primary-inverse);
}

.conjugation-tables th,
.conjugation-tables td {
  border: 1px solid var(--color-border);
  padding: 0.2rem 0.4rem;
  text-align: left;
}

.conjugation-tables th {
  background: var(--color-bg-hover);
  font-weight: bold;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.conjugation-tables td:first-child {
  font-weight: bold;
  background: var(--color-bg-subtle);
  white-space: nowrap;
}

/* ========================================================================
   Stacked Pronouns (il/elle and ils/elles)
   ======================================================================== */
.pronoun-stack {
  display: flex;
  flex-direction: column;
  font-size: 0.8em;
  line-height: 1.1;
}

/* ========================================================================
   Auxiliary Toggle
   ======================================================================== */
.auxiliary-toggle {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  padding: var(--space-xs) 0.4rem;
  border-radius: 3px;
  transition: background 0.15s;
}

.auxiliary-toggle:hover {
  background: var(--color-bg-hover);
}

.auxiliary-toggle .aux-option {
  color: var(--color-text-subtle);
  transition: color 0.15s;
}

.auxiliary-toggle .aux-option.active {
  font-weight: bold;
  color: var(--color-text);
}

.auxiliary-toggle .aux-separator {
  color: var(--color-text-faint);
  margin: 0 var(--space-xs);
}

.auxiliary-label {
  padding: var(--space-xs) 0.4rem;
}

/* ========================================================================
   Verb Info Panel (aux, participles, stems)
   ======================================================================== */
.verb-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs) var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-xs);
  background: var(--color-bg-subtle);
  align-items: baseline;
  font-size: var(--font-size-small);
}

.verb-info__item {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
}

.verb-info__item--passe .verb-info__value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-xs);
}

.verb-info__item--stems {
  flex-basis: 100%;
  justify-content: center;
}

.verb-info__item--semi-aux {
  flex-basis: 100%;
  padding-top: var(--space-sm);
}

.verb-info__label {
  font-weight: bold;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.verb-info__value {
  white-space: nowrap;
}

.verb-info__empty {
  color: var(--color-text-subtle);
}

.verb-info__irregular {
  color: var(--color-text-subtle);
  font-style: italic;
}

.verb-info .sep {
  color: var(--color-text-subtle);
  margin: 0 var(--space-xs);
}

.verb-info .masc,
.verb-info .fem {
  display: inline;
}

.verb-info .form-with-ipa {
  display: inline-flex;
  gap: var(--space-sm);
}

/* ========================================================================
   Semi-auxiliary Info
   ======================================================================== */
.semi-aux-info {
  flex: 0 0 100%;
  width: 100%;
  border-top: 1px dashed var(--color-text-subtle);
  padding-top: var(--space-sm);
  margin-top: var(--space-sm);
  display: flex;
  align-items: baseline;
}

.semi-aux-forms {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
}

.semi-aux-sep {
  display: none;
}

.semi-aux-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: baseline;
  flex: 1;
}

.semi-aux-construction {
  font-weight: bold;
}

.semi-aux-meaning {
  font-style: italic;
  color: var(--color-text-muted);
}

.semi-aux-notes {
  color: var(--color-text-subtle);
  font-size: var(--font-size-small);
}

.semi-aux-link {
  font-size: var(--font-size-small);
  color: var(--color-text-subtle);
  text-decoration: none;
  margin-left: auto;
}

.semi-aux-link:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* ========================================================================
   Stem/Suffix Coloring
   ======================================================================== */
.stem-green {
  color: var(--stem-green);
}
.stem-blue {
  color: var(--stem-blue);
}
.stem-red {
  color: var(--stem-red);
}

/* Stem category highlighting (colored underlines with pale backgrounds) */
.stem-base,
.stem-grave,
.stem-softc,
.stem-modified,
.stem-future {
  border-radius: 2px;
}
.stem-base {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--stem-base-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  background: var(--stem-base-bg);
}
.stem-grave {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--stem-grave-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  background: var(--stem-grave-bg);
}
.stem-softc {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--stem-softc-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  background: var(--stem-softc-bg);
}
.stem-modified {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--stem-modified-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  background: var(--stem-modified-bg);
}
.stem-future {
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--stem-future-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  background: var(--stem-future-bg);
}

/* ========================================================================
   Searched Form Highlight
   ======================================================================== */
.searched-form {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* ========================================================================
   Matching Spellings - 24 colors (consolidated using --match-color)
   ======================================================================== */
/* Base styles applied via --match-color custom property */
.match-a,
.match-b,
.match-c,
.match-d,
.match-e,
.match-f,
.match-g,
.match-h,
.match-i,
.match-j,
.match-k,
.match-l,
.match-m,
.match-n,
.match-o,
.match-p,
.match-q,
.match-r,
.match-s,
.match-t,
.match-u,
.match-v,
.match-w,
.match-x {
  background: var(--match-color);
}

/* IPA matching - box-shadow extends highlight to cell edge */
.ipa-match-a,
.ipa-match-b,
.ipa-match-c,
.ipa-match-d,
.ipa-match-e,
.ipa-match-f,
.ipa-match-g,
.ipa-match-h,
.ipa-match-i,
.ipa-match-j,
.ipa-match-k,
.ipa-match-l,
.ipa-match-m,
.ipa-match-n,
.ipa-match-o,
.ipa-match-p,
.ipa-match-q,
.ipa-match-r,
.ipa-match-s,
.ipa-match-t,
.ipa-match-u,
.ipa-match-v,
.ipa-match-w,
.ipa-match-x {
  background: var(--match-color);
  box-shadow:
    0.5rem 0 0 var(--match-color),
    -0.2rem 0 0 var(--match-color);
}

/* Color assignments */
.match-a,
.ipa-match-a {
  --match-color: var(--match-a);
}
.match-b,
.ipa-match-b {
  --match-color: var(--match-b);
}
.match-c,
.ipa-match-c {
  --match-color: var(--match-c);
}
.match-d,
.ipa-match-d {
  --match-color: var(--match-d);
}
.match-e,
.ipa-match-e {
  --match-color: var(--match-e);
}
.match-f,
.ipa-match-f {
  --match-color: var(--match-f);
}
.match-g,
.ipa-match-g {
  --match-color: var(--match-g);
}
.match-h,
.ipa-match-h {
  --match-color: var(--match-h);
}
.match-i,
.ipa-match-i {
  --match-color: var(--match-i);
}
.match-j,
.ipa-match-j {
  --match-color: var(--match-j);
}
.match-k,
.ipa-match-k {
  --match-color: var(--match-k);
}
.match-l,
.ipa-match-l {
  --match-color: var(--match-l);
}
.match-m,
.ipa-match-m {
  --match-color: var(--match-m);
}
.match-n,
.ipa-match-n {
  --match-color: var(--match-n);
}
.match-o,
.ipa-match-o {
  --match-color: var(--match-o);
}
.match-p,
.ipa-match-p {
  --match-color: var(--match-p);
}
.match-q,
.ipa-match-q {
  --match-color: var(--match-q);
}
.match-r,
.ipa-match-r {
  --match-color: var(--match-r);
}
.match-s,
.ipa-match-s {
  --match-color: var(--match-s);
}
.match-t,
.ipa-match-t {
  --match-color: var(--match-t);
}
.match-u,
.ipa-match-u {
  --match-color: var(--match-u);
}
.match-v,
.ipa-match-v {
  --match-color: var(--match-v);
}
.match-w,
.ipa-match-w {
  --match-color: var(--match-w);
}
.match-x,
.ipa-match-x {
  --match-color: var(--match-x);
}

/* ========================================================================
   IPA Pronunciation
   ======================================================================== */
.form-with-ipa {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
}

.form-with-ipa .ipa {
  font-size: var(--font-size-smaller);
  color: var(--color-text-muted);
  text-align: right;
}

/* ========================================================================
   Colour Palette Page
   ======================================================================== */
.colour-tables {
  display: flex;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

.colour-table-container {
  flex: 1;
  min-width: 280px;
}

.colour-table-container h2 {
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
}

.colour-table-desc {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.colour-table {
  width: 100%;
  border-collapse: collapse;
}

.colour-table th,
.colour-table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-text-faint);
}

.colour-table th {
  font-weight: 600;
  font-size: var(--font-size-small);
}

.colour-table code {
  font-family: inherit;
  background: var(--color-bg-subtle);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

.colour-swatch {
  display: inline-block;
  width: 2rem;
  height: 1.2rem;
  vertical-align: middle;
  border-radius: 2px;
}

.colour-swatch-ipa {
  display: inline-block;
  width: 2rem;
  height: 1.2rem;
  vertical-align: middle;
  border-radius: 2px;
  margin-left: var(--space-xs);
}

/* ========================================================================
   Footer Override
   ======================================================================== */
footer {
  text-align: center;
  padding: var(--space-md) var(--space-md);
  margin: var(--space-md) auto 0;
  max-width: calc(900px - 2 * var(--space-lg));
  font-size: var(--font-size-tiny);
  color: var(--color-text-subtle);
  border-top: 1px solid var(--color-border);
}

footer p {
  margin: 0;
}

footer .attribution {
  margin-top: var(--space-xs);
}

footer a {
  color: inherit;
  text-decoration: underline;
}

/* ========================================================================
   IPA Help Button
   ======================================================================== */
.ipa-help-btn {
  font-family: inherit;
  font-size: var(--font-size-small);
  width: 1.5em;
  height: 1.5em;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  margin-left: calc(-1 * var(--space-sm));
}

.ipa-help-btn:hover {
  background: var(--color-primary);
  color: var(--color-primary-inverse);
}

/* ========================================================================
   IPA Chart Dialog
   ======================================================================== */
.ipa-chart-dialog {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0;
  max-width: 90vw;
  max-height: 85vh;
  width: 700px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.ipa-chart-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.ipa-chart-content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.ipa-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-primary);
  color: var(--color-primary-inverse);
  border-radius: 7px 7px 0 0;
}

.ipa-chart-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.ipa-chart-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--space-sm);
  opacity: 0.8;
}

.ipa-chart-close:hover {
  opacity: 1;
}

.ipa-chart-body {
  padding: var(--space-lg);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.ipa-section h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-small);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.ipa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-small);
}

.ipa-table th,
.ipa-table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-text-faint);
}

.ipa-table th {
  font-weight: 600;
  color: var(--color-text-muted);
}

.ipa-table td:first-child {
  font-size: 1.1em;
  font-weight: 500;
}

.ipa-table b {
  color: var(--stem-blue);
}

/* ========================================================================
   Mobile Responsive
   ======================================================================== */
@media (max-width: 500px) {
  /* Prevent horizontal overflow */
  html,
  body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
  }

  /* Reduce horizontal padding on mobile */
  main {
    padding: 0 var(--space-sm) var(--space-sm);
    max-width: 100%;
  }

  form {
    max-width: 100%;
    margin: 0;
  }

  /* Form header adjustments - reduce border and constrain width */
  form header {
    flex-wrap: wrap;
    gap: var(--space-sm);
    width: 100%;
    max-width: 100%;
    border: 2px solid var(--color-border);
    padding: 0.25em;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }

  /* Search input: share row with button on mobile */
  form header .search-wrapper {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  form header .search-wrapper input {
    width: 100%;
    box-sizing: border-box;
  }

  /* Make submit button an arrow icon on mobile */
  form button[type="submit"] {
    flex: 0 0 auto;
    min-width: 0;
    font-size: 0;
    padding: 0.5em;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  form button[type="submit"]::before {
    content: "→";
    font-size: 1.5rem;
    line-height: 1;
  }

  /* Theme toggle: adjust border for mobile row context */
  form header .theme-toggle {
    flex: 0 0 auto;
    border-left: 2px solid var(--color-border);
    border-right: none;
  }

  /* Wrap checkboxes to their own row on mobile */
  form header .checkboxes {
    order: 10; /* Move to end */
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    border-top: 2px solid var(--color-border);
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-xs) var(--space-xs);
    font-size: var(--font-size-small);
  }

  /* Verb info: stack vertically on mobile */
  .verb-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-xs) var(--space-sm);
  }

  .verb-info__item--passe,
  .verb-info__item--stems {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-xs) var(--space-sm);
  }

  .verb-info__item--semi-aux {
    grid-column: 1 / -1;
  }

  .verb-info__value {
    white-space: normal;
  }

  /* Ensure all major containers respect viewport width */
  .disambiguation,
  .conjugation-tables,
  .suggestions {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Smaller table text and padding */
  .conjugation-tables {
    font-size: var(--font-size-mobile);
    overflow-x: auto;
    width: 100%;
  }

  .conjugation-tables table {
    table-layout: auto;
    max-width: 100%;
  }

  .conjugation-tables caption,
  .conjugation-tables th,
  .conjugation-tables td {
    font-size: var(--font-size-mobile);
    padding: var(--cell-padding-mobile);
  }

  .conjugation-tables th {
    word-break: break-word;
    hyphens: auto;
    min-width: 3em;
  }

  .conjugation-tables td {
    white-space: nowrap;
  }

  .conjugation-tables .ipa {
    font-size: var(--font-size-mobile-ipa);
  }

  /* Stack IPA below conjugation */
  .form-with-ipa {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .form-with-ipa .ipa {
    text-align: left;
  }

  /* Semi-auxiliary: ensure full width and horizontal flow */
  .semi-aux-info {
    width: 100%;
  }

  .semi-aux-forms {
    width: 100%;
  }

  .semi-aux-form {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  /* IPA dialog: single column */
  .ipa-chart-dialog {
    width: 95vw;
    max-height: 90vh;
  }

  .ipa-chart-body {
    grid-template-columns: 1fr;
    padding: var(--space-md);
  }

  .ipa-chart-header {
    padding: var(--space-sm) var(--space-md);
  }
}

/* Very narrow screens (smaller phones) */
@media (max-width: 380px) {
  /* Smaller checkbox labels */
  .checkbox {
    font-size: var(--font-size-small);
  }
}

/* ========================================================================
   Dark Mode
   ======================================================================== */
:root.dark {
  /* Base colors - warm dark theme */
  --color-bg: oklch(18% 0.005 30); /* #1c1917 warm dark */
  --color-text: oklch(91% 0.005 30); /* #e7e5e4 warm light */
  --color-text-muted: oklch(64% 0.008 30); /* #a8a29e warm medium */
  --color-text-subtle: oklch(50% 0.01 30); /* #78716c warm darker */
  --color-text-faint: oklch(37% 0.01 30); /* #57534e warm very dark */
  --color-primary: oklch(91% 0.005 30); /* light for dark mode */
  --color-primary-inverse: oklch(18% 0.005 30);
  --color-border: oklch(30% 0.008 30); /* #44403c warm medium-dark */
  --color-bg-hover: oklch(22% 0.005 30); /* #292524 slightly lighter */
  --color-bg-subtle: oklch(22% 0.005 30); /* for boxes */

  /* Links - light blue for visibility */
  --color-link: oklch(75% 0.12 240); /* #93c5fd light blue */
  --color-link-hover: oklch(70% 0.15 240); /* #60a5fa brighter blue */

  /* Status colors - brighter for dark mode */
  --color-success: oklch(65% 0.2 145); /* bright green */

  /* Match highlighting colors - dark mode (inverted lightness, same hues) */
  --match-a: oklch(30% 0.15 0); /* red */
  --match-b: oklch(24% 0.18 180); /* cyan */
  --match-c: oklch(30% 0.15 60); /* orange */
  --match-d: oklch(24% 0.18 300); /* magenta */
  --match-e: oklch(30% 0.15 120); /* green */
  --match-f: oklch(24% 0.18 30); /* peach */
  --match-g: oklch(30% 0.15 240); /* blue */
  --match-h: oklch(24% 0.18 90); /* yellow */
  --match-i: oklch(30% 0.15 330); /* pink */
  --match-j: oklch(24% 0.18 150); /* mint */
  --match-k: oklch(30% 0.15 210); /* teal */
  --match-l: oklch(24% 0.18 270); /* violet */
  --match-m: oklch(30% 0.15 45); /* gold */
  --match-n: oklch(24% 0.18 225); /* sky */
  --match-o: oklch(30% 0.15 165); /* seafoam */
  --match-p: oklch(24% 0.18 345); /* rose */
  --match-q: oklch(30% 0.15 285); /* purple */
  --match-r: oklch(24% 0.18 105); /* lime */
  --match-s: oklch(30% 0.15 15); /* coral */
  --match-t: oklch(24% 0.18 195); /* aqua */
  --match-u: oklch(30% 0.15 75); /* amber */
  --match-v: oklch(24% 0.18 255); /* indigo */
  --match-w: oklch(30% 0.15 135); /* spring */
  --match-x: oklch(24% 0.18 315); /* fuchsia */

  /* Stem coloring - adjusted for dark mode */
  --stem-green: oklch(60% 0.18 145);
  --stem-blue: oklch(60% 0.18 250);
  --stem-red: oklch(60% 0.2 27);

  /* Stem category backgrounds - darker tints for dark mode */
  --stem-base-bg: oklch(30% 0.12 240); /* dark blue */
  --stem-grave-bg: oklch(30% 0.14 25); /* dark red */
  --stem-softc-bg: oklch(30% 0.14 290); /* dark magenta */
  --stem-modified-bg: oklch(30% 0.12 60); /* dark orange */
  --stem-future-bg: oklch(30% 0.12 140); /* dark green */

  /* Stem underline colors - brighter for visibility on dark backgrounds */
  --stem-base-underline: oklch(70% 0.22 240); /* bright blue */
  --stem-grave-underline: oklch(75% 0.26 25); /* bright red */
  --stem-softc-underline: oklch(70% 0.24 290); /* bright magenta */
  --stem-modified-underline: oklch(70% 0.22 60); /* bright orange */
  --stem-future-underline: oklch(70% 0.2 140); /* bright green */
}

/* Table headers - invert for dark mode */
:root.dark .conjugation-tables caption {
  background: oklch(91% 0.005 30); /* light background */
  color: oklch(18% 0.005 30); /* dark text */
}

/* Form inputs - dark mode styling */
:root.dark input[type="text"],
:root.dark input[type="search"] {
  background: oklch(22% 0.005 30);
  color: oklch(91% 0.005 30);
  border-color: oklch(30% 0.008 30);
}

:root.dark input[type="text"]::placeholder,
:root.dark input[type="search"]::placeholder {
  color: oklch(50% 0.01 30);
}

/* Button hover states - invert */
:root.dark button:hover {
  background: oklch(91% 0.005 30);
  color: oklch(18% 0.005 30);
}

/* =============================================================================
   Collapsible pattern info (stem-irregular conjugation patterns)
   ============================================================================= */

.pattern-info {
  margin: var(--space-xs) 0;
  padding: var(--space-sm);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 0;
}

.pattern-info__summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  font-size: var(--font-size-base);
}

.pattern-info__summary:hover {
  color: var(--color-text-muted);
}

/* Hide default disclosure triangle */
.pattern-info__summary::-webkit-details-marker {
  display: none;
}

.pattern-info__icon {
  display: inline-block;
  width: 0.75em;
  font-size: 0.75em;
  transition: transform 0.2s ease;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.pattern-info[open] .pattern-info__icon {
  transform: rotate(90deg);
}

.pattern-info__preview {
  color: var(--color-text-muted);
  font-weight: normal;
  font-size: var(--font-size-small);
  flex: 1;
  margin-left: var(--space-sm);
}

.pattern-info[open] .pattern-info__preview {
  display: none;
}

.pattern-info__content {
  padding-top: var(--space-sm);
}

/* =============================================================================
   Stem display with tenses (verb info box)
   ============================================================================= */

.stem-with-tenses {
  display: inline;
}

.stem-value {
  font-weight: 500;
}

.stem-tenses {
  color: var(--color-text-muted);
  font-size: 0.9em;
  margin-left: 0.2em;
}

/* =============================================================================
   Stem list (pattern explanation)
   ============================================================================= */

.pattern-explanation__stems {
  margin: var(--space-sm) 0;
  font-size: var(--font-size-small);
}

.stem-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin: var(--space-xs) 0 0 0;
  padding: 0;
}

.stem-list dt,
.stem-list dd {
  margin: 0;
  padding: 0;
}

.stem-list__item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25em;
  padding: 0.2em 0.6em;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: var(--font-size-small);
}

.stem-list__label {
  color: var(--color-text-muted);
  font-size: 0.85em;
}

.stem-list__label::after {
  content: ":";
}

.stem-list__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  margin: 0;
}
/* =============================================================================
   Participle regularity indicators
   ============================================================================= */

.participle-method {
  font-size: 0.85em;
  color: var(--color-text-muted);
  font-style: italic;
  margin-left: 0.25em;
}

.participle-irregular {
  font-size: 0.9em;
  font-weight: 500;
  color: oklch(50% 0.12 40); /* muted orange text */
  margin-left: 0.25em;
  display: inline-block;
  vertical-align: 0.1em;
  cursor: help;
  user-select: none;
}

.participle-irregular:hover,
.participle-irregular:focus {
  color: oklch(45% 0.15 40); /* slightly darker on hover/focus */
  outline: none;
}

.accessible-tooltip {
  position: fixed;
  /* left and top will be set via <style> element with CSP nonce */
  background: oklch(20% 0.02 40);
  color: oklch(98% 0.01 40);
  padding: 0.5em 0.75em;
  border-radius: 0.375em;
  font-size: 0.875rem;
  max-width: 250px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  line-height: 1.4;
}
