
.jn-root {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 2147483001;

    display: flex;
    justify-content: center;

    padding: 0 12px;
    box-sizing: border-box;
    pointer-events: none;
}

.jn-root.jn-center {
    top: 0;
    bottom: 0;
    align-items: center;
}

.jn-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.40);
    z-index: 2147483000;
}

.jn-card {
    width: min(440px, 100%);
    max-height: 75vh;
    max-height: min(75dvh, 560px);

    overflow-y: auto;
    padding: 16px 20px;
    box-sizing: border-box;

    border-radius: 14px;
    background: #fff;
    color: #1f2937;
    border: 1px solid #dce3eb;

    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.18);

    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: anywhere;

    pointer-events: none;
}

.jn-card[role="alertdialog"] {
    pointer-events: auto;
}

.jn-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 7px;
}

.jn-message {
    white-space: pre-wrap;
}

.jn-warning {
    border-color: #facc15;
    background: #fffbeb;
    color: #92400e;
}

.jn-error,
.jn-logout {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.jn-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.jn-countdown {
    margin-top: 10px;
    font-size: 13px;
    opacity: 0.85;
}

.jn-track {
    margin-top: 7px;
    height: 4px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.22);
    overflow: hidden;
}

.jn-fill {
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: currentColor;
    transition: width .25s linear;
}

.jn-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.jn-btn {
    min-height: 40px;
    padding: 8px 16px;

    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1f2937;

    font: inherit;
    cursor: pointer;
}

.jn-btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.jn-btn:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

/* 手機直向 */
@media (max-width: 600px) {
    .jn-root {
        padding: 0 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .jn-root.jn-center {
        padding: 16px 12px;
    }

    .jn-card {
        width: 100%;
        max-height: 75vh;
        max-height: 75dvh;

        padding: 14px 16px;
        border-radius: 12px;
        font-size: 14px;
    }

    .jn-title {
        font-size: 15px;
    }

    .jn-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .jn-actions .jn-btn:only-child {
        grid-column: 1 / -1;
    }
}

/* 手機橫向、小高度 */
@media (max-height: 450px) {
    .jn-card {
        max-height: 68vh;
        max-height: 68dvh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jn-fill {
        transition: none;
    }
}
@media (max-width: 600px) {

    .jn-actions.jn-actions-many {
        display: grid;
        grid-template-columns: 1fr;
    }

    .jn-actions.jn-actions-many .jn-btn {
        width: 100%;
        min-height: 44px;
    }
}
/* Alert / Confirm 視窗 */
.jn-card[role="alertdialog"] {
    width: min(400px, 100%);
}

.jn-card[role="alertdialog"] .jn-actions {
    margin-top: 14px;
}

/* 手機 */
@media (max-width: 600px) {
    .jn-card[role="alertdialog"] {
        width: 100%;
    }

    .jn-card[role="alertdialog"] .jn-btn {
        min-height: 44px;
    }
}
/* 一般按鈕，即使取得焦點也維持中性色 */
.jn-actions .jn-btn:not(.jn-btn-primary),
.jn-actions .jn-btn:not(.jn-btn-primary):focus {
    background: #f8fafc;
    color: #1f2937;
    border-color: #cbd5e1;
}

/* 主要操作按鈕 */
.jn-actions .jn-btn.jn-btn-primary,
.jn-actions .jn-btn.jn-btn-primary:focus {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* 保留鍵盤操作的焦點提示 */
.jn-actions .jn-btn:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}