/* Survey Unit Converter — site-themed, mobile-friendly layout */

.ts-tool .suc-app {
    --suc-gap: 1rem;
    max-width: 100%;
}

/* Intro */
.ts-tool .suc-intro {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.85rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-sm);
}

.ts-tool .suc-intro p {
    flex: 1 1 14rem;
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.ts-tool .suc-help-link {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-primary);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.ts-tool .suc-help-link:hover {
    border-color: var(--color-primary);
    background: rgba(10, 124, 110, 0.06);
    color: var(--color-primary-hover);
}

/* Workflow chips */
.ts-tool .suc-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.ts-tool .suc-step {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
}

.ts-tool .suc-step i {
    color: var(--color-primary);
    font-size: 0.72rem;
}

.ts-tool .suc-step--active {
    color: var(--color-text);
    border-color: var(--color-primary);
    background: rgba(10, 124, 110, 0.08);
}

/* Workspace */
.ts-tool .suc-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--suc-gap);
    align-items: start;
}

.ts-tool .suc-form-col,
.ts-tool .suc-output-col {
    min-width: 0;
}

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

.ts-tool .suc-section.survey-tool {
    margin-bottom: 0;
}

.ts-tool .suc-section.survey-tool h2 {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-divider);
    color: var(--color-text);
}

.ts-tool .suc-section.survey-tool h2 i {
    color: var(--color-primary);
}

.ts-tool .suc-section .form-group {
    margin-bottom: 0.85rem;
}

.ts-tool .suc-section .form-group:last-of-type {
    margin-bottom: 0;
}

.ts-tool .suc-section label {
    margin-bottom: 0.35rem;
}

.ts-tool .suc-section input,
.ts-tool .suc-section select {
    margin-bottom: 0;
}

/* Live preview under value input (mobile / instant feedback) */
.ts-tool .suc-live-preview {
    margin-top: 0.75rem;
}

.ts-tool .suc-live-preview:empty {
    display: none;
}

.ts-tool .suc-live-preview .suc-details-advanced {
    display: none;
}

@media (min-width: 992px) {
    .ts-tool .suc-live-preview {
        display: none;
    }
}

.ts-tool .suc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.ts-tool .hidden {
    display: none !important;
}

.ts-tool #chainScaleRow.chain-hidden {
    grid-template-columns: 1fr;
}

/* Extra Gunter chain links box */
.ts-tool .suc-gunter-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.65rem;
    padding: 0.75rem 0.85rem;
    background: rgba(217, 119, 6, 0.08);
    border: 1px solid rgba(217, 119, 6, 0.35);
    border-left: 3px solid #d97706;
    border-radius: var(--radius-sm);
}

.ts-tool .suc-gunter-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
}

.ts-tool .suc-gunter-label i {
    color: var(--color-warning);
}

.ts-tool .suc-gunter-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-warning);
}

/* Buttons */
.ts-tool .suc-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.ts-tool .suc-btn-row button {
    flex: 1 1 auto;
    width: auto;
    margin: 0;
    transform: none;
    box-shadow: none;
}

.ts-tool .suc-btn-row .suc-btn--primary {
    background: var(--color-primary);
    color: #fff;
    border-color: transparent;
}

.ts-tool .suc-btn-row .suc-btn--primary:hover {
    background: var(--color-primary-hover);
}

.ts-tool .suc-btn-row .btn-secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.ts-tool .suc-btn-row .btn-secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-surface-2);
}

.ts-tool .suc-btn-row .btn-info {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

.ts-tool .suc-btn-row .btn-info:hover {
    border-color: var(--color-primary);
    background: rgba(10, 124, 110, 0.06);
}

/* Output panel */
.ts-tool .suc-output-panel {
    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.15rem);
    min-height: 10rem;
}

.ts-tool .suc-output-panel > h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-divider);
    color: var(--color-text);
}

/* History */
.ts-tool .survey-history-panel {
    max-height: 0;
    overflow: hidden;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.ts-tool .survey-history-panel.visible {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.65rem;
}

.ts-tool .survey-history-entry {
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--color-text-muted);
    border-left: 3px solid var(--color-primary);
}

.ts-tool .survey-history-entry:last-child {
    margin-bottom: 0;
}

.ts-tool .survey-history-entry strong {
    color: var(--color-text);
}

/* Results */
.ts-tool #result {
    font-size: 0.88rem;
    line-height: 1.55;
    text-align: left;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.ts-tool #result:empty::before {
    content: 'Enter a value above — results appear here automatically.';
    display: block;
    padding: 0.75rem 0.85rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Primary unit grid */
.ts-tool .suc-unit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ts-tool .suc-unit-card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.7rem 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.ts-tool .suc-unit-card--active {
    border-color: var(--color-primary);
    background: rgba(10, 124, 110, 0.08);
    box-shadow: 0 0 0 1px rgba(10, 124, 110, 0.15);
}

.ts-tool .suc-unit-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.ts-tool .suc-unit-card--active .suc-unit-label {
    color: var(--color-primary);
}

.ts-tool .suc-unit-value {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.ts-tool .suc-unit-suffix {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Collapsible detailed modes */
.ts-tool .suc-details-advanced {
    margin-top: 0.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    overflow: hidden;
}

.ts-tool .suc-details-advanced summary {
    padding: 0.6rem 0.75rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.ts-tool .suc-details-advanced summary::-webkit-details-marker {
    display: none;
}

.ts-tool .suc-details-advanced summary::before {
    content: '▸ ';
}

.ts-tool .suc-details-advanced[open] summary::before {
    content: '▾ ';
}

.ts-tool .suc-details-body {
    padding: 0 0.75rem 0.75rem;
    border-top: 1px solid var(--color-divider);
}

.ts-tool .suc-details-body .survey-result-group:first-child {
    margin-top: 0.65rem;
}

.ts-tool .survey-result-container {
    margin: 0;
    padding: 0.75rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.ts-tool .survey-result-summary {
    font-size: 0.84rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--color-divider);
}

.ts-tool .survey-result-summary strong {
    color: var(--color-text);
}

.ts-tool .survey-scale-note {
    color: var(--color-primary);
    font-weight: 600;
}

.ts-tool .survey-result-group {
    margin-bottom: 0.85rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-divider);
}

.ts-tool .survey-result-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.ts-tool .survey-conversion-type {
    color: var(--color-primary);
    font-weight: 600;
    margin-bottom: 0.65rem;
    font-size: 0.88rem;
}

.ts-tool .survey-result-error {
    margin: 0;
    padding: 0.75rem 0.85rem;
    background: var(--color-error-bg);
    border: 1px solid #feb2b2;
    border-radius: var(--radius-sm);
    color: var(--color-error);
    font-size: 0.88rem;
}

.ts-tool .survey-result-item {
    padding: 0.65rem 0.75rem;
    margin: 0.5rem 0;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.ts-tool .survey-result-item:first-of-type {
    margin-top: 0;
}

.ts-tool .survey-result-item:last-of-type {
    margin-bottom: 0;
}

.ts-tool .survey-result-icon {
    font-size: 1.25rem;
    width: 2rem;
    text-align: center;
    flex-shrink: 0;
}

.ts-tool .survey-result-text {
    flex: 1;
    min-width: 0;
}

.ts-tool .survey-result-from {
    color: var(--color-text-muted);
    font-size: 0.82rem;
}

.ts-tool .survey-result-to {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

/* Floating calculator */
.ts-tool .survey-float-button {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 3.25rem;
    height: 3.25rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: background-color 0.2s ease, transform 0.2s ease;
    z-index: 999;
    border: 2px solid var(--color-surface);
    margin: 0;
    padding: 0;
}

.ts-tool .survey-float-button:hover {
    background: var(--color-primary-hover);
    transform: scale(1.05);
}

.ts-tool .survey-floating-calculator {
    position: fixed;
    bottom: -420px;
    right: 1.25rem;
    width: min(320px, calc(100vw - 2rem));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: var(--shadow-md);
    transition: bottom 0.3s ease;
    color: var(--color-text);
    z-index: 1000;
    overflow: hidden;
}

.ts-tool .survey-floating-calculator.active {
    bottom: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.ts-tool .survey-calc-header {
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.ts-tool #calcInput {
    width: calc(100% - 1.5rem);
    margin: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    text-align: right;
}

.ts-tool .survey-calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
    padding: 0 0.75rem 0.75rem;
}

.ts-tool .survey-calc-button {
    padding: 0.75rem 0.5rem;
    font-size: 1rem;
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    margin: 0;
    width: 100%;
    box-shadow: none;
}

.ts-tool .survey-calc-button:hover {
    border-color: var(--color-primary);
    background: rgba(10, 124, 110, 0.08);
    transform: none;
}

.ts-tool .survey-calc-button.clear {
    background: var(--color-error-bg);
    color: var(--color-error);
    border-color: var(--color-error-border);
}

.ts-tool .survey-calc-button.delete {
    background: rgba(10, 124, 110, 0.1);
    color: var(--color-primary);
    border-color: rgba(10, 124, 110, 0.25);
}

/* How it works */
.ts-tool .suc-help {
    margin-top: 1.5rem;
    padding: 0;
}

.ts-tool .suc-help > h2 {
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    margin: 0 0 1rem;
    color: var(--color-text);
}

.ts-tool .suc-guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    gap: 0.75rem;
}

.ts-tool .suc-guide-step {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.ts-tool .suc-guide-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(10, 124, 110, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.65rem;
}

.ts-tool .suc-guide-icon i {
    color: var(--color-primary);
    font-size: 1.1rem;
}

.ts-tool .suc-guide-step h3 {
    font-size: 0.95rem;
    margin: 0 0 0.5rem;
    color: var(--color-text);
}

.ts-tool .suc-guide-step p {
    font-size: 0.84rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* Links-to-feet reference table */
.ts-tool .suc-conversion-table {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.ts-tool .suc-conversion-table > h2 {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 3vw, 1.35rem);
}

.ts-tool .suc-conversion-table > p {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.ts-tool .suc-table-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ts-tool .suc-table-tab {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    cursor: pointer;
}

.ts-tool .suc-table-tab--active {
    background: rgba(10, 124, 110, 0.1);
    border-color: rgba(10, 124, 110, 0.35);
    color: var(--color-primary);
}

.ts-tool .suc-table-wrap {
    max-height: 20rem;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

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

.ts-tool .suc-ref-table--hidden {
    display: none;
}

.ts-tool .suc-ref-table th,
.ts-tool .suc-ref-table td {
    padding: 0.4rem 0.65rem;
    text-align: right;
    border-bottom: 1px solid var(--color-border);
}

.ts-tool .suc-ref-table th:first-child,
.ts-tool .suc-ref-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--color-surface);
}

.ts-tool .suc-ref-table thead th {
    position: sticky;
    top: 0;
    background: var(--color-surface-2);
    font-weight: 600;
    z-index: 1;
}

.ts-tool .suc-ref-table__highlight {
    background: rgba(10, 124, 110, 0.06);
}

.ts-tool .suc-table-note {
    margin: 0.75rem 0 0;
    font-size: 0.84rem;
    color: var(--color-text-muted);
}

@media (max-width: 991px) {
    .ts-tool .suc-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .ts-tool .suc-steps {
        display: none;
    }

    .ts-tool .suc-form-row {
        grid-template-columns: 1fr;
    }

    .ts-tool .suc-unit-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ts-tool .suc-unit-value {
        font-size: 1.15rem;
    }

    .ts-tool .suc-btn-row button {
        flex: 1 1 100%;
    }

    .ts-tool .survey-floating-calculator {
        right: 0;
        width: 100%;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
}