:root {
  --ink: #0b2c44;
  --deep: #0b3a5c;
  --accent: #1595d8;
  --aqua: #7ec8e8;
  --card: #ffffff;
  --muted: #5c7285;
  --line: #d4e6f2;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang HK", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: #eef7fc;
}

/* ---------- topbar ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  border: none; background: none; font: inherit; font-size: 17px; font-weight: 800;
  color: var(--deep); cursor: pointer; letter-spacing: 0.5px;
}
nav { display: flex; gap: 4px; }
.nv {
  color: var(--deep); text-decoration: none; font-size: 13.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.nv:hover { background: #e3f2fb; }

/* ---------- 3D stage ---------- */
#stage {
  position: relative;
  height: clamp(320px, 58svh, 520px);
  background: linear-gradient(180deg, #9ed6f2 0%, #6db9e4 45%, #2c7bb8 100%);
  overflow: hidden;
}
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.ov { position: absolute; z-index: 10; }
.ov.row { display: flex; flex-wrap: wrap; gap: 6px; }

#strokeTabs { top: 12px; left: 12px; }
#viewBtns { top: 12px; right: 12px; }

.st, .vb, .pc, .sp {
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.82);
  color: var(--deep);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
}
.st.active { background: var(--deep); border-color: var(--deep); color: #fff; }
.vb.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pc.active { background: #ff7a3d; border-color: #ff7a3d; color: #fff; }
.sp.active { background: #1ca871; border-color: #1ca871; color: #fff; }

#partChips { bottom: 70px; left: 12px; }
#speedBtns { bottom: 70px; right: 12px; }

#phaseLabel {
  position: absolute; z-index: 10;
  bottom: 76px; left: 50%; transform: translateX(-50%);
  background: rgba(11, 44, 68, 0.82); color: #fff;
  padding: 5px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: 1px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}

#playBtn {
  position: absolute; z-index: 10;
  bottom: 14px; left: 14px;
  width: 52px; height: 52px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, 0.92);
  color: var(--deep); font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 20, 40, 0.25);
  display: grid; place-items: center;
  touch-action: manipulation;
}

.scrub {
  position: absolute; z-index: 10;
  bottom: 26px; left: 90px; right: 90px; width: calc(100% - 180px);
  accent-color: var(--deep);
  touch-action: none;
}

#viewerNote {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 8px 0 2px;
}

/* ---------- sections ---------- */
section { max-width: 960px; margin: 0 auto; padding: 40px 20px 24px; }
h2 { font-size: 26px; margin: 0 0 10px; color: var(--deep); letter-spacing: 0.5px; }
h3 { font-size: 20px; margin: 28px 0 10px; color: var(--deep); }
h4 { font-size: 16px; margin: 0 0 8px; color: var(--deep); }
.lead { color: var(--muted); font-size: 15px; line-height: 1.7; margin: 0 0 20px; }

.scard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: 0 4px 18px rgba(11, 58, 92, 0.06);
}
.scard h3 { margin-top: 0; font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.scard h3 span { font-size: 13px; color: var(--muted); font-weight: 500; }

.part-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.pcrd {
  background: #f4fafd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pcrd.hot { border-color: #ff7a3d; box-shadow: 0 0 0 2px rgba(255, 122, 61, 0.35); }
.pcrd ul { margin: 0 0 8px; padding-left: 18px; font-size: 14px; line-height: 1.75; }
.pcrd .err { margin: 0; font-size: 12.5px; color: #b3452a; background: #fdf3ee; border-radius: 8px; padding: 7px 9px; }

/* ---------- guide ---------- */
.cmp-card { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.cmp-card table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 13.5px; }
.cmp-card th {
  background: var(--deep); color: #fff; padding: 10px 12px; text-align: left; font-weight: 700;
}
.cmp-card th small { font-weight: 400; opacity: 0.85; }
.cmp-card td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; line-height: 1.6; }
.cmp-card td:first-child { font-weight: 700; color: var(--deep); background: #f4fafd; white-space: nowrap; }
.cmp-card tr:nth-child(2) td { border-top: 0; }

.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.why-grid article {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
}
.why-grid p { margin: 0; font-size: 14px; line-height: 1.75; color: #33475c; }

footer { max-width: 960px; margin: 0 auto; padding: 18px 20px 40px; color: var(--muted); font-size: 12.5px; }
footer a { color: var(--accent); text-decoration: none; }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  header { padding: 9px 12px; }
  .brand { font-size: 15px; }
  .nv { font-size: 12.5px; padding: 6px 9px; }
  #stage { height: clamp(300px, 52svh, 460px); }
  .st, .pc { font-size: 12px; padding: 6px 11px; }
  /* stack stroke tabs / view buttons so they never overlap on narrow screens */
  #strokeTabs { top: 10px; left: 10px; right: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #strokeTabs::-webkit-scrollbar { display: none; }
  .st { flex: 1 0 auto; }
  #viewBtns { top: 50px; left: 10px; right: 10px; flex-wrap: nowrap; overflow-x: auto; }
  .vb { flex: 1 0 auto; }
  #phaseLabel { bottom: 156px; }
  #partChips { bottom: 110px; left: 12px; right: 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #partChips::-webkit-scrollbar { display: none; }
  .pc { flex: 1 0 auto; }
  #speedBtns { bottom: 62px; right: 12px; }
  #playBtn { width: 48px; height: 48px; bottom: 12px; }
  .scrub { left: 74px; right: 74px; width: calc(100% - 148px); bottom: 22px; }
  section { padding: 30px 14px 18px; }
  h2 { font-size: 22px; }
  .ov.row { gap: 5px; }
}