:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --brand: #4338ca;
  --brand-ink: #ffffff;
  --accent: #b45309;
  --focus: #f59e0b;
  --radius: 14px;
  --glyph-font: "Noto Sans Egyptian Hieroglyphs", "Segoe UI Historic", "Noto Sans", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --card: #1c1a17;
    --ink: #f5f5f4;
    --muted: #a8a29e;
    --line: #2f2c28;
    --brand: #818cf8;
    --brand-ink: #12110f;
    --accent: #fbbf24;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 20px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: 14px; }
.nav { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.nav a:hover { color: var(--ink); }

/* page */
main { padding: 24px 0 40px; }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 22px; line-height: 1.3; margin: 32px 0 10px; }
h3 { font-size: 18px; margin: 20px 0 6px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 20px; max-width: 760px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.prose { max-width: 760px; }
.prose li { margin: 4px 0; }

/* controls */
label { font-weight: 600; font-size: 15px; }
textarea, input[type="text"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 76px; resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 12px 0; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  border-radius: 10px; padding: 9px 16px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--brand); }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: transparent; color: var(--muted); padding: 7px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.status { min-height: 1.4em; font-size: 14px; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: middle; }
th { font-size: 14px; color: var(--muted); font-weight: 600; }

/* tool grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tool-card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-decoration: none; color: var(--ink);
}
.tool-card:hover { border-color: var(--brand); }
.tool-card h3 { margin: 8px 0 4px; font-size: 17px; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; }
.glyph-icon { font-family: "Noto Sans Egyptian Hieroglyphs", "Noto Sans Runic", "Segoe UI Historic", sans-serif; font-size: 30px; line-height: 1; color: var(--accent); }
.tool-card .ic { color: var(--accent); width: 30px; height: 30px; }
.text-icon { font: 800 24px/30px ui-monospace, Consolas, monospace; color: var(--accent); letter-spacing: -.02em; }
.related { margin-top: 40px; }
.cat { margin-top: 28px; }
.hero { padding: 16px 0 4px; }

/* FAQ */
details { border-bottom: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 24px 0 16px; font-size: 15px; }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.site-footer h2 { font-size: 15px; margin: 0 0 6px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 4px 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }
.fine { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* script output (hieroglyphs and other alphabets) */
.hg-out {
  font-family: var(--glyph-font); line-height: 1.3; min-height: 1.6em; margin: 14px 0 6px;
  padding: 14px 18px; background: #fbf6e9; color: #1c1917; border-radius: 12px; overflow-x: auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 .35em;
}
.hg-out .hg-word { display: inline-flex; flex-wrap: wrap; align-items: flex-end; }
.hg-out .hg-empty { font: 15px/1.5 system-ui, sans-serif; color: #78716c; }
.hg-out.rtl { flex-direction: row-reverse; }
.hg-out.rtl .hg-word { flex-direction: row-reverse; }
.hg-out.rtl .hg-sign { display: inline-block; transform: scaleX(-1); }
.hg-out.ttb { flex-direction: column; align-items: center; width: max-content; max-width: 100%; }
.hg-out.ttb .hg-word { display: flex; flex-direction: column; align-items: center; white-space: normal; }
.hg-out.cartouche { border: 4px solid #1c1917; border-radius: 999px; position: relative; padding: 14px 28px; overflow: visible; width: fit-content; max-width: calc(100% - 14px); }
.hg-out.cartouche::after { content: ""; position: absolute; background: #1c1917; border-radius: 3px; }
.hg-out.cartouche.ltr { margin-right: 14px; }
.hg-out.cartouche.ltr::after { right: -14px; top: 12%; bottom: 12%; width: 5px; }
.hg-out.cartouche.rtl { margin-left: 14px; }
.hg-out.cartouche.rtl::after { left: -14px; top: 12%; bottom: 12%; width: 5px; }
.hg-out.cartouche.ttb { border-radius: 60px; padding: 24px 14px; margin-bottom: 20px; }
.hg-out.cartouche.ttb::after { bottom: -14px; left: 15%; right: 15%; height: 5px; }
.translit { font-family: ui-monospace, Consolas, monospace; font-size: 14px; color: var(--muted); word-break: break-word; }
.kb { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.kb-key {
  font-family: var(--glyph-font); font-size: 26px; line-height: 1; width: 46px; height: 46px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: #fbf6e9; color: #1c1917;
}
.glyph-cell { font-family: var(--glyph-font); font-size: 30px; line-height: 1.1; }
.rune-out, .rune-cell, .kb-key.rune { font-family: "Noto Sans Runic", "Segoe UI Historic", sans-serif; }
.rune-out { background: #f4efe6; letter-spacing: .08em; white-space: pre-wrap; display: block; }
.rune-cell { font-size: 26px; line-height: 1.1; }
input[type="range"] { width: 160px; accent-color: var(--brand); }

/* pigpen, flags and other drawn symbols */
.pp-out { margin: 14px 0 6px; min-height: 60px; }
.pp-out .hg-empty, .sym-out .hg-empty { display: block; padding: 16px; background: #fbf6e9; border-radius: 12px; color: #78716c; }
.pp-key { color: var(--ink); max-width: 560px; }
.pp-key svg text { font-weight: 600; }
.kb-key.pp-key, .kb-key.sym-key { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.pp-table td { padding: 4px 10px; }
.pp-table svg { color: var(--ink); display: block; }
.sym-out { margin: 14px 0 6px; }
.sym-out svg { display: block; max-width: 100%; height: auto; border-radius: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.out-box { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 2.6em; word-break: break-word; white-space: pre-wrap; }
.steps td, .steps th { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.sm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.sm-cell { margin: 0; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 6px; text-align: center; color: #1c1917; }
.sm-cell svg { width: 100%; height: auto; display: block; }
.sm-cell figcaption { font-weight: 700; font-size: 14px; }
.nf-cell { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.nf-cell svg { width: 100%; height: auto; display: block; }
.nf-cell figcaption { font-size: 13px; color: var(--muted); }
.nf-cell figcaption b { color: var(--ink); font-size: 15px; }
.nf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cz-wheel { max-width: 360px; margin: 0 auto; }
.cz-wheel svg { width: 100%; height: auto; display: block; }
.best { background: color-mix(in srgb, var(--brand) 14%, transparent); }

@media (max-width: 520px) {
  .nav { margin-left: 0; width: 100%; padding-bottom: 8px; }
  .card { padding: 14px; }
  .hg-out { padding: 10px 12px; }
  .hg-out.cartouche { padding: 10px 18px; }
}
