.group-header.group-header--with-preset .group-info {
    flex: 0 1 auto;
}

.group-header.group-header--with-preset .group-name {
    margin-inline-start: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.group-header--with-preset .group-avatar {
    flex: none;
}

.calculator-preset-trigger {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    max-width: 58%;
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid #484848;
    border-radius: 0;
    background: #252525;
    color: #d4d4d4;
    cursor: pointer;
    font: inherit;
    font-size: 0.75rem;
    line-height: 1.25;
    text-align: end;
}

.calculator-preset-trigger:hover {
    border-color: #777;
    background: #303030;
}

.calculator-preset-trigger-value {
    color: #fff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.calculator-preset-trigger svg {
    flex: none;
}

.calculator-preset-dialog {
    --preset-border: #3d3d3d;
    --preset-muted: #bcbcbc;
    --preset-inset: 20px;
    box-sizing: border-box;
    width: min(474px, calc(100% - 24px));
    max-height: calc(100dvh - 24px);
    padding: 0;
    border: 1px solid var(--preset-border);
    border-radius: 0;
    background: var(--card-background, #232323);
    color: #f4f4f4;
    color-scheme: dark;
    font-size: 0.875rem;
    overflow: hidden;
}

.calculator-preset-dialog form {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 26px);
    margin: 0;
}

.calculator-preset-dialog::backdrop {
    background: rgb(0 0 0 / 73%);
}

.calculator-preset-dialog [hidden] {
    display: none;
}

.calculator-preset-trigger:focus-visible,
.calculator-preset-dialog :is(input, button):focus-visible,
.calculator-preset-option:has(input:focus-visible) {
    outline: 1px solid #dedede;
    outline-offset: 2px;
}

.calculator-preset-heading {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
    padding: 12px var(--preset-inset);
    border-bottom: 1px solid var(--preset-border);
    background: #1b1b1b;
}

.calculator-preset-heading img {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 0;
    background: #313131;
    object-fit: cover;
    object-position: center 40%;
}

.calculator-preset-heading h2 {
    margin: 0;
    color: inherit;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
    outline: none;
}

.calculator-preset-heading p {
    margin: 2px 0 0;
    color: var(--preset-muted);
    font-size: 0.8125rem;
}

.calculator-preset-body,
.calculator-preset-fields {
    display: grid;
    gap: 16px;
}

.calculator-preset-body {
    min-height: 0;
    padding: 0 var(--preset-inset) 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.calculator-preset-modes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 1px solid var(--preset-border);
}

.calculator-preset-mode {
    position: relative;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    min-height: 44px;
    padding: 6px 10px;
    border-bottom: 2px solid transparent;
    color: var(--preset-muted);
    cursor: pointer;
    font-weight: 600;
    text-align: center;
}

.calculator-preset-mode:hover {
    background: #292929;
    color: #fff;
}

.calculator-preset-mode:has(input:checked) {
    border-bottom-color: #d77479;
    color: #fff;
}

.calculator-preset-mode:has(input:focus-visible) {
    outline: 1px solid #dedede;
    outline-offset: -3px;
}

.calculator-preset-dialog fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.calculator-preset-dialog legend {
    padding: 0;
    margin-bottom: 8px;
    font-weight: 600;
}

.calculator-preset-forge {
    margin-inline-start: 5px;
    color: var(--preset-muted);
    font-size: 0.8125rem;
    font-weight: 400;
}

.calculator-preset-choices {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.calculator-preset-choices--forge {
    grid-template-columns: repeat(8, minmax(0, 1fr));
}

.calculator-preset-option {
    position: relative;
    display: grid;
    place-content: center;
    box-sizing: border-box;
    gap: 2px;
    min-height: 44px;
    padding: 3px 1px;
    border: 1px solid transparent;
    border-radius: 0;
    background: #202020;
    cursor: pointer;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
}

.calculator-preset-option input,
.calculator-preset-mode input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.calculator-preset-option small {
    color: var(--preset-muted);
    font-size: 0.6875rem;
    font-weight: 400;
    white-space: nowrap;
}

.calculator-preset-option:hover {
    border-color: #777;
}

.calculator-preset-option:has(input:checked) {
    border-color: #ad555a;
    background: #39282a;
}

.calculator-preset-number,
.calculator-preset-check {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
}

.calculator-preset-number small {
    display: block;
    margin-top: 3px;
    color: var(--preset-muted);
    font-size: 0.75rem;
    font-weight: 400;
}

.calculator-preset-number input {
    flex: 0 0 72px;
    box-sizing: border-box;
    width: 72px;
    height: 38px;
    padding: 6px 8px;
    border: 1px solid #555;
    border-radius: 0;
    background: #191919;
    color: inherit;
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

.calculator-preset-check-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 12px;
}

.calculator-preset-check {
    justify-content: flex-start;
    min-height: 36px;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.calculator-preset-choices + .calculator-preset-check {
    margin-top: 8px;
}

.calculator-preset-check input[type="checkbox"] {
    order: -1;
    appearance: auto;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    margin: 0;
    background: none;
    accent-color: #b23b42;
}

.calculator-preset-check:has(input:disabled) {
    color: var(--preset-muted);
    cursor: default;
}

.calculator-preset-check input:disabled {
    cursor: default;
}

.calculator-preset-note {
    margin: 0;
    color: var(--preset-muted);
    font-size: 0.8125rem;
}

.calculator-preset-weapon-note {
    margin-bottom: 8px;
}

.calculator-preset-footer {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px var(--preset-inset);
    border-top: 1px solid var(--preset-border);
    background: #1b1b1b;
}

.calculator-preset-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    color: var(--preset-muted);
    font-size: 0.75rem;
    line-height: 1.3;
}

.calculator-preset-preview > div {
    display: grid;
    gap: 2px;
}

.calculator-preset-preview output {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.calculator-preset-actions {
    display: flex;
    gap: 8px;
    margin-inline-start: auto;
}

.calculator-preset-actions button {
    min-width: 62px;
    min-height: 40px;
    padding: 5px 9px;
    border: 1px solid #474747;
    border-radius: 0;
    background: #272727;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.calculator-preset-actions button:hover {
    background: #383838;
}

.calculator-preset-actions button[type="submit"] {
    border-color: #b84348;
    background: #9e2d34;
    color: #fff;
}

.calculator-preset-actions button[type="submit"]:hover {
    background: #b7373e;
}

@media (max-width: 480px) {
    .group-header.group-header--with-preset .group-header-inner {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        row-gap: 4px;
    }

    .group-header--with-preset .calculator-preset-trigger {
        grid-column: 2;
        justify-self: start;
        max-width: calc(100% - 36px);
        min-height: 30px;
        margin-inline-start: 36px;
        text-align: start;
    }

    .calculator-preset-dialog {
        --preset-inset: 14px;
    }

    .calculator-preset-choices--forge {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .calculator-preset-check-group {
        grid-template-columns: 1fr;
    }

    .calculator-preset-trigger {
        gap: 5px;
    }
}

@media (max-height: 600px) {
    .calculator-preset-body,
    .calculator-preset-fields {
        gap: 12px;
    }
}
