/* style.css - SB UpScaleX: เพิ่มความคมชัดภาพด้วย AI — โทนดำ/แดง/ขาว */

:root {
    --red-primary: #E4082F;
    --red-gradient: linear-gradient(135deg, #FF2A44 0%, #E4082F 50%, #8C0018 100%);
    --red-glow: rgba(228, 8, 47, 0.55);

    --white: #FFFFFF;
    --gray-light: #D8D8DC;
    --gray-mid: #9A9AA2;
    --gray-dark: #5C5C64;

    --bg-black: #030303;
    --bg-card: rgba(15, 15, 17, 0.94);
    --border-card: rgba(228, 8, 47, 0.3);
    --border-hover: rgba(228, 8, 47, 0.75);

    --font-main: 'Prompt', sans-serif;
    --radius: 14px;
    --transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

#app-shell { position: relative; z-index: 1; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(10, 10, 10, 0.8); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #FF2A44 0%, #8C0018 100%); border-radius: 10px; box-shadow: 0 0 10px rgba(228, 8, 47, 0.7); }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #FF425C 0%, #B0001F 100%); }

/* ---------- Credit widget ---------- */
#credit-widget { display: flex; align-items: center; gap: 8px; }
#credit-widget button {
    font-family: var(--font-main);
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--white);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
#credit-widget button:hover { border-color: var(--border-hover); background: rgba(228, 8, 47, 0.12); }
#credit-widget-loggedin { display: flex; align-items: center; gap: 8px; }
#credit-balance {
    font-weight: 800;
    color: var(--white);
    background: var(--red-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.credit-balance-pulse { animation: balancePulse 0.5s ease-out; }

@keyframes balancePulse {
    0% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.credit-modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.credit-modal-overlay.active { display: flex; }
.credit-modal {
    background: var(--bg-card);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius);
    padding: 24px;
    width: min(360px, 90vw);
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}
.credit-modal h3 { color: var(--white); margin-bottom: 12px; font-weight: 800; }
.credit-modal input {
    width: 100%;
    font-family: var(--font-main);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-card);
    color: var(--white);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}
.credit-modal input:focus { outline: 1.5px solid var(--red-primary); }
.credit-modal-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.credit-modal-actions button {
    font-family: var(--font-main);
    font-weight: 700;
    background: var(--red-gradient);
    border: none;
    color: var(--white);
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: var(--transition);
}
.credit-modal-actions button:hover { transform: translateY(-1px); }
#credit-topup-close {
    background: rgba(255, 255, 255, 0.08) !important;
}
.credit-modal-message { color: var(--red-primary); min-height: 1.2em; font-size: 0.85rem; margin-top: 4px; font-weight: 600; }
.credit-modal-hint { color: var(--gray-mid); font-size: 0.8rem; margin: 6px 0; }

/* ---------- Login / register modal ---------- */
.credit-modal-auth {
    position: relative;
    width: min(380px, 90vw);
    padding: 32px 28px 28px;
    text-align: center;
    overflow: visible;
}

.credit-modal-x {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--gray-light);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.credit-modal-x:hover { border-color: var(--red-primary); color: var(--white); background: rgba(228, 8, 47, 0.15); }

.credit-auth-logo-wrap {
    width: 76px;
    height: 76px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.credit-auth-logo-wrap::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(228, 8, 47, 0.45) 0%, transparent 70%);
}

.credit-auth-logo {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 14px rgba(228, 8, 47, 0.7));
}

.credit-modal-auth h3 { font-size: 1.15rem; margin-bottom: 6px; }
.credit-modal-auth .credit-modal-hint { margin-bottom: 20px; }

.credit-auth-field {
    text-align: left;
    margin-bottom: 14px;
}

.credit-auth-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--gray-mid);
    margin-bottom: 6px;
}

.credit-auth-field input { margin-bottom: 0; }

.credit-auth-primary-btn {
    width: 100%;
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--white);
    background: var(--red-gradient);
    border: none;
    border-radius: 999px;
    padding: 13px;
    cursor: pointer;
    margin-top: 6px;
    box-shadow: 0 8px 24px rgba(228, 8, 47, 0.5);
    transition: var(--transition);
}

.credit-auth-primary-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(228, 8, 47, 0.65); }
.credit-auth-primary-btn:active { transform: scale(0.98); }

.credit-auth-secondary-btn {
    width: 100%;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--gray-mid);
    background: transparent;
    border: none;
    padding: 14px 0 0;
    cursor: pointer;
    transition: var(--transition);
}

.credit-auth-secondary-btn:hover { color: var(--red-primary); }

/* ---------- Top-up (PromptPay) modal ---------- */
.credit-modal-topup {
    position: relative;
    width: min(400px, 90vw);
    padding: 30px 26px 26px;
    text-align: center;
    overflow: visible;
}

.credit-topup-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: var(--red-primary);
    background: rgba(228, 8, 47, 0.12);
    border: 1px solid rgba(228, 8, 47, 0.4);
    border-radius: 999px;
    padding: 5px 12px;
    margin-bottom: 14px;
}

.credit-topup-badge-icon { font-size: 0.8rem; }

.credit-modal-topup h3 { font-size: 1.15rem; margin-bottom: 6px; }
.credit-modal-topup .credit-modal-hint { margin-bottom: 18px; }

.credit-topup-quick {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.credit-topup-chip {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--gray-light);
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 10px 4px;
    cursor: pointer;
    transition: var(--transition);
}

.credit-topup-chip:hover { border-color: var(--border-hover); color: var(--white); }

.credit-topup-chip.is-active {
    background: var(--red-gradient);
    border-color: transparent;
    color: var(--white);
    box-shadow: 0 4px 14px rgba(228, 8, 47, 0.5);
}

/* ---------- Bank transfer card ---------- */
.credit-bank-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 16px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.credit-bank-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.credit-bank-row-logo {
    justify-content: center;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.credit-bank-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.credit-bank-label { font-size: 0.7rem; font-weight: 700; color: var(--gray-mid); width: 72px; flex-shrink: 0; }
.credit-bank-value { font-size: 0.88rem; font-weight: 700; color: var(--white); flex: 1; }
.credit-bank-account { font-size: 1rem; font-weight: 800; letter-spacing: 0.5px; color: var(--red-primary); }

.credit-bank-copy-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 5px 9px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}
.credit-bank-copy-btn:hover { border-color: var(--red-primary); }

.credit-topup-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--gray-light);
    background: rgba(228, 8, 47, 0.06);
    border: 1px solid rgba(228, 8, 47, 0.25);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    text-align: left;
}
.credit-topup-summary strong { color: var(--white); }

#credit-topup-slip {
    width: 100%;
    font-family: var(--font-main);
    font-size: 0.78rem;
    color: var(--gray-light);
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px dashed rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
}

.credit-topup-slip-preview { margin-top: 10px; }
.credit-topup-slip-preview img {
    max-width: 100%;
    max-height: 160px;
    border-radius: 10px;
    border: 2px solid var(--white);
}

.credit-topup-done-icon { font-size: 2.6rem; margin-bottom: 10px; }
#credit-topup-step-pay .credit-auth-secondary-btn { margin-top: 4px; }

.credit-topup-amount-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.credit-topup-amount-currency {
    position: absolute;
    left: 16px;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--red-primary);
    pointer-events: none;
}

.credit-topup-amount-wrap input {
    width: 100%;
    font-family: var(--font-main);
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    padding: 14px 16px 14px 40px;
    margin-bottom: 0;
    transition: var(--transition);
}

.credit-topup-amount-wrap input:focus {
    outline: none;
    border-color: var(--red-primary);
    background: rgba(228, 8, 47, 0.06);
}

.credit-topup-amount-wrap input::placeholder { color: var(--gray-dark); font-weight: 700; }

/* ซ่อนลูกศรขึ้น-ลงของ <input type="number"> ที่ดูรกและไม่เข้าธีม */
.credit-topup-amount-wrap input::-webkit-outer-spin-button,
.credit-topup-amount-wrap input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.credit-topup-amount-wrap input[type="number"] { -moz-appearance: textfield; }

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: var(--font-main);
    background-color: var(--bg-black);
    background-image:
        radial-gradient(ellipse at 15% 0%, rgba(228, 8, 47, 0.25) 0%, transparent 620px),
        radial-gradient(ellipse at 85% 100%, rgba(228, 8, 47, 0.18) 0%, transparent 620px);
    background-attachment: fixed;
    color: var(--white);
}

/* ---------- Mobile gate (บล็อกการใช้งานบนโทรศัพท์) ---------- */
body.mobile-locked #app-shell {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

.mobile-gate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(2, 2, 2, 0.9);
    padding: 24px;
}

.mobile-gate-overlay.active { display: flex; }

.mobile-gate-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    padding: 32px 26px;
    max-width: 340px;
    width: 100%;
    text-align: center;
}

.mobile-gate-icon {
    font-size: 2.8rem;
    margin-bottom: 14px;
    filter: drop-shadow(0 0 16px rgba(228, 8, 47, 0.6));
}

.mobile-gate-card h2 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--white);
    margin-bottom: 10px;
}

.mobile-gate-desc {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--gray-light);
    margin-bottom: 12px;
}

.mobile-gate-hint {
    font-size: 0.72rem;
    color: var(--gray-mid);
}

#app-shell {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}

/* ---------- Sidebar ---------- */
#sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1.5px solid var(--border-card);
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 34px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    margin-bottom: -20px;
}

.brand-logo-wrap {
    position: relative;
    width: 168px;
    height: 168px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: logoBreathe 2.6s ease-in-out infinite;
}

.brand-logo {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---------- โลโก้กระพริบสไตล์ chromatic-glitch: หายใจเบาๆ + ออร่าแดงเต้น + สีเหลื่อมกระพริบเป็นจังหวะ
   (ใช้ร่วมกับ .logo-aura / .logo-glitch-r / .logo-glitch-b บน element ลูกที่ประกาศไว้ใน HTML) ---------- */
.logo-aura {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 45, 58, 0.45), transparent 70%);
    filter: blur(14px);
    animation: logoAuraPulse 2.6s ease-in-out infinite;
    pointer-events: none;
}

img.logo-glitch {
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: screen;
    opacity: 0;
    pointer-events: none;
}
.logo-glitch-r { filter: brightness(1.4) sepia(1) hue-rotate(-50deg) saturate(6); animation: logoGlitchR 6s ease-in-out infinite; }
.logo-glitch-b { filter: brightness(1.4) sepia(1) hue-rotate(160deg) saturate(6); animation: logoGlitchB 6s ease-in-out infinite; }

@keyframes logoBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
@keyframes logoAuraPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}
@keyframes logoGlitchR {
    0%, 92%, 100% { opacity: 0; transform: translate(0, 0); }
    93% { opacity: 0.8; transform: translate(-4px, 1px); }
    94% { opacity: 0.6; transform: translate(3px, -1px); }
    95% { opacity: 0.8; transform: translate(-2px, 0); }
    96% { opacity: 0; transform: translate(0, 0); }
}
@keyframes logoGlitchB {
    0%, 92%, 100% { opacity: 0; transform: translate(0, 0); }
    93% { opacity: 0.7; transform: translate(4px, -1px); }
    94% { opacity: 0.6; transform: translate(-3px, 1px); }
    95% { opacity: 0.7; transform: translate(2px, 0); }
    96% { opacity: 0; transform: translate(0, 0); }
}

.brand-text { display: flex; flex-direction: column; align-items: center; }
.brand-title { font-size: 1.15rem; font-weight: 800; letter-spacing: 0.3px; color: var(--white); }
.brand-title-accent { color: var(--red-primary); }
.brand-sub { font-size: 0.68rem; color: var(--gray-mid); margin-top: 2px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-light);
    text-decoration: none;
    transition: var(--transition);
}

.sidebar-nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--white); }

.sidebar-nav-item.active {
    background: var(--red-gradient);
    color: var(--white);
    box-shadow: 0 4px 16px rgba(228, 8, 47, 0.4);
}

.sidebar-nav-icon { font-size: 1rem; display: inline-block; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.sidebar-nav-item:hover .sidebar-nav-icon { transform: scale(1.25) rotate(-6deg); }

.sidebar-tips {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px;
}

.sidebar-tips h3 {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--red-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.sidebar-tips ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-tips li {
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--gray-mid);
    padding-left: 14px;
    position: relative;
}

.sidebar-tips li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--red-primary);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.65rem;
    color: var(--gray-dark);
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ---------- Main content ---------- */
#main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Topbar ---------- */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: rgba(8, 8, 9, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1.5px solid var(--border-card);
    padding: 22px 36px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-title h1 { font-size: 1.1rem; font-weight: 800; color: var(--white); }

.badge-offline {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--white);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ---------- Help accordion (วิธีใช้งาน & คำเตือน) ---------- */
.help-accordion {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.help-accordion-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.help-accordion-title::after {
    content: '▾';
    font-size: 0.75rem;
    color: var(--red-primary);
    transition: transform 0.25s ease;
}

.help-accordion.is-collapsed .help-accordion-title::after { transform: rotate(-90deg); }

.help-accordion-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 14px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
}

.help-accordion.is-collapsed .help-accordion-body {
    max-height: 0 !important;
    opacity: 0;
    margin-top: 0;
}

@media (max-width: 700px) {
    .help-accordion-body { grid-template-columns: 1fr; }
}

.help-col h4 {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--red-primary);
    margin-bottom: 8px;
}

.info-steps, .warning-list {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-steps li, .warning-list li {
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--gray-light);
}

/* ---------- Low credit banner ---------- */
#low-credit-banner {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 200, 0, 0.12);
    border: 1.5px solid rgba(255, 200, 0, 0.45);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.85rem;
}
.low-credit-icon { font-size: 1.1rem; }
.low-credit-text { flex: 1; color: var(--gray-light); }
.low-credit-text strong { color: #FFD666; }
#low-credit-topup-btn {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--white);
    background: var(--red-gradient);
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
    white-space: nowrap;
}

/* ---------- Main layout ---------- */
#app-main {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 28px;
    align-items: start;
    flex: 1;
    padding: 32px 36px 48px;
}

@media (max-width: 960px) {
    #sidebar { display: none; }
    #app-main { grid-template-columns: 1fr; }
}

/* ---------- Canvas panel ---------- */
#canvas-panel {
    background:
        linear-gradient(160deg, rgba(228, 8, 47, 0.06) 0%, transparent 40%),
        var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    gap: 26px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ตอนกำลังประมวลผลอยู่ ให้กรอบทั้งหมดเรืองแสงเบาๆ เป็นจังหวะ ให้รู้สึกว่ากำลังทำงานอยู่จริง */
#canvas-panel.is-processing {
    border-color: var(--red-primary);
    animation: canvasPulse 1.8s ease-in-out infinite;
}

@keyframes canvasPulse {
    0%, 100% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 0 rgba(228, 8, 47, 0); }
    50% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 32px rgba(228, 8, 47, 0.65); }
}

/* ไฮไลต์ตอนลากไฟล์มาวางเหนือหน้าเว็บ */
#dropzone.drag-over #src-box {
    border-color: var(--red-primary);
    border-style: solid;
    background: rgba(228, 8, 47, 0.12);
    transform: scale(1.015);
}

/* เด้ง flash ขาวรอบรูปผลลัพธ์ตอนประมวลผลเสร็จ ให้รู้สึกว่า "เสร็จแล้วนะ" ชัดเจน */
#dest-box.flash-done {
    animation: flashDone 0.9s ease-out;
}

@keyframes flashDone {
    0% { box-shadow: 0 0 0 rgba(255, 255, 255, 0); border-color: rgba(255, 255, 255, 0.14); }
    30% { box-shadow: 0 0 34px rgba(255, 255, 255, 0.9); border-color: var(--white); }
    100% { box-shadow: 0 0 0 rgba(255, 255, 255, 0); border-color: rgba(255, 255, 255, 0.14); }
}

/* ---------- Step indicator ---------- */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.5;
    transition: var(--transition);
}

.step-item.is-active, .step-item.is-done { opacity: 1; }

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--gray-mid);
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    transition: var(--transition);
}

.step-item.is-active .step-num {
    color: var(--white);
    background: var(--red-gradient);
    border-color: transparent;
    box-shadow: 0 0 0 4px rgba(228, 8, 47, 0.18);
}

.step-item.is-done .step-num {
    color: var(--white);
    background: rgba(228, 8, 47, 0.25);
    border-color: rgba(228, 8, 47, 0.5);
}

.step-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-mid);
    white-space: nowrap;
}

.step-item.is-active .step-label, .step-item.is-done .step-label { color: var(--white); }

.step-line {
    width: 36px;
    height: 1.5px;
    background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 560px) {
    .step-label { display: none; }
    .step-line { width: 18px; }
}

#dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.frame-block {
    flex: 1;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.frame-label {
    align-self: center;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gray-mid);
    padding: 4px 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
}

#src-box, #dest-box {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0A0A0B;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

#src-box:hover { border-color: var(--border-hover); box-shadow: 0 0 0 4px rgba(228, 8, 47, 0.12); }
#dest-box:hover { border-color: rgba(255, 255, 255, 0.35); }

#src, #dest {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    cursor: zoom-in;
}

#dest { background: repeating-conic-gradient(rgba(255,255,255,0.05) 0% 25%, transparent 0% 50%) 50% / 18px 18px; }

#dropzone-hint {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 16px;
    cursor: pointer;
    color: var(--gray-light);
    background:
        radial-gradient(circle at 50% 30%, rgba(228, 8, 47, 0.14) 0%, transparent 65%),
        rgba(3, 3, 3, 0.4);
}

.dropzone-icon {
    font-size: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(228, 8, 47, 0.12);
    border: 1.5px dashed rgba(228, 8, 47, 0.5);
}
#dropzone-hint p { font-size: 0.8rem; line-height: 1.5; max-width: 220px; }

#src-box.has-image #dropzone-hint { display: none; }

#change-image-btn {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    z-index: 2;
    transition: var(--transition);
}

#change-image-btn:hover { border-color: var(--red-primary); transform: rotate(90deg); }

#src-box.has-image #change-image-btn { display: flex; }

#remove-image-btn {
    display: none;
    position: absolute;
    top: 10px;
    right: 52px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    z-index: 2;
    color: var(--white);
    font-family: var(--font-main);
    transition: var(--transition);
}

#remove-image-btn:hover { border-color: var(--red-primary); background: rgba(228, 8, 47, 0.25); transform: scale(1.1); }
#remove-image-btn:active { transform: scale(0.92); }

#src-box.has-image #remove-image-btn { display: flex; }

#file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

#paste-button a {
    text-decoration: none;
    margin-left: 4px;
    color: var(--red-primary);
    font-weight: 700;
}

/* ---------- Processing bar ---------- */
#progress-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
}

#progress-bar-wrap.is-active {
    max-height: 30px;
    opacity: 1;
    margin-bottom: 4px;
}

#progress-bar-track {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
    position: relative;
}

#progress-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #FF2A44, #E4082F, #8C0018, #E4082F, #FF2A44);
    background-size: 300% 100%;
    box-shadow: 0 0 12px rgba(228, 8, 47, 0.7);
    transition: width 0.25s ease-out;
    position: relative;
    overflow: hidden;
    animation: progressGradientFlow 2.4s linear infinite, progressGlowPulse 1.4s ease-in-out infinite;
}

/* ลายเส้นเคลื่อนไหว ให้รู้สึกว่ากำลังทำงานอยู่จริงแม้ % จะขยับช้า */
#progress-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.25) 0px,
        rgba(255, 255, 255, 0.25) 10px,
        transparent 10px,
        transparent 20px
    );
    background-size: 28px 28px;
    animation: progressStripes 1s linear infinite;
}

/* ดาวหางแสงวิ่งผ่านหน้าแถบซ้ำๆ ให้ดูมีชีวิตขึ้นอีกชั้น */
#progress-bar-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -30%;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
    animation: progressComet 1.6s ease-in-out infinite;
    z-index: 1;
}

#progress-bar-wrap.is-paused #progress-bar-fill { box-shadow: 0 0 8px rgba(255, 255, 255, 0.4); animation-play-state: paused; }
#progress-bar-wrap.is-paused #progress-bar-fill::after,
#progress-bar-wrap.is-paused #progress-bar-fill::before { animation-play-state: paused; }

@keyframes progressStripes {
    from { background-position: 0 0; }
    to { background-position: 28px 0; }
}
@keyframes progressGradientFlow {
    from { background-position: 0% 0; }
    to { background-position: 300% 0; }
}
@keyframes progressGlowPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(228, 8, 47, 0.6); }
    50% { box-shadow: 0 0 20px rgba(228, 8, 47, 1); }
}
@keyframes progressComet {
    0% { left: -30%; }
    100% { left: 100%; }
}

#progress-bar-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--gray-light);
    min-width: 38px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-light);
    min-height: 1.4em;
}

#message a { color: var(--red-primary); font-weight: 700; }

/* ---------- ไอคอนสถานะหน้า #message แทนตัวอักษร ASCII หน้า (script.js เซ็ต data-state ให้) ---------- */
#message::before {
    content: '';
    flex-shrink: 0;
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gray-mid);
    opacity: 0.5;
}

#message[data-state="processing"]::before {
    width: 13px;
    height: 13px;
    background: transparent;
    border: 2px solid rgba(228, 8, 47, 0.25);
    border-top-color: var(--red-primary);
    opacity: 1;
    animation: messageSpin 0.7s linear infinite;
}

#message[data-state="success"]::before {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: transparent;
    border: none;
    opacity: 1;
    color: #4ADE80;
    font-size: 0.75rem;
    line-height: 15px;
    text-align: center;
    content: '✓';
    animation: messageIconPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#message[data-state="warning"]::before {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    opacity: 1;
    color: #FFB020;
    font-size: 0.85rem;
    content: '⚠';
    animation: messageIconShake 0.4s ease;
}

#message[data-state="error"]::before {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    opacity: 1;
    color: var(--red-primary);
    font-size: 0.85rem;
    font-weight: 800;
    content: '✕';
    animation: messageIconShake 0.4s ease;
}

@keyframes messageSpin { to { transform: rotate(360deg); } }
@keyframes messageIconPop {
    0% { transform: scale(0.4); opacity: 0; }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes messageIconShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
}

.message-pop { animation: messagePop 0.35s ease-out; }

@keyframes messagePop {
    0% { transform: scale(0.94); opacity: 0.4; }
    100% { transform: scale(1); opacity: 1; }
}

#button-box {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

#start, #stop, #cancel, #compare-btn {
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 0.92rem;
    border: none;
    border-radius: 999px;
    padding: 15px 30px;
    cursor: pointer;
    color: var(--white);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

/* แสงวิ่งผ่านปุ่มตอน hover — micro-interaction เล็กๆ ให้ปุ่มดูมีชีวิตขึ้น */
#start::before, #stop::before, #cancel::before, #compare-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.5s ease;
    pointer-events: none;
}
#start:hover:not(:disabled)::before, #stop:hover::before, #cancel:hover::before, #compare-btn:hover::before { left: 130%; }

.btn-icon { font-size: 1rem; display: inline-block; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
#start:hover:not(:disabled) .btn-icon, #stop:hover .btn-icon, #cancel:hover .btn-icon, #compare-btn:hover .btn-icon { transform: scale(1.25) rotate(-8deg); }

#start {
    background: var(--red-gradient);
    box-shadow: 0 8px 28px rgba(228, 8, 47, 0.55);
}

#start:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 32px rgba(228, 8, 47, 0.7); }
#start:active:not(:disabled) { transform: translateY(0) scale(0.98); }

#start:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---------- เอฟเฟกต์ "ติดเครื่อง" ตอนกดปุ่มเริ่ม (ริปเปิลวงกลม + ปุ่มเด้งวาบ) ---------- */
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.15) 45%, transparent 70%);
    transform: scale(0);
    opacity: 1;
    pointer-events: none;
    animation: btnRippleExpand 0.7s ease-out forwards;
    z-index: -1;
}

@keyframes btnRippleExpand {
    to { transform: scale(1); opacity: 0; }
}

#start.is-igniting {
    animation: btnIgnite 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes btnIgnite {
    0% { transform: scale(1); box-shadow: 0 8px 28px rgba(228, 8, 47, 0.55); }
    35% { transform: scale(0.92); box-shadow: 0 4px 14px rgba(228, 8, 47, 0.4); }
    65% { transform: scale(1.08); box-shadow: 0 0 46px rgba(228, 8, 47, 1); }
    100% { transform: scale(1); box-shadow: 0 8px 28px rgba(228, 8, 47, 0.55); }
}

/* กรอบ canvas-panel แฟลชวาบพร้อมกัน ให้รู้สึกเหมือน "จ่ายไฟ" เข้าระบบตอนกดเริ่ม */
#canvas-panel.ignite-flash {
    animation: canvasIgniteFlash 0.55s ease;
}

@keyframes canvasIgniteFlash {
    0% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 0 rgba(228, 8, 47, 0); border-color: var(--border-card); }
    40% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 60px rgba(228, 8, 47, 0.9); border-color: var(--red-primary); }
    100% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 0 rgba(228, 8, 47, 0); border-color: var(--border-card); }
}

#stop {
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

#stop:hover { border-color: var(--white); background: rgba(255, 255, 255, 0.08); }
#stop:active { transform: scale(0.98); }

#cancel {
    background: transparent;
    border: 1.5px solid rgba(228, 8, 47, 0.45);
    color: var(--red-primary);
}

#cancel:hover { border-color: var(--red-primary); color: var(--white); background: rgba(228, 8, 47, 0.12); }
#cancel:active { transform: scale(0.98); }

/* ---------- Settings panel ---------- */
#settings-panel {
    background: var(--bg-card);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius);
    padding: 26px 24px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-title { font-size: 0.95rem; font-weight: 800; color: var(--white); margin-bottom: 10px; }

.field-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.field-group:last-of-type { border-bottom: none; padding-bottom: 4px; }
.save-mode-group.field-group { border-bottom: none; padding: 14px 16px; }

.field-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-light);
    margin-bottom: 2px;
}

.field-group select {
    font-family: var(--font-main);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--white);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    color-scheme: dark;
}

.field-group select:focus { outline: 1.5px solid var(--red-primary); }

/* เบราว์เซอร์สมัยใหม่ (Chromium) รองรับสไตล์สีพื้นหลัง/ตัวอักษรของ <option> ในลิสต์ dropdown ได้
   ถ้าไม่ใส่ตรงนี้ ตัวลิสต์ dropdown จะใช้สีขาวของระบบ (มองข้อความบนพื้นเข้มไม่เห็น) */
.field-group select option {
    background-color: #0F0F11;
    color: var(--white);
}

.field-hint { font-size: 0.68rem; color: var(--gray-mid); line-height: 1.5; }

/* ---------- Segmented pill control (ขยายภาพ / ลดสัญญาณรบกวน) ---------- */
.sr-only-select { display: none; }

.segmented {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 4px;
}

.segmented-btn {
    flex: 1;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--gray-mid);
    background: transparent;
    border: none;
    border-radius: 7px;
    padding: 8px 4px;
    cursor: pointer;
    transition: var(--transition);
}

.segmented-btn:hover { color: var(--white); transform: translateY(-1px); }
.segmented-btn:active { transform: scale(0.94); }

.segmented-btn.is-active {
    animation: segPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: var(--red-gradient);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(228, 8, 47, 0.5);
}

@keyframes segPop {
    0% { transform: scale(0.85); }
    60% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* ---------- Toggle switch (โหมดประหยัด) ---------- */
.toggle-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
}

.toggle-label { font-size: 0.85rem; font-weight: 700; color: var(--white); }

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--red-gradient);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-light);
    cursor: pointer;
    margin-top: 4px;
}

.save-mode-group {
    background: rgba(228, 8, 47, 0.08);
    border: 1.5px solid rgba(228, 8, 47, 0.35);
    border-radius: 10px;
    padding: 14px 16px;
}

.save-mode-group .field-hint { color: var(--gray-light); }

.advanced-settings {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.advanced-settings summary {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-light);
    list-style: none;
}

.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 4px;
    color: var(--red-primary);
    transition: transform 0.25s ease;
}
.advanced-settings[open] summary::before { transform: rotate(90deg); }

.advanced-settings > .field-group { margin-top: 4px; }

.settings-footer {
    font-size: 0.68rem;
    color: var(--gray-mid);
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-footer a { color: var(--red-primary); }

/* ---------- Credit history modal ---------- */
.credit-modal-wide { width: min(480px, 90vw); text-align: left; }
.credit-history-list {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
}
.credit-history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.78rem;
    color: var(--gray-light);
}
.credit-history-status {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--gray-mid);
    background: rgba(255, 255, 255, 0.08);
}
.credit-history-status.status-committed { color: #FFFFFF; background: rgba(228, 8, 47, 0.35); }
.credit-history-status.status-refunded { color: var(--gray-mid); background: rgba(255, 255, 255, 0.08); }
.credit-history-status.status-reserved { color: var(--white); background: rgba(255, 255, 255, 0.15); }
.credit-history-cost { font-weight: 800; color: var(--red-primary); white-space: nowrap; }

/* ---------- Page entrance animation ---------- */
#sidebar {
    animation: slideInLeft 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

#app-header {
    animation: fadeInDown 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

#canvas-panel {
    animation: fadeInUp 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: 0.08s;
}

#settings-panel {
    animation: fadeInUp 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: 0.16s;
}

.sidebar-nav-item {
    animation: fadeInLeft 0.4s ease-out both;
}
.sidebar-nav-item:nth-child(1) { animation-delay: 0.12s; }
.sidebar-nav-item:nth-child(2) { animation-delay: 0.18s; }
.sidebar-nav-item:nth-child(3) { animation-delay: 0.24s; }

.sidebar-tips { animation: fadeInLeft 0.4s ease-out both; animation-delay: 0.3s; }

/* หมายเหตุ: keyframes slideInLeft / fadeInLeft / fadeInDown / fadeInUp มาจาก vendor/animate.min.css
   (Animate.css) ที่โหลดไว้ใน <head> อยู่แล้ว — ใช้ชื่อ keyframe เดียวกันได้เลยโดยไม่ต้องประกาศเอง */

/* ---------- Modal เข้าฉากด้วย Animate.css (fadeIn ทับพื้นหลัง + zoomIn ตัวการ์ด) ---------- */
.credit-modal-overlay.active { animation: fadeIn 0.2s ease both; }
.credit-modal-overlay.active .credit-modal,
.credit-modal-overlay.active .credit-modal-auth,
.credit-modal-overlay.active .credit-modal-wide {
    animation: zoomIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ---------- ผลลัพธ์ประมวลผลเสร็จ เด้งเข้าด้วย Animate.css bounceIn ---------- */
#dest.result-ready { animation: bounceIn 0.6s ease both; }

/* ---------- Extra hover / interaction polish ---------- */
.frame-block { transition: transform 0.25s ease; }
.frame-block:hover { transform: translateY(-3px); }

.help-accordion-title { cursor: pointer; transition: color 0.2s ease; }
.help-accordion-title:hover { color: var(--white); }

.credit-history-row { transition: transform 0.2s ease, border-color 0.2s ease; }
.credit-history-row:hover { transform: translateX(3px); border-color: rgba(228, 8, 47, 0.4); }

/* ปุ่มกด Start ทุกปุ่มเด้งเบาๆ ตอน hover อยู่แล้ว เพิ่ม focus-visible ให้เข้าถึงง่ายขึ้นด้วย */
#start:focus-visible, #stop:focus-visible, #cancel:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}

/* ---------- Processing shimmer sweep บนปุ่ม Start ระหว่างประมวลผล ---------- */
#canvas-panel.is-processing #start {
    position: relative;
    overflow: hidden;
}
#canvas-panel.is-processing #start::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
    background-size: 200% 100%;
    animation: shimmerSweep 1.4s linear infinite;
}

@keyframes shimmerSweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Image lightbox: กดรูปต้นฉบับ/ผลลัพธ์แล้ว pop ขึ้นมาแบบเต็มจอ ---------- */
.image-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    cursor: zoom-out;
}
.image-lightbox.active { display: flex; animation: fadeIn 0.2s ease both; }
.image-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 10px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.9);
    cursor: default;
    animation: zoomIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    background: repeating-conic-gradient(rgba(255, 255, 255, 0.05) 0% 25%, transparent 0% 50%) 50% / 18px 18px;
}
.image-lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1;
}
.image-lightbox-close:hover { border-color: var(--red-primary); background: rgba(228, 8, 47, 0.25); transform: rotate(90deg); }

#src, #dest { cursor: zoom-in; }

/* ---------- เปรียบเทียบต้นฉบับ-ผลลัพธ์แบบลาก slider ---------- */
#compare-btn {
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}
#compare-btn:hover { border-color: var(--white); background: rgba(255, 255, 255, 0.08); }
#compare-btn:active { transform: scale(0.98); }

.compare-box {
    position: relative;
    max-width: 88vw;
    max-height: 82vh;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.9);
    cursor: ew-resize;
    user-select: none;
    animation: zoomIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    touch-action: none;
}

.compare-box img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}

#compare-after {
    clip-path: inset(0 0 0 var(--compare-split, 50%));
}

.compare-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--compare-split, 50%);
    width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.compare-handle::before {
    content: '';
    position: absolute;
    inset: 0;
    width: 2px;
    left: -1px;
    background: var(--white);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}
.compare-handle-grip {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--red-gradient);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    box-shadow: 0 4px 16px rgba(228, 8, 47, 0.6), 0 0 0 3px rgba(0, 0, 0, 0.4);
}

.compare-label {
    position: absolute;
    top: 14px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--white);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 4px 12px;
    border-radius: 999px;
    pointer-events: none;
}
.compare-label-before { left: 14px; }
.compare-label-after { right: 14px; }

