:root {
    --lsth-primary: #5b21b6;
    --lsth-primary-light: #ede9fe;
    --lsth-border: #d4d4d8;
    --lsth-surface: #ffffff;
    --lsth-muted: #6b7280;
    --lsth-bg: #f8fafc;
    --lsth-radius: 12px;
    --lsth-font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

.lsth-tool-root {
    font-family: var(--lsth-font);
    color: #0f172a;
}

.lsth-card {
    background: var(--lsth-surface);
    border: 1px solid var(--lsth-border);
    border-radius: var(--lsth-radius);
    padding: clamp(1.25rem, 3vw, 2rem);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.lsth-header h2 {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.lsth-header p {
    margin: 0.25rem 0 1.5rem;
    color: var(--lsth-muted);
    max-width: 55ch;
}

.lsth-session {
    border: 1px dashed var(--lsth-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: var(--lsth-bg);
}

.lsth-session label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.lsth-session-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.lsth-session-row input {
    flex: 1 1 200px;
    border-radius: 999px;
    border: 1px solid var(--lsth-border);
    padding: 0.5rem 0.95rem;
    font-size: 1rem;
    background: #fff;
}

.lsth-session-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.lsth-session-hint {
    margin: 0;
    font-size: 0.9rem;
    color: var(--lsth-muted);
}

.lsth-status {
    margin-top: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--lsth-primary);
}

.lsth-status[data-state="error"] {
    color: #dc2626;
}

.lsth-status[data-state="success"] {
    color: #059669;
}

.lsth-form {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.lsth-form label {
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    gap: 0.25rem;
}

.lsth-form input[type="text"],
.lsth-form textarea {
    border-radius: 10px;
    border: 1px solid var(--lsth-border);
    padding: 0.65rem 0.85rem;
    font-size: 1rem;
    font-family: inherit;
    background: var(--lsth-bg);
}

.lsth-form input[type="text"]:focus,
.lsth-form textarea:focus {
    outline: 2px solid var(--lsth-primary);
    border-color: transparent;
    background: #fff;
}

.lsth-form textarea {
    resize: vertical;
}

.lsth-form .lsth-notes {
    grid-column: 1 / -1;
}

.lsth-slider {
    width: 100%;
    accent-color: var(--lsth-primary);
}

.lsth-primary {
    grid-column: 1 / -1;
    padding: 0.9rem 1.25rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lsth-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(91, 33, 182, 0.3);
}

.lsth-actions {
    margin: 1.5rem 0 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.lsth-secondary {
    padding: 0.7rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--lsth-border);
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.lsth-secondary:hover {
    background: var(--lsth-primary-light);
}

.lsth-link-btn {
    border: none;
    background: transparent;
    color: var(--lsth-primary);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.lsth-link-btn:hover {
    text-decoration: underline;
}

.lsth-results {
    display: grid;
    gap: 1.5rem;
    margin-top: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.lsth-table-section h3,
.lsth-matrix-section h3,
.lsth-chart-section h3 {
    margin-bottom: 0.75rem;
}

.lsth-table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th,
td {
    text-align: left;
    padding: 0.65rem;
    border-bottom: 1px solid var(--lsth-border);
}

th {
    background: var(--lsth-bg);
    font-weight: 600;
}

.lsth-empty-row td {
    text-align: center;
    color: var(--lsth-muted);
}

.lsth-actions-cell {
    text-align: right;
}

.lsth-table-wrapper table {
    width: 100%;
}

.lsth-table-wrapper th,
.lsth-table-wrapper td {
    width: auto;
}

.lsth-table-wrapper thead th {
    white-space: nowrap;
}

.lsth-remove {
    border: none;
    background: transparent;
    color: #dc2626;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 640px) {
    .lsth-actions {
        justify-content: flex-start;
    }

    .lsth-actions .lsth-secondary {
        flex: 1 1 220px;
    }

    .lsth-table-wrapper {
        overflow: visible;
    }

    .lsth-table-wrapper table,
    .lsth-table-wrapper thead,
    .lsth-table-wrapper tbody,
    .lsth-table-wrapper th,
    .lsth-table-wrapper td,
    .lsth-table-wrapper tr {
        display: block;
        width: 100%;
    }

    .lsth-table-wrapper thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        border: 0;
    }

    .lsth-table-body tr {
        margin-bottom: 1rem;
        border: 1px solid var(--lsth-border);
        border-radius: 12px;
        padding: 0.85rem;
        background: #fff;
        box-shadow: 0 6px 22px rgba(15, 23, 42, 0.08);
    }

    .lsth-table-body tr:last-child {
        margin-bottom: 0;
    }

    .lsth-table-body td {
        border: 0;
        padding: 0.5rem 0;
    }

    .lsth-table-body td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--lsth-muted);
        margin-bottom: 0.15rem;
    }

    .lsth-table-body .lsth-actions-cell {
        display: flex;
        gap: 0.75rem;
        justify-content: flex-end;
        border-top: 1px dashed var(--lsth-border);
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }

    .lsth-table-body .lsth-actions-cell::before {
        display: none;
    }
}

.lsth-matrix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    min-width: 520px;
}

.lsth-matrix-wrapper {
    position: relative;
    padding-left: clamp(2.5rem, 6vw, 3.75rem);
    padding-bottom: clamp(1.25rem, 4vw, 2.4rem);
    overflow-x: auto;
}

.lsth-matrix-axis {
    position: absolute;
    display: flex;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--lsth-muted);
}

.lsth-matrix-axis--x {
    bottom: 0;
    left: 2.4rem;
    right: 0;
    justify-content: space-between;
}

.lsth-matrix-axis--y {
    top: 0;
    bottom: 2.4rem;
    left: 0;
    width: clamp(2.4rem, 6vw, 4.25rem);
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 0.35rem;
}

.lsth-matrix-axis--y span {
    transform: none;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    text-align: right;
    display: block;
    width: 100%;
    white-space: nowrap;
}

.lsth-matrix-axis-label {
    position: absolute;
    font-weight: 700;
    color: #0f172a;
}

.lsth-matrix-axis-label--x {
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
}

.lsth-matrix-axis-label--y {
    left: clamp(1.4rem, 4vw, 2.5rem);
    top: 50%;
    transform-origin: center;
    transform: translate(-50%, -50%) rotate(-90deg);
    white-space: nowrap;
}

@media (max-width: 520px) {
    .lsth-matrix-grid {
        min-width: 420px;
    }

    .lsth-matrix-axis--y {
        width: auto;
        padding-right: 0;
        align-items: flex-start;
    }

    .lsth-matrix-axis--y span {
        text-align: left;
    }

    .lsth-matrix-axis-label {
        font-size: 0.85rem;
    }

    .lsth-matrix-axis-label--x {
        bottom: -1.75rem;
    }

    .lsth-matrix-axis-label--y {
        bottom: -3rem;
        top: auto;
        left: 50%;
        transform: translate(-50%, 0);
        text-align: center;
        white-space: normal;
    }
}

.lsth-matrix-cell {
    border: 1px solid var(--lsth-border);
    border-radius: 12px;
    padding: 1rem;
    min-height: 160px;
    background: var(--lsth-bg);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lsth-matrix-cell header {
    font-weight: 700;
}

.lsth-matrix-cell ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lsth-matrix-cell li {
    background: #fff;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.lsth-matrix-cell li strong {
    display: block;
}

.lsth-matrix-cell li span {
    color: var(--lsth-muted);
    font-size: 0.85rem;
}

.lsth-empty {
    color: var(--lsth-muted);
    border-style: dashed;
    text-align: center;
}

.lsth-chart-section {
    background: var(--lsth-bg);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--lsth-border);
}

.lsth-chart {
    width: 100%;
    height: auto;
    display: block;
}

.lsth-chart-legend {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    padding: 0.75rem;
    background: var(--lsth-bg);
    border-radius: 12px;
    border: 1px solid var(--lsth-border);
}

.lsth-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    font-weight: 600;
    color: #0f172a;
    flex: 1 1 220px;
    min-width: clamp(150px, 45%, 220px);
}

.lsth-legend-icon {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
}

@media (max-width: 640px) {
    .lsth-chart-legend {
        justify-content: flex-start;
    }

    .lsth-legend-item {
        flex-basis: 100%;
    }
}

@media (min-width: 900px) {
    .lsth-results {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
    }
}
