/* ═══════════════════════════════════════════
   Flashing Drawing Tool – Styles
   ═══════════════════════════════════════════ */

/* Reset within plugin */
.fdt-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
.fdt-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    color: #333;
    overflow-x: clip;
    box-sizing: border-box;
}

/* ─── Config Panel ─── */
.fdt-config-panel { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 24px; }
.fdt-title { font-size: 22px; font-weight: 600; margin-bottom: 20px; }
.fdt-field { margin-bottom: 16px; }
.fdt-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.fdt-req { color: #e53935; }
.fdt-select { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; background: #fff; }

/* Colour grid */
.fdt-colour-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.fdt-colour-swatch {
    width: 44px; height: 44px; border-radius: 6px; border: 2px solid #ddd;
    cursor: pointer; position: relative; transition: border-color .15s;
    background-repeat: no-repeat;
}
.fdt-colour-swatch--texture {
    background-color: #c0c0c0;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.fdt-colour-swatch:hover { border-color: #888; }
.fdt-colour-swatch.selected { border-color: #e53935; }
.fdt-colour-swatch.selected::after {
    content: '';
    position: absolute;
    inset: 7px;
    border: 2px solid #fff;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.25);
    pointer-events: none;
}

/* Lines rows — Qty + Length on first line, Description full-width below */
.fdt-lines-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
}
.fdt-lines-header-metrics {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: center;
}
.fdt-lines-header-desc {
    display: block;
    width: 100%;
}
.fdt-line-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.fdt-line-metrics {
    display: grid !important;
    grid-template-columns: 80px minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.fdt-line-row input,
.fdt-line-row select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.fdt-line-row .fdt-desc-input {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
}
.fdt-line-row .fdt-remove-line {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 4px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.fdt-add-line { display: inline-flex; align-items: center; gap: 4px; color: #2e7d32; font-size: 14px; font-weight: 500; text-decoration: none; margin-top: 8px; }
.fdt-add-line:hover { text-decoration: underline; }

/* Buttons */
.fdt-btn { padding: 12px 24px; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s; }
.fdt-btn-primary { background: #00897B; color: #fff; width: 100%; margin-top: 12px; }
.fdt-btn-primary:hover { background: #00796B; }
.fdt-btn-secondary { background: #f5f5f5; color: #333; border: 1px solid #ccc; }
.fdt-btn-secondary:hover { background: #e8e8e8; }
.fdt-btn-danger { background: #e53935; color: #fff; }

/* Lock WP page scroll while the drawing canvas fills the screen */
html.fdt-canvas-lock,
html.fdt-canvas-lock body {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
}
body.fdt-canvas-lock {
    position: fixed !important;
    width: 100% !important;
    left: 0;
    right: 0;
}

/* ─── Canvas Panel ─── */
.fdt-wrapper.fdt-mode-canvas {
    max-width: 100%;
    margin: 0;
    padding: 0;
}
.fdt-canvas-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Height is set in JS to fit remaining viewport (no page scroll). */
    min-height: 0;
    height: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.fdt-canvas-panel .fdt-topbar,
.fdt-canvas-panel .fdt-toolbar,
.fdt-canvas-panel .fdt-settings-panel,
.fdt-canvas-panel .fdt-bottom-bar,
.fdt-canvas-panel .fdt-updating-bar {
    flex-shrink: 0;
}

/* 2D → 3D waiting bar (matches reference site) */
.fdt-updating-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 12px 10px;
    background: #cfcfcf;
    border-bottom: 1px solid #bdbdbd;
    color: #424242;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    z-index: 5;
    overflow: hidden;
    animation: fdt-updating-in 0.18s ease-out;
}
.fdt-updating-bar[hidden] { display: none !important; }
.fdt-updating-bar.is-leaving {
    animation: fdt-updating-out 0.22s ease-in forwards;
}
.fdt-updating-text {
    position: relative;
    z-index: 1;
}
.fdt-updating-progress {
    position: relative;
    width: min(280px, 55%);
    height: 3px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
.fdt-updating-progress-fill {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(90deg, #607d8b, #455a64, #607d8b);
    background-size: 200% 100%;
    animation: fdt-updating-fill 0.85s cubic-bezier(0.4, 0, 0.2, 1) forwards,
               fdt-updating-shimmer 0.9s linear infinite;
}
@keyframes fdt-updating-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fdt-updating-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes fdt-updating-fill {
    from { width: 8%; }
    to   { width: 100%; }
}
@keyframes fdt-updating-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.fdt-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #eceff1;
    border-bottom: 1px solid #d0d5d8;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.fdt-topbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.fdt-mode-btn {
    width: 40px; height: 36px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: 800; color: #fff;
}
.fdt-taper-btns {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.fdt-mode-2d { background: #90a4ae; }
.fdt-mode-3d { background: #1e88e5; font-size: 12px; width: 44px; }
.fdt-mode-2d.is-active {
    background: linear-gradient(180deg, #7ad7e4 0%, #3ec4d4 55%, #2bb8ca 100%);
    box-shadow: 0 2px 0 #1a9aab, inset 0 1px 0 rgba(255,255,255,.45);
}
.fdt-mode-3d.is-active { background: #1565c0; box-shadow: inset 0 0 0 2px #90caf9; }
/* Taper tabs: pale = current end, bright = the other end */
.fdt-taper-btn.fdt-mode-2d {
    background: linear-gradient(180deg, #cfd8dc 0%, #b0bec5 100%);
    box-shadow: 0 1px 0 #90a4ae, inset 0 1px 0 rgba(255,255,255,.35);
    opacity: 0.72;
}
.fdt-taper-btn.fdt-mode-2d.is-active {
    opacity: 1;
    background: linear-gradient(180deg, #7ad7e4 0%, #3ec4d4 55%, #2bb8ca 100%);
    box-shadow: 0 2px 0 #1a9aab, inset 0 1px 0 rgba(255,255,255,.45);
}
.fdt-taper-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 54px !important;
    height: 36px !important;
    padding: 0 5px;
    border-radius: 10px !important;
    font-size: 13px;
    line-height: 1;
}
.fdt-taper-btn[hidden] {
    display: none !important;
}
.fdt-taper-icon {
    display: block;
    flex-shrink: 0;
    width: 26px;
    height: 16px;
}
.fdt-taper-num {
    font-weight: 800;
    font-size: 17px;
    color: #fff;
    text-shadow: 0 1px 0 rgba(0,0,0,.18);
    line-height: 1;
}
.fdt-taper-controls {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 8px;
}
.fdt-taper-controls[hidden] { display: none !important; }
.fdt-legends-3d[hidden] { display: none !important; }
.fdt-legends-2d[hidden] { display: none !important; }
.fdt-view-3d #fdt-legends-2d { display: none !important; }
.fdt-view-3d #fdt-legends-3d:not([hidden]) { display: inline-flex !important; }
.fdt-view-3d .fdt-taper-btns { display: none !important; }
.fdt-view-3d #fdt-set-scale-btn,
.fdt-view-3d #fdt-delete-btn,
.fdt-view-3d #fdt-close-drawing-btn,
.fdt-view-3d #fdt-download-btn,
.fdt-view-3d #fdt-undo-btn { display: none !important; }
.fdt-view-3d #fdt-taper-sort-bar { display: none !important; }
.fdt-view-3d .fdt-taper-controls:not([hidden]) {
    display: inline-flex !important;
}
.fdt-taper-sort-bar {
    height: 36px;
    min-width: 170px;
    padding: 0 32px 0 10px;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23555' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    -webkit-appearance: none;
    font-size: 13px;
    color: #333;
    cursor: pointer;
}
.fdt-taper-end-btn {
    height: 36px;
    padding: 0 14px;
    border: 1px solid #42a5f5;
    border-radius: 6px;
    background: #fff;
    color: #1e88e5;
    font-size: 13px;
    font-weight: 700;
    cursor: default;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}
.fdt-taper-canvas-label {
    position: absolute;
    top: 18px;
    right: 28px;
    z-index: 5;
    pointer-events: none;
    font-size: clamp(42px, 7vw, 72px);
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #e91e63;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255,255,255,.65);
    user-select: none;
}
.fdt-taper-canvas-label[hidden] { display: none !important; }
.fdt-mouse-legends {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: 10px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e8eef1;
    border-radius: 10px;
    overflow: visible;
}
.fdt-legend {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #455a64;
    cursor: help;
}
.fdt-legend-label { font-weight: 650; white-space: nowrap; letter-spacing: 0.01em; }
.fdt-mouse-svg {
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.08));
}

.fdt-mouse-guide {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 130;
    min-width: 240px;
    background: #263238;
    color: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.45;
    box-shadow: 0 10px 28px rgba(0,0,0,.22);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
    pointer-events: none;
}
.fdt-mouse-guide::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 18px;
    border: 6px solid transparent;
    border-bottom-color: #263238;
    border-top-width: 0;
}
.fdt-mouse-guide strong { display: block; margin-bottom: 6px; font-size: 12px; }
.fdt-mouse-guide ul { margin: 0; padding-left: 16px; }
.fdt-mouse-guide li { margin: 2px 0; }
.fdt-mouse-legends:hover .fdt-mouse-guide,
.fdt-mouse-legends:focus-within .fdt-mouse-guide {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.fdt-cart-btn { background: #43a047 !important; color: #fff !important; border-color: #2e7d32 !important; }
.fdt-sync-btn { background: #26a69a !important; color: #fff !important; border-color: #00897b !important; }
.fdt-settings-btn { background: #e53935 !important; color: #fff !important; border-color: #c62828 !important; margin-left: auto; }
.fdt-desc-top {
    flex: 1 1 auto;
    min-width: 150px;
    max-width: 360px;
    height: 34px;
    border: 1px solid #cfd8dc;
    border-radius: 4px;
    padding: 0 10px;
    font-size: 13px;
    box-sizing: border-box;
}
.fdt-undo-btn { background: #29b6f6 !important; color: #fff !important; border-color: #0288d1 !important; }

.fdt-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #f8f8f8; border-bottom: 1px solid #e0e0e0; gap: 8px; flex-wrap: wrap; position: relative; z-index: 300; overflow: visible; }
.fdt-toolbar-left, .fdt-toolbar-center, .fdt-toolbar-right { display: flex; align-items: center; gap: 6px; position: relative; z-index: 301; }
.fdt-tool-btn {
    width: 41px; height: 36px; border: 1px solid #d2d2d2; border-radius: 3px;
    background: #fff; cursor: pointer; display: flex; align-items: center;
    justify-content: center; font-size: 18px; transition: background .15s;
}
.fdt-tool-btn:hover { background: #eee; }
.fdt-tool-btn.fdt-active { background: #e3f2fd; border-color: #42a5f5; }
.fdt-tool-btn.fdt-scale-btn {
    background: #fff;
    border-color: #e53935;
    color: #546e7a;
}
.fdt-tool-btn.fdt-scale-btn:hover,
.fdt-tool-btn.fdt-scale-btn.fdt-active {
    background: #ffebee;
    border-color: #c62828;
    color: #c62828;
}
.fdt-tool-btn.fdt-scale-btn svg,
.fdt-tool-btn.fdt-scale-btn .fdt-scale-icon {
    display: block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.fdt-tool-btn.fdt-scale-btn img.fdt-scale-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
}
.fdt-tool-btn.fdt-check-btn {
    background: #fff;
    border-color: #9e9e9e;
    color: #424242;
    font-size: 22px;
    font-weight: 700;
}
.fdt-tool-btn.fdt-check-btn:hover {
    background: #e8f5e9;
    border-color: #66bb6a;
    color: #2e7d32;
}
.fdt-colour-side-label { font-size: 16px; font-weight: 500; }
.fdt-colour-side-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}
.fdt-cs-img {
    display: block;
    height: 31px;
    width: auto;
}

.fdt-menu-wrap { position: relative; z-index: 320; }

/* Hamburger menu — theme-proof (WP themes often force white text on buttons) */
#fdt-root #fdt-hamburger-menu.fdt-dropdown,
#fdt-root .fdt-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 10050;
    min-width: 200px;
    padding: 6px;
    border: 1px solid #cfd8dc;
    border-radius: 10px;
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #212121 !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
    color-scheme: light;
    -webkit-text-fill-color: #212121;
}
/* Escapes overflow:auto toolbars on mobile */
#fdt-root .fdt-dropdown.fdt-dropdown--fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    z-index: 10080;
    max-height: min(70vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff !important;
    color: #212121 !important;
}
#fdt-root #fdt-hamburger-menu.fdt-dropdown .fdt-menu-item,
#fdt-root #fdt-hamburger-menu.fdt-dropdown button,
#fdt-root #fdt-hamburger-menu.fdt-dropdown button.fdt-menu-item,
#fdt-root .fdt-dropdown .fdt-menu-item,
#fdt-root .fdt-dropdown button,
#fdt-root .fdt-dropdown button.fdt-menu-item {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 2px;
    padding: 10px 12px;
    border: none !important;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.35;
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
    background: #f5f5f5 !important;
    background-color: #f5f5f5 !important;
    background-image: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    text-shadow: none !important;
    box-shadow: none !important;
    filter: none !important;
    mix-blend-mode: normal !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
#fdt-root #fdt-hamburger-menu.fdt-dropdown .fdt-menu-item:last-child,
#fdt-root #fdt-hamburger-menu.fdt-dropdown button:last-child,
#fdt-root .fdt-dropdown .fdt-menu-item:last-child,
#fdt-root .fdt-dropdown button:last-child {
    margin-bottom: 0;
}
#fdt-root #fdt-hamburger-menu.fdt-dropdown .fdt-menu-item:hover,
#fdt-root #fdt-hamburger-menu.fdt-dropdown .fdt-menu-item:focus,
#fdt-root #fdt-hamburger-menu.fdt-dropdown button:hover,
#fdt-root #fdt-hamburger-menu.fdt-dropdown button:focus,
#fdt-root .fdt-dropdown .fdt-menu-item:hover,
#fdt-root .fdt-dropdown .fdt-menu-item:focus,
#fdt-root .fdt-dropdown button:hover,
#fdt-root .fdt-dropdown button:focus {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    background: #e0e0e0 !important;
    background-color: #e0e0e0 !important;
    outline: 2px solid #90caf9;
    outline-offset: -2px;
}
#fdt-root #fdt-hamburger-menu.fdt-dropdown .fdt-menu-item:active,
#fdt-root #fdt-hamburger-menu.fdt-dropdown button:active,
#fdt-root .fdt-dropdown .fdt-menu-item:active,
#fdt-root .fdt-dropdown button:active {
    background: #cfd8dc !important;
    background-color: #cfd8dc !important;
    color: #000000 !important;
}
body.rtl #fdt-root .fdt-dropdown,
html[dir="rtl"] #fdt-root .fdt-dropdown {
    left: auto;
    right: 0;
}
body.rtl #fdt-root .fdt-dropdown .fdt-menu-item,
body.rtl #fdt-root .fdt-dropdown button,
html[dir="rtl"] #fdt-root .fdt-dropdown .fdt-menu-item,
html[dir="rtl"] #fdt-root .fdt-dropdown button {
    text-align: right;
}
.fdt-settings-panel {
    display: flex; gap: 16px; padding: 8px 12px; background: #fff8e1; border-bottom: 1px solid #ffe082; font-size: 13px;
}
.fdt-settings-panel[hidden] { display: none !important; }
.fdt-dropdown[hidden] { display: none !important; }
.fdt-settings-panel label { display: flex; align-items: center; gap: 8px; }

/* Full Settings modal (reference-style) */
.fdt-settings-modal .fdt-settings-card {
    width: min(560px, calc(100vw - 24px));
    max-height: min(90vh, 720px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0,0,0,.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.fdt-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 8px;
}
.fdt-settings-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #222;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fdt-settings-gear { font-size: 22px; line-height: 1; }
.fdt-settings-x {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 22px;
    color: #fff;
    text-shadow: 0 0 2px #333, 0 1px 2px #000;
    cursor: pointer;
    line-height: 1;
    width: 28px;
    height: 28px;
}
.fdt-settings-tabs {
    display: flex;
    gap: 0;
    padding: 0 12px;
    border-bottom: 1px solid #ddd;
    overflow-x: auto;
}
.fdt-settings-tab {
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 6px 6px 0 0;
    margin-bottom: -1px;
}
.fdt-settings-tab.is-active {
    background: #fff;
    border-color: #ccc;
    color: #111;
    font-weight: 700;
    box-shadow: 0 1px 0 #fff;
}
.fdt-settings-body {
    padding: 14px 18px 8px;
    overflow-y: auto;
    flex: 1 1 auto;
}
.fdt-settings-pane[hidden] { display: none !important; }
.fdt-settings-pane {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px 12px;
}
.fdt-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 4px;
    font-size: 14px;
    color: #333;
}
.fdt-settings-row > span { flex: 1 1 auto; }
.fdt-color-swatch {
    width: 36px;
    height: 28px;
    padding: 0;
    border: 1px solid #bbb;
    border-radius: 2px;
    background: #fff;
    cursor: pointer;
}
.fdt-color-hex {
    width: 88px;
    height: 28px;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0 8px;
    font-size: 13px;
    font-family: ui-monospace, monospace;
}
.fdt-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 3px;
    overflow: hidden;
    background: #f7f7f7;
}
.fdt-stepper button {
    width: 32px;
    height: 30px;
    border: none;
    background: #eee;
    color: #444;
    font-size: 16px;
    cursor: pointer;
}
.fdt-stepper button:hover { background: #e0e0e0; }
.fdt-stepper input {
    width: 56px;
    height: 30px;
    border: none;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    text-align: center;
    font-size: 14px;
    background: #fff;
}
.fdt-settings-num {
    width: 88px;
    height: 30px;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0 8px;
    text-align: center;
    font-size: 14px;
}
.fdt-switch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    user-select: none;
}
.fdt-switch-input { position: absolute; opacity: 0; width: 0; height: 0; }
.fdt-switch-ui {
    width: 46px;
    height: 26px;
    border-radius: 13px;
    background: #cfd8dc;
    position: relative;
    flex-shrink: 0;
    transition: background .15s ease;
}
.fdt-switch-ui::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .15s ease;
}
.fdt-switch-input:checked + .fdt-switch-ui { background: #1e88e5; }
.fdt-switch-input:checked + .fdt-switch-ui::after { transform: translateX(20px); }
.fdt-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid #e6e6e6;
}
.fdt-help-bubble.is-hidden-by-settings { display: none !important; }
.fdt-toast {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 140;
    max-width: min(520px, calc(100% - 24px));
    background: #263238;
    color: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    pointer-events: none;
}
.fdt-toast[hidden] { display: none !important; }
.fdt-toast.is-error { background: #c62828; }
.fdt-toast.is-success { background: #2e7d32; }

.fdt-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.fdt-modal[hidden] { display: none !important; }
.fdt-modal-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 16px 40px rgba(0,0,0,.25);
}
.fdt-modal-title { font-size: 18px; margin-bottom: 8px; }
.fdt-modal-text { font-size: 14px; color: #555; margin-bottom: 14px; white-space: pre-line; }
.fdt-modal-field-wrap { margin-bottom: 16px; }
.fdt-modal-field-wrap label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.fdt-modal-field-wrap input {
    width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 15px;
}
.fdt-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fdt-modal-actions .fdt-btn { width: auto; margin: 0; min-width: 90px; }

/* Tapered Flashing dialog (reference match) */
.fdt-taper-modal-card {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 28px rgba(0,0,0,.28);
    overflow: hidden;
}
.fdt-taper-modal-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid #e6e6e6;
}
.fdt-taper-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #222;
    letter-spacing: 0.01em;
}
.fdt-taper-modal-body {
    padding: 18px 18px 22px;
}
.fdt-taper-modal-text {
    margin: 0 0 16px;
    font-size: 15px;
    line-height: 1.45;
    color: #333;
}
.fdt-taper-select {
    display: block;
    width: 100%;
    height: 42px;
    padding: 8px 36px 8px 12px;
    border: 1px solid #b3e5ec;
    border-radius: 6px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23555' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    -webkit-appearance: none;
    font-size: 15px;
    color: #222;
    box-sizing: border-box;
}
.fdt-taper-select:focus {
    outline: none;
    border-color: #4db6c6;
    box-shadow: 0 0 0 2px rgba(77, 182, 198, 0.25);
}
.fdt-taper-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid #e6e6e6;
    background: #fff;
}
.fdt-taper-btn-cancel,
.fdt-taper-btn-ok {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 108px;
    height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
}
.fdt-taper-btn-cancel { background: #e53935; }
.fdt-taper-btn-cancel:hover { background: #c62828; }
.fdt-taper-btn-ok { background: #43a047; }
.fdt-taper-btn-ok:hover { background: #2e7d32; }
.fdt-taper-btn-ico {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

/* Canvas — fills leftover space under toolbars inside the fitted panel */
.fdt-canvas-container {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    background: #fafafa;
    overflow: hidden;
    border-radius: 0;
}
.fdt-canvas-container canvas { display: block; width: 100%; height: 100%; }
.fdt-three-host {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: #fff;
}
.fdt-three-host[hidden] { display: none !important; }
.fdt-three-host canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.fdt-three-end-label,
.fdt-three-front-label,
.fdt-three-back-label {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
    pointer-events: none;
    color: #d32f2f;
    font: 500 13px/1 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0.04em;
    text-shadow: 0 0 2px #fff, 0 0 2px #fff;
    white-space: nowrap;
    opacity: 0.92;
}
.fdt-three-end-label[hidden],
.fdt-three-front-label[hidden],
.fdt-three-back-label[hidden] { display: none !important; }
.fdt-view-3d #fdt-canvas { pointer-events: none; }

/* Point menu (+ Line / Folding popup) */
.fdt-point-menu, .fdt-folding-menu {
    position: absolute; z-index: 100; background: #fff;
    border: 1px solid #ddd; border-radius: 8px; padding: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15); display: flex; gap: 4px;
}
.fdt-point-menu button, .fdt-folding-menu button {
    padding: 6px 14px; border: 1px solid #ccc; border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 13px; font-weight: 500;
}
.fdt-point-menu .fdt-pm-line { background: #e3f2fd; border-color: #42a5f5; color: #1565c0; }
.fdt-point-menu .fdt-pm-fold { background: #e8f5e9; border-color: #66bb6a; color: #2e7d32; }
.fdt-point-menu .fdt-pm-close { background: #f5f5f5; }

/* End Folding popup (reference) */
.fdt-folding-menu {
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 6px;
    border-color: #cfd8dc;
    box-shadow: 0 4px 14px rgba(0,0,0,.16);
}
.fdt-folding-menu .fdt-fold-title {
    font-weight: 600;
    font-size: 12px;
    color: #333;
    padding: 0 0 6px;
    margin: 0;
    border-bottom: none;
}
.fdt-folding-menu .fdt-fold-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.fdt-folding-menu .fdt-fold-select {
    flex: 1 1 auto;
    min-width: 88px;
    max-width: 140px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #90a4ae;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}
.fdt-folding-menu .fdt-fold-swap,
.fdt-folding-menu .fdt-fold-ok,
.fdt-folding-menu .fdt-fold-cancel {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.fdt-folding-menu .fdt-fold-swap {
    background: #43a047;
    color: #fff;
}
.fdt-folding-menu .fdt-fold-swap:hover { background: #2e7d32; }
.fdt-folding-menu .fdt-fold-swap-icon {
    display: block;
    width: 18px;
    height: 12px;
    pointer-events: none;
}
.fdt-folding-menu .fdt-fold-ok { background: #1e88e5; color: #fff; }
.fdt-folding-menu .fdt-fold-ok:hover { background: #1565c0; }
.fdt-folding-menu .fdt-fold-cancel { background: #546e7a; color: #fff; }
.fdt-folding-menu .fdt-fold-cancel:hover { background: #37474f; }

/* + Line / length / angle value popups (reference) */
.fdt-add-line-menu,
.fdt-value-menu {
    position: absolute;
    z-index: 110;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,.16);
}
.fdt-add-line-menu[hidden],
.fdt-add-line-menu[style*="display: none"],
.fdt-value-menu[hidden],
.fdt-value-menu[style*="display: none"] { display: none !important; }
.fdt-alm-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fdt-alm-field label {
    font-size: 12px;
    color: #333;
    font-weight: 500;
    white-space: nowrap;
}
.fdt-alm-field input {
    width: 72px;
    height: 30px;
    border: 1px solid #90a4ae;
    border-radius: 3px;
    padding: 0 6px;
    font-size: 14px;
    text-align: center;
}
.fdt-alm-field input:focus {
    outline: none;
    border-color: #1565c0;
    box-shadow: 0 0 0 2px rgba(21,101,192,.2);
}
.fdt-alm-actions {
    display: flex;
    gap: 6px;
    padding-bottom: 1px;
}
.fdt-alm-ok,
.fdt-alm-cancel {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}
.fdt-alm-ok { background: #1e88e5; }
.fdt-alm-ok:hover { background: #1565c0; }
.fdt-alm-cancel { background: #546e7a; }
.fdt-alm-cancel:hover { background: #37474f; }

/* In-canvas numeric keypad (length pencil / angle tap) */
.fdt-value-menu.fdt-numpad {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 200px;
    max-width: min(260px, calc(100vw - 16px));
    padding: 10px;
    background: #f8bbd0;
    border: 1px solid #f48fb1;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(173, 20, 87, 0.22);
}
.fdt-numpad-caption {
    font-size: 12px;
    font-weight: 600;
    color: #880e4f;
    text-align: center;
}
.fdt-numpad-top {
    display: flex;
    align-items: center;
    gap: 6px;
}
.fdt-numpad-step,
.fdt-numpad-ok,
.fdt-numpad-cancel,
.fdt-numpad-key {
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.fdt-numpad-step {
    width: 36px;
    height: 36px;
    background: #fff;
    color: #ad1457;
    font-size: 20px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.fdt-numpad-value {
    flex: 1;
    min-width: 56px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 700;
    color: #212121;
    box-shadow: inset 0 0 0 1px #f48fb1;
}
.fdt-numpad-ok {
    width: 36px;
    height: 36px;
    background: #1e88e5;
    color: #fff;
    font-size: 18px;
}
.fdt-numpad-cancel {
    width: 36px;
    height: 36px;
    background: #78909c;
    color: #fff;
    font-size: 18px;
}
.fdt-numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.fdt-numpad-key {
    height: 40px;
    background: #fff;
    color: #212121;
    font-size: 17px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.fdt-numpad-key:active { background: #fce4ec; }
.fdt-numpad-back { background: #fff59d; color: #f57f17; }
.fdt-numpad-clear { background: #ef9a9a; color: #b71c1c; }

/* Bottom bar */
.fdt-bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid #e0e0e0; background: #f8f8f8; flex-wrap: wrap; gap: 8px; }
.fdt-bottom-actions { display: flex; gap: 8px; }
.fdt-meta-status { font-size: 12px; color: #555; white-space: nowrap; }
.fdt-help-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.fdt-help-bubble {
    flex: 1; font-size: 13px; color: #1b5e20; background: #e8f5e9;
    border: 1px solid #81c784; border-radius: 8px; padding: 8px 12px;
}
.fdt-plugin-version {
    font-size: 11px;
    color: #9e9e9e;
    line-height: 1.2;
}

/* Editable labels on canvas (overlays) */
.fdt-canvas-label {
    position: absolute; background: #fff; border: 1px solid #aaa; border-radius: 4px;
    padding: 2px 6px; font-size: 12px; font-weight: 600; cursor: pointer;
    user-select: none; white-space: nowrap; z-index: 50;
}
.fdt-canvas-label.fdt-length-label { color: #333; }
.fdt-canvas-label.fdt-angle-label { color: #2e7d32; }

/* ─── Responsive ─── */
@media (max-width: 960px) {
    .fdt-wrapper { max-width: 100%; padding: 0 8px; }
    .fdt-mouse-legends { gap: 8px; margin-left: 6px; }
    .fdt-legend-label { display: none; }
}

@media (max-width: 768px) {
    .fdt-config-panel { padding: 14px; border-radius: 0; }
    .fdt-title { font-size: 18px; }
    .fdt-lines-header { font-size: 12px; }
    .fdt-lines-header-metrics,
    .fdt-line-metrics { grid-template-columns: 64px minmax(0, 1fr) 36px; gap: 6px; }
    .fdt-line-row input,
    .fdt-line-row select { font-size: 16px; /* avoid iOS zoom */ }

    .fdt-canvas-panel { min-height: 0; border-radius: 0; }
    .fdt-bottom-bar { padding: 6px 10px; }
    .fdt-meta-status { font-size: 11px; }
    .fdt-topbar { padding: 8px; }
    .fdt-topbar-row {
        gap: 6px;
        flex-wrap: wrap;
    }
    .fdt-desc-top {
        order: 10;
        flex: 1 1 100%;
        max-width: 100%;
        min-width: 0;
        font-size: 16px;
        height: 40px;
    }
    .fdt-settings-btn { margin-left: auto; }

    .fdt-toolbar {
        padding: 6px;
        gap: 6px;
        align-items: stretch;
        overflow: visible;
    }
    /* Keep left (hamburger) unclipped so the menu can open; scroll only the other rows */
    .fdt-toolbar-left {
        flex-wrap: nowrap;
        overflow: visible;
        max-width: none;
        position: relative;
        z-index: 400;
    }
    .fdt-toolbar-center,
    .fdt-toolbar-right {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        padding-bottom: 2px;
    }
    .fdt-toolbar-center { order: 3; flex: 1 1 100%; justify-content: flex-start; }
    .fdt-mouse-legends { display: none; }
    .fdt-tool-btn {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }
    #fdt-root #fdt-hamburger-menu.fdt-dropdown .fdt-menu-item,
    #fdt-root #fdt-hamburger-menu.fdt-dropdown button,
    #fdt-root .fdt-dropdown .fdt-menu-item,
    #fdt-root .fdt-dropdown button {
        min-height: 44px;
        padding: 12px 14px;
        font-size: 15px;
        color: #111111 !important;
        -webkit-text-fill-color: #111111 !important;
        background: #f5f5f5 !important;
        background-color: #f5f5f5 !important;
    }

    .fdt-canvas-container {
        min-height: 0;
        height: auto;
        flex: 1 1 0;
        max-height: none;
    }
    .fdt-canvas-panel {
        max-height: none;
        border-radius: 0;
    }

    .fdt-bottom-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 6px 8px;
        gap: 4px;
        flex-shrink: 0;
    }
    .fdt-meta-status { white-space: normal; font-size: 11px; }
    /* Compact green help so menus + canvas + status fit one screen */
    .fdt-help-bubble {
        display: block;
        flex: 1 1 100%;
        order: -1;
        font-size: 11px;
        line-height: 1.3;
        padding: 6px 8px;
        border-radius: 6px;
        max-height: 4.2em;
        overflow: hidden;
    }
    .fdt-bottom-actions .fdt-btn { width: 100%; }

    .fdt-point-menu button,
    .fdt-folding-menu button {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 15px;
    }

    .fdt-value-menu.fdt-value-menu--sheet {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        top: auto;
        z-index: 200;
        width: auto;
        max-width: none;
        padding: 12px 14px;
        border-radius: 12px;
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
        align-items: center;
        justify-content: space-between;
    }
    .fdt-value-menu.fdt-value-menu--sheet .fdt-alm-field input {
        width: 110px;
        height: 44px;
        font-size: 18px; /* avoid iOS zoom */
    }
    .fdt-value-menu.fdt-value-menu--sheet .fdt-alm-ok,
    .fdt-value-menu.fdt-value-menu--sheet .fdt-alm-cancel {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .fdt-modal-card { padding: 16px; border-radius: 10px; }
    .fdt-modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .fdt-modal-actions .fdt-btn { width: 100%; min-width: 0; }
    .fdt-taper-modal-footer {
        flex-wrap: wrap;
    }
    .fdt-taper-btn-cancel,
    .fdt-taper-btn-ok {
        flex: 1 1 auto;
        justify-content: center;
    }

    .fdt-dropdown {
        min-width: min(220px, calc(100vw - 24px));
    }
}

@media (max-width: 480px) {
    .fdt-colour-grid { gap: 6px; }
    .fdt-colour-swatch { width: 40px; height: 40px; }
    .fdt-mode-btn { width: 36px; height: 34px; }
    .fdt-canvas-container {
        min-height: 0;
        height: auto;
    }
    .fdt-point-menu, .fdt-folding-menu {
        max-width: calc(100vw - 16px);
    }
    .fdt-help-bubble { font-size: 11.5px; }
}

@media (hover: none) and (pointer: coarse) {
    .fdt-tool-btn,
    .fdt-btn,
    .fdt-colour-swatch {
        touch-action: manipulation;
    }
    /* Default allows vertical page scroll; JS sets touch-action:none while drawing/dragging */
    .fdt-canvas-container {
        touch-action: pan-y;
        overscroll-behavior: contain;
    }
    .fdt-canvas-container canvas {
        touch-action: pan-y;
    }
    .fdt-help-bubble,
    .fdt-bottom-bar,
    .fdt-toolbar,
    .fdt-topbar {
        touch-action: manipulation;
    }
    .fdt-help-bubble {
        display: block;
    }
    .fdt-wrapper.fdt-mode-canvas {
        overscroll-behavior-y: none;
    }
}

/* Inside locked canvas mode, allow pan/zoom gestures on the drawing surface */
html.fdt-canvas-lock .fdt-canvas-container,
html.fdt-canvas-lock .fdt-canvas-container canvas {
    touch-action: none;
}
html.fdt-canvas-lock .fdt-toolbar,
html.fdt-canvas-lock .fdt-topbar,
html.fdt-canvas-lock .fdt-bottom-bar,
html.fdt-canvas-lock .fdt-help-bubble,
html.fdt-canvas-lock .fdt-tool-btn,
html.fdt-canvas-lock .fdt-btn {
    touch-action: manipulation;
}
