#tool-body {
  --primary: #0f766e;
  --primary-hover: #0d9488;
  --card-bg: #fff;
  --card-border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --well: #0b1f1b;
  --well-ring: rgba(45, 212, 191, 0.22);
  --bubble: #c6e84a;
  --bubble-hi: #f7ffd4;
  --bubble-edge: #7cac18;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}
.theme-dark-mode #tool-body {
  --card-bg: #252528;
  --card-border: #3a3a3e;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
#tool-body .lvl-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
#tool-body .lvl-stage-card {
  padding: 18px 16px 16px;
}
#tool-body .lvl-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
#tool-body .lvl-status-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
#tool-body.is-level .lvl-status-text {
  color: var(--ok);
}
#tool-body.is-locked .lvl-status-text {
  color: var(--warn);
}
#tool-body .lvl-mode-tag {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
#tool-body .lvl-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  grid-template-rows: auto auto;
  gap: 18px 10px;
  align-items: stretch;
  user-select: none;
  -webkit-user-select: none;
}
#tool-body .lvl-dial-wrap {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  justify-content: center;
}
#tool-body .lvl-dial {
  position: relative;
  width: min(68vw, 280px);
  height: min(68vw, 280px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #16352e 0%, var(--well) 68%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    inset 0 10px 24px rgba(0, 0, 0, 0.35),
    0 0 0 6px #0f2a25,
    0 10px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
#tool-body.is-level .lvl-dial {
  box-shadow:
    inset 0 0 0 2px rgba(74, 222, 128, 0.28),
    inset 0 10px 24px rgba(0, 0, 0, 0.35),
    0 0 0 6px #0f2a25,
    0 0 22px rgba(34, 197, 94, 0.28);
}
#tool-body .lvl-ring {
  position: absolute;
  inset: 18%;
  border: 1px solid var(--well-ring);
  border-radius: 50%;
  pointer-events: none;
}
#tool-body .lvl-ring-2 {
  inset: 32%;
}
#tool-body .lvl-cross::before,
#tool-body .lvl-cross::after {
  content: "";
  position: absolute;
  background: rgba(153, 246, 228, 0.28);
  pointer-events: none;
}
#tool-body .lvl-cross::before {
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
}
#tool-body .lvl-cross::after {
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 1px;
}
#tool-body .lvl-target {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22%;
  height: 22%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(198, 232, 74, 0.55);
  border-radius: 50%;
  pointer-events: none;
}
#tool-body.is-level .lvl-target {
  border-color: rgba(74, 222, 128, 0.9);
}
#tool-body .lvl-bubble {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18%;
  height: 18%;
  margin: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bubble-hi), var(--bubble) 46%, var(--bubble-edge) 78%);
  box-shadow: 0 0 16px rgba(198, 232, 74, 0.4), inset 0 -4px 8px rgba(0, 0, 0, 0.12);
  transform: translate(-50%, -50%);
  will-change: transform;
}
#tool-body.is-level .lvl-bubble {
  background: radial-gradient(circle at 35% 30%, #ecfdf5, #4ade80 46%, #15803d 78%);
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.55);
}
#tool-body .lvl-vial {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #1a4a3a 0%, #0d281f 42%, #163d32 100%);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}
#tool-body .lvl-vial::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 55%);
}
#tool-body .lvl-vial-h {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 34px;
  border-radius: 17px;
}
#tool-body .lvl-vial-h::after {
  left: 10%;
  right: 10%;
  top: 3px;
  height: 9px;
  border-radius: 9px;
}
#tool-body .lvl-vial-v {
  grid-column: 2;
  grid-row: 1;
  width: 34px;
  border-radius: 17px;
  justify-self: center;
}
#tool-body .lvl-vial-v::after {
  top: 10%;
  bottom: 50%;
  left: 4px;
  right: 10px;
  width: auto;
  height: auto;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 70%);
}
#tool-body .lvl-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#tool-body .lvl-vial-h .lvl-ticks::before,
#tool-body .lvl-vial-h .lvl-ticks::after {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 2px;
  background: rgba(255, 255, 255, 0.5);
}
#tool-body .lvl-vial-h .lvl-ticks::before { left: calc(50% - 15px); }
#tool-body .lvl-vial-h .lvl-ticks::after { left: calc(50% + 13px); }
#tool-body .lvl-vial-v .lvl-ticks::before,
#tool-body .lvl-vial-v .lvl-ticks::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  height: 2px;
  background: rgba(255, 255, 255, 0.5);
}
#tool-body .lvl-vial-v .lvl-ticks::before { top: calc(50% - 15px); }
#tool-body .lvl-vial-v .lvl-ticks::after { top: calc(50% + 13px); }
#tool-body .lvl-vial-bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bubble-hi), var(--bubble) 50%, var(--bubble-edge));
  box-shadow: 0 0 10px rgba(198, 232, 74, 0.35);
  will-change: transform;
}
#tool-body.is-level .lvl-vial-bubble {
  background: radial-gradient(circle at 35% 30%, #ecfdf5, #4ade80 50%, #15803d);
}
#tool-body .lvl-vial-h .lvl-vial-bubble,
#tool-body .lvl-vial-v .lvl-vial-bubble {
  width: 26px;
  height: 26px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
#tool-body.is-bar .lvl-dial-wrap { display: none; }
#tool-body.is-bar .lvl-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
#tool-body.is-bar .lvl-vial-h {
  width: 100%;
  height: 48px;
  border-radius: 24px;
}
#tool-body.is-bar .lvl-vial-h .lvl-vial-bubble,
#tool-body.is-bar .lvl-vial-v .lvl-vial-bubble {
  width: 36px;
  height: 36px;
}
#tool-body.is-bar .lvl-vial-h .lvl-ticks::before { left: calc(50% - 22px); }
#tool-body.is-bar .lvl-vial-h .lvl-ticks::after { left: calc(50% + 20px); }
#tool-body.is-bar .lvl-vial-v {
  width: 48px;
  height: min(42vh, 240px);
  height: min(42dvh, 240px);
  border-radius: 24px;
}
#tool-body.is-bar .lvl-vial-v .lvl-ticks::before { top: calc(50% - 22px); }
#tool-body.is-bar .lvl-vial-v .lvl-ticks::after { top: calc(50% + 20px); }
#tool-body .lvl-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}
#tool-body .lvl-readouts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
#tool-body .lvl-read {
  text-align: center;
  padding: 10px 4px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card-bg);
}
#tool-body .lvl-read-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
#tool-body .lvl-read-val {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
#tool-body #lvl-dev {
  color: var(--warn);
}
#tool-body.is-level #lvl-dev {
  color: var(--ok);
}
#tool-body .lvl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
#tool-body .lvl-actions .layui-btn {
  flex: 1 1 0;
  min-width: 120px;
  margin: 0;
}
#tool-body .lvl-btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
#tool-body .lvl-btn-primary:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}
#tool-body .lvl-settings {
  margin-top: 12px;
}
#tool-body .lvl-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
}
#tool-body .lvl-set-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
#tool-body .lvl-set-label {
  font-size: 13px;
  color: var(--text);
  flex: 0 0 auto;
}
#tool-body .lvl-set-row .layui-form-radio {
  margin: 0 0 0 6px !important;
}
#tool-body .lvl-view-btns .layui-btn {
  margin: 0;
  border-radius: 0;
}
#tool-body .lvl-banner {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.5;
}
.theme-dark-mode #tool-body .lvl-banner {
  background: #3b2a14;
  color: #fdba74;
}
#tool-body .lvl-overlay {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  min-height: 280px;
}
#tool-body .lvl-main {
  display: none;
}
#tool-body.is-started .lvl-overlay {
  display: none;
}
#tool-body.is-started .lvl-main {
  display: block;
}
#tool-body .lvl-overlay-inner {
  text-align: center;
  max-width: 320px;
}
#tool-body .lvl-overlay-icon {
  width: 72px;
  height: 72px;
  line-height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 32px;
}
#tool-body .lvl-overlay-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
#tool-body .lvl-overlay-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 18px;
}
#tool-body .lvl-overlay-err {
  display: none;
  font-size: 13px;
  color: #dc2626;
  margin: 0 0 12px;
  line-height: 1.6;
}
#tool-body .lvl-calibrated {
  display: none;
  font-size: 12px;
  color: var(--primary);
  margin-left: 4px;
}
#tool-body .lvl-calibrated a,
#tool-body .lvl-cal-clear {
  color: var(--primary);
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
}
@media (max-width: 420px) {
  #tool-body .lvl-read-val { font-size: 17px; }
  #tool-body .lvl-actions .layui-btn { min-width: 0; }
}