/* ── Robot Joint Order Check Tool ───────────────────────────────── */
/* Palette follows imchong.github.io (Notion-inspired warm neutrals);
   the site header follows Humanoid_Robot_Learning_Paper_Notebooks. */

:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f7f6f3;
  --border: #e8e8e4;
  --border-strong: #d6d5d0;
  --text: #37352f;
  --text-dim: #6b6b6b;
  --text-faint: #787774;
  --accent: #2d74da;
  --accent-hover: #1a5bb8;
  --accent-weak: #eaf1fc;
  --ok: #2c7a52;
  --ok-bg: #edf6f0;
  --ok-border: #b7ddc6;
  --bad: #c4554d;
  --bad-bg: #fbeeed;
  --bad-border: #eec2be;
  --warn: #9a6b12;
  --warn-bg: #fdf5e7;
  --warn-border: #e8d3a3;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .1);
  --radius: 8px;
  --header-h: 56px;
  --transition: .2s ease;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Noto Sans SC",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Arial, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191919;
  --surface: #222222;
  --surface-2: #2f2f2f;
  --border: #3d3d3d;
  --border-strong: #4e4e4c;
  --text: #e8e8e4;
  --text-dim: #aaa9a5;
  --text-faint: #9b9a97;
  --accent: #5b9cf6;
  --accent-hover: #7ab3ff;
  --accent-weak: #22344d;
  --ok: #6cc48f;
  --ok-bg: #1c2a22;
  --ok-border: #33553f;
  --bad: #e8918a;
  --bad-bg: #2e2220;
  --bad-border: #5c3a36;
  --warn: #d6a55c;
  --warn-bg: #2b2519;
  --warn-border: #56462a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* Author `display` rules outrank the UA's [hidden] rule — keep it authoritative. */
[hidden] { display: none !important; }

/* Scrollbars: transparent track everywhere, so no pale band shows through on
   dark surfaces. scrollbar-* is inherited, covering Firefox from the root. */
:root {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
::-webkit-scrollbar { width: 11px; height: 11px; background: transparent; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }
::-webkit-scrollbar-corner { background: transparent; }

html, body { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

code, pre, .mono { font-family: var(--mono); }

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Site header ── */
.site-header {
  position: sticky; top: 0; z-index: 1200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding-top: env(safe-area-inset-top, 0px);
  transition: background var(--transition), border-color var(--transition);
}
.header-inner {
  min-height: var(--header-h);
  padding-top: 8px; padding-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.site-title {
  display: flex; align-items: center; gap: 11px; min-width: 0;
  color: var(--text); text-decoration: none;
}
.site-mark { width: 28px; height: 28px; color: var(--accent); flex: none; transition: color var(--transition); }
.site-title-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
/* The name is bilingual by design — it reads the same in either language mode,
   so it is not run through i18n. The 中文 half drops once the row gets tight. */
.site-title-text strong { font-size: 1rem; font-weight: 700; }
.site-title-text small {
  font-size: 12px; color: var(--text-faint); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-title:hover { color: var(--accent); text-decoration: none; }
.site-title:hover .site-mark { color: var(--accent-hover); }

.header-right { display: flex; align-items: center; gap: .75rem; flex: none; }

.github-link {
  display: inline-flex; align-items: center; height: 30px; padding: 0 2px;
  font-size: .85rem; color: var(--text-faint); text-decoration: none;
  box-sizing: border-box; transition: color var(--transition);
}
.github-link:hover { color: var(--accent); text-decoration: none; }

.lang-toggle, .theme-toggle {
  flex-shrink: 0; background: none; font: inherit;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0 .6rem; cursor: pointer; line-height: 1; user-select: none;
  min-width: 36px; height: 30px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.lang-toggle { font-size: .78rem; font-weight: 700; }
.theme-toggle { font-size: .85rem; }
.lang-toggle:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Buttons ── */
.btn {
  font: inherit; font-size: 13px; line-height: 1;
  padding: 8px 13px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: background .13s, border-color .13s, color .13s;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-link {
  background: none; border: none; color: var(--accent); padding: 4px 0;
  font-size: 13px; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; background: none; }
.btn-chip {
  font: inherit; font-size: 12.5px; padding: 5px 11px; margin: 0 6px 6px 0;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-dim); cursor: pointer;
}
.btn-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin: 18px 0;
  transition: background var(--transition), border-color var(--transition);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 650; margin: 0 0 4px; }
.card-hint { font-size: 13px; color: var(--text-dim); margin: 0 0 14px; }
.sub { font-size: 13px; font-weight: 650; color: var(--text-dim); margin: 0 0 8px; }
.sub-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
.sub-head .sub { margin: 0; }

/* ── Intro ── */
.intro { margin: 24px 0 6px; }
.intro-title {
  font-size: 21px; line-height: 1.35; font-weight: 700;
  margin: 0 0 10px; letter-spacing: -.01em;
}
.intro-lead, .intro-note { margin: 0 0 13px; font-size: 13.5px; color: var(--text-dim); max-width: 84ch; }
.intro-lead { font-size: 14px; }
.intro-lead b, .intro-note b { color: var(--text); font-weight: 650; }
.intro-lead code, .intro-note code {
  background: rgba(127, 127, 127, .14); padding: 1px 5px; border-radius: 4px; font-size: 12px;
}

.intro-demo {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); overflow: hidden; margin: 0 0 13px;
}
.intro-demo-label {
  display: block; padding: 6px 12px; font-size: 11px; font-weight: 700;
  letter-spacing: .03em; color: var(--text-faint);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.intro-demo pre { margin: 0; padding: 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }
.intro-demo .d-key { color: var(--text-faint); }
.intro-demo .d-hi { color: var(--bad); font-weight: 650; }

.intro-links { margin: 0; font-size: 13px; }

/* ── Dropzone ── */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 30px 20px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text-dim); background: var(--surface-2);
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-over {
  border-color: var(--accent); color: var(--accent); background: var(--accent-weak); outline: none;
}
.dropzone.is-over { border-style: solid; }
.dz-icon { width: 30px; height: 30px; }
.dropzone small { font-size: 12px; color: var(--text-faint); }

.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.samples { font-size: 13px; }
.samples-label { color: var(--text-dim); margin-right: 6px; }

.paste-area { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.paste-area textarea {
  width: 100%; font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  padding: 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); resize: vertical;
}
.paste-area textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.file-meta {
  margin-top: 14px; padding: 10px 13px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-dim);
}
.file-meta b { color: var(--text); font-weight: 600; }

/* ── Messages ── */
.msg {
  border-radius: 10px; padding: 11px 15px; margin: 12px 0; font-size: 13.5px;
  border: 1px solid; display: flex; gap: 9px; align-items: flex-start;
}
.msg-icon { flex: none; font-weight: 700; }
.msg-error { background: var(--bad-bg); border-color: var(--bad-border); color: var(--bad); }
.msg-warn  { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.msg-info  { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }
.msg code { background: rgba(127,127,127,.16); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ── Verdict ── */
.verdict {
  border-radius: var(--radius); padding: 18px 22px; margin: 18px 0;
  border: 1.5px solid; display: flex; gap: 15px; align-items: flex-start;
}
.verdict-mark { font-size: 26px; line-height: 1.1; flex: none; }
.verdict h2 { margin: 0 0 3px; font-size: 17px; font-weight: 700; }
.verdict p { margin: 0; font-size: 13.5px; opacity: .92; }
.verdict-ok   { background: var(--ok-bg);   border-color: var(--ok-border);   color: var(--ok); }
.verdict-bad  { background: var(--bad-bg);  border-color: var(--bad-border);  color: var(--bad); }
.verdict-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.verdict-list { margin: 9px 0 0; padding-left: 19px; font-size: 13px; }
.verdict-list li { margin: 2px 0; }

/* ── Options ── */
.options { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.opt { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
.opt select {
  font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  min-width: 230px;
}
.opt-check { flex-direction: row; align-items: center; gap: 8px; align-self: flex-end; padding-bottom: 8px; }
.opt-check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ── Segmented control ── */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn {
  font: inherit; font-size: 12.5px; padding: 5px 12px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer;
}
.seg-btn.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.09); }
.seg-sm .seg-btn { padding: 4px 9px; font-size: 12px; }

/* ── Tables ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: separate; border-spacing: 0; font-size: 13px; width: 100%; }
.tbl th, .tbl td { padding: 7px 11px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl thead th {
  position: sticky; top: 0; background: var(--surface); z-index: 2;
  font-weight: 650; font-size: 12.5px; border-bottom: 2px solid var(--border-strong); vertical-align: bottom;
}
.tbl tbody tr:hover td { background: var(--surface-2); }
/* Keep the joint / index column visible while scrolling a wide table sideways. */
.tbl th:first-child, .tbl td:first-child {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface); border-right: 1px solid var(--border);
}
.tbl thead th:first-child { z-index: 3; }
.tbl .col-idx { color: var(--text-faint); font-family: var(--mono); font-size: 12px; text-align: right; width: 1%; }
.tbl .col-ref { background: var(--accent-weak); }
.tbl thead th.col-ref { background: var(--accent-weak); }
.tbl-sm { font-size: 12.5px; }
.tbl-sm th, .tbl-sm td { padding: 5px 9px; }

.th-name { display: block; font-weight: 650; }
.th-rule { display: block; font-weight: 400; font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.th-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; margin-top: 5px; letter-spacing: .02em;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-border); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad);  border: 1px solid var(--bad-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-na   { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }

.cell { font-family: var(--mono); font-size: 12.5px; }
.cell-ok  { color: var(--ok); }
.cell-bad { background: var(--bad-bg); color: var(--bad); font-weight: 650; }
.cell-shift { background: var(--warn-bg); color: var(--warn); }
.cell-na  { color: var(--text-faint); background: repeating-linear-gradient(135deg, transparent, transparent 5px, rgba(127,127,127,.09) 5px, rgba(127,127,127,.09) 10px); }
.cell-idx { font-family: var(--mono); }
.cell-fixed { opacity: .62; font-style: italic; }
.delta { font-size: 11px; opacity: .75; margin-left: 5px; }

.legend-swatch {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  vertical-align: -1px; margin: 0 5px 0 14px; border: 1px solid var(--border-strong);
}
.card-hint .legend-swatch:first-child { margin-left: 0; }
.legend-ok    { background: var(--ok-bg);   border-color: var(--ok-border); }
.legend-bad   { background: var(--bad-bg);  border-color: var(--bad-border); }
.legend-shift { background: var(--warn-bg); border-color: var(--warn-border); }
.legend-na  { background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(127,127,127,.3) 4px, rgba(127,127,127,.3) 8px); }

/* ── Code block ── */
.code-block { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 14px; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.code-block pre { margin: 0; padding: 14px; overflow-x: auto; background: var(--surface); font-size: 12.5px; line-height: 1.55; }
.export-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ── Tree / split ── */
/* Stacked, not side by side: a humanoid's tree is deep enough that half the
   width would wrap or scroll every branch line. */
.split { display: flex; flex-direction: column; gap: 22px; }
.split > * { min-width: 0; }
.tree {
  margin: 0; padding: 14px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 12.5px; line-height: 1.65;
  overflow: auto; max-height: 460px;
}
/* Expanded: drop the cap so the whole tree is on the page — a 40-joint humanoid
   runs well past 460px, and reading it inside a scroll box loses the shape.
   overflow stays auto so long branch lines still scroll sideways. */
.tree.is-expanded { max-height: none; }
.tree .t-joint { color: var(--accent); }
.tree .t-fixed { color: var(--text-faint); }
.tree .t-type { color: var(--text-faint); }

/* ── Rules ── */
.rules { display: flex; flex-direction: column; gap: 8px; }
.rule { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.rule > summary {
  cursor: pointer; padding: 11px 15px; font-size: 13.5px; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.rule > summary::-webkit-details-marker { display: none; }
.rule > summary::before { content: "▸"; color: var(--text-faint); font-size: 11px; transition: transform .15s; }
.rule[open] > summary::before { transform: rotate(90deg); }
.rule-key { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); font-weight: 400; }
.rule-body { padding: 0 15px 14px 36px; font-size: 13px; color: var(--text-dim); }
.rule-body p { margin: 0 0 8px; }
.rule-body b { color: var(--text); }
.rule-body a { color: var(--accent); }
.rule-body code { background: rgba(127,127,127,.14); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.rule-verify { margin-top: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.rule-verify-label {
  display: block; padding: 6px 12px; font-size: 11px; font-weight: 700;
  letter-spacing: .03em; color: var(--text-faint);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.rule-verify pre { margin: 0; padding: 11px 12px; overflow-x: auto; font-size: 12px; line-height: 1.55; }
.rule-verify pre code { background: none; padding: 0; font-size: 12px; }

/* Root-node quaternion: same shell as the verify block, plus a colour-coded
   chip so scalar-first and scalar-last are separable at a glance. */
.rule-quat > .rule-verify-label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.rule-quat-note {
  padding: 10px 12px; border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: 12.5px;
}
.rule-quat-note p:last-child, .rule-quat-note ul:last-child { margin-bottom: 0; }
.rule-quat-note ul { margin: 0 0 8px; padding-left: 18px; }
.rule-quat-note li { margin-bottom: 4px; }

.quat-chip {
  margin-left: auto; padding: 2px 8px; border-radius: 999px;
  border: 1px solid transparent; font-family: var(--mono);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.rule-quat .quat-chip { margin-left: 0; }
.quat-wxyz { color: var(--accent); background: var(--accent-weak); border-color: var(--accent-weak); }
.quat-xyzw { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.quat-mixed {
  color: var(--text-faint); background: var(--surface);
  border-color: var(--border-strong); white-space: normal;
}

/* ── Footer ── */
.footer { border-top: 1px solid var(--border); margin-top: 34px; padding: 22px 0 40px; color: var(--text-faint); font-size: 12.5px; }
.footer p { margin: 0 0 6px; }
.footer a { color: var(--accent); }
.footer code { background: rgba(127,127,127,.14); padding: 1px 5px; border-radius: 4px; }
.footer-copyright { margin-top: 14px; }
.footer-copyright a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ── Responsive ── */
@media (max-width: 820px) {
  .site-title-text small { display: none; }
  .site-title-zh { display: none; }
  .opt select { min-width: 0; width: 100%; }
  .opt { width: 100%; }
}
@media (max-width: 600px) {
  /* Title wraps to a second line rather than truncating — the English name is
     too long for a 375px row, and a cut-off name is worse than two lines. Both
     lines still fit the header's min-height, and the toggles stay on the row. */
  .header-inner { flex-wrap: nowrap; gap: .5rem; min-width: 0; }
  .site-title { flex: 1 1 0; min-width: 0; gap: 8px; }
  .site-title-text { min-width: 0; }
  .site-title-text strong { font-size: .95rem; }
  .header-right { flex: 0 0 auto; gap: .35rem; margin-left: auto; }
  .github-link { font-size: .78rem; white-space: nowrap; }
  .lang-toggle, .theme-toggle { min-width: 32px; padding: 0 .45rem; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 14px; }
  .card { padding: 16px 15px; }
  .intro-title { font-size: 18px; }
}
