:root {
    --lsv-blossom: #FAEFE9;
    --lsv-onion: #E2D5C2;
    --lsv-carmine: #7A5063;
    --lsv-plum: #4A2C3F;
    --lsv-peach: #F4A384;
    --lsv-blue: #486D83;
    --lsv-blue-dark: #2F4A5A;
    --lsv-blue-soft: #DCE6E8;
    --lsv-ink: #211722;
    --lsv-paper: #fff8f2;
    --panel: rgba(250, 239, 233, .08);
    --panel-strong: rgba(250, 239, 233, .14);
    --border: rgba(250, 239, 233, .18);
    --shadow: 0 24px 64px rgba(20, 9, 19, .28);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--lsv-blue-dark);
}

body {
    margin: 0;
    min-height: 100%;
    background:
        linear-gradient(180deg, rgba(47, 74, 90, .92), rgba(33, 23, 34, .96)),
        linear-gradient(135deg, var(--lsv-plum), var(--lsv-blue));
    color: var(--lsv-blossom);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 76px;
    padding: 14px clamp(16px, 4vw, 44px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(47, 74, 90, .72);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(250, 239, 233, .3);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
    font-weight: 900;
}

.brand small {
    margin-top: 2px;
    color: rgba(250, 239, 233, .68);
    font-size: 12px;
    font-weight: 700;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.icon-btn,
.primary-btn,
.ghost-btn,
.danger-btn {
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--lsv-blossom);
    background: rgba(250, 239, 233, .08);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.primary-btn {
    border-color: transparent;
    background: var(--lsv-peach);
    color: var(--lsv-plum);
    box-shadow: 0 16px 34px rgba(244, 163, 132, .18);
}

.ghost-btn {
    min-height: 38px;
    color: var(--lsv-peach);
}

.ghost-btn.compact {
    min-height: 30px;
    padding: 0 12px;
    font-size: 10px;
}

.danger-btn {
    min-height: 34px;
    color: #ffd8d8;
    border-color: rgba(255, 120, 120, .24);
    background: rgba(255, 120, 120, .08);
}

.file-button input {
    display: none;
}

.workspace {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: clamp(18px, 3vw, 42px);
    display: grid;
    grid-template-columns: minmax(320px, .92fr) minmax(520px, 1.4fr);
    gap: 16px;
    align-items: start;
}

.project-panel,
.library-panel,
.builder-panel {
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.project-panel,
.library-panel,
.builder-panel {
    padding: 18px;
}

.project-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(250px, .7fr) minmax(180px, .45fr) minmax(420px, 1.2fr);
    gap: 18px;
    align-items: center;
}

.section-heading h1,
.panel-header h2 {
    margin: 0;
    font-weight: 950;
    line-height: .96;
    letter-spacing: 0;
    text-transform: uppercase;
}

.section-heading h1 {
    max-width: 13ch;
    font-size: clamp(26px, 2.65vw, 38px);
    line-height: 1.04;
    overflow-wrap: break-word;
}

.tool-visual {
    width: 100%;
    margin: 0;
    align-self: stretch;
    min-height: 148px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(250, 239, 233, .18);
    background: rgba(20, 9, 19, .2);
}

.tool-visual img {
    width: 100%;
    height: 100%;
    max-height: 180px;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.panel-header h2 {
    font-size: clamp(24px, 2.5vw, 34px);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--lsv-peach);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.project-fields {
    display: grid;
    gap: 10px;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: rgba(250, 239, 233, .68);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

input,
.search-input {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(250, 239, 233, .18);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--lsv-blossom);
    background: rgba(20, 9, 19, .22);
    outline: none;
}

input:focus {
    border-color: rgba(244, 163, 132, .72);
}

.panel-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-chip {
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 12px;
    color: rgba(250, 239, 233, .72);
    background: transparent;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.filter-chip.is-active {
    color: var(--lsv-plum);
    background: var(--lsv-peach);
    border-color: var(--lsv-peach);
}

.equipment-grid,
.device-list {
    display: grid;
    gap: 10px;
}

.equipment-card,
.device-card {
    border: 1px solid var(--border);
    background: rgba(20, 9, 19, .18);
}

.equipment-card {
    padding: 14px;
    text-align: left;
    color: inherit;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.equipment-card:hover {
    transform: translateY(-3px);
    border-color: rgba(244, 163, 132, .7);
    background: rgba(250, 239, 233, .12);
}

.equipment-card h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.08;
}

.equipment-card p,
.device-kind {
    margin: 7px 0 0;
    color: rgba(250, 239, 233, .66);
    font-size: 13px;
    line-height: 1.35;
}

.tag-row,
.channel-stats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.count-controls {
    margin-top: 12px;
}

.count-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.count-group {
    padding: 10px;
    border: 1px solid rgba(250, 239, 233, .14);
    background: rgba(250, 239, 233, .05);
}

.count-group > span {
    display: block;
    margin-bottom: 8px;
    color: var(--lsv-peach);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.count-group label {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    margin-top: 6px;
    color: rgba(250, 239, 233, .76);
    font-size: 11px;
    font-weight: 900;
}

.count-group input {
    min-height: 34px;
}

.tag,
.stat {
    min-height: 26px;
    border: 1px solid rgba(250, 239, 233, .14);
    border-radius: 999px;
    padding: 5px 9px;
    color: rgba(250, 239, 233, .82);
    background: rgba(250, 239, 233, .06);
    font-size: 11px;
    font-weight: 850;
}

.device-card {
    padding: 14px;
}

.device-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.device-name {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 900;
}

details {
    margin-top: 12px;
}

summary {
    color: var(--lsv-peach);
    cursor: pointer;
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.channels-table {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}

.channel-row {
    display: grid;
    grid-template-columns: 42px 58px minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    color: rgba(250, 239, 233, .76);
    font-size: 12px;
}

.channel-row input {
    min-height: 34px;
}

.empty-state {
    min-height: 220px;
    border: 1px dashed rgba(250, 239, 233, .22);
    display: grid;
    place-items: center;
    text-align: center;
    color: rgba(250, 239, 233, .58);
    padding: 28px;
}

@media (max-width: 1180px) {
    .workspace,
    .project-panel {
        grid-template-columns: 1fr 1fr;
    }

    .tool-visual {
        min-height: 220px;
    }

    .tool-visual img {
        max-height: 260px;
    }

    .project-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .topbar,
    .panel-header,
    .device-top {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        position: static;
    }

    .top-actions {
        justify-content: stretch;
    }

    .top-actions > * {
        flex: 1;
    }

    .workspace,
    .project-panel {
        grid-template-columns: 1fr;
    }

    .channel-row {
        grid-template-columns: 38px 54px minmax(0, 1fr);
    }

    .channel-row .route-input {
        grid-column: 3;
    }

    .count-grid {
        grid-template-columns: 1fr;
    }
}
