/*modal*/
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fade 140ms ease-out;
}

@keyframes fade {
    from {
        opacity: 0;
    }
}

.modal-box {
    background: var(--surface);
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    max-width: 440px;
    width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: sheet 180ms ease-out;
}

@keyframes sheet {
    from {
        transform: translateY(24px);
        opacity: .6;
    }
}

@media (prefers-reduced-motion: reduce) {

    .modal-box,
    .modal-backdrop {
        animation: none;
    }
}

@media (min-width: 480px) {
    .modal-backdrop {
        align-items: center;
        padding: 16px;
    }

    .modal-box {
        border-radius: var(--r-panel);
        padding: 22px;
    }

    .modal-grabber {
        display: none;
    }
}

/* hit area is the full strip, the visible bar is ::before / drag down to dismiss (js/lib/modal.js) */
.modal-grabber {
    position: relative;
    height: 28px;
    margin: -10px -20px 0;
    touch-action: none;
    cursor: grab;
}

.modal-grabber::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 4px;
    background: var(--line-strong);
    transition: background var(--speed);
}

.modal-grabber.dragging {
    cursor: grabbing;
}

.modal-grabber.dragging::before {
    background: var(--faint);
}

.modal-title {
    font-weight: 600;
    font-size: 1.08rem;
    margin-bottom: 10px;
}

.modal-header {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg);
    border-radius: var(--r-ctl);
}

.modal-header img.thumb {
    width: 84px;
}

.modal-header .mh-title {
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modal-header .mh-sub {
    font-size: .76rem;
    color: var(--muted);
    margin-top: 2px;
}

.modal-body {
    font-size: .88rem;
    color: var(--muted);
    line-height: 1.65;
}

.modal-body p {
    margin: 0 0 10px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body strong {
    color: var(--text);
}

.modal-box .field-group {
    margin-top: 4px;
}

.modal-box label {
    margin-top: 12px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin: 0;
    border: 1.5px solid var(--line);
    border-radius: var(--r-ctl);
    cursor: pointer;
    transition: border-color var(--speed), background var(--speed);
    color: var(--text);
}

.radio-option:has(input:checked) {
    border-color: var(--ink);
    background: var(--bg);
}

.radio-option input {
    accent-color: var(--ink);
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex-shrink: 0;
}

.radio-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.radio-label {
    font-size: .92rem;
    font-weight: 600;
}

.radio-desc {
    font-size: .78rem;
    color: var(--muted);
    font-weight: 400;
    line-height: 1.45;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.modal-actions .btn {
    flex: 1;
}

.modal-secondary {
    display: flex;
    justify-content: center;
    margin-top: 6px;
}

.modal-secondary .btn {
    border: 0;
    background: none;
    color: var(--red-text);
    min-height: 40px;
    font-size: .86rem;
}

.modal-secondary .btn:hover {
    background: var(--red-tint);
}

/*toast*/
#ui-toast-root {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1100;
    width: calc(100% - 32px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    background: var(--ink);
    color: var(--on-ink);
    border-radius: var(--r-ctl);
    padding: 12px 16px;
    font-size: .86rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px);
    opacity: 0;
    transition: transform var(--speed), opacity var(--speed);
}

.toast.show {
    transform: none;
    opacity: 1;
}

.toast.toast-error {
    background: var(--red-strong);
    color: #fff;
}