.clamp-dimension-anchor { width: 0; height: 0; opacity: 0; pointer-events: none; }
.clamp-dimensions-overlay { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.clamp-dimensions-overlay[hidden], .clamp-dimensions-legend[hidden], .clamp-dimension-label[hidden] { display: none !important; }

/* Lines and witnesses */
.clamp-dimensions-lines {
    width: 100%;
    height: 100%;
    color: #ff7843;
    overflow: visible;
}
.clamp-dimensions-lines line {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.clamp-dimensions-lines .dimension-witness {
    stroke-dasharray: 4 3;
    stroke-width: 1.5;
    opacity: 0.8;
}

/* Dimension Labels (Default / Dark Theme) */
.clamp-dimension-label {
    position: absolute;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    transform: translate(-50%, -50%);
    padding: 4px 10px 4px 5px;
    border: 1.5px solid rgba(255, 107, 53, 0.65);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.94);
    color: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), 0 0 10px rgba(255, 107, 53, 0.2);
    backdrop-filter: blur(8px);
    user-select: none;
}
.clamp-dimension-label b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background: linear-gradient(135deg, #ff6b35, #ea580c);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 4px rgba(234, 88, 12, 0.4);
    flex-shrink: 0;
}
.clamp-dimension-label span {
    color: #f1f5f9;
    letter-spacing: 0.01em;
}

/* Dimension Labels & Lines in Light Theme */
html[data-theme="light"] .clamp-dimensions-lines {
    color: #ea580c;
}
html[data-theme="light"] .clamp-dimensions-lines line {
    stroke-width: 2;
}
html[data-theme="light"] .clamp-dimensions-lines .dimension-witness {
    stroke-width: 1.5;
    opacity: 0.85;
}
html[data-theme="light"] .clamp-dimension-label {
    background: rgba(255, 255, 255, 0.97);
    border: 1.5px solid rgba(234, 88, 12, 0.45);
    color: #0f172a;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06), 0 0 8px rgba(234, 88, 12, 0.1);
}
html[data-theme="light"] .clamp-dimension-label b {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(194, 65, 12, 0.35);
}
html[data-theme="light"] .clamp-dimension-label span {
    color: #0f172a;
    font-weight: 700;
}

/* Controls & Toggle button */
.home-clamp-controls { flex-wrap: wrap; justify-content: center; }
.clamp-dimensions-toggle[aria-pressed="true"] {
    border-color: #ff9d70;
    color: #ffe0cd;
    background: #ff6b3526;
}
html[data-theme="light"] .home-clamp .clamp-dimensions-toggle[aria-pressed="true"],
html[data-theme="light"] .clamp-dimensions-toggle[aria-pressed="true"] {
    background: #ea580c !important;
    border-color: #ea580c !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3);
}

/* Legend below 3D stage */
.clamp-dimensions-legend { width: 100%; margin-top: 12px; text-align: left; }
.clamp-dimensions-legend dl { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0; }
.clamp-dimensions-legend dt { color: #ffad8d; font-size: 0.8rem; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.clamp-dimensions-legend dd { color: #b8c2d0; margin: 0; font-size: 0.76rem; line-height: 1.5; }
.clamp-dimensions-legend .clamp-dimensions-note { margin: 14px 0 0; color: #9cabbc; font-size: 0.72rem; line-height: 1.5; }

html[data-theme="light"] .clamp-dimensions-legend dt { color: #c2410c; }
html[data-theme="light"] .clamp-dimensions-legend dd,
html[data-theme="light"] .clamp-dimensions-legend .clamp-dimensions-note { color: #334155; }

@media (max-width: 600px) {
    .clamp-dimension-label span { display: none; }
    .clamp-dimension-label { min-width: 28px; justify-content: center; padding: 4px; }
    .clamp-dimensions-legend dl { gap: 10px; }
}
