:root {
    --shopie-accent:      #7C3AED;
    --shopie-accent-dark: #6D28D9;
    --shopie-radius:      16px;
    --shopie-shadow:      0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
    --shopie-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shopie-bot-bubble:  #F3F4F6;
    --shopie-bot-text:    #111827;
    --shopie-bg:          #fff;
    --shopie-border:      #E5E7EB;
    --shopie-input-bg:    #F9FAFB;
    --shopie-meta:        #9CA3AF;
}

#shopie-root * { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--shopie-font); }
#shopie-root button { text-transform: none !important; letter-spacing: normal !important; }

#shopie-toggle {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--shopie-accent);
    color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; overflow: hidden;
    box-shadow: 0 4px 20px rgba(124,58,237,.4), 0 2px 8px rgba(0,0,0,.12);
    z-index: 999999;
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    outline: none;
}
#shopie-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(124,58,237,.55); }
#shopie-toggle:active { transform: scale(.94); }

#shopie-btn-icon { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; display: block; pointer-events: none; }
#shopie-icon-close { position: absolute; }

#shopie-unread-badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 18px; height: 18px;
    background: #EF4444; color: #fff;
    font-size: 10px; font-weight: 700;
    border-radius: 9px; display: flex; align-items: center; justify-content: center;
    padding: 0 4px; border: 2px solid #fff; pointer-events: none;
}

#shopie-window {
    position: fixed; bottom: 96px; right: 24px;
    width: 372px; max-width: calc(100vw - 32px);
    height: 580px; max-height: calc(100vh - 120px);
    background: var(--shopie-bg);
    border-radius: var(--shopie-radius);
    box-shadow: var(--shopie-shadow);
    z-index: 999998;
    display: flex; flex-direction: column; overflow: hidden;
    min-height: 0;
    transform-origin: bottom right;
    animation: shopie-pop-in .24s cubic-bezier(.34,1.56,.64,1);
}

#shopie-window.gk-debug-open {
    padding-left: 240px;
}

#gk-debug-panel {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    background: #0f172a;
    color: #e2e8f0;
    border-right: 1px solid rgba(148, 163, 184, 0.16);
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.gk-debug-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 10px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.gk-debug-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f8fafc;
}
.gk-debug-actions { display: flex; gap: 6px; align-items: center; }
.gk-debug-clear, .gk-debug-close {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.85);
    color: #cbd5e1;
    cursor: pointer;
}
.gk-debug-close { padding: 4px 7px; font-weight: 700; }
.gk-debug-clear:hover, .gk-debug-close:hover {
    background: rgba(51, 65, 85, 0.95);
    color: #f1f5f9;
    border-color: rgba(148, 163, 184, 0.28);
}
.gk-debug-log {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.gk-debug-log::-webkit-scrollbar { width: 5px; }
.gk-debug-log::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.45); border-radius: 3px; }
.gk-debug-block {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(51, 65, 85, 0.85);
    background: rgba(15, 23, 42, 0.5);
}
.gk-debug-block--out { box-shadow: inset 3px 0 0 0 #38bdf8; }
.gk-debug-block--in  { box-shadow: inset 3px 0 0 0 #4ade80; }
.gk-debug-block--err { box-shadow: inset 3px 0 0 0 #fb7185; }
.gk-debug-block-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: rgba(2, 6, 23, 0.35);
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}
.gk-debug-chip {
    flex-shrink: 0;
    font-family: monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 3px 6px;
    border-radius: 4px;
}
.gk-debug-block--out .gk-debug-chip { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.gk-debug-block--in  .gk-debug-chip { background: rgba(74, 222, 128, 0.14); color: #86efac; }
.gk-debug-block--err .gk-debug-chip { background: rgba(251, 113, 133, 0.16); color: #fda4af; }
.gk-debug-meta {
    font-family: monospace;
    font-size: 10px;
    color: #94a3b8;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gk-debug-block-pre {
    margin: 0;
    padding: 9px 10px 10px;
    font-family: monospace;
    font-size: 10px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cbd5e1;
    background: #020617;
    max-height: 200px;
    overflow: auto;
}

@keyframes shopie-pop-in {
    from { opacity: 0; transform: scale(.86) translateY(14px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

#shopie-header {
    background: var(--shopie-accent);
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
#shopie-header-info { display: flex; align-items: center; gap: 10px; }

#shopie-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,.22); color: #fff;
    font-size: 16px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

#shopie-bot-name { color: #fff; font-size: 15px; font-weight: 600; line-height: 1.2; }
#shopie-status { color: rgba(255,255,255,.75); font-size: 12px; display: flex; align-items: center; gap: 5px; margin-top: 2px; }

.shopie-dot {
    width: 7px; height: 7px; background: #4ADE80; border-radius: 50%;
    display: inline-block; animation: shopie-pulse 2.2s ease-in-out infinite;
}
@keyframes shopie-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

#shopie-test-badge {
    margin-left: auto;
    background: rgba(239,68,68,.18); color: #FCA5A5;
    font-size: 10px; font-weight: 700; letter-spacing: .06em;
    padding: 3px 7px; border-radius: 5px; border: 1px solid rgba(239,68,68,.3); flex-shrink: 0;
}

#shopie-close-btn {
    background: rgba(255,255,255,.14); border: none; color: #fff;
    width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s; outline: none; flex-shrink: 0;
}
#shopie-close-btn:hover { background: rgba(255,255,255,.28); }

#shopie-messages {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 14px 12px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
#shopie-messages::-webkit-scrollbar { width: 4px; }
#shopie-messages::-webkit-scrollbar-track { background: transparent; }
#shopie-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }

.shopie-msg-row { display: flex; flex-direction: column; }
.shopie-msg-row.user { align-items: flex-end; }
.shopie-msg-row.bot  { align-items: flex-start; }
.shopie-msg-row.system { align-items: center; }

#shopie-root .shopie-bubble {
    max-width: 82%; padding: 11px 16px; border-radius: 14px;
    font-size: 14px; line-height: 1.55; word-break: break-word; white-space: pre-wrap;
}
#shopie-root .shopie-msg-row.user .shopie-bubble { background: var(--shopie-accent); color: #fff; border-bottom-right-radius: 4px; }
#shopie-root .shopie-msg-row.bot  .shopie-bubble { background: var(--shopie-bot-bubble); color: var(--shopie-bot-text); border-bottom-left-radius: 4px; }

.shopie-meta { font-size: 11px; color: var(--shopie-meta); margin-top: 3px; padding: 0 2px; }

.shopie-system-notice {
    font-size: 11px; color: #6B7280;
    background: #F3F4F6; border: 1px dashed #D1D5DB;
    border-radius: 6px; padding: 5px 10px;
    font-family: monospace; max-width: 90%; text-align: center;
}

.shopie-typing-label {
    font-size: 11px;
    color: var(--shopie-meta);
    margin-bottom: 4px;
    padding-left: 2px;
}

.shopie-typing {
    display: flex; align-items: center; gap: 5px;
    padding: 12px 16px; background: var(--shopie-bot-bubble);
    border-radius: 18px; border-bottom-left-radius: 4px; width: fit-content;
}

.shopie-typing span {
    width: 8px; height: 8px;
    background: #9CA3AF;
    border-radius: 50%;
    display: inline-block;
    animation: shopie-wa-typing 1.2s ease-in-out infinite;
    transform-origin: center bottom;
}

.shopie-typing span:nth-child(1) { animation-delay: 0s; }
.shopie-typing span:nth-child(2) { animation-delay: 0.2s; }
.shopie-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes shopie-wa-typing {
    0%   { transform: translateY(0);    opacity: .4; }
    30%  { transform: translateY(-6px); opacity: 1;  }
    60%  { transform: translateY(0);    opacity: .4; }
    100% { transform: translateY(0);    opacity: .4; }
}

#shopie-suggestions {
    display: flex; flex-direction: column; gap: 7px;
    padding: 4px 14px 14px; flex-shrink: 0;
}
#shopie-root .shopie-suggestion-btn {
    text-align: left; background: transparent;
    border: 1.5px solid var(--shopie-accent); color: var(--shopie-accent);
    border-radius: 10px; padding: 10px 14px;
    font-size: 13px; line-height: 1.45; cursor: pointer;
    text-transform: none !important; letter-spacing: normal !important;
    transition: background .15s, color .15s, transform .1s;
    font-family: var(--shopie-font); width: 100%;
}
#shopie-root .shopie-suggestion-btn:hover { background: var(--shopie-accent); color: #fff; transform: translateX(2px); }
#shopie-root .shopie-suggestion-btn:active { transform: scale(.97); }

.shopie-actions {
    display: flex; flex-direction: column; gap: 7px;
    max-width: 82%;
}

#shopie-root .shopie-action-btn {
    text-align: left; border-radius: 10px; padding: 10px 14px;
    font-size: 13px; line-height: 1.45; cursor: pointer;
    text-transform: none !important; letter-spacing: normal !important;
    transition: background .15s, color .15s, transform .1s;
    font-family: var(--shopie-font); width: 100%;
}

#shopie-root .shopie-action-btn:first-child {
    background: var(--shopie-accent); color: #fff; border: none;
    font-weight: 600;
}
#shopie-root .shopie-action-btn:first-child:hover { background: var(--shopie-accent-dark); transform: translateX(2px); }

#shopie-root .shopie-action-btn:not(:first-child) {
    background: transparent; color: var(--shopie-accent);
    border: 1.5px solid var(--shopie-accent);
}
#shopie-root .shopie-action-btn:not(:first-child):hover { background: var(--shopie-accent); color: #fff; transform: translateX(2px); }
#shopie-root .shopie-action-btn:active { transform: scale(.97); }

.sophie-msg-row.system { display: flex; justify-content: center; padding: 4px 0; }
.sophie-system-msg {
    font-size: 11px; color: var(--shopie-meta);
    background: var(--shopie-bot-bubble);
    padding: 4px 14px; border-radius: 20px;
}

#shopie-kyc-source {
    display: none !important;
}

.shopie-kyc-row {
    width: 100%;
    max-width: 100%;
}

.shopie-kyc-row #shopie-kyc-form {
    max-width: 92%;
    padding: 14px 16px 12px;
    border: 1px solid var(--shopie-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    background: var(--shopie-bot-bubble);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

#shopie-kyc-form {
    padding: 14px 16px 12px;
    border-top: 1px solid var(--shopie-border);
    background: #FAFAFA;
    display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
#shopie-kyc-intro { font-size: 13px; color: #374151; line-height: 1.4; margin-bottom: 2px; }
#shopie-root .kyc-sub {
    font-size: 12px;
    color: #6B7280;
    line-height: 1.5;
    margin: -2px 0 2px;
}
#shopie-kyc-form input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--shopie-border); border-radius: 9px;
    font-size: 13px; color: #111827; background: #fff; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
#shopie-kyc-form input:focus { border-color: var(--shopie-accent); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
#shopie-kyc-submit {
    background: var(--shopie-accent); color: #fff; border: none;
    border-radius: 9px; padding: 9px 14px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s, transform .1s; margin-top: 2px;
}
#shopie-kyc-submit:hover  { background: var(--shopie-accent-dark); }
#shopie-kyc-submit:active { transform: scale(.97); }

#shopie-input-area {
    padding: 10px 12px; border-top: 1px solid var(--shopie-border);
    display: flex; align-items: flex-end; gap: 8px;
    background: var(--shopie-bg); flex-shrink: 0;
}
#shopie-input {
    flex: 1; background: var(--shopie-input-bg);
    border: 1px solid var(--shopie-border); border-radius: 10px;
    padding: 9px 12px; font-size: 14px; color: #111827;
    resize: none; max-height: 100px; outline: none; line-height: 1.45;
    transition: border-color .15s, box-shadow .15s;
}
#shopie-input:focus { border-color: var(--shopie-accent); background: #fff; box-shadow: 0 0 0 3px rgba(124,58,237,.1); }

#shopie-send {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--shopie-accent); color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background .15s, transform .1s, opacity .15s; outline: none;
}
#shopie-send:disabled              { opacity: .4; cursor: not-allowed; }
#shopie-send:not(:disabled):hover  { background: var(--shopie-accent-dark); }
#shopie-send:not(:disabled):active { transform: scale(.92); }

#shopie-footer-brand {
    text-align: center; font-size: 11px; color: #9CA3AF;
    padding: 5px 0 8px; background: var(--shopie-bg);
    flex-shrink: 0; letter-spacing: .01em;
}
#shopie-footer-brand strong { color: var(--shopie-accent); }

@media (max-width: 420px) {
    #shopie-window { bottom: 0; right: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
    #shopie-toggle { bottom: 16px; right: 16px; }
}

.sophie-calendar-wrap { width: 100%; display: flex; flex-direction: column; gap: 0; }
.sophie-cal-step { display: flex; flex-direction: column; gap: 10px; background: var(--shopie-bot-bubble); border-radius: 14px; border-bottom-left-radius: 4px; padding: 10px; width: 100%; }
.shopie-msg-row.bot:has(.sophie-calendar-wrap) { width: 100%; }
.sophie-calendar-row { width: 100% !important; align-items: stretch !important; }
.shopie-cal-header { display: flex; align-items: center; justify-content: space-between; }
.shopie-cal-month { font-size: 13px; font-weight: 600; color: var(--shopie-bot-text); }
#shopie-root .shopie-cal-nav { background: transparent; border: none; cursor: pointer; font-size: 15px; color: var(--shopie-meta); padding: 4px 8px; border-radius: 6px; text-transform: none; letter-spacing: normal; }
#shopie-root .shopie-cal-nav:hover { color: var(--shopie-accent); }
.shopie-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.shopie-cal-dayname { font-size: 10px; color: var(--shopie-meta); padding: 3px 0; }
#shopie-root .shopie-cal-day { padding: 6px 2px; border-radius: 8px; font-size: 12px; border: none; cursor: pointer; width: 100%; text-transform: none; letter-spacing: normal; background: transparent; color: var(--shopie-bot-text); display: flex; flex-direction: column; align-items: center; gap: 2px; }
#shopie-root .shopie-cal-day.available { background: #EDE9FE; color: #534AB7; font-weight: 500; }
#shopie-root .shopie-cal-day.available:hover { background: var(--shopie-accent); color: #fff; }
#shopie-root .shopie-cal-day.disabled { color: #D1D5DB; cursor: default; }
.shopie-cal-dot { width: 4px; height: 4px; background: var(--shopie-accent); border-radius: 50%; display: block; }
.shopie-cal-back-row { display: flex; align-items: center; gap: 8px; }
#shopie-root .shopie-cal-back { background: transparent; border: none; cursor: pointer; color: var(--shopie-accent); font-size: 13px; padding: 0; text-transform: none; letter-spacing: normal; }
.shopie-cal-date-label { font-size: 13px; font-weight: 600; color: var(--shopie-bot-text); }
.shopie-cal-slots-label { font-size: 11px; font-weight: 600; color: var(--shopie-meta); text-transform: uppercase; letter-spacing: .05em; }
.shopie-cal-slot-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
#shopie-root .shopie-slot-btn { background: #fff; border: 1.5px solid #E5E7EB; border-radius: 8px; padding: 9px 4px; font-size: 13px; font-weight: 500; color: #374151; cursor: pointer; text-transform: none; letter-spacing: normal; }
#shopie-root .shopie-slot-btn.selected { background: var(--shopie-accent); border-color: var(--shopie-accent); color: #fff; }
#shopie-root .shopie-slot-btn:hover:not(.selected) { border-color: var(--shopie-accent); color: var(--shopie-accent); }
.shopie-cal-confirm-wrap { margin-top: 4px; }
