/* Letters & Sounds tile chart — dark navy base, language accent from data/menu.json. */
.letter-chart {
  --lc-card: #253352;
  --lc-card2: #2e3d60;
  --lc-text: #F4F6F9;
  --lc-muted: #b4bfcf;
  --lc-mid: #89BDD6;
  --lc-high: #F0B45C;
  --lc-low: #9FD3A8;
  --lc-script: "Noto Sans Thai Looped", "Noto Sans Thai", sans-serif;
  max-width: 820px;
  margin: 0 auto 120px;
  color: var(--lc-text);
}
.letter-chart[data-lang="th"][data-font="loopless"] { --lc-script: "Noto Sans Thai", "Noto Sans Thai Looped", sans-serif; }
.letter-chart[data-lang="hi"] { --lc-script: "Noto Sans Devanagari", sans-serif; }
.letter-chart [lang="th"], .letter-chart [lang="hi"] { font-family: var(--lc-script); }

/* tools */
.lc-tools {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center;
  font-size: 0.92rem; color: var(--lc-muted); margin: 10px 0;
}
.lc-seg { display: inline-flex; align-items: center; gap: 4px; }
.lc-seg-label { margin-right: 4px; }
.lc-seg-btn, .lc-play, .lc-stop, .lc-cards-open {
  background: var(--lc-card); color: var(--lc-text); border: 1px solid #475569;
  border-radius: 999px; padding: 6px 12px; font-size: 0.9rem; cursor: pointer;
}
.lc-seg-btn[aria-pressed="true"] { background: var(--lc-accent); color: #19233D; border-color: var(--lc-accent); font-weight: 700; }
.lc-play { border-color: var(--lc-accent); }
.lc-stop { background: #7f2d2d; border-color: #b45454; }
.lc-tools label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.lc-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.lc-toc a {
  padding: 6px 12px; border: 1px solid #475569; border-radius: 999px;
  color: var(--lc-text); text-decoration: none; font-size: 0.9rem;
}
.lc-legend, .lc-foot { color: var(--lc-muted); font-size: 0.85rem; line-height: 1.6; }

/* sections */
.lc-group { margin: 34px 0 6px; padding-bottom: 6px; border-bottom: 2px solid var(--lc-accent); scroll-margin-top: 70px; }
.lc-section { margin: 22px 0; scroll-margin-top: 70px; }
.lc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lc-head h3 { margin: 0; font-size: 1.15rem; }
.lc-play--sec, .lc-cards-open--sec { padding: 4px 10px; font-size: 0.82rem; }
.lc-sub { margin: 4px 0 10px; color: var(--lc-muted); font-size: 0.9rem; }
.lc-note { margin: 4px 0 10px; font-size: 0.9rem; line-height: 1.6; border-left: 3px solid var(--lc-accent); padding-left: 10px; }
.lc-classes { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 0.88rem; color: var(--lc-muted); }
.lc-key { padding: 2px 10px; border-radius: 999px; border: 2px solid; color: var(--lc-text); }
.lc-key--mid { border-color: var(--lc-mid); }
.lc-key--high { border-color: var(--lc-high); }
.lc-key--low { border-color: var(--lc-low); }

/* tiles */
.lc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.lc-grid--wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.lc-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 92px; padding: 8px 4px; background: var(--lc-card); color: var(--lc-text);
  border: 1px solid #3b4a6b; border-top: 4px solid #3b4a6b; border-radius: 12px; cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.lc-tile:hover, .lc-tile:focus-visible { background: var(--lc-card2); }
.lc-tile:focus-visible { outline: 3px solid var(--lc-accent); outline-offset: 2px; }
.lc-tile:active { transform: scale(0.96); }
.lc-tile.is-playing { background: var(--lc-card2); box-shadow: 0 0 0 3px var(--lc-accent); }
.lc-tile.lc-cls--mid { border-top-color: var(--lc-mid); }
.lc-tile.lc-cls--high { border-top-color: var(--lc-high); }
.lc-tile.lc-cls--low { border-top-color: var(--lc-low); }
.lc-tile--old { opacity: 0.6; }
.lc-ch { font-size: 2.1rem; line-height: 1.5; }
.lc-tile--sent { min-height: 110px; }
.lc-tile--sent .lc-ch { font-size: 1.8rem; }
.lc-sylls { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; }
.lc-syll { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.lc-rom { font-size: 0.9rem; color: var(--lc-accent); font-weight: 700; }
.lc-letters { font-size: 0.85rem; color: var(--lc-muted); text-align: center; }
.lc-tag { font-size: 0.7rem; color: var(--lc-muted); }
.lc-dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--lc-accent); }
.lc-no-rom .lc-rom, .lc-no-rom .lc-r { visibility: hidden; }

/* tones */
.lc-tones { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.lc-tone { font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; background: #1b2640; border: 1px solid #56657f; }
.lc-tone--mid { border-color: #9aa8bf; }
.lc-tone--low { border-color: #7fb3ff; color: #bcd6ff; }
.lc-tone--falling { border-color: #f08a8a; color: #ffc4c4; }
.lc-tone--high { border-color: #f5d06b; color: #ffe7a6; }
.lc-tone--rising { border-color: #8fe0a8; color: #c4f2d1; }
.lc-rules-wrap { overflow-x: auto; }
.lc-rules { border-collapse: collapse; font-size: 0.85rem; min-width: 560px; }
.lc-rules th, .lc-rules td { border: 1px solid #3b4a6b; padding: 6px 8px; text-align: center; }
.lc-rules thead th { background: var(--lc-card); font-weight: 600; }
.lc-rules td.lc-tone { border-radius: 0; background: none; font-size: 0.85rem; }
.lc-rules th.lc-cls--mid { color: var(--lc-mid); }
.lc-rules th.lc-cls--high { color: var(--lc-high); }
.lc-rules th.lc-cls--low { color: var(--lc-low); }

/* detail card (bottom sheet) */
.lc-detail, .lc-cards-box, .lc-card {
  box-sizing: border-box;
}
.lc-detail {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 50;
  width: min(100%, 640px); max-height: 70vh; overflow-y: auto;
  background: #1f2b47; border: 1px solid var(--lc-accent); border-bottom: none;
  border-radius: 18px 18px 0 0; padding: 16px 18px 20px; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
}
.lc-detail[hidden], .lc-cards[hidden] { display: none; }
.lc-close {
  position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--lc-card); color: var(--lc-text); border: 1px solid #475569; font-size: 1.3rem; cursor: pointer;
}
.lc-d-top { display: flex; gap: 16px; align-items: center; padding-right: 40px; }
.lc-d-ch {
  flex: 0 0 auto; min-width: 96px; min-height: 96px; padding: 4px 12px; font-size: 3.4rem; line-height: 1.4;
  background: var(--lc-card); color: var(--lc-text); border: 1px solid #3b4a6b; border-top: 5px solid var(--lc-accent);
  border-radius: 14px; cursor: pointer;
}
.lc-d-ch--sent { font-size: 1.9rem; }
.lc-d-ch.lc-cls--mid { border-top-color: var(--lc-mid); }
.lc-d-ch.lc-cls--high { border-top-color: var(--lc-high); }
.lc-d-ch.lc-cls--low { border-top-color: var(--lc-low); }
.lc-d-ch.is-playing { box-shadow: 0 0 0 3px var(--lc-accent); }
.lc-d-info { display: flex; flex-direction: column; gap: 4px; font-size: 0.95rem; }
.lc-d-name { font-size: 1.15rem; }
.lc-r { color: var(--lc-accent); }
.lc-d-mean { color: var(--lc-muted); }
.lc-d-note { margin: 12px 0 4px; font-size: 0.92rem; line-height: 1.6; border-left: 3px solid var(--lc-accent); padding-left: 10px; }
.lc-d-ex { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lc-d-ex li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--lc-card); border-radius: 10px; padding: 8px 10px; }
.lc-ex-play {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--lc-accent); color: #19233D; font-size: 0.95rem;
}
.lc-ex-play.is-playing { box-shadow: 0 0 0 3px #fff; }
.lc-ex-w { font-size: 1.7rem; line-height: 1.5; }
.lc-ex-w mark { background: none; color: var(--lc-accent); text-decoration: underline; text-underline-offset: 6px; }
.lc-ex-r { font-weight: 700; }
.lc-ex-m { color: var(--lc-muted); font-size: 0.92rem; }

/* flashcards */
.lc-lock { overflow: hidden; }
.lc-cards {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 15, 28, 0.85);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.lc-cards-box { position: relative; width: min(100%, 480px); background: #1f2b47; border-radius: 22px; padding: 16px 16px 22px; }
.lc-cards-head { display: flex; gap: 12px; align-items: center; padding-right: 44px; min-height: 36px; color: var(--lc-accent); font-weight: 700; }
.lc-cards-count { margin-left: auto; color: var(--lc-muted); font-weight: 400; font-size: 0.9rem; }
.lc-card {
  width: 100%; min-height: 280px; margin: 12px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--lc-card); color: var(--lc-text); border: 2px dashed var(--lc-accent); border-radius: 22px; cursor: pointer;
}
.lc-card-ch { font-size: clamp(3rem, 16vw, 5.5rem); line-height: 1.4; visibility: hidden; }
.lc-card-rom { font-size: 1.2rem; color: var(--lc-accent); font-weight: 700; visibility: hidden; text-align: center; padding: 0 10px; }
.lc-card.is-open { border-style: solid; }
.lc-card.is-open .lc-card-ch, .lc-card.is-open .lc-card-rom { visibility: visible; }
.lc-card.is-open .lc-card-hint { display: none; }
.lc-card-hint { color: var(--lc-muted); font-size: 0.9rem; }
.lc-cards-ctrl { display: flex; justify-content: center; gap: 14px; }
.lc-cbtn {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer; font-size: 1.3rem;
  background: var(--lc-card2); color: var(--lc-text);
}
.lc-cbtn--play { background: var(--lc-accent); color: #19233D; }

@media (max-width: 520px) {
  .lc-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
  .lc-grid--wide { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .lc-ch { font-size: 1.8rem; }
  .lc-d-ch { min-width: 80px; min-height: 80px; font-size: 2.8rem; }
}
