/* Minimal, clean UI. No external fonts. */
:root{
  --bg: #0b1220;
  --card: #0f1b33;
  --card2: #0c172d;
  --text: #e7eefc;
  --muted: #a9b7d3;
  --line: rgba(255,255,255,.10);
  --btn: rgba(255,255,255,.10);
  --btn2: rgba(255,255,255,.16);
  --good: #2dd4bf;
  --bad: #fb7185;
  --warn: #fbbf24;
  --primary: #60a5fa;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  background: radial-gradient(1200px 700px at 20% 0%, #12264f 0%, var(--bg) 55%, #050a14 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar{
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(255,255,255,.06), rgba(255,255,255,.02));
}

.brand{ display:flex; gap:12px; align-items:center; }
.dot{
  width: 12px; height: 12px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(96,165,250,.12);
}
.title{ font-weight: 700; letter-spacing:.2px; }
.subtitle{ color: var(--muted); font-size: 13px; margin-top: 2px; }
.status{ display:flex; gap:10px; align-items:center; }

.pill{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  font-variant-numeric: tabular-nums;
}

.layout{
  display:grid;
  grid-template-columns: minmax(520px, 1.45fr) minmax(320px, 1fr);
  gap: 14px;
  padding: 14px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow:hidden;
}

.stage{ padding: 14px; }
.stageHead{
  display:flex;
  justify-content: space-between;
  align-items:flex-end;
  gap:12px;
  padding: 6px 4px 10px;
}
.kicker{ color: var(--muted); font-size: 12px; }
.stageTitle{ font-size: 16px; font-weight: 700; margin-top: 4px; }

.mini{
  background: rgba(0,0,0,.18);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  min-width: 170px;
}
.miniLabel{ color: var(--muted); font-size: 12px; }
.miniValue{ margin-top: 4px; font-weight: 700; }

.canvasWrap{
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow:hidden;
  background: rgba(0,0,0,.18);
}

#toothSvg{ width: 100%; height: auto; display:block; }

.controlsRow{
  display:flex;
  gap:12px;
  justify-content: space-between;
  align-items:center;
  margin-top: 12px;
  padding: 0 4px 2px;
}

.rotation .label{ color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.rotBtns{ display:flex; align-items:center; gap:10px; }
.rotValue{
  min-width: 56px;
  text-align:center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  font-variant-numeric: tabular-nums;
}

.btn{
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  user-select:none;
}
.btn:hover{ background: var(--btn2); }
.btn:disabled{
  opacity: .55;
  cursor: not-allowed;
}
.btn.primary{
  background: rgba(96,165,250,.18);
  border-color: rgba(96,165,250,.35);
}
.btn.primary:hover{ background: rgba(96,165,250,.26); }
.btn.ghost{
  background: transparent;
}

.panel{ padding: 14px; }
.panelHead{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap:10px;
  padding: 6px 4px 10px;
}
.panelTitle{ font-size: 16px; font-weight: 800; }
.stepPill{
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.stepBox{
  border: 1px solid var(--line);
  background: rgba(0,0,0,.20);
  border-radius: 16px;
  padding: 12px;
}
.stepName{ font-weight: 800; font-size: 15px; }
.stepDesc{ margin-top: 6px; color: var(--muted); line-height: 1.5; }
.stepRule{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255,255,255,.14);
  color: rgba(231,238,252,.92);
  font-size: 13px;
  line-height: 1.6;
}

.toolGrid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.toolBtn{
  text-align:left;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.18);
}
.toolBtn:hover{ background: rgba(0,0,0,.28); }
.toolBtn.active{
  outline: 2px solid rgba(96,165,250,.45);
  background: rgba(96,165,250,.12);
}

/* Ensure tool buttons render readable text across browsers (some UAs default button text to black). */
.toolBtn{ color: var(--text); }
.toolBtn .toolName{ color: var(--text); }
.toolBtn .toolHint{ color: var(--muted); }

.toolName{ font-weight: 800; }
.toolHint{ color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.3; }

.feedback{
  margin-top: 12px;
  border-radius: 16px;
  overflow:hidden;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.20);
}
.feedbackHead{
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}
.feedbackBody{
  padding: 10px 12px;
  color: rgba(231,238,252,.92);
  line-height: 1.55;
  min-height: 76px;
}

.footerActions{
  display:flex;
  gap:10px;
  margin-top: 12px;
  padding: 0 4px 2px;
  flex-wrap: wrap;
}

/* SVG styling */
.bg{ fill: rgba(0,0,0,.06); }
.tooth{ fill: rgba(255,255,255,.90); stroke: rgba(255,255,255,.25); stroke-width: 2; }
.zone{ fill: rgba(251,191,36,.20); stroke: rgba(251,191,36,.55); stroke-width: 2; }
.zoneText{ fill: rgba(251,191,36,.9); font-size: 16px; font-weight: 800; }
.paint{ fill: rgba(45,212,191,.22); stroke: rgba(45,212,191,.55); stroke-width: 2; }
.bracket{ fill: rgba(255,255,255,.88); stroke: rgba(96,165,250,.55); stroke-width: 2; }
.slot{ fill: rgba(15,23,42,.85); }
.dot2{ fill: rgba(96,165,250,.95); }
.target{ fill: none; stroke: rgba(96,165,250,.45); stroke-width: 2; stroke-dasharray: 6 5; }
.flash{ fill: none; stroke: rgba(251,113,133,.70); stroke-width: 3; stroke-linecap: round; }
.svgToast{ fill: rgba(231,238,252,.92); font-size: 14px; }
.hidden{ display:none; }

/* Dialog */
dialog{
  border: none;
  padding: 0;
  background: transparent;
}
dialog::backdrop{
  background: rgba(0,0,0,.55);
}
.dialogCard{
  width: min(680px, calc(100vw - 28px));
  margin: 14vh auto 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  padding: 14px;
}
.dialogTitle{ font-weight: 900; font-size: 16px; }
.dialogBody{ margin-top: 10px; color: rgba(231,238,252,.92); line-height: 1.7; }
.dialogBody ul{ margin: 10px 0 0 18px; }
.dialogBody code{
  background: rgba(0,0,0,.28);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.dialogActions{ display:flex; justify-content:flex-end; margin-top: 12px; }
.muted{ color: var(--muted); }


/* Force readable button text across platforms (macOS may apply native button text colors) */
.toolBtn{
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
.toolBtn *{ color: inherit; }

/* Simple form controls for start dialog */
.formRow{ display:flex; gap:12px; align-items:center; margin: 10px 0 6px; flex-wrap: wrap; }
.formLabel{ color: var(--muted); font-size: 13px; min-width: 48px; }
.input{
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  color: var(--text);
  outline: none;
}
.input:focus{
  border-color: rgba(96,165,250,.55);
  box-shadow: 0 0 0 4px rgba(96,165,250,.12);
}
