:root {
  --paper: #f5f1e8;
  --paper-2: #ece6d9;
  --ink: #1e1c18;
  --ink-2: #6f685b;
  --line: rgba(30, 28, 24, .16);
  --red: #b6462c;
  --red-soft: rgba(182, 70, 44, .12);
  --net-bg: #0a0f13;
  --net-card: #111920;
  --net-line: #23313c;
  --net-mut: #7d929f;
  --net-green: #67d7b0;
  color-scheme: light;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------------- compass shell ---------------- */
.shell--compass {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 90% at 50% 0%, #fbf8f0 0%, var(--paper) 48%, #eee8db 100%);
  padding: max(18px, env(safe-area-inset-top)) 24px max(18px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.c-top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 520px; width: 100%; margin: 0 auto;
  padding: 2px 2px 0;
}
.c-brand {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  font-size: 26px; letter-spacing: .08em; font-weight: 600;
}
.c-top time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; color: var(--ink-2); letter-spacing: .08em;
}
.c-main {
  flex: 1; width: 100%; max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 0 0;
}
.c-readout {
  display: flex; align-items: baseline; gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-2); letter-spacing: .04em;
}
.c-readout #c-deg { font-size: 34px; color: var(--ink); font-weight: 300; }
.c-readout #c-dir { font-size: 14px; min-width: 2em; }
.c-dial {
  position: relative;
  width: min(74vw, 330px);
  aspect-ratio: 1;
  margin: 2px 0 6px;
  border-radius: 50%;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.55) 0 56%, transparent 56.4%),
    radial-gradient(circle at 50% 50%, transparent 0 68%, rgba(30,28,24,.04) 68.2%, transparent 69%);
  box-shadow:
    0 0 0 1px rgba(30,28,24,.2),
    0 0 0 10px rgba(30,28,24,.025),
    0 24px 60px -28px rgba(50,42,30,.35);
}
.c-dial:active { cursor: grabbing; }
.c-dial::before, .c-dial::after {
  content: ""; position: absolute; inset: 8%; border-radius: 50%;
  border: 1px solid rgba(30,28,24,.10); pointer-events: none;
}
.c-dial::after { inset: 19%; border-style: dashed; opacity: .55; }
.c-ticks { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.c-ticks .tick {
  position: absolute; inset: 0; pointer-events: none;
  transform: rotate(var(--a));
}
.c-ticks .tick::before {
  content: ""; position: absolute; left: 50%; top: 5.2%;
  width: 1px; height: 7px; margin-left: -.5px;
  background: rgba(30,28,24,.34);
}
.c-ticks .tick.maj::before { height: 12px; width: 1.5px; margin-left: -.75px; background: var(--ink); }
.c-label {
  position: absolute; inset: 0; pointer-events: none;
  transform: rotate(var(--a));
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 12px; color: var(--ink-2); letter-spacing: .08em;
}
.c-label i {
  position: absolute; left: 50%; top: 10.5%; transform: translateX(-50%);
  font-style: normal;
}
.c-label.n i { color: var(--red); font-weight: 700; font-size: 15px; }
.c-needle {
  position: absolute; left: 50%; top: 50%;
  width: 28%; height: 58%;
  transform-origin: 50% 50%;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  transition: transform .12s linear;
  cursor: pointer;
  border: 0; background: transparent; padding: 0;
  z-index: 2;
}
.c-needle::before, .c-needle::after {
  content: ""; position: absolute; left: 50%; width: 20px; margin-left: -10px; height: 50%;
  filter: drop-shadow(0 5px 7px rgba(120,35,20,.18));
}
.c-needle::before {
  top: 0; background: var(--red);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.c-needle::after {
  bottom: 0; background: rgba(30,28,24,.78);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.c-hub {
  position: absolute; left: 50%; top: 50%; width: 17px; height: 17px;
  border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--paper); border: 1px solid var(--ink); z-index: 3;
  box-shadow: 0 0 0 4px rgba(245,241,232,.9);
  pointer-events: none;
}
.c-dial[data-aligned="1"] { box-shadow: 0 0 0 1px rgba(182,70,44,.55), 0 0 0 12px var(--red-soft), 0 24px 60px -28px rgba(50,42,30,.35); }
.c-state {
  margin: 2px 0 0; font-size: 13px; color: var(--ink-2); letter-spacing: .04em;
  min-height: 20px;
}
.c-state.on { color: var(--red); }
.c-hint { margin: 0; font-size: 11.5px; color: rgba(30,28,24,.42); letter-spacing: .04em; }
.c-foot {
  max-width: 520px; width: 100%; margin: 0 auto; padding-top: 8px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; color: rgba(30,28,24,.36); letter-spacing: .08em;
}

/* ---------------- NetCheck shell ---------------- */
.shell--net {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(100% 80% at 50% 0%, #13212a 0%, var(--net-bg) 54%);
  color: #dce8ec;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}
.n-top, .n-foot {
  width: 100%; max-width: 680px; margin: 0 auto;
  display: flex; align-items: baseline; justify-content: space-between;
}
.n-brand { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .12em; color: #e9f2f2; }
.n-sub { font-size: 10px; letter-spacing: .18em; color: var(--net-mut); text-transform: uppercase; }
.n-main { flex: 1; display: grid; place-items: center; padding: 26px 0; }
.n-card {
  width: 100%; max-width: 680px;
  border: 1px solid var(--net-line);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(255,255,255,.035), rgba(255,255,255,.01));
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8), inset 0 1px rgba(255,255,255,.05);
  padding: 22px 22px 18px;
}
.n-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.n-head h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; font-weight: 500; }
.n-head p { margin: 4px 0 0; font-size: 11.5px; color: var(--net-mut); letter-spacing: .02em; }
.n-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; letter-spacing: .06em; color: var(--net-mut);
  border: 1px solid var(--net-line); border-radius: 999px; padding: 4px 9px; white-space: nowrap;
}
.n-pill.on { color: var(--net-green); border-color: rgba(103,215,176,.4); }
.n-run {
  margin: 18px 0 4px; width: 100%; padding: 10px 14px;
  border: 1px solid rgba(103,215,176,.45); border-radius: 9px;
  background: rgba(103,215,176,.09); color: var(--net-green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; letter-spacing: .06em; cursor: pointer;
}
.n-run:hover { background: rgba(103,215,176,.16); }
.n-run:disabled { opacity: .45; cursor: wait; }
.n-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; margin: 18px 0 0; }
.n-grid > div { border-top: 1px solid rgba(35,49,60,.72); padding: 10px 0 9px; min-width: 0; }
.n-grid .n-wide { grid-column: 1 / -1; }
.n-grid dt { font-size: 10px; color: var(--net-mut); letter-spacing: .08em; text-transform: uppercase; }
.n-grid dd {
  margin: 4px 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; color: #d8e7ea; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.n-latency {
  border: 0; padding: 0; background: transparent; color: var(--net-green);
  font-family: inherit; font-size: 26px; line-height: 1.05; cursor: pointer;
  letter-spacing: -.02em;
}
.n-latency small { font-size: 12px; color: var(--net-mut); letter-spacing: .02em; }
.n-log {
  margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--net-line);
  min-height: 52px; max-height: 118px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; line-height: 1.7; color: #718792; white-space: pre-wrap;
}
.n-foot { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; letter-spacing: .08em; color: #4c5f68; }

@media (max-width: 480px) {
  .shell--compass { padding-left: 20px; padding-right: 20px; }
  .c-brand { font-size: 23px; }
  .c-dial { width: min(78vw, 318px); }
  .n-grid { grid-template-columns: 1fr; }
  .n-grid .n-wide { grid-column: auto; }
  .n-card { padding: 18px 16px 14px; border-radius: 14px; }
  .n-head h1 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
