:root {
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e5eaf1;
    --card: #ffffff;
    --brand: #2f6fed;
    --red: #dc2626;
    --shadow: 0 20px 44px -30px rgba(15,23,42,.55);
}

* {
    box-sizing: border-box
}

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px
}

header.top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 2px
}

h1 {
    font-size: 22px;
    margin: 0 0 6px;
    letter-spacing: -.01em;
    font-weight: 700
}

    h1 em {
        font-style: normal;
        color: var(--brand)
    }

p.sub {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px
}

    p.sub b {
        color: #33465a;
        font-weight: 600;
        font-variant-numeric: tabular-nums
    }

.seg {
    display: flex;
    gap: 2px;
    background: #eef2f7;
    border: 1px solid var(--line);
    padding: 3px;
    border-radius: 14px
}

    .seg button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1px;
        line-height: 1.25;
        padding: 5px 15px;
        border: 0;
        background: transparent;
        border-radius: 11px;
        cursor: pointer;
        font-family: inherit;
        color: #4a5b70;
        transition: background .16s,color .16s,box-shadow .16s;
    }

        .seg button b {
            font-size: 13px;
            font-weight: 600
        }

        .seg button i {
            font-style: normal;
            font-size: 10.5px;
            color: #8794a6;
            font-variant-numeric: tabular-nums
        }

        .seg button:hover {
            background: #f7fafd
        }

        .seg button.on {
            background: #fff;
            box-shadow: 0 2px 7px -2px rgba(15,23,42,.22);
            color: #16233a
        }

            .seg button.on i {
                color: var(--brand)
            }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow)
}

.stage {
    padding: 8px 6px 0;
    overflow-x: auto;
    overflow-y: hidden;
    user-select: none
}

#main {
    display: block;
    width: 100%;
    min-width: 720px;
    height: 316px;
    touch-action: none;
    cursor: crosshair;
    outline: none
}

.magcard {
    padding: 12px 14px 14px
}

.maghead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 4px 6px;
    font-size: 12.5px;
    color: var(--muted)
}

    .maghead b {
        color: #243447;
        font-weight: 600
    }

.tag {
    font-variant-numeric: tabular-nums;
    background: #f1f5f9;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 11.5px;
    color: #475569
}

#mag {
    display: block;
    width: 100%;
    height: 172px
}

.panel {
    padding: 18px 20px 20px;
    display: grid;
    grid-template-columns: 236px 1fr;
    gap: 20px 26px;
    align-items: start
}

    .panel > * {
        min-width: 0
    }

.result {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 2px
}

.lab {
    font-size: 11.5px;
    color: var(--muted);
    letter-spacing: .10em
}

#value {
    font-size: 42px;
    line-height: 1.06;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
    color: #b6c0cf;
    transition: color .18s
}

    #value.on {
        color: var(--ink)
    }

#valueHint {
    font-size: 12.5px;
    color: var(--muted);
    min-height: 17px
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center
}

.btn {
    height: 44px;
    padding: 0 20px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: #22314a;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .16s,border-color .16s,transform .06s
}

    .btn:hover {
        border-color: #c6d3e2;
        background: #f8fafc
    }

    .btn:active {
        transform: translateY(1px)
    }

    .btn.primary {
        background: linear-gradient(180deg,#3b7bf5,#2a63e0);
        border-color: #2a63e0;
        color: #fff;
        box-shadow: 0 10px 20px -12px rgba(42,99,224,.95)
    }

        .btn.primary:hover {
            filter: brightness(1.06);
            background: linear-gradient(180deg,#3b7bf5,#2a63e0)
        }

    .btn.ghost {
        background: transparent;
        color: #5b6b80
    }

        .btn.ghost:hover {
            background: #f4f7fb;
            color: #334155
        }

.field {
    position: relative;
    display: flex;
    align-items: center
}

    .field input {
        height: 44px;
        width: 196px;
        border-radius: 12px;
        border: 1px solid var(--line);
        padding: 0 44px 0 14px;
        font-size: 15px;
        font-variant-numeric: tabular-nums;
        color: var(--ink);
        outline: none;
        background: #fff;
        font-family: inherit;
        transition: border-color .16s,box-shadow .16s
    }

        .field input::placeholder {
            color: #9aa7b8;
            font-size: 13.5px
        }

        .field input:focus {
            border-color: #9ebcf7;
            box-shadow: 0 0 0 3px rgba(47,111,237,.12)
        }

    .field .u {
        position: absolute;
        right: 14px;
        font-size: 12.5px;
        color: var(--muted);
        pointer-events: none
    }

.explain {
    margin-top: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #edf1f7;
    padding: 4px 14px
}

.ex-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 0;
    font-size: 13.5px;
    color: #41526a;
    border-bottom: 1px dashed #e3e9f1
}

    .ex-row:last-child {
        border-bottom: 0
    }

    .ex-row b {
        font-variant-numeric: tabular-nums;
        color: #16233a;
        font-weight: 600;
        white-space: nowrap
    }

    .ex-row.total {
        border-top: 1px solid #e3e9f1;
        color: #16233a;
        font-weight: 600;
        align-items: baseline
    }

        .ex-row.total b {
            color: var(--red);
            font-size: 16px
        }

.foot {
    margin: 2px 4px 0;
    font-size: 12.5px;
    color: #7c8a9c;
    text-align: center;
    line-height: 1.9
}

kbd {
    font-family: inherit;
    background: #fff;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 5px;
    font-size: 11.5px;
    color: #425268
}

@media (max-width:840px) {
    body {
        padding: 20px 12px 40px
    }

    .panel {
        grid-template-columns: 1fr;
        gap: 14px
    }

    #value {
        font-size: 36px
    }

    header.top {
        align-items: flex-start
    }

    #main {
        min-width: 640px
    }

    .controls {
        gap: 8px
    }

    .field {
        flex: 1 1 150px
    }

        .field input {
            width: 100%
        }

    .btn {
        padding: 0 16px
    }

    .ex-row {
        font-size: 12.5px
    }
}
