:root {
    --wdbb-page: #1e1e1e;
    --wdbb-card: #34363d;
    --wdbb-text: #fff;
    --wdbb-muted: #ccc;
    --wdbb-blue: #3fc2ff;
    --wdbb-orange: #ff9727;
    --wdbb-side: 300px;
    --wdbb-card-px: 320px;
}

* {
    box-sizing: border-box;
    scrollbar-color: #4a5160 transparent;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--wdbb-page);
    color: var(--wdbb-text);
    font-family: Lexend, sans-serif;
    font-size: 15px;
    color-scheme: dark;
    overscroll-behavior: none;
}

button,
select,
input {
    font: inherit;
    color: inherit;
    touch-action: manipulation;
}

:focus-visible {
    outline: 2px solid var(--wdbb-blue);
    outline-offset: 2px;
}

.wdbb-size {
    display: grid;
    grid-template-columns: var(--wdbb-side) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.wdbb-size-side {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    padding: 22px 18px 28px;
    overflow: auto;
    background: #26282e;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.wdbb-size-side h1,
.wdbb-size-picks h2,
.wdbb-size-name {
    margin: 0;
    font-family: Hanuman, sans-serif;
    font-weight: 700;
    line-height: 1.1;
}

.wdbb-size-side h1 {
    font-size: 34px;
}

.wdbb-size-help summary {
    color: var(--wdbb-blue);
    font-weight: 600;
    cursor: pointer;
}

.wdbb-size-help summary:hover {
    color: #79d6ff;
}

.wdbb-size-lead,
.wdbb-size-limit,
.wdbb-size-note,
.wdbb-size-measures {
    margin: 0;
    color: var(--wdbb-muted);
    line-height: 1.45;
}

.wdbb-size-slider-label {
    font-size: 13px;
    font-weight: 600;
}

.wdbb-size-side input[type="range"] {
    width: 100%;
    height: 32px;
    margin: 0;
    accent-color: var(--wdbb-blue);
    cursor: pointer;
}

.wdbb-size-units {
    display: flex;
    gap: 8px;
}

.wdbb-size-units button,
.wdbb-size-add button,
.wdbb-size-view,
.wdbb-size-remove,
.wdbb-size-close {
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.wdbb-size-units button {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--wdbb-muted);
}

.wdbb-size-units button.is-on {
    border-color: var(--wdbb-blue);
    background: var(--wdbb-blue);
    color: #1e1e1e;
    font-weight: 600;
}

.wdbb-size-picks h2 {
    font-size: 22px;
}

.wdbb-size-limit {
    font-size: 12px;
}

.wdbb-size-picks ul {
    display: grid;
    gap: 8px;
    margin: 10px 0;
    padding: 0;
    list-style: none;
}

.wdbb-size-picks li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 38px;
    padding: 6px 8px 6px 10px;
    border: 1px solid rgba(63, 194, 255, 0.45);
    border-radius: 8px;
    background: #1e1e1e;
    font-size: 13px;
    font-weight: 600;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.wdbb-size-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--wdbb-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.wdbb-size-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.wdbb-size select {
    width: 100%;
    min-height: 40px;
    padding: 0 32px 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: #1e1e1e;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23cccccc' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px 8px;
    font-size: 16px;
    appearance: none;
    cursor: pointer;
}

.wdbb-size-add button,
.wdbb-size-view {
    min-height: 40px;
    padding: 0 14px;
    background: var(--wdbb-blue);
    color: #1e1e1e;
    font-weight: 600;
    text-decoration: none;
}

.wdbb-size-add button:disabled {
    opacity: 0.45;
    cursor: default;
}

.wdbb-size-stage {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: auto;
    background: #2a2c31;
}

.wdbb-size-scroll {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    width: max-content;
    min-width: 100%;
}

.wdbb-size-figures,
.wdbb-size-descs {
    display: flex;
    gap: 28px;
    width: max-content;
    min-width: 100%;
}

.wdbb-size-figures {
    flex: 1 1 auto;
    align-items: flex-end;
    overflow: visible;
    padding: 96px 28px 0 18px;
}

.wdbb-size-descs {
    flex: 0 0 auto;
    align-items: flex-start;
    overflow: visible;
    padding: 14px 28px 72px 18px;
    background: #26282e;
    border-top: 2px solid rgba(255, 255, 255, 0.28);
}

.wdbb-size-spacer {
    flex: 0 0 calc(var(--wdbb-card-px) + 24px);
    width: calc(var(--wdbb-card-px) + 24px);
}

.wdbb-size-card {
    position: fixed;
    z-index: 1;
    top: 18px;
    left: calc(var(--wdbb-side) + 18px);
    width: var(--wdbb-card-px);
    font-size: calc(var(--wdbb-card-px) / 22);
    pointer-events: none;
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.38));
}

.wdbb-size-card.is-preview {
    position: relative;
    top: auto;
    left: auto;
    width: 360px;
    font-size: 16.4px;
    filter: none;
}

.wdbb-size-figure,
.wdbb-size-desc {
    position: relative;
    z-index: 2;
}

.wdbb-size-card-face {
    position: relative;
    aspect-ratio: 85.6 / 53.98;
    overflow: hidden;
    border-radius: 0.72em;
    background:
        radial-gradient(90% 80% at 100% 0%, rgba(63, 194, 255, 0.38), transparent 46%),
        linear-gradient(145deg, #3a4554 0%, #1a1e26 42%, #12151b 100%);
    color: #f5f7fb;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.wdbb-size-card-art,
.wdbb-size-card-shine {
    position: absolute;
    inset: 0;
}

.wdbb-size-card-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wdbb-size-card-shine {
    background: linear-gradient(115deg, rgba(255, 255, 255, 0.22), transparent 34%);
    mix-blend-mode: screen;
    pointer-events: none;
}

.wdbb-size-card-copy {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    padding: 0.78em 0.95em 0.7em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.wdbb-size-card-top,
.wdbb-size-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6em;
}

.wdbb-size-card-brand {
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.wdbb-size-card-wave {
    width: 1.35em;
    height: 1.35em;
    color: #fff;
}

.wdbb-size-card-chip {
    width: 1.85em;
    height: 1.4em;
    margin-top: 0.7em;
    border-radius: 0.22em;
    background:
        linear-gradient(#f8e7b0, #f8e7b0) center / 100% 1px no-repeat,
        linear-gradient(90deg, transparent 49%, #c6a15a 49% 51%, transparent 51%) center / 100% 100% no-repeat,
        linear-gradient(160deg, #f8e7b0, #d7b15e 46%, #f3dd9a 70%, #a8843c);
    box-shadow: inset 0 0 0 1px rgba(90, 60, 10, 0.35);
}

.wdbb-size-card-number {
    margin-top: auto;
    font-weight: 600;
    letter-spacing: 0.12em;
    line-height: 1;
}

.wdbb-size-card-bottom {
    margin-top: 0.55em;
}

.wdbb-size-card-name {
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.wdbb-size-card-expiry {
    display: grid;
    justify-items: end;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1;
}

.wdbb-size-card-expiry small {
    font-size: 0.55em;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.8;
}

.wdbb-size-figure {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-end;
    align-self: flex-end;
    justify-content: center;
}

.wdbb-size-desc {
    display: grid;
    flex: 0 0 auto;
    align-content: start;
    gap: 8px;
}

.wdbb-size-desc-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.wdbb-size-grip {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #9aa3ad;
    cursor: grab;
    touch-action: none;
}

.wdbb-size-grip svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.wdbb-size-grip:active,
.wdbb-size-picks li:active,
.wdbb-size-desc-head:active,
.is-dragging {
    cursor: grabbing;
}

.wdbb-size-figure.is-dragging,
.wdbb-size-desc.is-dragging,
.wdbb-size-picks li.is-dragging {
    z-index: 4;
    opacity: 1;
}

.wdbb-size-table-wrap {
    border-radius: 8px;
    background: #1e1e1e;
}

.wdbb-size-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.wdbb-size-table-wrap th,
.wdbb-size-table-wrap td {
    height: 32px;
    padding: 0 8px;
    text-align: left;
    white-space: nowrap;
    line-height: 32px;
}

.wdbb-size-table-wrap th {
    background: #34363d;
    color: var(--wdbb-blue);
    font-weight: 600;
}

.wdbb-size-table-wrap td:last-child,
.wdbb-size-table-wrap th:last-child {
    text-align: right;
}

.wdbb-size-table-wrap tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.04);
}

.wdbb-size-table-wrap .is-empty {
    color: #6d7480;
}

.wdbb-size-figure svg,
.wdbb-size-figure img {
    display: block;
    align-self: flex-end;
    max-width: none;
    margin: 0;
}

.wdbb-size-meta {
    display: grid;
    justify-items: center;
    gap: 8px;
    width: min(220px, 100%);
    text-align: center;
}

.wdbb-size-picks li span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wdbb-size-desc .wdbb-size-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 22px;
}

.wdbb-size-desc select {
    width: 100%;
}

.wdbb-size-empty {
    margin: auto;
    max-width: 360px;
    color: var(--wdbb-muted);
    font-size: 18px;
    line-height: 1.45;
}

.wdbb-size-measures {
    font-size: 12px;
}

.wdbb-size-note {
    font-size: 11px;
}

.wdbb-size-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border-radius: 8px;
}

.wdbb-size-close {
    position: fixed;
    z-index: 6;
    top: max(14px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    min-height: 36px;
    padding: 0 12px;
    color: #fff;
    font-weight: 600;
}

.wdbb-size-tools {
    position: fixed;
    z-index: 5;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
}

.wdbb-size-tools button {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(30, 30, 30, 0.92);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.wdbb-size-tools button.is-done {
    border-color: var(--wdbb-blue);
    color: var(--wdbb-blue);
}

@media (hover: hover) {
    .wdbb-size-units button,
    .wdbb-size-add button,
    .wdbb-size-view,
    .wdbb-size-remove,
    .wdbb-size-close,
    .wdbb-size-tools button,
    .wdbb-size-grip,
    .wdbb-size-picks li,
    .wdbb-size select {
        transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    }

    .wdbb-size-add button:hover,
    .wdbb-size-view:hover,
    .wdbb-size-units button.is-on:hover {
        background: #79d6ff;
    }

    .wdbb-size-units button:hover,
    .wdbb-size-tools button:hover,
    .wdbb-size select:hover {
        border-color: var(--wdbb-blue);
    }

    .wdbb-size-remove:hover,
    .wdbb-size-close:hover,
    .wdbb-size-grip:hover {
        color: var(--wdbb-blue);
    }

    .wdbb-size-picks li:hover {
        border-color: var(--wdbb-blue);
        background: #2c3138;
    }

    .wdbb-size-tools button:hover {
        background: #34363d;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wdbb-size-units button,
    .wdbb-size-add button,
    .wdbb-size-view,
    .wdbb-size-tools button,
    .wdbb-size-picks li {
        transition: none;
    }
}

@media (max-width: 800px) {
    .wdbb-size {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }

    .wdbb-size-side {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        flex: 0 0 auto;
        align-items: center;
        height: auto;
        max-height: none;
        min-height: 0;
        gap: 6px 10px;
        padding: 8px 12px 8px;
        padding-top: max(8px, env(safe-area-inset-top));
        position: relative;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .wdbb-size-side h1 {
        grid-column: 1 / -1;
        padding-right: 132px;
        font-size: 22px;
    }

    .wdbb-size-help,
    .wdbb-size-slider-label,
    .wdbb-size-side input[type="range"],
    .wdbb-size-picks {
        grid-column: 1 / -1;
    }

    .wdbb-size-units {
        grid-column: 1 / -1;
        margin: 0;
    }

    .wdbb-size-slider-label,
    .wdbb-size-picks h2 {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .wdbb-size-help {
        font-size: 13px;
    }

    .wdbb-size-help summary {
        min-height: 28px;
    }

    .wdbb-size-picks ul {
        display: flex;
        gap: 6px;
        margin: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .wdbb-size-picks ul:empty {
        display: none;
    }

    .wdbb-size-picks li {
        flex: 0 0 auto;
        max-width: 220px;
        min-height: 34px;
        margin: 0;
    }

    .wdbb-size-add {
        margin-top: 6px;
    }

    .wdbb-size-stage {
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .wdbb-size-card {
        top: var(--wdbb-card-top, 46%);
        left: max(12px, env(safe-area-inset-left));
    }

    .wdbb-size-limit {
        display: none;
    }

    .wdbb-size-figures {
        padding-top: calc(var(--wdbb-card-px) * 53.98 / 85.6 + 16px);
    }

    .wdbb-size-spacer {
        flex-basis: 12px;
        width: 12px;
    }
}

@media (min-width: 801px) {
    .wdbb-size-help summary {
        display: none;
    }
}
