/* Shared online tool UI — matches Form-15 / site theme */

.ts-tool,
.ts-tool * {
    box-sizing: border-box;
}

.ts-tool {
    --ts-tool-touch: 2.75rem;
    font-family: var(--font-body);
    color: var(--color-text);
    line-height: 1.6;
    max-width: 100%;
    padding: 0;
    background: transparent;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.ts-tool__inner {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Utility: keep collapsed panels out of layout without relying on tool-specific CSS */
.ts-tool .hidden,
#appView.ts-notice-tool .hidden,
.ts-tool [hidden],
#appView.ts-notice-tool [hidden] {
    display: none !important;
}

/* Hide duplicate in-tool titles (page header already shows the name) */
.ts-tool .elementor-heading-title,
.ts-tool .survey-hero h1,
.ts-tool .calc-container > h1:first-of-type {
    display: none;
}

.ts-tool .survey-tool-page,
.ts-tool .calc-container,
.ts-tool #fmb-calculator,
.ts-tool .tool-panel {
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 0;
}

.ts-tool .survey-hero {
    padding: 0 0 1rem;
    margin: 0 0 1rem;
    text-align: left;
}

.ts-tool .survey-hero-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 0 0.75rem;
    box-shadow: var(--shadow-sm);
}

.ts-tool .survey-hero-icon i {
    font-size: 1.35rem;
}

.ts-tool .survey-hero p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--color-text-muted);
}

.ts-tool .survey-container {
    max-width: 100%;
}

.ts-tool .survey-tool,
.ts-tool .tool-card,
.ts-tool .panel,
.ts-tool #results {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: clamp(0.75rem, 2.5vw, 1.25rem);
}

.ts-tool h2,
.ts-tool h3,
.ts-tool h4 {
    font-family: var(--font-display);
    color: var(--color-text);
    line-height: 1.3;
}

.ts-tool label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--color-text);
}

.ts-tool input[type="text"],
.ts-tool input[type="number"],
.ts-tool input[type="email"],
.ts-tool input[type="file"],
.ts-tool input[type="date"],
.ts-tool input[type="time"],
.ts-tool input[type="search"],
.ts-tool input[type="tel"],
.ts-tool input[type="url"],
.ts-tool select,
.ts-tool textarea {
    width: 100%;
    max-width: 100%;
    min-height: var(--ts-tool-touch);
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    /* 16px prevents iOS Safari focus zoom */
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-surface);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.ts-tool textarea {
    min-height: 6rem;
    resize: vertical;
}

.ts-tool input:focus,
.ts-tool select:focus,
.ts-tool textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 124, 110, 0.15);
}

.ts-tool button,
.ts-tool input[type="button"],
.ts-tool input[type="submit"],
.ts-tool .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: var(--ts-tool-touch);
    padding: 0.62rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.2s ease, transform 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ts-tool button:hover,
.ts-tool input[type="button"]:hover,
.ts-tool input[type="submit"]:hover,
.ts-tool .btn:hover {
    background: var(--color-primary-hover);
}

.ts-tool button:disabled,
.ts-tool input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ts-tool table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.ts-tool th,
.ts-tool td {
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--color-border);
    text-align: left;
}

.ts-tool th {
    background: var(--color-surface-2);
    font-weight: 600;
}

.ts-tool .responsive-table,
.ts-tool .table-scroll,
.ts-tool .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ts-tool .bend-table {
    min-width: 540px;
}

.ts-tool #results div:nth-child(odd) {
    background: var(--color-surface-2);
}

.ts-tool #results div:nth-child(even) {
    background: var(--color-surface);
}

.ts-tool #map,
.ts-tool .map-container,
.ts-tool #mapDiv {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.ts-tool form {
    max-width: 100%;
}

.ts-tool #surveyForm p {
    margin: 0.65rem 0;
    font-size: 1rem;
    line-height: 1.5;
}

.ts-tool #surveyForm input[type="text"] {
    margin-top: 0.35rem;
}

.ts-tool-faq {
    margin-top: 1.75rem;
    padding: 1.25rem 1.35rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface, #fff);
}

.ts-tool-faq__title {
    margin: 0 0 1rem;
    font-size: 1.2rem;
    font-family: 'Source Serif 4', Georgia, serif;
}

.ts-tool-faq__item + .ts-tool-faq__item {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.ts-tool-faq__q {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.ts-tool-faq__a {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--color-text-muted, #5f7168);
}

/* —— Shared mobile foundation (all .ts-tool tools) —— */
@media (max-width: 767px) {
    .ts-tool {
        overflow-x: clip;
    }

    .ts-tool .survey-tool,
    .ts-tool .tool-card,
    .ts-tool .panel,
    .ts-tool #results {
        padding: 0.75rem 0.65rem;
        border-radius: var(--radius-sm);
    }

    .ts-tool .survey-hero {
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .ts-tool .survey-hero-icon {
        width: 2.5rem;
        height: 2.5rem;
    }

    .ts-tool h2 {
        font-size: clamp(1.05rem, 4.5vw, 1.25rem);
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .ts-tool h3,
    .ts-tool h4 {
        font-size: clamp(0.95rem, 4vw, 1.1rem);
        overflow-wrap: anywhere;
    }

    .ts-tool p,
    .ts-tool li {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Primary actions: full-width, easy thumb reach */
    .ts-tool button,
    .ts-tool input[type="button"],
    .ts-tool input[type="submit"],
    .ts-tool .btn {
        width: 100%;
        max-width: 100%;
        min-height: var(--ts-tool-touch);
        justify-content: center;
    }

    /* Icon-only / compact toolbar & row actions stay compact */
    .ts-tool button.icon-btn,
    .ts-tool button.icon-only,
    .ts-tool .icon-btn,
    .ts-tool .tool-icon-btn,
    .ts-tool [class*="toolbar"] button,
    .ts-tool [class*="-toolbar"] button,
    .ts-tool [class*="floating"] button,
    .ts-tool .btn-icon,
    .ts-tool .btn-sm,
    .ts-tool .btn-small,
    .ts-tool .lac-tool-btn,
    .ts-tool .cac-tool-btn,
    .ts-tool .gis-rail-btn,
    .ts-tool .gis-topbar-btn,
    .ts-tool .gis-layer-btn,
    .ts-tool button[class*="delete"],
    .ts-tool button[class*="remove"],
    .ts-tool button[class*="icon"],
    .ts-tool td button,
    .ts-tool th button,
    .ts-tool tr button,
    .ts-tool .table-actions button,
    .ts-tool .row-actions button {
        width: auto;
        min-width: var(--ts-tool-touch);
        min-height: var(--ts-tool-touch);
        padding-inline: 0.65rem;
        flex: 0 0 auto;
    }

    /* Stack multi-column form rows */
    .ts-tool .form-row,
    .ts-tool .form-row-2,
    .ts-tool .form-row-3,
    .ts-tool .form-grid,
    .ts-tool .form-grid-2,
    .ts-tool .form-grid-3,
    .ts-tool .grid-2,
    .ts-tool .grid-3,
    .ts-tool .fields-row,
    .ts-tool .input-row,
    .ts-tool .controls-row,
    .ts-tool .action-row,
    .ts-tool .actions,
    .ts-tool .button-row,
    .ts-tool .btn-row,
    .ts-tool .btn-group,
    .ts-tool .controls,
    .ts-tool .toolbar:not([class*="floating"]):not([class*="rail"]) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .ts-tool [class*="grid"][style*="grid-template"],
    .ts-tool .two-col,
    .ts-tool .three-col {
        grid-template-columns: 1fr !important;
    }

    /* Tables: horizontal scroll, never page overflow */
    .ts-tool table {
        font-size: 0.84rem;
    }

    .ts-tool th,
    .ts-tool td {
        padding: 0.5rem 0.55rem;
    }

    .ts-tool .responsive-table,
    .ts-tool .table-scroll,
    .ts-tool .table-wrapper,
    .ts-tool .table-wrap,
    .ts-tool [class*="table-wrap"],
    .ts-tool [class*="table-scroll"] {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        margin-inline: 0;
    }

    .ts-tool .bend-table {
        min-width: min(540px, 100%);
    }

    /* Maps / canvases: usable height without dominating the phone */
    .ts-tool #map,
    .ts-tool .map-container,
    .ts-tool #mapDiv,
    .ts-tool [id$="-map"],
    .ts-tool [class*="map-wrap"],
    .ts-tool [class*="canvas-stage"],
    .ts-tool canvas {
        max-width: 100%;
    }

    .ts-tool #map,
    .ts-tool .map-container,
    .ts-tool #mapDiv {
        min-height: 16rem;
        height: min(50vh, 22rem);
    }

    /* File inputs and long labels */
    .ts-tool input[type="file"] {
        font-size: 0.88rem;
        padding: 0.55rem;
    }

    .ts-tool label {
        font-size: 0.9rem;
        line-height: 1.35;
    }

    /* Fixed bottom chrome clears the phone tab bar */
    .ts-tool [class*="fixed-bar"],
    .ts-tool [class*="bottom-bar"] {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
        bottom: calc(var(--mobile-tab-height, 3.65rem) + env(safe-area-inset-bottom, 0px));
    }

    .ts-tool button,
    .ts-tool input[type="button"],
    .ts-tool input[type="submit"],
    .ts-tool .btn {
        border-radius: 12px;
        font-weight: 700;
    }

    .ts-tool input[type="text"],
    .ts-tool input[type="number"],
    .ts-tool input[type="email"],
    .ts-tool input[type="file"],
    .ts-tool input[type="date"],
    .ts-tool input[type="time"],
    .ts-tool input[type="search"],
    .ts-tool input[type="tel"],
    .ts-tool input[type="url"],
    .ts-tool select,
    .ts-tool textarea {
        border-radius: 12px;
        min-height: 3rem;
    }

    .ts-tool label {
        margin-bottom: 0.4rem;
    }

    .ts-tool-faq {
        padding: 0.9rem 0.85rem;
        margin-top: 1.25rem;
    }

    .ts-tool-faq__title {
        font-size: 1.05rem;
    }

    .ts-tool-faq__q {
        font-size: 0.95rem;
    }

    .ts-tool-faq__a {
        font-size: 0.9rem;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    .ts-tool .survey-tool,
    .ts-tool .tool-card,
    .ts-tool .panel,
    .ts-tool #results {
        padding: 0.6rem 0.5rem;
    }

    .ts-tool button,
    .ts-tool input[type="button"],
    .ts-tool input[type="submit"],
    .ts-tool .btn {
        font-size: 0.88rem;
        padding-inline: 0.75rem;
    }
}

/* Prefer reduced motion: no hover lifts on touch devices */
@media (hover: none) and (pointer: coarse) {
    .ts-tool button:hover,
    .ts-tool input[type="button"]:hover,
    .ts-tool input[type="submit"]:hover,
    .ts-tool .btn:hover {
        transform: none;
    }
}