.hb-shell {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: grid;
    place-items: center;
    padding: 16px;
}

.hb-shell[hidden],
.hb-option[hidden],
.hb-image-options[hidden],
.hb-recenter[hidden] {
    display: none;
}

.hb-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
}

.hb-recenter {
    position: fixed;
    z-index: 2;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    padding: 8px 14px;
    border: var(--glass-border, 1.5px solid rgba(79, 172, 254, 0.3));
    border-radius: 8px;
    background: var(--glass-nav-bg-light, rgba(30, 40, 56, 0.9));
    backdrop-filter: var(--glass-blur, blur(20px));
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.hb-dialog {
    position: relative;
    width: min(100%, 540px);
    max-height: min(90vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--glass-nav-bg-light, rgba(30, 40, 56, 0.78));
    backdrop-filter: var(--glass-blur, blur(20px));
    -webkit-backdrop-filter: var(--glass-blur, blur(20px));
    border: var(--glass-border, 1.5px solid rgba(79, 172, 254, 0.3));
    color: #f6f8fc;
    border-radius: 18px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

.hb-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 18px 8px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.hb-header.dragging {
    cursor: grabbing;
}

.hb-header button {
    cursor: pointer;
}

.hb-header h2 {
    font-size: 1.12rem;
    margin: 0;
}

.hb-hint {
    margin: 0;
    color: #d0dae8;
    font-size: 0.88rem;
    line-height: 1.45;
}

.hb-close {
    border: 0;
    background: transparent;
    color: #f6f8fc;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.hb-body {
    padding: 0 18px 12px;
    overflow-y: auto;
}

.hb-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin: 10px 0;
    padding: 3px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
}

.hb-tabs button {
    padding: 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #f6f8fc;
    font: inherit;
    cursor: pointer;
}

.hb-tabs button.active {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.hb-image-options label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
}

.hb-color-controls {
    display: grid;
    gap: 10px;
    padding: 4px 0 8px;
}

.hb-color-row,
.hb-color-controls label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.hb-color-row > span:first-child {
    margin-right: auto;
}

.hb-color-chip {
    width: 26px;
    height: 26px;
    flex: none;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 6px;
}

.hb-hex {
    width: 88px;
    padding: 5px 7px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font: inherit;
}

.hb-color-controls > label input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 10px;
    margin-left: auto;
    border-radius: 10px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.hb-hue {
    background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red);
}

.hb-color-controls input[type="range"]::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #2d3748;
    -webkit-appearance: none;
}

.hb-color-controls input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #2d3748;
}

.hb-file-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#hb-file {
    max-width: 100%;
}

.hb-hint {
    margin-top: 4px;
}

.hb-image-options {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.hb-image-options label {
    flex-wrap: wrap;
}

.hb-image-options select {
    padding: 5px;
    border: 1px solid #cad2dc;
    border-radius: 6px;
    background: #f6f8fc;
    color: #1c1e21;
}

.hb-image-options input[type="range"] {
    flex: 1;
    min-width: 90px;
}

.hb-image-options output {
    min-width: 38px;
    text-align: right;
}

.hb-status {
    margin: 8px 0 0;
    color: #d0dae8;
    font-size: 0.86rem;
}

.hb-status.error {
    color: #ffb6ae;
}

.hb-status:empty {
    display: none;
}

.hb-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 9px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.hb-actions button {
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    padding: 6px 11px;
    background: rgba(255, 255, 255, 0.12);
    color: #f6f8fc;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.hb-actions .hb-save {
    border-color: #1877f2;
    background: #1877f2;
    color: #fff;
}

.hb-actions button:hover:not(:disabled),
.hb-tabs button:hover {
    border-color: rgba(255, 255, 255, 0.65);
    background-color: rgba(255, 255, 255, 0.22);
}

.hb-actions .hb-save:hover:not(:disabled) {
    background: #1266d4;
}

.hb-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .hb-shell {
        padding: 10px;
    }
    .hb-header,
    .hb-actions {
        padding-left: 14px;
        padding-right: 14px;
    }
    .hb-body {
        padding-left: 14px;
        padding-right: 14px;
    }
}
