#pe-chat-container {
    --pe-accent: #c47052;
    --pe-accent-dark: #a85a3d;
    --pe-accent-soft: rgba(196, 112, 82, 0.10);
    --pe-bg: #ffffff;
    --pe-panel: #fafaf7;
    --pe-text: #313131;
    --pe-muted: #8a817a;
    --pe-border: #ece7e1;
    --pe-serif: var(--wp--preset--font-family--cormorant-garamond, Georgia, "Times New Roman", serif);
    --pe-sans: var(--wp--preset--font-family--dm-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);

    font-family: var(--pe-sans);
    color: var(--pe-text);
    max-width: 740px;
    margin: 24px auto;
    background: var(--pe-bg);
    border: 1px solid var(--pe-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 30px -12px rgba(49, 49, 49, 0.18), 0 2px 6px -2px rgba(49, 49, 49, 0.08);
}

/* ---------- Header bar ---------- */
#pe-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(120deg, #fbf4f0 0%, var(--pe-panel) 70%);
    border-bottom: 1px solid var(--pe-border);
}

#pe-chat-header .pe-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--pe-accent);
    color: #fff;
    flex: 0 0 auto;
}

#pe-chat-header .pe-header-icon svg {
    width: 18px;
    height: 18px;
}

#pe-chat-header .pe-header-title {
    font-family: var(--pe-serif);
    font-size: 26px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ---------- Start screen ---------- */
#pe-start-screen {
    padding: 40px 24px;
    text-align: center;
}

#pe-start-screen h2 {
    margin: 0 0 12px;
    font-family: var(--pe-serif);
    font-size: 28px;
    font-weight: 600;
}

.pe-privacy-notice {
    font-size: 13px;
    color: var(--pe-muted);
    margin: 0 0 20px;
    font-style: italic;
}

.pe-mode-btn {
    display: inline-block;
    margin: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid var(--pe-accent);
    background: #fff;
    color: var(--pe-accent);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pe-mode-btn:hover {
    background: var(--pe-accent);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -6px rgba(196, 112, 82, 0.6);
}

.pe-mode-btn:active {
    transform: translateY(0);
}

/* ---------- Chat thread ---------- */
#pe-chat-thread {
    padding: 18px 16px;
    max-height: 500px;
    overflow-y: auto;
    background: var(--pe-bg);
}

/* message row = avatar + bubble */
.pe-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    animation: pe-msg-in 0.28s ease both;
}

.pe-row.pe-row-user {
    flex-direction: row-reverse;
}

.pe-avatar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.pe-avatar-assistant {
    background: var(--pe-accent);
    color: #fff;
}

.pe-avatar-user {
    background: #efe9e3;
    color: var(--pe-text);
}

.pe-message {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(49, 49, 49, 0.06);
}

.pe-user .pe-message,
.pe-message.pe-user {
    background: var(--pe-accent-soft);
    border-bottom-right-radius: 4px;
}

.pe-assistant .pe-message,
.pe-message.pe-assistant {
    background: var(--pe-panel);
    border-bottom-left-radius: 4px;
}

.pe-message h1, .pe-message h2, .pe-message h3 {
    margin: 12px 0 6px;
    line-height: 1.3;
    font-family: var(--pe-serif);
}

.pe-message h1 { font-size: 22px; }
.pe-message h2 { font-size: 19px; }
.pe-message h3 { font-size: 16px; }

.pe-message p { margin: 0 0 8px; }
.pe-message p:last-child { margin-bottom: 0; }

.pe-message ul { margin: 6px 0; padding-left: 20px; }
.pe-message li { margin-bottom: 4px; }

.pe-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
}

.pe-message th, .pe-message td {
    border: 1px solid var(--pe-border);
    padding: 6px 10px;
    text-align: left;
}

.pe-message th {
    background: #f1ebe5;
    font-weight: 600;
}

/* ---------- Code blocks (dark hero) ---------- */
.pe-message pre {
    position: relative;
    background: #1e1e24;
    color: #e8e6e3;
    padding: 30px 14px 14px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    margin: 10px 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.pe-message pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 8px;
    left: 14px;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #9a948c;
    font-family: var(--pe-sans);
}

.pe-message code {
    background: #f1ebe5;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
}

.pe-message pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.pe-system_meta {
    text-align: center;
    font-size: 12px;
    color: var(--pe-muted);
    padding: 4px 16px;
    margin-bottom: 12px;
    animation: pe-msg-in 0.28s ease both;
}

/* ---------- Copy bar ---------- */
#pe-copy-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: linear-gradient(120deg, #fbf4f0, var(--pe-panel));
    border-top: 1px solid var(--pe-border);
    border-bottom: 1px solid var(--pe-border);
}

#pe-copy-bar.pe-show {
    animation: pe-slide-up 0.35s ease both, pe-pulse 1.6s ease 0.35s 1;
}

.pe-copy-bar-text {
    font-size: 14px;
    color: var(--pe-text);
    flex: 1;
    min-width: 200px;
}

#pe-copy-prompt-btn {
    padding: 11px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--pe-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

#pe-copy-prompt-btn:hover {
    background: var(--pe-accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -6px rgba(196, 112, 82, 0.6);
}

#pe-copy-prompt-btn:active {
    transform: translateY(0);
}

#pe-copy-prompt-btn.pe-copied {
    background: #1a7f37;
}

/* ---------- Input area ---------- */
#pe-input-area {
    padding: 14px 16px;
    background: var(--pe-bg);
}

#pe-input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #ddd5cc;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--pe-text);
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#pe-input:focus {
    border-color: var(--pe-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--pe-accent-soft);
}

#pe-send-btn {
    margin-top: 10px;
    padding: 9px 22px;
    background: var(--pe-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

#pe-send-btn:hover {
    background: var(--pe-accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -6px rgba(196, 112, 82, 0.6);
}

#pe-send-btn:active {
    transform: translateY(0);
}

#pe-send-btn:disabled {
    background: #c9bfb6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#pe-chat-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
}

#pe-end-btn {
    padding: 5px 14px;
    font-size: 12px;
    font-family: inherit;
    background: transparent;
    color: #c0392b;
    border: 1px solid #d9a59e;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

#pe-end-btn:hover {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

.pe-budget-display {
    color: var(--pe-muted);
}

.pe-budget-warning {
    color: #c0392b;
    font-weight: 600;
}

.pe-usage-info {
    color: var(--pe-muted);
    margin-left: auto;
}

/* ---------- Typing bubble ---------- */
#pe-thinking {
    display: none;
    align-items: flex-start;
    gap: 10px;
    padding: 0 16px 16px;
}

#pe-thinking .pe-avatar {
    margin-top: 2px;
}

.pe-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
    background: var(--pe-panel);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(49, 49, 49, 0.06);
}

.pe-thinking-dot {
    width: 8px;
    height: 8px;
    background: var(--pe-accent);
    border-radius: 50%;
    animation: pe-bounce 1.4s infinite ease-in-out both;
}

.pe-thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.pe-thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.pe-thinking-dot:nth-child(3) { animation-delay: 0s; }

#pe-turnstile-wrapper {
    margin: 16px 0;
    display: flex;
    justify-content: center;
}

/* ---------- Animations ---------- */
@keyframes pe-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pe-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pe-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(196, 112, 82, 0.45); }
    70%  { box-shadow: 0 0 0 12px rgba(196, 112, 82, 0); }
    100% { box-shadow: 0 0 0 0 rgba(196, 112, 82, 0); }
}

@keyframes pe-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .pe-row,
    .pe-system_meta,
    #pe-copy-bar.pe-show {
        animation: none !important;
    }
    .pe-mode-btn:hover,
    #pe-send-btn:hover,
    #pe-copy-prompt-btn:hover {
        transform: none;
    }
    .pe-thinking-dot {
        animation-duration: 2s;
    }
}
