/* ==========================================================
   Confirm pop-up (replaces the browser's own "xxx says" box).
   Built by assets/js/confirm-dialog.js, used by every <form data-confirm="...">.
   Types: danger | warning | success | info  (data-confirm-type, or guessed from the form).
   ========================================================== */
body.cd-lock { overflow: hidden; }

.cd {
    --cd-a: #4f46e5; --cd-b: #0891b2; --cd-soft: rgba(79, 70, 229, .12); --cd-glow: rgba(79, 70, 229, .35);
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.cd[data-type="danger"]  { --cd-a: #e11d48; --cd-b: #fb7185; --cd-soft: rgba(225, 29, 72, .12);  --cd-glow: rgba(225, 29, 72, .38); }
.cd[data-type="warning"] { --cd-a: #d97706; --cd-b: #fbbf24; --cd-soft: rgba(217, 119, 6, .13);  --cd-glow: rgba(217, 119, 6, .36); }
.cd[data-type="success"] { --cd-a: #059669; --cd-b: #34d399; --cd-soft: rgba(5, 150, 105, .12);  --cd-glow: rgba(5, 150, 105, .36); }

.cd-backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, .55);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    animation: cd-fade .22s ease-out both;
}

.cd-card {
    position: relative; width: min(100%, 380px); max-height: 100%; overflow: hidden auto;
    text-align: center;
    color: var(--text, #0f172a);
    background: var(--glass-strong, rgba(255, 255, 255, .92));
    -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, .75));
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, .38), 0 0 0 1px rgba(255, 255, 255, .06) inset;
    animation: cd-in .46s cubic-bezier(.2, 1.25, .3, 1) both;
}
.cd-card::before {                       /* accent bar on top */
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; z-index: 2;
    background: linear-gradient(90deg, var(--cd-a), var(--cd-b));
}
.cd[data-type="danger"] .cd-card { animation: cd-in .46s cubic-bezier(.2, 1.25, .3, 1) both, cd-shake .5s .42s ease-in-out; }

/* picture */
.cd-art {
    position: relative; display: flex; align-items: center; justify-content: center;
    height: 168px; padding-top: 6px; overflow: hidden;
    background:
        radial-gradient(circle at 50% 62%, var(--cd-soft), transparent 68%),
        radial-gradient(circle at 12% 18%, var(--cd-soft), transparent 40%),
        radial-gradient(circle at 90% 80%, var(--cd-soft), transparent 42%);
}
.cd-art::after {                         /* soft dotted texture */
    content: ""; position: absolute; inset: 0; opacity: .5; pointer-events: none;
    background-image: radial-gradient(var(--cd-soft) 1.2px, transparent 1.4px); background-size: 16px 16px;
    -webkit-mask-image: linear-gradient(#000, transparent 85%); mask-image: linear-gradient(#000, transparent 85%);
}
.cd-glow {
    position: absolute; width: 150px; height: 150px; border-radius: 50%;
    background: radial-gradient(circle, var(--cd-glow), transparent 68%);
    animation: cd-breathe 3s ease-in-out infinite;
}
.cd-img {
    position: relative; z-index: 1; display: block; width: 210px; max-width: 80%; height: auto;
    animation: cd-pop .6s .12s cubic-bezier(.2, 1.4, .3, 1) both;
}

/* text */
.cd-body { padding: 6px 22px 4px; }
.cd-title {
    margin: 0 0 8px; font-size: 1.32rem; font-weight: 800; line-height: 1.25; letter-spacing: 0;
    animation: cd-up .4s .16s ease-out both;
}
.cd-msg {
    margin: 0; font-size: 1.02rem; font-weight: 600; line-height: 1.55; color: var(--text, #0f172a);
    overflow-wrap: anywhere; white-space: pre-line;
    animation: cd-up .4s .22s ease-out both;
}
.cd-note {
    display: inline-flex; align-items: center; gap: 8px; margin: 12px 0 0; padding: 7px 13px;
    font-size: .84rem; font-weight: 700; line-height: 1.4; color: var(--cd-a);
    background: var(--cd-soft); border-radius: 999px;
    animation: cd-up .4s .28s ease-out both;
}
.cd-note::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cd-a); }

/* buttons */
.cd-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 18px 20px 22px; animation: cd-up .4s .3s ease-out both; }
.cd-btn {
    min-height: 50px; padding: 0 14px; border: 1px solid transparent; border-radius: 16px;
    font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.cd-btn:active { transform: scale(.96); }
.cd-btn:focus-visible { outline: 3px solid var(--cd-b); outline-offset: 2px; }
.cd-btn-ghost { color: var(--text, #0f172a); background: var(--glass, rgba(255, 255, 255, .6)); border-color: var(--line, rgba(15, 23, 42, .12)); }
.cd-btn-ghost:hover { border-color: var(--cd-a); }
.cd-btn-ok {
    color: #fff; background: linear-gradient(135deg, var(--cd-a), var(--cd-b));
    box-shadow: 0 10px 24px var(--cd-glow);
}
.cd-btn-ok:hover { filter: brightness(1.06); }

/* closing */
.cd.is-closing .cd-backdrop { animation: cd-fade-out .2s ease-in both; }
.cd.is-closing .cd-card { animation: cd-out .2s ease-in both; }

@media (max-width: 340px) {
    .cd-actions { grid-template-columns: 1fr; }
    .cd-btn-ok { order: -1; }
}
@media (max-height: 520px) {
    .cd-art { height: 110px; }
    .cd-img { width: 150px; }
}

@keyframes cd-fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes cd-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes cd-in       { from { opacity: 0; transform: translateY(34px) scale(.86); } to { opacity: 1; transform: none; } }
@keyframes cd-out      { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(18px) scale(.94); } }
@keyframes cd-pop      { from { opacity: 0; transform: scale(.5) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes cd-up       { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes cd-breathe  { 0%, 100% { transform: scale(.9); opacity: .7; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes cd-shake    { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

@media (prefers-reduced-motion: reduce) {
    .cd-backdrop, .cd-card, .cd-glow, .cd-img, .cd-title, .cd-msg, .cd-note, .cd-actions { animation: none !important; }
    .cd-btn { transition: none; }
}
