/* Markers, gaps, and treatment overlays */

.tooth__markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker-item {
  position: absolute;
  pointer-events: none;
}

.marker-item--attachment,
.marker-item--missing_tooth,
.marker-item--extract {
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
}

/* Crown face center — sit in the middle of the crown body, not at the cervix.
   Upper: roots up / crown down. Lower: crown up / roots down. */
.tooth--upper .marker-item--attachment,
.tooth--upper .marker-item--missing_tooth,
.tooth--upper .marker-item--extract {
  top: 78%;
}

.tooth--lower .marker-item--attachment,
.tooth--lower .marker-item--missing_tooth,
.tooth--lower .marker-item--extract {
  top: 16%;
}

/* Keep the same crown-center anchor; nudge the two X markers apart so both
   colors read as separate crosses when Missing + Extract are applied. */
.tooth--stacked-crosses .marker-item--missing_tooth {
  transform: translate(calc(-50% - 5px), calc(-50% - 4px));
  z-index: 1;
}

.tooth--stacked-crosses .marker-item--extract {
  transform: translate(calc(-50% + 5px), calc(-50% + 4px));
  z-index: 2;
}

.tooth--stacked-crosses .marker-item--missing_tooth .marker-x svg,
.tooth--stacked-crosses .marker-item--extract .marker-x svg {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9));
}

.marker-item--button_cut_out,
.marker-item--lingual_button {
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
}

/* Lower: arc sits at crown base (before root), open toward roots.
   Upper: same cervix placement, icon flipped vertically. */
.tooth--lower .marker-item--button_cut_out,
.tooth--lower .marker-item--lingual_button {
  top: 30%;
  transform: translate(-50%, -50%);
}

.tooth--upper .marker-item--button_cut_out,
.tooth--upper .marker-item--lingual_button {
  top: 70%;
  transform: translate(-50%, -50%) scaleY(-1);
}

/* Same cervix anchor; nudge arcs apart when both cut-outs are applied. */
.tooth--stacked-cutouts.tooth--lower .marker-item--button_cut_out {
  transform: translate(calc(-50% - 8px), -50%);
}

.tooth--stacked-cutouts.tooth--lower .marker-item--lingual_button {
  transform: translate(calc(-50% + 8px), -50%);
}

.tooth--stacked-cutouts.tooth--upper .marker-item--button_cut_out {
  transform: translate(calc(-50% - 8px), -50%) scaleY(-1);
}

.tooth--stacked-cutouts.tooth--upper .marker-item--lingual_button {
  transform: translate(calc(-50% + 8px), -50%) scaleY(-1);
}

.marker-item--bite_ramp { top: 2px; left: 50%; transform: translateX(-50%); }
.marker-item--pressure_point { bottom: 6px; left: 4px; }
.marker-item--hook_slit {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Outer crown corner: left half faces left, right half faces right.
   Upper points up (toward roots/numbers); lower points down. */
.tooth--upper .marker-hook-slit--up-left {
  top: 56%;
  left: 10%;
  transform: scaleX(-1);
}

.tooth--upper .marker-hook-slit--up-right {
  top: 56%;
  right: 10%;
  left: auto;
}

.tooth--lower .marker-hook-slit--down-left {
  top: 28%;
  left: 10%;
  transform: scale(-1);
}

.tooth--lower .marker-hook-slit--down-right {
  top: 28%;
  right: 10%;
  left: auto;
  transform: scaleY(-1);
}

.marker-item--power_arm { bottom: 8px; right: 4px; }
.marker-item--ipr_tooth { top: 10%; bottom: 10%; left: 50%; transform: translateX(-50%); width: 6px; }
.marker-item--ipr_side { top: 10%; bottom: 10%; width: 4px; }
.marker-item--ipr_side.marker-ipr-side--mesial { left: 0; top: 6%; bottom: 6%; width: 6px; }
.marker-item--ipr_side.marker-ipr-side--distal { right: 0; top: 6%; bottom: 6%; width: 6px; }

/* Marker popover */

.tooth__marker-menu {
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #e2e9f2;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(28, 55, 90, 0.2);
  z-index: 1100;
  pointer-events: auto;
  white-space: nowrap;
  cursor: default;
}

.tooth__marker-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 8px;
}

.tooth__marker-chip:hover { background: rgba(0, 194, 168, 0.08); }

.tooth__marker-chip-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tooth__marker-chip-icon > div {
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none !important;
}

.tooth__marker-chip-icon svg { width: 14px; height: 14px; display: block; }
.tooth__marker-chip-icon .marker-attachment__square { width: 10px; height: 10px; }

.tooth__marker-chip-label {
  flex: 1 1 auto;
  font-size: 0.6875rem;
  font-weight: 650;
  color: var(--dc-text, #0f1b2d);
  text-transform: capitalize;
  padding-right: 8px;
}

.tooth__marker-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-left: auto;
  border: none;
  border-radius: 50%;
  background: #f43f5e;
  cursor: pointer;
  flex: 0 0 16px;
}

.tooth__marker-chip-remove svg {
  width: 9px;
  height: 9px;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
}

.tooth__marker-chip-remove:hover { background: #e11d48; }

/* Marker states on teeth */

.tooth--has-marker .tooth__number {
  color: var(--dc-blue, #2f7cff);
  font-weight: 750;
}

.tooth--has-marker .tooth__enamel {
  fill: #dceaff;
  stroke: rgba(47, 124, 255, 0.4);
}

.tooth--attachment .tooth__enamel {
  fill: #c7f1e8;
  stroke: rgba(0, 194, 168, 0.45);
}

.tooth--attachment .tooth__number { color: var(--dc-mint-strong, #02a890); }

/* Marker shapes */

.marker-attachment {
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-attachment__square {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: #0f766e;
  box-shadow: 0 0 6px rgba(15, 118, 110, 0.45);
}

.marker-attachment__bar {
  width: 30px;
  height: 6px;
  border-radius: 2px;
  background: #00c2a8;
  box-shadow: 0 0 6px rgba(0, 194, 168, 0.6);
}

.marker-bite-ramp svg,
.marker-pressure-point svg { width: 24px; height: 24px; }
.marker-button-cutout svg,
.marker-lingual-button svg { width: 26px; height: 16px; display: block; }
.marker-x svg { width: 28px; height: 28px; }
.marker-power-arm svg { width: 32px; height: 32px; }
.marker-hook-slit svg { width: 20px; height: 20px; display: block; }

.marker-x--blue line {
  stroke: #2f7cff;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.marker-x--red line {
  stroke: #f43f5e;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.marker-ipr-tooth svg,
.marker-ipr-side svg {
  width: 4px;
  height: 100%;
  display: block;
}

.marker-ipr-side { width: 4px; height: 100%; }
.marker-ipr-side--mesial svg,
.marker-ipr-side--distal svg { width: 5px; }

/* Gaps */

.tooth-gap {
  flex: 0 0 10px;
  min-width: 8px;
  max-width: 14px;
  align-self: stretch;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: flex 0.2s ease, min-width 0.2s ease, max-width 0.2s ease, background 0.12s;
}

.tooth-gap--narrow {
  flex: 0 0 4px !important;
  min-width: 4px !important;
  max-width: 4px !important;
}

.tooth-gap--collapsed {
  flex: 0 0 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  pointer-events: none;
}

.arch-midline-gap.tooth-gap--collapsed {
  width: 0 !important;
  min-width: 0 !important;
}

/* Match full tooth column height (icon + FDI numbers) so the IPR line
   reaches the numbering row (e.g. 13 / 14). */
.dental-arch--upper .tooth-gap,
.dental-arch--lower .tooth-gap {
  align-self: stretch;
  height: auto;
  min-height: 100%;
}

.tooth-gap:hover { background: rgba(245, 158, 11, 0.16); }

.tooth-gap--selected,
.arch-midline-gap.tooth-gap--selected {
  background: rgba(0, 194, 168, 0.2);
  outline: 2px solid var(--dc-mint, #00c2a8);
  box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.14);
}

.tooth-gap--excluded,
.arch-midline-gap.tooth-gap--excluded {
  opacity: 0.2;
  pointer-events: none;
  cursor: not-allowed;
}

.tooth-gap--flash,
.arch-midline-gap--flash {
  background: rgba(245, 158, 11, 0.22);
  outline: 2px solid var(--dc-amber, #f59e0b);
  outline-offset: -1px;
}

/* Gap IPR marker */

.gap-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  pointer-events: none;
  width: 100%;
  padding: 2px 0;
  box-sizing: border-box;
}

.gap-marker__meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.gap-marker__label {
  font-size: 0.5625rem;
  font-weight: 750;
  color: #c2740a;
  line-height: 1;
}

.gap-marker__line {
  width: 2px;
  flex: 1 1 auto;
  min-height: 48px;
  background: var(--dc-amber, #f59e0b);
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.gap-marker__amount {
  font-size: 0.5625rem;
  font-weight: 650;
  color: #c2740a;
  line-height: 1;
  white-space: nowrap;
}

.arch-midline-gap {
  width: 18px;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  align-self: stretch;
  height: auto;
  min-height: 100%;
  border-radius: 3px;
  transition: background 0.12s;
}

.dental-arch--upper .arch-midline-gap,
.dental-arch--lower .arch-midline-gap {
  align-self: stretch;
  height: auto;
}

.arch-midline-gap:hover { background: rgba(245, 158, 11, 0.16); }
