/* Nihao Kit v2.0 - self-hosted, zero external font/image requests */
:root {
  --navy: #123b63;
  --navy-2: #1c5286;
  --navy-deep: #0b2640;
  --teal: #17a986;
  --teal-dark: #0e7a60;
  --mint: #4bd6b0;
  --ink: #14202e;
  --muted: #526375;
  --line: #d7e2ec;
  --pale: #f3f7fb;
  --white: #fff;
  --amber: #8c5a00;
  --amber-bg: #fff6dc;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(18, 59, 99, .05), 0 4px 12px rgba(18, 59, 99, .04);
  --shadow-md: 0 4px 16px rgba(18, 59, 99, .08), 0 10px 28px rgba(18, 59, 99, .06);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--pale);
  color: var(--ink);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Keep the footer at the bottom of the viewport on short pages (404). */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }
a { color: var(--navy-2); text-underline-offset: 2px; }
a:hover { color: var(--teal-dark); }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 22px; }

/* Keyboard navigation: visible focus everywhere, including the skip link. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
.site-header a:focus-visible, .site-footer a:focus-visible, .skip-link:focus-visible { outline-color: var(--mint); }
main:focus { outline: none; }
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 20;
  background: #fff; color: var(--navy); padding: 9px 14px;
  border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 12px; }

.site-header {
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding-top: 15px; padding-bottom: 15px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.brand:hover { color: #fff; }
.brand-mark { width: 32px; height: 32px; flex: 0 0 32px; display: block; }
.site-nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 16px; }
.site-nav a { color: #d9e8f5; text-decoration: none; font-size: 14px; font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; transition: color .15s ease, border-color .15s ease; }
.site-nav a:hover { color: #fff; border-bottom-color: rgba(75, 214, 176, .45); }
.site-nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--mint); font-weight: 600; }

/* Language switcher: only rendered once 2+ locales pass the i18n gate. */
.lang-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 12.5px; color: #d9e8f5; }
.lang-switch > span { opacity: .82; }
.lang-switch a { color: #d9e8f5; text-decoration: none; padding: 3px 10px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.lang-switch a:hover { color: #fff; border-color: var(--mint); background: rgba(75, 214, 176, .12); }
.lang-switch a[aria-current="true"] { color: var(--navy-deep); background: var(--mint); border-color: var(--mint); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* RTL groundwork for the planned Arabic edition. */
html[dir="rtl"] .wrap, html[dir="rtl"] .site-nav, html[dir="rtl"] .footer-links, html[dir="rtl"] .lang-switch { direction: rtl; }
html[dir="rtl"] .site-nav { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .site-footer .disclaimer { border-left: 0; border-right: 3px solid var(--mint); }

.hero {
  background:
    radial-gradient(ellipse 65% 80% at 88% 12%, rgba(75, 214, 176, .22), transparent 62%),
    radial-gradient(ellipse 50% 60% at 15% 95%, rgba(23, 169, 134, .18), transparent 60%),
    linear-gradient(155deg, #123b63 0%, #174c7c 58%, #156d82 100%);
  color: #fff;
  padding: 58px 0 52px;
  margin: 0 0 38px;
  border-bottom: 3px solid rgba(75, 214, 176, .35);
}
.hero h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.15; margin: 0 0 16px; letter-spacing: -0.03em; font-weight: 800; }
.hero p { max-width: 700px; margin: 0; color: #e2effa; font-size: 17px; line-height: 1.65; }
.hero .kicker {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11.5px;
  color: var(--mint);
  background: rgba(75, 214, 176, .14);
  border: 1px solid rgba(75, 214, 176, .32);
  padding: 4px 12px;
  border-radius: 999px;
  margin: 0 0 16px;
  font-weight: 700;
}

main { padding: 36px 0 60px; }
main:has(> .hero) { padding-top: 0; }
section { margin-bottom: 40px; }
h1 { font-size: clamp(26px, 4vw, 34px); color: var(--navy); margin: 0 0 10px; letter-spacing: -0.025em; line-height: 1.22; }
h2 { font-size: 24px; color: var(--navy); margin: 0 0 10px; letter-spacing: -0.02em; }
h3 { font-size: 17px; color: var(--navy); margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 22px; font-size: 16px; max-width: 760px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.card:hover { border-color: #9ec5df; transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card p { color: var(--muted); margin: 0 0 16px; font-size: 14px; flex: 1 0 auto; }
.card .btn { align-self: flex-start; margin-top: auto; }
.card h2 { font-size: 17px; color: var(--navy); margin: 0 0 6px; }
.card .tagline {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--teal-dark);
  background: #e6f7f2;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 12px;
}
:lang(zh-Hant) .card .tagline, :lang(ja) .card .tagline, :lang(ko) .card .tagline { text-transform: none; letter-spacing: 0; font-size: 12px; }
.see-all { margin: 16px 0 0; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  min-height: 40px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, transform .12s ease, border-color .15s ease;
}
.btn:hover { background: var(--navy-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.secondary:hover { background: #eef4fa; border-color: #b4cbe0; color: var(--navy); }
.btn-sm { padding: 6px 13px; min-height: 34px; font-size: 13px; border-radius: 8px; }

.notice {
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  font-size: 14px;
  margin: 0 0 20px;
  border: 1px solid #d4e3f1;
  border-left: 4px solid var(--navy-2);
  background: #edf4fb;
}
.notice.warn { background: var(--amber-bg); border-color: #f0d794; border-left-color: #d49b00; color: #5c4000; }
.notice.method { background: #eaf7f3; border-color: #bfe8dc; border-left-color: var(--teal); color: #114338; }
.notice small { display: block; margin-top: 5px; opacity: .85; }
.notice a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.translation-draft { margin: 0 0 24px; padding: 12px 16px; font-size: 13px; border: 1px dashed #d9a400; border-left-width: 4px; }
.translation-draft strong { font-weight: 600; }
.translation-draft a { font-weight: 700; white-space: nowrap; }

/* Traditional Chinese needs its own system stack; no webfont is fetched. */
html[lang^="zh"] body, html[lang^="zh"] button, html[lang^="zh"] input, html[lang^="zh"] select {
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", "Source Han Sans TC", system-ui, sans-serif;
}
html[lang^="zh"] .hero h1, html[lang^="zh"] h1, html[lang^="zh"] h2, html[lang^="zh"] h3 { letter-spacing: 0; }

/* Japanese and Korean system font stacks (still zero webfonts). */
html[lang^="ja"] body, html[lang^="ja"] button, html[lang^="ja"] input, html[lang^="ja"] select {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", system-ui, sans-serif;
}
html[lang^="ko"] body, html[lang^="ko"] button, html[lang^="ko"] input, html[lang^="ko"] select {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", system-ui, sans-serif;
}
html[lang^="ja"] .hero h1, html[lang^="ko"] .hero h1,
html[lang^="ja"] h1, html[lang^="ja"] h2, html[lang^="ja"] h3,
html[lang^="ko"] h1, html[lang^="ko"] h2, html[lang^="ko"] h3 { letter-spacing: 0; }
html[lang^="ko"] { word-break: keep-all; }

html[lang^="ru"] .hero h1, html[lang^="ru"] h1, html[lang^="ru"] h2, html[lang^="ru"] h3 { letter-spacing: 0; hyphens: auto; }
html[lang^="de"] .hero h1, html[lang^="de"] h1, html[lang^="de"] h2, html[lang^="de"] h3, html[lang^="de"] .card h2 { letter-spacing: 0; hyphens: auto; }

.share-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 0; }

.tool-layout { display: grid; grid-template-columns: minmax(270px, 355px) 1fr; gap: 24px; align-items: start; }
.tool-col { min-width: 0; }
@media (min-width: 781px) {
  .tool-col:first-child { position: sticky; top: 18px; }
}
.panel-label { font-size: 14px; font-weight: 700; letter-spacing: 0; color: var(--navy); margin: 0 0 8px; }
.label-note { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 18px 0 0; }
@media (max-width: 780px) { .tool-layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 700; color: var(--navy); margin-bottom: 10px; font-size: 14px; }
label.field { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
label.field span { display: block; font-weight: 600; color: var(--navy); font-size: 13px; margin-bottom: 5px; }
input[type="number"], input[type="text"], input[type="search"], select {
  width: 100%;
  padding: 10px 12px;
  min-height: 42px;
  border: 1px solid #c9d7e5;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="number"]:focus, input[type="text"]:focus, input[type="search"]:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 169, 134, .14);
}
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; font-size: 14px; font-weight: 400; cursor: pointer; line-height: 1.45; }
.check input { margin-top: 3px; width: 17px; height: 17px; flex: 0 0 17px; accent-color: var(--teal); }

.result-empty { color: var(--muted); font-size: 14px; padding: 20px 0; }
.result-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: #fff;
  transition: border-color .15s ease;
}
.result-item:hover { border-color: #b4cce1; }
.result-item h3 { margin: 0 0 6px; font-size: 16px; color: var(--navy); display: flex; align-items: center; }
.result-item p { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.replaces-line { font-size: 12.5px; color: var(--navy); background: #f2f7fc; padding: 6px 10px; border-radius: 8px; margin: 8px 0; }
.tip-box {
  font-size: 13px;
  color: #173a4c;
  background: #f1faf7;
  border-left: 3px solid var(--teal);
  border-radius: 0 8px 8px 0;
  padding: 9px 12px;
  margin: 8px 0 10px;
  line-height: 1.55;
}
.channel-box {
  background: #f2f7fc;
  border: 1px solid #d2e2f2;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px 0 16px;
}
.channel-box h3 { margin: 0 0 8px; font-size: 15px; color: var(--navy); }
.route-snapshot {
  background: #f2f8fb;
  border: 1px solid #cde2ee;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 16px;
}
.route-snapshot > strong { display: block; font-size: 16px; color: var(--navy); margin-bottom: 6px; }
.route-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13.5px; color: var(--ink); margin-bottom: 6px; }
.route-snapshot .small { margin: 0; }

/* Show-to-local Chinese communication cards */
.phrase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 12px; }
.phrase-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(18, 59, 99, .04);
}
.phrase-card-custom {
  border: 2px solid var(--teal);
  background: #f2fbf8;
  margin-bottom: 14px;
}
.phrase-card-emergency {
  border-color: #e6c675;
  background: #fffcf2;
}
.phrase-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.phrase-head h3 { margin: 0; font-size: 15px; color: var(--navy); }
.phrase-head .pills { margin: 0; }
.phrase-note { margin: 0; }
.phrase-zh {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--navy-deep);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  word-break: break-word;
}
.phrase-pinyin { margin: 0; font-size: 12.5px; color: var(--muted); }
.phrase-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }

/* Full-screen high-contrast modal for showing directly to locals */
.card-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 38, 64, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.card-modal[hidden] { display: none; }
.card-modal-inner {
  background: #fff;
  color: var(--navy-deep);
  border-radius: 20px;
  max-width: 780px;
  width: 100%;
  padding: 28px 30px 36px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
}
.card-modal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.card-modal-label { margin: 0; font-size: 15px; font-weight: 700; color: var(--muted); }
.card-modal-zh {
  margin: 0 0 18px;
  font-size: clamp(32px, 7.5vw, 60px);
  line-height: 1.32;
  font-weight: 800;
  color: var(--navy-deep);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  word-break: break-word;
}
.card-modal-pinyin { margin: 0; font-size: clamp(15px, 2.4vw, 20px); color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.pill { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; background: #edf3f9; color: var(--navy); }
.pill.req { background: #e3f6ef; color: #0c6c52; }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.urgent { background: #fcecc2; color: #754700; border: 1px solid #e6bf5c; }
.pill.official { background: #eaeefc; color: #313d8c; }
.result-item a { font-size: 13px; font-weight: 600; }
.rank { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; border-radius: 8px; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; margin-right: 9px; flex: 0 0 26px; }
.score { font-size: 22px; font-weight: 800; color: var(--teal-dark); }
.score-bar { display: block; width: 100%; height: 8px; border-radius: 6px; background: #e4edf5; margin: 8px 0 16px; }
.score-bar rect { fill: var(--teal); }
ul.clean { margin: 0 0 14px; padding-left: 20px; font-size: 14px; }
ul.clean li { margin-bottom: 7px; }
ul.preset-list { list-style: none; padding-left: 0; }
ul.preset-list li { border-left: 3px solid var(--teal); padding-left: 12px; margin-bottom: 7px; }

.table-scroll { overflow-x: auto; margin-bottom: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table th, .data-table td { white-space: nowrap; }
.data-table td.wrap { white-space: normal; min-width: 190px; }
.data-table th { background: #eef4fa; color: var(--navy); font-weight: 700; }
.data-table caption { text-align: left; }

.site-footer { background: var(--navy-deep); color: #cbdcec; padding: 34px 0; font-size: 13px; }
.site-footer .disclaimer { background: rgba(255,255,255,.07); border-left: 3px solid var(--mint); padding: 14px 18px; border-radius: 10px; margin: 0 0 18px; line-height: 1.6; }
.site-footer strong { color: #fff; }
.site-footer a { color: var(--mint); }
.site-footer .affiliate-disclosure { color: #cbdcec; border-top: 1px solid rgba(255,255,255,.16); padding-top: 10px; margin: 0 0 14px; line-height: 1.55; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px 18px; margin-bottom: 12px; }
.small { font-size: 12.5px; color: var(--muted); }
.site-footer .small { color: #a9c2da; }
.legal-original { opacity: .82; border-left: 2px solid var(--line); padding-left: 10px; margin-top: 8px; }
.legal-original-label { font-weight: 700; color: var(--mint); }
code { background: #eaf0f7; padding: 2px 6px; border-radius: 5px; font-size: 12px; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .site-header .wrap { gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .brand { font-size: 17px; }
  .site-nav { margin-left: 0; width: 100%; gap: 14px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .site-nav a { white-space: nowrap; font-size: 13.5px; }
  .hero { padding: 40px 0 34px; }
  .hero h1 { font-size: clamp(26px, 7vw, 34px); }
  .hero p { font-size: 15px; }
  .hero .kicker { font-size: 11px; letter-spacing: .07em; margin-bottom: 12px; }
  main { padding: 24px 0 42px; }
  section { margin-bottom: 30px; }
  h2 { font-size: 21px; }
  .grid, .phrase-grid { grid-template-columns: 1fr; }
  .card, .panel { padding: 18px; }
  .card-modal-inner { padding: 20px 18px 26px; }
  .footer-links { gap: 10px 14px; }
  .share-row { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .btn, .site-nav a, .lang-switch a, .result-item { transition: none; }
  .card:hover, .btn:active { transform: none; }
}
