/*
 * tools-viewer.css — the two free browser tools of the 3D shop: the 3D model viewer & converter (3d/viewer.php,
 * assets/js/tools-viewer.js) and the G-code viewer (3d/gcode-viewer.php, assets/js/tools-gcode.js). Every rule is
 * scoped to .tv-… classes so nothing else on the site changes. Colours come from the 3D theme tokens (site.css .div-3d).
 */
.tv-hero .lead { max-width: 760px; }
.tv-eyebrow { margin: 0 0 6px; font-size: .9rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.tv-private { display: inline-flex; gap: 8px; align-items: flex-start; margin: 4px 0 0; padding: 10px 14px; border-radius: 12px;
    background: color-mix(in srgb, var(--success) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
    color: var(--ink); font-weight: 600; max-width: 760px; }
.tv-section { padding-top: 36px; }

/* ---- layout: big stage left, controls right; one column on small screens */
.tv-tool { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.tv-main { min-width: 0; }
.tv-side { display: grid; gap: 14px; min-width: 0; }
.tv-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.tv-card h2 { font-size: 1.05rem; margin: 0 0 10px; }

/* ---- the 3D stage */
.tv-stage { position: relative; height: clamp(380px, 64vh, 700px); border-radius: 18px; overflow: hidden; border: 1px solid var(--line-2);
    background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #f1eefc 60%, #e7e2fa 100%); touch-action: none; }
.tv-stage canvas { display: block; width: 100%; height: 100%; }
.tv-stage.tv-over { outline: 3px dashed var(--accent); outline-offset: -8px; }
.tv-drop { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    text-align: center; padding: 24px; cursor: pointer; color: var(--ink-2); background: rgba(251, 250, 255, .72); z-index: 2; }
.tv-drop strong { font-size: 1.1rem; color: var(--ink); }
.tv-drop small { color: var(--muted); letter-spacing: .08em; }
.tv-drop-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-size: 1.8rem; color: var(--accent-ink);
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); margin-bottom: 6px; }
.tv-drop:hover .tv-drop-icon { transform: translateY(-2px); }
.tv-has .tv-drop { display: none; }
.tv-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.tv-busy .tv-stage { cursor: progress; }

/* ---- toolbar under the stage */
.tv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; }
.tv-pick { position: relative; cursor: pointer; }
.tv-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.tv-drop:focus-within { outline: 3px solid var(--accent); outline-offset: -6px; }
.tv-views { display: inline-flex; gap: 4px; }
.tv-check { display: inline-flex; align-items: center; gap: 6px; font-size: .92rem; color: var(--ink-2); cursor: pointer; }
.tv-check { white-space: nowrap; }
.tv-check input, .tv-legend input { width: auto; padding: 0; margin: 0; accent-color: var(--accent); }
.tv-layers input[type=range] { padding: 0; border: 0; background: transparent; }
.tv-msg { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--tint-1); color: var(--ink-2); font-size: .94rem; }
.tv-msg-bad { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); }

/* ---- buttons, fields */
.tv-btn { font: inherit; font-size: .9rem; font-weight: 600; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line-2);
    background: var(--surface); color: var(--ink); cursor: pointer; transition: background .15s, border-color .15s; }
.tv-btn:hover:not(:disabled) { background: var(--tint-2); border-color: var(--accent); }
.tv-btn:disabled { opacity: .45; cursor: not-allowed; }
.tv-btn.tv-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tv-btn-strong { min-width: 64px; }
.tv-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tv-row:last-child { margin-bottom: 0; }
.tv-label { margin: 8px 0 4px; font-size: .82rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tv-field { display: grid; gap: 4px; margin-bottom: 8px; font-size: .9rem; }
.tv-field span { font-weight: 600; color: var(--ink-2); }
.tv-field select, .tv-scale input, .tv-side select { font: inherit; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line-2);
    background: var(--surface); color: var(--ink); min-width: 0; }
.tv-scale { align-items: center; }
.tv-scale input { width: 96px; }
.tv-note { margin: 8px 0 0; font-size: .84rem; color: var(--muted); }

/* ---- stats */
.tv-stats { margin: 0; display: grid; gap: 0; }
.tv-stats > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.tv-stats > div:last-child { border-bottom: 0; }
.tv-stats dt { color: var(--muted); }
.tv-stats dd { margin: 0; font-weight: 650; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tv-stats .tv-bad { color: var(--danger); }
.tv-stats .tv-good { color: var(--success); }

/* ---- explanation block */
.tv-about { padding: 56px 0; }
.tv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.tv-cols h2 { font-size: 1.35rem; }
.tv-cols li { color: var(--ink-2); margin-bottom: 6px; }

/* ---- G-code viewer extras */
.tv-progress { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(320px, 80%); z-index: 3;
    background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; padding: 14px 16px; text-align: center; box-shadow: var(--shadow); }
.tv-progress[hidden] { display: none; }
.tv-progress progress { width: 100%; accent-color: var(--accent); }
.tv-layers { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 12px; }
.tv-layers input[type=range] { width: 100%; accent-color: var(--accent); }
.tv-layer-out { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.tv-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tv-legend li { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.tv-legend li[hidden] { display: none; }
.tv-legend label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; padding: 3px 0; }
.tv-legend input { accent-color: var(--accent); }
.tv-legend small { color: var(--muted); font-variant-numeric: tabular-nums; }
.tv-sw { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(0, 0, 0, .15); }
.tv-sw-0 { background: #ff7a00; } .tv-sw-1 { background: #f5c400; } .tv-sw-2 { background: #2f80ff; } .tv-sw-3 { background: #d13b3b; }
.tv-sw-4 { background: #9b51e0; } .tv-sw-5 { background: #ff4fa3; } .tv-sw-6 { background: #27ae60; } .tv-sw-7 { background: #14a3a3; }
.tv-sw-8 { background: #8d6e63; } .tv-sw-9 { background: #7fd3ff; } .tv-sw-10 { background: #9aa0a6; } .tv-sw-11 { background: #f39c12; }
.tv-sw-12 { background: #3b4cca; }

@media (max-width: 960px) {
    .tv-tool { grid-template-columns: minmax(0, 1fr); }
    .tv-stage { height: clamp(320px, 58vh, 520px); }
    .tv-cols { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 520px) {
    .tv-section { padding-top: 20px; }
    .tv-stage { border-radius: 14px; }
    .tv-layers-layer { grid-template-columns: auto minmax(0, 1fr); row-gap: 4px; }
    .tv-layers-layer .tv-layer-out { grid-column: 1 / -1; font-size: .9rem; }
}
.tv-speed { width: auto; padding: 4px 8px; border-radius: 10px; }
.tv-layers-scrub .tv-label { margin: 0; }
