/* ============================================================
   LIPI · Mithila Script Converter — shared design system
   Vanilla CSS (no framework).

   Linked AFTER each page's inline <style> so its rules take
   precedence and give index.html, chart.html and help.html one
   consistent, professional look. Page-specific UI (editor,
   suggest box, action bar, unicode chart, zoom modal, font
   guide, etc.) stays defined in that page's own <style>.
   ============================================================ */

/* ---------- Font loading ---------- */
@font-face {
  font-family: 'Mithilauni';
  src: url('./fonts/Mithilauni.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+11480-114FF;
}

@font-face {
  font-family: 'Mithilauni';
  src: url('./fonts/Mithilauni.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+11480-114FF;
}

/* ---------- Design tokens ---------- */
:root {
  --primary: #8B1A1A;
  --primary-dark: #5C0F0F;
  --secondary: #D4A017;
  --bg: #FDF6E3;
  --surface: #FFFFFF;
  --text: #2C1810;
  --text-light: #8B7355;
  --border: #C8A96E;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(139,26,26,0.12);
  --font-primary: 'Noto Sans Devanagari', 'Segoe UI', Arial, sans-serif;
  --font-tirhuta: 'Mithilauni', 'Noto Sans Tirhuta', serif !important;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: var(--transition);
}

/* ---------- Header ---------- */
/* Branded crimson headline bar. Theme-aware so it clearly reads as a
   distinct colour in light and dark mode. */
.header {
  background: linear-gradient(135deg, #9a2a2a, #5c0f0f);
  color: #fff;
  padding: 16px 20px;
  text-align: center;
  box-shadow: 0 6px 24px rgba(154, 42, 42, 0.35);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  font-family: var(--font-tirhuta);
  margin: 0 0 4px;
  letter-spacing: normal;
}

.header h1 .highlight {
  color: var(--secondary);
}

.header .subtitle {
  opacity: .9;
  font-size: clamp(.75rem, 1.8vw, .95rem);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.header-actions button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* ---------- Language switcher ---------- */
.lang-switcher {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.lang-btn {
  padding: 5px 15px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 22px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: clamp(.7rem, 1.2vw, .85rem);
  font-weight: 600;
  transition: var(--transition);
  font-family: 'Mithilauni', 'Noto Sans Tirhuta', 'Noto Sans Devanagari', Arial, sans-serif;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.55);
}

.lang-btn.active {
  background: var(--secondary);
  border-color: var(--secondary);
  color: var(--text);
}

/* ---------- Navigation ---------- */
.nav-bar,
.help-nav {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 10px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin: 0;
}

.nav-bar a,
.help-nav a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(.8rem, 1.4vw, .95rem);
  padding: 7px 18px;
  border-radius: 22px;
  transition: var(--transition);
  border: 2px solid transparent;
  font-family: 'Mithilauni', 'Noto Sans Tirhuta', 'Noto Sans Devanagari', Arial, sans-serif;
}

.nav-bar a:hover,
.help-nav a:hover {
  background: var(--bg);
  border-color: var(--border);
}

.nav-bar a.active,
.help-nav a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nav-bar a .icon,
.help-nav a .icon {
  margin-right: 4px;
}

/* ---------- Container & cards ---------- */
.container {
  max-width: 1100px;
  margin: 12px auto;
  padding: 0 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.card h2,
.card h3,
.card h4 {
  color: var(--primary);
  margin: 0 0 8px;
  font-family: 'Mithilauni', 'Noto Sans Tirhuta', 'Noto Sans Devanagari', Arial, sans-serif;
}

.card p {
  margin: 6px 0;
}

/* ---------- Notes / tables / grids ---------- */
.note {
  background: #FFF8E7;
  border-left: 4px solid var(--secondary);
  padding: 11px 14px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  font-size: clamp(.75rem, 1.2vw, .85rem);
}

.note b {
  color: var(--primary);
}

.tablewrap {
  overflow-x: auto;
  margin: 10px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

th,
td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #F5E8C8;
  color: var(--primary);
  font-weight: 700;
}

code {
  background: #F0E8DC;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'Courier New', monospace;
  font-size: .9em;
}

/* ---------- Grid / item / kbd ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  transition: var(--transition);
}

.item:hover {
  border-color: var(--secondary);
  box-shadow: 0 2px 10px rgba(139, 26, 26, 0.1);
}

.kbd {
  font-weight: 700;
  color: var(--primary);
  background: #F0E8DC;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: .85em;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.toolbar a {
  background: var(--surface);
  color: var(--primary);
  padding: 7px 13px;
  border-radius: 22px;
  text-decoration: none;
  border: 1px solid var(--border);
  font-weight: 700;
  transition: var(--transition);
}

.toolbar a:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ---------- Global Tirhuta font selector ---------- */
.global-font-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px auto 0;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.10);
  width: max-content;
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
}

.global-font-control select {
  border: 0;
  border-radius: 16px;
  padding: 5px 10px;
  background: #fff;
  color: var(--text);
  font: 600 .82rem inherit;
  cursor: pointer;
  outline: none;
}

body[data-tirhuta-font="mithilauni"] .tir-font,
body[data-tirhuta-font="mithilauni"] .use-mithilauni,
body[data-tirhuta-font="mithilauni"] .tirhuta-text,
body[data-tirhuta-font="mithilauni"] .tir,
body[data-tirhuta-font="mithilauni"] .tirhuta-cell,
body[data-tirhuta-font="mithilauni"] .char,
body[data-tirhuta-font="mithilauni"] .big-char,
body[data-tirhuta-font="mithilauni"] .tirhuta-font-run {
  font-family: 'Mithilauni' !important;
}

body[data-tirhuta-font="noto"] .noto-font,
body[data-tirhuta-font="noto"] .use-noto-tirhuta,
body[data-tirhuta-font="noto"] .tirhuta-text,
body[data-tirhuta-font="noto"] .tir,
body[data-tirhuta-font="noto"] .tirhuta-cell,
body[data-tirhuta-font="noto"] .char,
body[data-tirhuta-font="noto"] .big-char,
body[data-tirhuta-font="noto"] .tirhuta-font-run {
  font-family: 'Noto Sans Tirhuta' !important;
}

/* ---------- Font run / text base ---------- */
.tirhuta-font-run,
.tirhuta-text,
.tir,
.tirhuta-cell,
.char,
.big-char {
  font-family: var(--tirhuta-font-family) !important;
  font-synthesis: none !important;
  font-style: normal !important;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 18px 16px;
  color: var(--text-light);
  font-size: clamp(.7rem, 1.3vw, .85rem);
  border-top: 1px solid var(--border);
  margin-top: 18px;
  background: var(--surface);
}

.footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.footer .footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.footer .footer-links a:hover {
  color: var(--secondary);
}

.footer .multi-lang {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: .8rem;
}

.footer .multi-lang span {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* ---------- Theme ---------- */
[data-theme="dark"] {
  --bg: #16162a;
  --surface: #16213e;
  --text: #e8e8e8;
  --text-light: #b0a090;
  --border: #3a3a5a;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.55);
}

body[data-theme="dark"] .header {
  background: linear-gradient(135deg, #4a1212, #1f0707);
  box-shadow: 0 6px 24px rgba(74, 18, 18, 0.5);
}  /* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .header-top {
    flex-direction: column;
  }

  .header-actions {
    margin-top: 6px;
  }

  .nav-bar,
  .help-nav {
    padding: 8px 10px;
    gap: 8px;
  }

  .nav-bar a,
  .help-nav a {
    padding: 6px 12px;
    font-size: .82rem;
  }

  .header {
    padding: 14px 12px;
  }

  .container {
    padding: 0 8px;
  }

  .card {
    padding: 14px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    gap: 6px;
  }

  .global-font-control {
    width: 100%;
  }

  .global-font-control select {
    width: 100%;
  }
}


/* ============================================================
   MOBILE-FIRST HEADER REFRESH — compact brand bar + hamburger
   ============================================================ */
.header {
  padding: 12px clamp(14px, 3vw, 28px);
  text-align: left;
  background: linear-gradient(120deg, #7d171b 0%, #4d1016 100%);
  box-shadow: 0 5px 22px rgba(62, 13, 18, .18);
}
.header-top {
  max-width: 1180px;
  margin: 0 auto;
  flex-wrap: nowrap;
  gap: 16px;
}
.header h1 { line-height: 1.25; margin: 0; }
.header .subtitle { max-width: 1180px; margin: 5px auto 0; opacity: .82; }
.header-actions { margin: 0; flex-shrink: 0; }
.header-actions button { width: 40px; height: 40px; }
.mobile-menu-toggle {
  display: none !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 12px !important;
}
.mobile-menu-toggle span {
  width: 19px; height: 2px; display: block; border-radius: 4px;
  background: currentColor; transition: transform .22s ease, opacity .22s ease;
}
.mobile-menu-toggle.is-open span:first-child { transform: translateY(7px) rotate(45deg); }
.mobile-menu-toggle.is-open span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.is-open span:last-child { transform: translateY(-7px) rotate(-45deg); }
.mobile-menu-panel { max-width: 1180px; margin: 0 auto; }
.nav-bar { position: sticky; top: 0; z-index: 90; backdrop-filter: blur(14px); }
@media (max-width: 700px) {
  .header { padding: 10px 14px; position: sticky; top: 0; z-index: 120; }
  .header-top { flex-direction: row; align-items: center; }
  .header h1 { font-size: clamp(1rem, 4.5vw, 1.25rem); max-width: calc(100% - 100px); }
  .header-actions { margin: 0; gap: 8px; }
  .header-actions button { width: 38px; height: 38px; }
  .mobile-menu-toggle { display: flex !important; }
  .header .subtitle { display: none; }
  .mobile-menu-panel {
    display: none; padding: 14px 0 5px; margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,.18);
    animation: menuReveal .18s ease-out;
  }
  .mobile-menu-panel.is-open { display: block; }
  .lang-switcher { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
  .lang-btn { padding: 8px 5px; min-height: 40px; font-size: .78rem; }
  .global-font-control { width: 100%; margin: 10px 0 0; padding: 8px 10px; border-radius: 12px; justify-content: space-between; }
  .global-font-control select { width: auto; max-width: 65%; min-height: 36px; }
  .header:has(.mobile-menu-toggle) ~ .nav-bar {
    display: none; position: sticky; top: 58px; padding: 8px 12px;
    justify-content: stretch; gap: 6px; border-bottom: 1px solid var(--border);
  }
  body.mobile-menu-open .nav-bar { display: flex; }
  .nav-bar a { flex: 1; text-align: center; padding: 8px 5px; font-size: .8rem; }
  .container { margin-top: 12px; padding: 0 12px; }
}
@keyframes menuReveal { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .mobile-menu-panel { animation: none; }
  .mobile-menu-toggle span { transition: none; }
}


/* Keep language selection visible and separate from the hamburger menu */
.language-quick-select {
  max-width: 1180px;
  margin: 10px auto 0;
  justify-content: flex-start;
}
@media (max-width: 700px) {
  .language-quick-select {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin: 9px auto 0;
  }
  .language-quick-select .lang-btn {
    min-height: 40px;
    padding: 8px 5px;
    border-radius: 12px;
    font-size: .8rem;
  }
}


/* Font selection stays visible, separate from the hamburger menu on every page */
.font-quick-select {
  width: min(100% - 28px, 1180px);
  margin: 8px auto 12px;
}
.font-quick-select .global-font-control {
  margin: 0;
  width: fit-content;
  max-width: 100%;
}
@media (max-width: 700px) {
  .font-quick-select {
    width: calc(100% - 24px);
    margin: 8px auto 10px;
  }
  .font-quick-select .global-font-control {
    display: flex;
    width: 100%;
    justify-content: space-between;
    border-radius: 14px;
    padding: 8px 12px;
  }
  .font-quick-select .global-font-control select {
    width: auto;
    max-width: 68%;
    min-height: 36px;
  }
}


/* Unified compact top bar: language + font dropdowns + all-page menu */
.header .header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
}
.header .header-top h1 { flex: 1; min-width: 0; text-align: left; }
.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.header-select {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 4px 9px;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 12px;
  background: rgba(255,255,255,.11);
  color: #fff;
}
.header-select select {
  width: auto;
  max-width: 150px;
  min-height: 28px;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font: 600 .82rem inherit;
  cursor: pointer;
}
.header-select select option { color: #2c1810; background: #fff; }
.header .mobile-menu-toggle {
  display: flex !important;
  width: 38px;
  height: 38px;
  border-radius: 11px !important;
}
.mobile-menu-panel { display: none; }
.mobile-menu-panel.is-open { display: block; }
.mobile-page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1180px;
  margin: 10px auto 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.2);
}
.mobile-page-links a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: .88rem;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 10px;
  background: rgba(255,255,255,.08);
}
.mobile-page-links a:hover { background: rgba(255,255,255,.18); }
@media (max-width: 700px) {
  .header { padding: 9px 10px; }
  .header .header-top { flex-direction: row !important; gap: 7px; align-items: center; }
  .header .header-top h1 { font-size: clamp(.85rem, 3.8vw, 1.1rem); line-height: 1.2; max-width: none; }
  .header-tools { gap: 5px; }
  .header-select { min-height: 35px; gap: 2px; padding: 3px 5px; border-radius: 9px; }
  .header-select > span { font-size: .78rem; }
  .header-select select { max-width: 76px; min-height: 27px; font-size: .7rem; }
  .header-select.font-select select { max-width: 78px; }
  .header .mobile-menu-toggle { width: 34px; height: 35px; min-width: 34px; padding: 0; gap: 4px; }
  .header .mobile-menu-toggle span { width: 17px; }
  .header .subtitle { display: none; }
  .mobile-page-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .mobile-page-links a { text-align: center; padding: 8px 3px; font-size: .72rem; }
  .nav-bar { display: none !important; }
}

/* ============================================================
   POLISHED MOBILE-FIRST CONVERTER REDESIGN
   ============================================================ */
body.converter-page {
  --primary: #941b28;
  --primary-dark: #5c1018;
  --accent: #d9a817;
  --cream: #fff8e8;
  background:
    radial-gradient(ellipse at top, rgba(255,255,255,.96), rgba(255,248,232,.97) 50%, #fff4df 100%);
  color: #381c20;
}
body.converter-page .header {
  position: relative;
  overflow: hidden;
  padding: 18px clamp(14px, 3vw, 34px) 20px;
  text-align: left;
  background: linear-gradient(112deg, #a9202c 0%, #74131e 55%, #4c0d16 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(87,15,24,.18);
}
body.converter-page .header::after {
  content: "𑒞";
  position: absolute; right: 13%; bottom: -48px;
  font-size: 170px; line-height: 1; color: rgba(255,205,104,.075);
  pointer-events: none;
}
body.converter-page .header-top {
  position: relative; z-index: 1;
  max-width: 1240px; gap: 18px;
}
body.converter-page .header h1 {
  margin: 0; font-size: clamp(1.3rem, 3.2vw, 2.25rem);
  line-height: 1.2; letter-spacing: -.025em;
}
body.converter-page .header .highlight { color: #ffd45b; }
body.converter-page .header .subtitle {
  position: relative; z-index: 1;
  max-width: 1240px; margin: 7px auto 0;
  font-size: clamp(.86rem, 1.5vw, 1.08rem); color: rgba(255,255,255,.84);
}
body.converter-page .header-tools { gap: 10px; }
body.converter-page .header-select {
  min-height: 44px; padding: 5px 12px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 14px; background: rgba(255,255,255,.13);
  box-shadow: inset 0 1px rgba(255,255,255,.1);
}
body.converter-page .header-select select {
  max-width: 145px; font-size: .92rem; font-weight: 600;
}
body.converter-page .mobile-menu-toggle {
  width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.12); color: white;
}
body.converter-page .mobile-menu-panel { position: relative; z-index: 3; }
body.converter-page .mobile-page-links {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.18);
}
body.converter-page .nav-bar {
  position: relative; top: auto; z-index: 2;
  max-width: 1240px; margin: 14px auto 0; padding: 8px;
  display: flex; justify-content: space-around; gap: 8px;
  border: 1px solid rgba(125,26,37,.06); border-radius: 22px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 8px 24px rgba(74,28,22,.07);
  backdrop-filter: blur(12px);
}
body.converter-page .nav-bar a {
  flex: 1; justify-content: center; text-align: center;
  border-radius: 15px; padding: 12px 16px; color: #781823;
  font-weight: 700; transition: .18s ease;
}
body.converter-page .nav-bar a.active {
  color: white; background: linear-gradient(135deg, #b71f2d, #78121e);
  box-shadow: 0 4px 12px rgba(126,17,30,.2);
}
body.converter-page .container {
  max-width: 1240px; margin: 22px auto 34px; padding: 0 18px;
}
body.converter-page #seoHeading {
  font-size: clamp(1.35rem, 2.8vw, 2.1rem) !important;
  line-height: 1.25; margin: 0 0 8px !important; letter-spacing: -.02em;
}
body.converter-page .container::before {
  content: attr(data-intro);
  display: block; color: #7c7774; font-size: 1rem;
  margin: 0 0 22px;
}
body.converter-page .card {
  border: 1px solid #f0e4d2; border-radius: 22px;
  background: rgba(255,255,255,.84);
  box-shadow: 0 8px 28px rgba(74,35,20,.06);
  padding: clamp(16px, 2.5vw, 26px);
}
body.converter-page .controls {
  display: grid; grid-template-columns: minmax(0,1fr) 58px minmax(0,1fr);
  align-items: end; gap: 14px;
}
body.converter-page .ctrl-group label {
  display: block; margin-bottom: 8px; color: #7f1a25;
  font-weight: 750; font-size: .94rem;
}
body.converter-page .ctrl-group select {
  min-height: 52px; border: 1.5px solid #e4cf9f;
  border-radius: 14px; background: #fff9eb; color: #43262a;
  padding: 10px 14px; font-size: 1rem; width: 100%;
}
body.converter-page .btn-swap {
  width: 54px; height: 54px; border-radius: 50%;
  color: white; background: linear-gradient(145deg, #e1b62b, #c99208);
  box-shadow: 0 5px 14px rgba(187,137,8,.24); font-size: 1.5rem;
}
body.converter-page .editor-grid {
  display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 20px;
}
body.converter-page .panel {
  overflow: hidden; border: 1px solid #f0d9d8; border-radius: 22px;
  background: #fff; box-shadow: 0 7px 22px rgba(84,24,25,.045);
}
body.converter-page .panel-head {
  min-height: 60px; padding: 14px 18px;
  background: linear-gradient(100deg, #fff0ef, #fff7f0);
  color: #811924; border-bottom: 1px solid #f4dfdd;
  gap: 10px;
}
body.converter-page .panel-head b { font-size: 1.03rem; font-weight: 800; }
body.converter-page .count {
  border-radius: 999px; padding: 6px 11px;
  background: rgba(127,25,36,.08); color: #8a4b4f; font-size: .82rem;
}
body.converter-page #inText, body.converter-page #outText {
  display: block; width: 100%; min-height: 180px;
  padding: 18px 20px; border: 0; border-radius: 0;
  background: #fff; color: #302125; font-size: 1.12rem;
  line-height: 1.65; resize: vertical; box-shadow: none;
}
body.converter-page #inText { min-height: 205px; }
body.converter-page #inText:focus, body.converter-page #outText:focus {
  outline: 2px solid rgba(192,37,50,.18); outline-offset: -3px;
}
body.converter-page #inText::placeholder, body.converter-page #outText::placeholder {
  color: #aaa5a0; opacity: 1;
}
body.converter-page .font-size-slider {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0; padding: 12px 16px; border: 1px solid #f0e4d2;
  border-radius: 15px; background: rgba(255,255,255,.7);
}
body.converter-page .action-bar {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px; margin: 14px 0;
}
body.converter-page .action-bar[style*="grid-template-columns:1fr 1fr 1fr"] {
  grid-template-columns: repeat(3, minmax(0,1fr)) !important;
}
body.converter-page .btn {
  min-height: 46px; border-radius: 13px; padding: 10px 12px;
  font-weight: 750; box-shadow: 0 3px 10px rgba(50,20,20,.05);
}
body.converter-page .btn-primary {
  background: linear-gradient(135deg, #b51f2d, #7c1420);
}
body.converter-page .phonetic-rules, body.converter-page .about-section {
  margin-top: 20px; padding: 20px;
  border: 1px solid #efe2d1; border-radius: 20px;
  background: rgba(255,255,255,.78);
}
body.converter-page .footer { margin-top: 36px; }
@media (min-width: 900px) {
  body.converter-page .editor-grid { grid-template-columns: 1fr 1fr; }
  body.converter-page #inText, body.converter-page #outText { min-height: 300px; }
}
@media (max-width: 700px) {
  body.converter-page .header { padding: 14px 12px 16px; }
  body.converter-page .header-top { flex-wrap: nowrap; gap: 8px; }
  body.converter-page .header h1 { font-size: clamp(.95rem, 4.1vw, 1.28rem); max-width: none; }
  body.converter-page .header-tools { gap: 5px; }
  body.converter-page .header-select { min-height: 36px; padding: 3px 5px; gap: 2px; border-radius: 10px; }
  body.converter-page .header-select > span { font-size: .78rem; }
  body.converter-page .header-select select { max-width: 76px; font-size: .72rem; min-height: 28px; }
  body.converter-page .header-select.font-select select { max-width: 79px; }
  body.converter-page .mobile-menu-toggle { width: 34px; height: 36px; min-width: 34px; }
  body.converter-page .header .subtitle { display: block; font-size: .75rem; margin-top: 8px; }
  body.converter-page .nav-bar { margin: 10px 12px 0; padding: 5px; gap: 4px; border-radius: 17px; }
  body.converter-page .nav-bar a { padding: 10px 3px; font-size: .78rem; }
  body.converter-page .nav-bar a .icon { margin-right: 3px; }
  body.converter-page .container { margin: 18px auto 26px; padding: 0 12px; }
  body.converter-page #seoHeading { font-size: 1.3rem !important; margin-bottom: 6px !important; }
  body.converter-page .container::before { font-size: .86rem; margin-bottom: 16px; }
  body.converter-page .card { padding: 14px; border-radius: 18px; }
  body.converter-page .controls { grid-template-columns: minmax(0,1fr); gap: 12px; }
  body.converter-page .btn-swap { justify-self: center; width: 46px; height: 46px; transform: rotate(90deg); }
  body.converter-page .ctrl-group select { min-height: 48px; }
  body.converter-page .editor-grid { gap: 14px; margin-top: 16px; }
  body.converter-page .panel { border-radius: 17px; }
  body.converter-page .panel-head { min-height: 52px; padding: 11px 13px; }
  body.converter-page .panel-head b { font-size: .88rem; }
  body.converter-page #inText, body.converter-page #outText { min-height: 160px; padding: 15px; font-size: 1rem; }
  body.converter-page #inText { min-height: 185px; }
  body.converter-page .font-size-slider { flex-wrap: wrap; gap: 8px; }
  body.converter-page .action-bar { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  body.converter-page .action-bar[style*="grid-template-columns:1fr 1fr 1fr"] { grid-template-columns: 1fr !important; }
  body.converter-page .btn { min-height: 44px; font-size: .83rem; }
  body.converter-page .phonetic-rules, body.converter-page .about-section { padding: 15px; border-radius: 16px; }
}


/* Refined conversion settings card — compact, clear and touch-friendly */
body.converter-page .container > .card:has(.controls) {
  position: relative;
  padding: 22px;
  margin-top: 18px;
  border: 1px solid rgba(190,160,103,.55);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(255,251,240,.96));
  box-shadow: 0 12px 32px rgba(92,48,28,.075), inset 0 1px 0 #fff;
}
body.converter-page .container > .card:has(.controls)::before {
  content: "⚙️  रूपांतरण सेटिंग्स";
  display: block;
  margin: 0 0 18px;
  color: #781823;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .01em;
}
body.converter-page .controls {
  display: grid;
  grid-template-columns: minmax(0,1fr) 54px minmax(0,1fr);
  align-items: end;
  gap: 14px;
}
body.converter-page .ctrl-group {
  min-width: 0;
}
body.converter-page .ctrl-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  color: #7b2029;
  font-size: .9rem;
  font-weight: 800;
}
body.converter-page .ctrl-group select {
  appearance: none;
  width: 100%;
  min-height: 54px;
  padding: 0 42px 0 15px;
  border: 1.5px solid #d9c18b;
  border-radius: 15px;
  color: #352528;
  font-size: 1rem;
  font-weight: 600;
  background-color: #fffaf0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238b2029' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
body.converter-page .ctrl-group select:focus {
  outline: none;
  border-color: #a52230;
  box-shadow: 0 0 0 4px rgba(165,34,48,.10);
  background-color: #fff;
}
body.converter-page .btn-swap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: end;
  width: 52px;
  height: 52px;
  margin-bottom: 1px;
  border: 0;
  border-radius: 17px;
  color: #4b2c08;
  background: linear-gradient(145deg, #f4cf52, #d9a313);
  box-shadow: 0 6px 15px rgba(182,132,9,.22);
  font-size: 1.55rem;
  transition: transform .18s ease, box-shadow .18s ease;
}
body.converter-page .btn-swap:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 18px rgba(182,132,9,.28);
}
body.converter-page .btn-swap:active { transform: scale(.96); }
@media (max-width: 700px) {
  body.converter-page .container > .card:has(.controls) {
    margin-top: 15px;
    padding: 16px;
    border-radius: 20px;
  }
  body.converter-page .container > .card:has(.controls)::before {
    margin-bottom: 14px;
    font-size: .92rem;
  }
  body.converter-page .controls {
    grid-template-columns: minmax(0,1fr) 46px;
    align-items: end;
    gap: 12px 9px;
  }
  body.converter-page .controls .ctrl-group:first-child { grid-column: 1; }
  body.converter-page .controls .btn-swap {
    grid-column: 2;
    grid-row: 1;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    margin-bottom: 2px;
    font-size: 1.3rem;
  }
  body.converter-page .controls .ctrl-group:last-child {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  body.converter-page .ctrl-group label {
    margin-bottom: 7px;
    font-size: .83rem;
  }
  body.converter-page .ctrl-group select {
    min-height: 48px;
    padding: 0 38px 0 12px;
    border-radius: 13px;
    font-size: .94rem;
    background-position: right 12px center;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.converter-page .ctrl-group select,
  body.converter-page .btn-swap { transition: none; }
}


/* Keep direction, swap, and auto-convert controls on one row on mobile */
@media (max-width: 700px) {
  body.converter-page .controls {
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr) !important;
    align-items: end !important;
    gap: 7px !important;
  }
  body.converter-page .controls .ctrl-group:first-child {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  body.converter-page .controls .btn-swap {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    margin: 0 0 3px !important;
    border-radius: 13px !important;
    transform: none !important;
    font-size: 1.2rem !important;
  }
  body.converter-page .controls .ctrl-group:last-child {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }
  body.converter-page .ctrl-group label {
    font-size: .74rem !important;
    line-height: 1.2;
    min-height: 28px;
    margin-bottom: 6px !important;
    gap: 3px;
  }
  body.converter-page .ctrl-group select {
    min-width: 0 !important;
    width: 100% !important;
    min-height: 44px !important;
    padding: 0 26px 0 8px !important;
    font-size: .78rem !important;
    background-position: right 7px center !important;
    background-size: 14px 14px !important;
    border-radius: 11px !important;
  }
  body.converter-page .container > .card:has(.controls) {
    padding: 12px 9px !important;
  }
  body.converter-page .container > .card:has(.controls)::before {
    font-size: .85rem !important;
    margin-bottom: 12px !important;
  }
}
@media (max-width: 360px) {
  body.converter-page .controls {
    grid-template-columns: minmax(0,1fr) 34px minmax(0,1fr) !important;
    gap: 5px !important;
  }
  body.converter-page .controls .btn-swap {
    width: 33px !important; min-width: 33px !important; height: 36px !important;
  }
  body.converter-page .ctrl-group label { font-size: .68rem !important; }
  body.converter-page .ctrl-group select { font-size: .7rem !important; padding-left: 6px !important; }
}


/* Fix live typing suggestions hidden by the redesigned editor panel */
body.converter-page .panel {
  overflow: visible !important;
  position: relative;
}
body.converter-page .panel:focus-within { z-index: 30; }
body.converter-page .suggest-box {
  position: absolute;
  left: 8px; right: 8px;
  top: calc(100% - 4px);
  z-index: 9999;
  display: none;
  max-height: min(260px, 42vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #d7b6a5;
  border-radius: 14px;
  background: #fffdf8;
  box-shadow: 0 14px 34px rgba(65,20,20,.22);
  color: #351d20;
}
body.converter-page .suggest-box.show { display: block !important; }
body.converter-page .suggest-item {
  min-height: 42px;
  padding: 10px 13px;
  border-bottom: 1px solid #f1e5d8;
  background: #fffdf8;
  color: #351d20;
  cursor: pointer;
}
body.converter-page .suggest-item:hover,
body.converter-page .suggest-item.active { background: #fff1d2; }
@media (max-width: 700px) {
  body.converter-page .editor-grid { gap: 18px; }
  body.converter-page .suggest-box {
    left: 5px; right: 5px;
    max-height: 34vh;
  }
}


/* PWA install control: compact, visible and safe-area aware on phones */
.pwa-install-wrap{position:fixed;z-index:10000;right:max(14px,env(safe-area-inset-right));bottom:max(14px,env(safe-area-inset-bottom));display:flex;flex-direction:column;align-items:flex-end;gap:6px;max-width:calc(100vw - 28px)}
.pwa-install-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:46px;padding:0 17px;border:1px solid rgba(255,255,255,.22);border-radius:999px;color:#fff8e8;background:linear-gradient(135deg,#a8202d,#65121d);box-shadow:0 8px 24px rgba(76,14,23,.27);font:inherit;font-weight:800;cursor:pointer}
.pwa-install-button:hover{transform:translateY(-1px)}
.pwa-install-button:disabled{opacity:.85;cursor:default}
.pwa-install-button.is-installable{outline:3px solid rgba(221,177,48,.4)}
.pwa-status{max-width:min(320px,calc(100vw - 32px));padding:8px 12px;border-radius:12px;color:#392026;background:#fff8e8;box-shadow:0 4px 18px rgba(50,20,20,.14);font-size:.82rem}
.pwa-status:empty{display:none}
@media(max-width:600px){.pwa-install-wrap{right:10px;bottom:max(10px,env(safe-area-inset-bottom))}.pwa-install-button{min-height:43px;padding:0 14px;font-size:.88rem}}


/* Tirhuta glyph coverage hardening across converter, chart and help pages.
   Prefer the bundled font, then use Noto Sans Tirhuta for any missing glyphs. */
@font-face {
  font-family: "Lipi Tirhuta Fallback";
  src: url("./fonts/Mithilauni.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+11480-U+114DF;
}
.tirhuta-font-run,
.tirhuta-text,
.tirhuta-cell,
.tirhuta-output,
.tir,
.char,
.big-char,
.use-mithilauni,
.use-noto-tirhuta,
.noto-font {
  font-family: var(--tirhuta-font-family, "Mithilauni", "Noto Sans Tirhuta", serif) !important;
  font-synthesis: none;
  font-style: normal;
}
html, body {
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}


/* Mobile readability pass: larger text and script samples without horizontal overflow */
@media (max-width: 700px) {
  body { font-size: 17px; }
  body.converter-page #inText,
  body.converter-page #outText { font-size: 1.12rem; line-height: 1.75; }
  body.converter-page .ctrl-group label { font-size: 1rem; }
  body.converter-page .panel-head b { font-size: .98rem; }
  body.converter-page .btn { font-size: .9rem; }
  .help-wrap { font-size: 17px; }
  .help-wrap p, .help-wrap li { font-size: 1rem; line-height: 1.8; }
  .help-wrap .char-btn .tir { font-size: clamp(1.65rem, 6vw, 2rem); line-height: 1.5; }
  .help-wrap .char-btn .dev { font-size: 1.2rem; }
  .help-wrap .char-btn code { font-size: .78rem; }
  .help-wrap .roman-table th { font-size: clamp(.72rem, 2.9vw, .88rem); }
  .help-wrap .roman-table td { font-size: clamp(.8rem, 3vw, .96rem); }
  .help-wrap .roman-table kbd { font-size: clamp(.72rem, 2.8vw, .86rem); }
  .help-wrap .keymap-item .tir { font-size: 1.7rem; }
  .help-wrap .keymap-item .dev { font-size: 1.25rem; }
}
