﻿:root {
    --bg: #eef3e8;
    --card: #fff;
    --ink: #1b1b1b;
    --muted: #556;
    --accent: #2f6f3e;
    --line: #d9e2cf;
    --page-w: 1100px;
    --rail-w: 360px;
    --rail-gap: 24px;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    padding: 24px;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px
}

h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: .2px
}

.muted {
    color: var(--muted)
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center
}

input, select, button {
    padding: .55rem .7rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background-color: lightblue;
    color: var(--ink);
    font: 16px system-ui;
    min-height: 42px;
}

input[type="number"] {
    width: 110px
}

select {
    min-width: 160px
}

button {
    cursor: pointer;
    background: var(--card)
}

button.primary {
    background: var(--accent);
    color: #fff;
    border: 1px solid #1c4627
}

.grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 18px;
    align-items: start
}

.card {
    background-color: peachpuff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 1px 0 rgba(0,0,0,.04)
}

.card h2 {
    margin: 0 0 12px 0;
    font-size: 22px
}

.pill {
    display: block;
    padding: 4px 10px;
    border-radius: 9px;
    background-color: powderblue;
    border: 1px solid var(--line);
    font-size: 24px
}

.spaced {
    display: flex;
    justify-content: space-between;
    align-items: center
}

.field {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 10px 0
}

.field > label:first-child {
    min-width: 180px;
    color: var(--muted)
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 12px 0
}

.total-line {
    font-weight: 600
}

/* Table styles for sections */
table {
    width: 100%;
    border-collapse: collapse
}

th, td {
    border-bottom: 1px solid #edf1e6;
    padding: .5rem;
    text-align: left
}

.set-header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem
}

.set-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap
}

.set-name {
    min-width: 50px;
    width: 120px;
    max-width: 150px;
}

.set-qty {
    width: 75px;
    min-width: 50px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.mini {
    padding: .35rem .55rem;
    font-size: .95rem;
    border-radius: 8px
}

.small {
    font-size: 13px;
    line-height: 1.35;
}


.info-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
    cursor: help;
    user-select: none;
    background: #fff;
    color: var(--muted);
}

.info-dot:hover {
    box-shadow: 0 0 0 2px rgba(0,0,0,.04) inset;
}

.delete-set {
    background-color: tomato;
}

.del {
    background-color: tomato;
}

.add-row {
    background-color: lightgreen;
}

.add-set-below {
    background-color: lightgreen;
}

/* Floating + collapsible Result card */
#resultCard {
    position: fixed;
    top: var(--header-h, 80px);
    right: max(calc((100vw - 1100px)/2 + 16px), 16px);
    width: 420px;
    z-index: 1000;
    background: #fbe6d6;
    border: 2px solid #ccc;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    cursor: grab; /* show drag hint */
}

#resultCard.dragging {
    opacity: 0.85;
    cursor: grabbing;
}

/* header row inside card */
#resultCard .rc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: 0 0 .5rem 0;
}

#resultCard .rc-title {
    margin: 0;
    font-size: 1.3rem;            /* bigger title */
}

#resultCard .rc-toggle {
    border: 1px solid #ddd;
    background: #f7f7f7;
    border-radius: 8px;
    padding: .25rem .5rem;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

#resultCard .rc-toggle:focus-visible {
    outline: 2px solid #5b9dd9;
}

#resultCard .rc-toggle .chev {
    display: inline-block;
    transition: transform .18s ease;
}

/* total + details */
#resultCard .total-line {
    font-weight: 700;
    font-size: 1.2rem;            /* emphasized total */
    margin-top: .35rem;
}

#resultCard .counts,
#resultCard .breakdown {
    margin-top: .35rem;
    color: #566;
}

/* collapsed: keep only total line visible */
#resultCard.collapsed .counts,
#resultCard.collapsed .breakdown {
    display: none !important;
}

#resultCard.collapsed .rc-toggle .chev {
    transform: rotate(-90deg);    /* ▾ -> ▸ */
}

/* Responsive: center & tighten on small screens */
@media (max-width: 768px) {
    #resultCard {
        width: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        padding: .75rem 1rem;
        font-size: 1rem;
    }
    #resultCard .rc-title {
        font-size: 1.1rem;
    }
    /* optionally hide details on phones */
    #resultCard .counts,
    #resultCard .breakdown{
        display: none;
    }
}

/* ---------- Header layout ---------- */
.set-header {
    margin-bottom: .5rem;
}

    .set-header .set-controls {
        display: grid;
        /* 2fr for larger Set name, then Qty, #Cords, and a fixed Actions-width column that matches table */
        grid-template-columns: 2fr max-content max-content var(--actions-col-w, 180px);
        align-items: end;
        column-gap: 12px;
    }

    /* Make Set name input wider and pleasant */
    .set-header .set-name {
        min-width: 29ch; 
    }

    /* Push the Remove button to the far right column (aligns with table Actions) */
    .set-header .delete-set {
        justify-self: end;
    }

/* ---------- Table column sizing & spacing ---------- */
.set-table {
    width: 100%;
    border-collapse: collapse;
}

/* Column widths: Knot Type ~50% wider; VLen narrower; Actions fixed */
.col-knot-type {
    width: 1.5fr;
}
/* uses fr via grid fallback below */
.col-vlen {
    width: 0.9fr;
}

.col-actions {
    width: var(--actions-col-w, 180px);
}

/* Tighter gap between Knot Type and VLen */
.set-table th, .set-table td {
    padding: .45rem .5rem;
}

    .set-table td:nth-child(1) {
        padding-right: .4rem;
    }
    /* smaller right padding -> visually closer */
    .set-table td:nth-child(2) {
        padding-left: .3rem;
    }
    /* tighter gutter */

    /* Ensure the Actions column stays a fixed visual width */
    .set-table th:nth-child(3),
    .set-table td:nth-child(3) {
        width: var(--actions-col-w, 180px);
        text-align: left; /* keep buttons natural */
    }

/* Inputs/selects within table cells fill their column nicely */
.set-table select.knot,
.set-table input.vlen {
    width: 100%;
    box-sizing: border-box;
}

/* ---------- Knot summary styles (match "Result (All Sets)" look) ---------- */
/* Slightly lighter peach than the page background; rounded w/ soft shadow */
:root {
    /* adjust these to match your theme if you already expose them */
    --peach: #f7d8c3; /* your main peachy bg (approx) */
    --peach-light: #fbe6d6; /* slightly lighter for summary card */
    --card-radius: 12px;
    --card-shadow: 0 6px 18px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    --line: #e9d3c6;
}

.knot-summary {
    margin-top: .75rem;
    padding: .9rem 1rem;
    background: var(--peach-light);
    border: 1px solid var(--line);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

    .knot-summary .muted {
        margin-bottom: .25rem;
    }

/* ---------- Buttons (optional visual alignment help) ---------- */
button.mini {
    padding: .5rem .75rem;
    border-radius: 8px;
}

.del.knotSet.mini { /* "Remove Knot" buttons in table */
    display: inline-block;
    width: 100%;
    max-width: 170px;
}

.knot {
    font-style: oblique
}

.knotSet {
    font-weight:600;
}

/* Make only the header the drag handle (not the whole card) */
#resultCard {
    cursor: auto;
}

    /* Tinted header so it's obvious you can drag it */
    #resultCard .rc-head {
        background: #f7d9c9; /* a touch deeper than #fbe6d6 */
        border: 1px solid #e6c6b6;
        border-radius: 10px;
        padding: .4rem .6rem;
        cursor: grab; /* show drag hint on the header */
        transition: background-color .15s ease, box-shadow .15s ease;
    }

        /* Hover/active feedback */
        #resultCard .rc-head:hover {
            background: #f5ceb9; /* slightly stronger on hover */
            box-shadow: 0 1px 3px rgba(0,0,0,.08) inset;
        }

    #resultCard.dragging .rc-head {
        cursor: grabbing;
        background: #f2c6af;
    }

    /* Keep the title/chevron comfy inside the tinted header */
    #resultCard .rc-title {
        margin: 0;
    }

    #resultCard .rc-toggle {
        background: #fff;
    }
/* still readable on the tinted header */
