/*
 * SailWP AI Co-pilot — persistent admin/front-end chat rail.
 * Fixed right edge, collapsible. Works in WP admin + front-end (logged-in editors).
 */

:root {
    --sw-rail-coral:        #e8845c;
    --sw-rail-coral-dark:   #d36e47;
    --sw-rail-coral-soft:   #f0c5ad;          /* pale coral for soft borders/accents */
    --sw-rail-bg:           #fbf6ee;          /* warm cream — panel */
    --sw-rail-bg-soft:      #f5ecde;          /* slightly deeper cream — headers/status */
    --sw-rail-card:         #fffcf6;          /* near-white cream — cards/composer */
    --sw-rail-border:       #eadfcd;          /* warm taupe */
    --sw-rail-border-soft:  #f1e7d6;          /* softer warm taupe */
    --sw-rail-text:         #3a2e24;          /* warm dark brown — not cold navy */
    --sw-rail-text-soft:    #7d6e60;          /* warm gray-brown */
    --sw-rail-bubble-bot:   #f3e8d8;          /* warm sand — bot bubbles */
    --sw-rail-shadow:       0 12px 40px rgba(122, 81, 56, 0.12);
    --sw-rail-shadow-soft:  0 2px 8px rgba(232, 132, 92, 0.08);
    --sw-rail-sage:         #9bb074;          /* warm sage — for "done" state */
    --sw-rail-width:        380px;
    --sw-rail-collapsed-w:  44px;
    --sw-rail-radius:       12px;
}

/* Container — always rendered, swaps between collapsed (icon only) and expanded (panel) */
.sw-rail {
    position: fixed;
    top: 32px;                  /* WP admin bar */
    right: 0;
    bottom: 0;
    z-index: 99998;             /* under modal overlays, over content */
    pointer-events: none;       /* children re-enable */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    color: var(--sw-rail-text);
    line-height: 1.45;
    --sw-bar-height: 32px;
}

/* Bigger admin bar on small viewports */
@media screen and (max-width: 782px) {
    .sw-rail { top: 46px; --sw-bar-height: 46px; }
}

/* When admin bar is hidden (e.g. logged-in front-end with no bar) — set top to 0 via JS */
.sw-rail[data-no-adminbar="true"] { top: 0; --sw-bar-height: 0px; }

.sw-rail > * { pointer-events: auto; }

/* Strip WP-admin / theme button styling that bleeds into the rail. Themes
   like Astra and Cadence apply blue button:hover colors that override
   our class-based rules; we lock all rail buttons down here. Keyboard
   accessibility is preserved via :focus-visible (soft coral ring). */
.sw-rail button {
    outline: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-family: inherit;
    font-weight: 500;
}
.sw-rail button:focus { outline: none !important; }
.sw-rail button:focus-visible {
    outline: 2px solid var(--sw-rail-coral-soft) !important;
    outline-offset: 2px;
    border-radius: 6px;
}
/* Force the bare-icon buttons to keep our colors no matter what the host
   theme says about button:hover. */
.sw-rail .sw-rail-attach,
.sw-rail .sw-rail-mic,
.sw-rail-actions button {
    color: var(--sw-rail-text-soft) !important;
    background: transparent !important;
    border: none !important;
}
.sw-rail .sw-rail-attach:hover,
.sw-rail .sw-rail-mic:hover,
.sw-rail-actions button:hover {
    color: var(--sw-rail-coral-dark) !important;
    background: transparent !important;
}
.sw-rail .sw-rail-mic.is-listening {
    color: #fff !important;
    background: var(--sw-rail-coral) !important;
}
.sw-rail .sw-rail-attachment-remove {
    color: var(--sw-rail-text-soft) !important;
    background: transparent !important;
    border: none !important;
}
.sw-rail .sw-rail-attachment-remove:hover {
    color: var(--sw-rail-coral-dark) !important;
}

/* === Collapsed: just a tab on the right edge === */
.sw-rail[data-collapsed="true"] .sw-rail-toggle {
    display: flex;
}
.sw-rail[data-collapsed="true"] .sw-rail-panel {
    display: none;
}

.sw-rail-toggle {
    position: absolute;
    right: 24px;
    bottom: 24px;
    top: auto;
    width: 60px;
    height: 60px;
    border: none;
    background: #ffffff;
    border-radius: 50%;
    box-shadow:
        0 0 0 1px rgba(232, 132, 92, 0.20),
        0 10px 28px rgba(232, 132, 92, 0.32),
        0 2px 6px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    animation: sw-rail-toggle-pulse 2.8s ease-in-out infinite;
    padding: 8px;
}
.sw-rail-toggle:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 0 0 1px rgba(232, 132, 92, 0.30),
        0 14px 36px rgba(232, 132, 92, 0.45),
        0 2px 6px rgba(0, 0, 0, 0.10);
    animation: none;
}
.sw-rail-toggle svg { width: 26px; height: 26px; }

@keyframes sw-rail-toggle-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(232, 132, 92, 0.20),
            0 10px 28px rgba(232, 132, 92, 0.32),
            0 2px 6px rgba(0, 0, 0, 0.08),
            0 0 0 0 rgba(232, 132, 92, 0);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(232, 132, 92, 0.30),
            0 10px 28px rgba(232, 132, 92, 0.40),
            0 2px 6px rgba(0, 0, 0, 0.10),
            0 0 0 12px rgba(232, 132, 92, 0.10);
    }
}

/* === Expanded: panel slides in from right === */
.sw-rail[data-collapsed="false"] .sw-rail-toggle {
    display: none;
}
.sw-rail[data-collapsed="false"] .sw-rail-panel {
    display: flex;
}

.sw-rail-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: var(--sw-rail-width);
    max-width: calc(100vw - 24px);
    background: var(--sw-rail-bg);
    border: 1px solid var(--sw-rail-border);
    border-radius: var(--sw-rail-radius);
    box-shadow: var(--sw-rail-shadow);
    flex-direction: column;
    overflow: hidden;
}

.sw-rail-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--sw-rail-border);
    background: linear-gradient(180deg, var(--sw-rail-card) 0%, var(--sw-rail-bg-soft) 100%);
    flex-shrink: 0;
}

.sw-rail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--sw-rail-text);
}

.sw-rail-title-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.sw-rail-title-mark .sw-rail-brand-img {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}

/* SailWP sail-mark inside the FAB (collapsed state). Icon sits directly
   on the white FAB so the full sailboat is visible without inner-circle
   "eye" effect. Coral attention comes from the pulse ring around the FAB. */
.sw-rail-toggle .sw-rail-brand-img {
    width: 40px;
    height: 40px;
    display: block;
    object-fit: contain;
    background: transparent;
    box-shadow: none;
}

.sw-rail-actions {
    display: flex;
    gap: 4px;
}

.sw-rail-actions button {
    background: transparent;
    border: none;
    color: var(--sw-rail-text-soft);
    padding: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}
.sw-rail-actions button svg {
    width: 18px;
    height: 18px;
    display: block;
}
.sw-rail-actions button:hover {
    color: var(--sw-rail-coral-dark);
}

.sw-rail-status {
    padding: 6px 14px;
    font-size: 11px;
    color: var(--sw-rail-text-soft);
    border-bottom: 1px solid var(--sw-rail-border);
    background: var(--sw-rail-bg-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.sw-rail-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sw-rail-empty {
    padding: 12px 4px;
    color: var(--sw-rail-text-soft);
    font-size: 13px;
}
.sw-rail-empty h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--sw-rail-text);
    margin: 0 0 4px;
}
.sw-rail-empty p {
    margin: 0 0 12px;
    font-size: 13px;
}

.sw-rail-suggestion-section {
    margin-bottom: 14px;
}
.sw-rail-suggestion-section:last-child {
    margin-bottom: 0;
}
.sw-rail-suggestion-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sw-rail-text-soft);
    font-weight: 600;
    margin: 0 0 6px;
    padding: 0 4px;
}
.sw-rail-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sw-rail-suggestions button {
    text-align: left;
    background: var(--sw-rail-card);
    border: 1px solid var(--sw-rail-border-soft);
    color: var(--sw-rail-text);
    padding: 9px 12px;
    font-size: 13px;
    border-radius: 10px;
    cursor: pointer;
    line-height: 1.45;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.sw-rail-suggestions button:hover {
    background: #fbe5d3;
    border-color: var(--sw-rail-coral-soft);
}

/* Markdown-rendered content inside assistant bubbles */
.sw-rail-bubble p {
    margin: 0 0 8px;
}
.sw-rail-bubble p:last-child {
    margin: 0;
}
.sw-rail-bubble strong {
    font-weight: 600;
}
.sw-rail-bubble em {
    font-style: italic;
}
.sw-rail-bubble code {
    background: rgba(122, 81, 56, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
}
.sw-rail-bubble ul {
    margin: 4px 0 8px;
    padding-left: 20px;
}
.sw-rail-bubble ul:last-child {
    margin-bottom: 0;
}
.sw-rail-bubble li {
    margin: 2px 0;
}
.sw-rail-bubble a {
    color: inherit;
    text-decoration: underline;
}
.sw-rail-msg.is-user .sw-rail-bubble code {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.sw-rail-msg.is-user .sw-rail-bubble a {
    color: #fff;
}

.sw-rail-msg {
    display: flex;
}
.sw-rail-msg.is-user {
    justify-content: flex-end;
}
.sw-rail-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.sw-rail-msg.is-user .sw-rail-bubble {
    background: var(--sw-rail-coral);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sw-rail-msg.is-assistant .sw-rail-bubble {
    background: var(--sw-rail-bubble-bot);
    color: var(--sw-rail-text);
    border-bottom-left-radius: 4px;
}
.sw-rail-msg.is-error .sw-rail-bubble {
    background: #f5dfd1;
    color: #8a4a2c;
    border-bottom-left-radius: 4px;
}

/* Floating SailWP icon — replaces the typing dots while waiting on a
   reply. Brand-on-brand feedback that the co-pilot is thinking. */
.sw-rail-thinking-bubble {
    background: transparent !important;
    box-shadow: none;
    padding: 6px 4px !important;
}
.sw-rail-thinking {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    animation: sw-rail-thinking-drift 2.4s ease-in-out infinite;
}
.sw-rail-thinking .sw-rail-brand-img {
    width: 30px;
    height: 30px;
    display: block;
    object-fit: contain;
    opacity: 0.95;
    filter: drop-shadow(0 2px 3px rgba(122, 81, 56, 0.18));
}
@keyframes sw-rail-thinking-drift {
    0%   { transform: translateY(0)    rotate(-2deg); }
    50%  { transform: translateY(-6px) rotate(2deg);  }
    100% { transform: translateY(0)    rotate(-2deg); }
}

.sw-rail-composer {
    border-top: 1px solid var(--sw-rail-border);
    padding: 10px 12px 12px;
    background: var(--sw-rail-card);
    flex-shrink: 0;
}

/* Pending-attachment pills above the textarea */
.sw-rail-attachments {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

/* "View last preview" recovery chip — shown when the iframe overlay was
   closed (failed apply, accidental discard, page reload) and the stashed
   preview for the current page is still around. */
.sw-rail-preview-recovery[data-empty="true"] {
    display: none;
}
.sw-rail-preview-recovery {
    margin-bottom: 8px;
    display: flex;
}
.sw-rail-preview-recovery-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 8px;
    background: var(--sw-rail-card);
    border: 1px solid var(--sw-rail-border);
    border-radius: 999px;
    color: var(--sw-rail-text);
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.sw-rail-preview-recovery-chip:hover {
    background: var(--sw-rail-card-hover, var(--sw-rail-card));
    border-color: var(--sw-rail-coral, #e8845c);
}
.sw-rail-preview-recovery-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sw-rail-coral, #e8845c);
}
.sw-rail-preview-recovery-icon svg,
.sw-rail-preview-recovery-icon .sw-rail-brand-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}
.sw-rail-preview-recovery-label {
    font-weight: 500;
}
.sw-rail-preview-recovery-dismiss {
    margin-left: 4px;
    padding: 0 6px;
    font-size: 16px;
    line-height: 1;
    color: var(--sw-rail-text-soft);
    border-radius: 999px;
}
.sw-rail-preview-recovery-dismiss:hover {
    color: var(--sw-rail-text);
    background: var(--sw-rail-border);
}

/* Version timeline — a row of dots sitting between any attachments and
   the textarea. Each dot is one WP revision; the leftmost (filled coral)
   is the current state. Hover/focus surfaces a tiny age tooltip. */
.sw-rail-timeline[data-empty="true"] {
    display: none;
}
.sw-rail-timeline {
    margin-bottom: 8px;
}
.sw-rail-timeline-track {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px;
}
.sw-rail-timeline-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sw-rail-text-soft);
    font-weight: 600;
    flex-shrink: 0;
}
.sw-rail-timeline-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 4px 2px;
    /* Faint connector line behind the dots so the row reads as a timeline,
       not as scattered buttons. */
    background-image: linear-gradient(to right, var(--sw-rail-border) 0, var(--sw-rail-border) 100%);
    background-repeat: no-repeat;
    background-size: 100% 1px;
    background-position: left center;
}
.sw-rail-timeline-dots::-webkit-scrollbar { display: none; }
.sw-rail-timeline-dot {
    position: relative;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    appearance: none;
    border: 1.5px solid var(--sw-rail-coral-soft);
    background: var(--sw-rail-card);
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.sw-rail-timeline-dot:hover,
.sw-rail-timeline-dot:focus-visible {
    border-color: var(--sw-rail-coral);
    background: var(--sw-rail-coral-soft);
    transform: scale(1.25);
    outline: none;
}
.sw-rail-timeline-dot.is-current {
    background: var(--sw-rail-coral);
    border-color: var(--sw-rail-coral);
    cursor: default;
}
.sw-rail-timeline-dot.is-current:hover,
.sw-rail-timeline-dot.is-current:focus-visible {
    transform: scale(1.15);
}
/* "is-previewing": dot the user is currently viewing in the overlay
   (clicked but not yet restored). Distinct from is-current (= live). A
   ring around the dot signals "selected for preview" without claiming
   it's already live. */
.sw-rail-timeline-dot.is-previewing {
    background: var(--sw-rail-card);
    border-color: var(--sw-rail-coral);
    box-shadow: 0 0 0 3px rgba(232, 132, 92, 0.22);
    transform: scale(1.25);
}
.sw-rail-timeline[data-restoring="true"] .sw-rail-timeline-dots {
    opacity: 0.55;
    pointer-events: none;
    filter: saturate(0.6);
}
.sw-rail-timeline-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--sw-rail-text);
    color: var(--sw-rail-card);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
    z-index: 5;
}
.sw-rail-timeline-dot:hover .sw-rail-timeline-tooltip,
.sw-rail-timeline-dot:focus-visible .sw-rail-timeline-tooltip {
    opacity: 1;
}
.sw-rail-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background: var(--sw-rail-bg-soft);
    border: 1px solid var(--sw-rail-border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--sw-rail-text);
}
.sw-rail-attachment-icon {
    display: inline-flex;
    width: 14px;
    height: 14px;
    color: var(--sw-rail-coral-dark);
    flex-shrink: 0;
}
.sw-rail-attachment-icon svg { width: 14px; height: 14px; display: block; }
.sw-rail-attachment-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sw-rail-attachment-remove {
    background: transparent;
    border: none;
    color: var(--sw-rail-text-soft);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}
.sw-rail-attachment-remove:hover {
    color: var(--sw-rail-coral-dark);
}

/* Composer shell — looks like a textarea but holds buttons inside */
.sw-rail-composer-shell {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--sw-rail-border);
    border-radius: 14px;
    background: var(--sw-rail-card);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sw-rail-composer-shell:focus-within {
    border-color: var(--sw-rail-coral-soft);
    box-shadow: 0 0 0 3px rgba(232, 132, 92, 0.10);
}
.sw-rail-composer-shell textarea {
    width: 100%;
    min-height: 64px;
    max-height: 200px;
    resize: none;
    padding: 12px 14px 4px;
    border: none;
    background: transparent;
    color: var(--sw-rail-text);
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
    outline: none;
}
.sw-rail-composer-shell textarea::placeholder {
    color: var(--sw-rail-text-soft);
}
.sw-rail-composer-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 8px;
}
.sw-rail-composer-spacer { flex: 1; }

/* Composer-bar buttons. Attach + idle-mic are bare-icon (no tile); send and
   listening-mic are filled coral as meaningful active/primary states. */
.sw-rail-attach,
.sw-rail-mic,
.sw-rail-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    padding: 8px;
    transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.sw-rail-attach,
.sw-rail-mic {
    background: transparent;
    color: var(--sw-rail-text-soft);
}
.sw-rail-attach svg,
.sw-rail-mic svg,
.sw-rail-send svg {
    width: 18px;
    height: 18px;
    display: block;
}
.sw-rail-attach:hover,
.sw-rail-mic:hover {
    color: var(--sw-rail-coral-dark);
}

.sw-rail-mic.is-listening {
    background: var(--sw-rail-coral);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    padding: 0;
    animation: sw-rail-mic-pulse 1.6s ease-in-out infinite;
}
.sw-rail-mic.is-listening:hover {
    background: var(--sw-rail-coral-dark);
}
@keyframes sw-rail-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 132, 92, 0.45); }
    50%      { box-shadow: 0 0 0 8px rgba(232, 132, 92, 0.00); }
}

.sw-rail-send {
    background: var(--sw-rail-coral);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    padding: 0;
}
.sw-rail-send:hover:not(:disabled) {
    background: var(--sw-rail-coral-dark);
    transform: translateX(1px);
}
.sw-rail-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Attachment indicators inside user-bubbles (after send) */
.sw-rail-bubble-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}
.sw-rail-bubble-attachment {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.30);
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.4;
}

/* === Mobile / phone — bottom-sheet panel, larger tap targets, sticky composer === */
@media screen and (max-width: 720px) {
    .sw-rail {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;                    /* span full viewport so the bottom-sheet has width to fill */
        z-index: 100000;            /* above WP admin bar (99999) */
    }
    .sw-rail-panel {
        top: auto;                  /* anchored to bottom only */
        right: 0;
        bottom: 0;
        left: 0;
        height: 75vh;
        max-height: 92dvh;          /* dynamic viewport height for iOS Safari */
        width: auto;
        max-width: none;
        border-radius: 16px 16px 0 0;
        border: none;
        border-top: 1px solid var(--sw-rail-border);
        box-shadow: 0 -10px 36px rgba(122, 81, 56, 0.20);
        animation: sw-rail-sheet-up 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
        -webkit-overflow-scrolling: touch;
    }
    /* Drag-handle visual at top of the sheet (decorative for now) */
    .sw-rail-panel::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        border-radius: 2px;
        background: var(--sw-rail-border);
    }
    .sw-rail-header { padding: 22px 16px 12px; }   /* room for drag handle */
    @keyframes sw-rail-sheet-up {
        from { transform: translateY(20px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    .sw-rail-toggle {
        right: 18px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0));
        width: 60px;
        height: 60px;
        z-index: 100001;
    }
    .sw-rail-toggle .sw-rail-brand-img {
        width: 38px;
        height: 38px;
    }

    /* Header — bigger tap targets on phone */
    .sw-rail-header { padding: 14px 16px; }
    .sw-rail-actions button {
        width: 40px;
        height: 40px;
        padding: 8px;
    }

    /* Messages — fluid height + extra bottom-padding so the composer
       (sticky-bottom) does not cover the latest message. */
    .sw-rail-messages {
        padding: 16px 14px 20px;
    }

    /* Composer — sticky bottom with safe-area + room for keyboard. */
    .sw-rail-composer {
        padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0));
    }
    .sw-rail-composer-shell textarea {
        font-size: 16px;            /* prevents iOS Safari auto-zoom on focus */
        line-height: 1.45;
        min-height: 56px;
        max-height: 35vh;           /* never let textarea eat the screen */
        padding: 14px 14px 4px;
    }

    /* Action chips — 44×44 minimum tap targets */
    .sw-rail-chip { padding: 14px 16px; }
    .sw-rail-chip-confirm,
    .sw-rail-chip-cancel {
        min-height: 44px;
        padding: 11px 18px;
        font-size: 14px;
    }
    .sw-rail-chip-actions { gap: 10px; }

    /* In-shell composer-bar buttons (paperclip / mic / send) — 44×44 */
    .sw-rail-attach,
    .sw-rail-mic,
    .sw-rail-send {
        padding: 11px;
    }
    .sw-rail-mic.is-listening,
    .sw-rail-send {
        width: 44px;
        height: 44px;
    }
    .sw-rail-attach svg,
    .sw-rail-mic svg,
    .sw-rail-send svg {
        width: 20px;
        height: 20px;
    }

    /* Suggestion chips — easier to tap */
    .sw-rail-suggestions button {
        padding: 12px 14px;
        font-size: 14px;
        line-height: 1.4;
    }

    /* Empty-state heading — slightly bigger on phone */
    .sw-rail-empty h3 { font-size: 17px; }
    .sw-rail-empty p  { font-size: 14px; line-height: 1.45; }

    /* Hide the welcome banner on small admin screens — it eats the
       limited admin space; rail itself is invitation enough. */
    .swcp-welcome { display: none !important; }
}

/* === Mobile preview overlay — full-screen, banner sticky, rail goes away === */
@media screen and (max-width: 720px) {
    #swcp-preview-overlay,
    #swcp-version-preview-overlay {
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 99999;             /* above the rail on phone */
        /* iOS Safari: enable touch-momentum scroll inside the iframe */
        -webkit-overflow-scrolling: touch;
    }
    .swcp-preview-iframe {
        /* iOS quirk: explicit height (not flex) + touch behaviour
           lets the iframe handle its own native scroll. */
        flex: 1 1 auto;
        height: 100%;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
    body.admin-bar #swcp-preview-overlay,
    body.admin-bar #swcp-version-preview-overlay { top: 46px; }
    /* On phone the floating pill shrinks to icons-only style would be a
       bigger refactor; for now keep it readable and hide the title text. */
    .swcp-preview-banner {
        top: 10px;
        right: 12px;
        padding: 6px 6px 6px 12px;
        gap: 8px;
    }
    .swcp-preview-banner-title {
        display: none;
    }
    .swcp-preview-btn-discard,
    .swcp-preview-btn-apply {
        min-height: 36px;
        padding: 7px 12px;
        font-size: 13px;
    }
}

/* WP admin bar shows in admin AND on front-end logged-in. Body classes already adjust top. */
body.admin-bar.has-sailwp-copilot-rail .sw-rail { top: 32px; }
@media screen and (max-width: 782px) {
    body.admin-bar.has-sailwp-copilot-rail .sw-rail { top: 46px; }
}

/* === Preview overlay (live design preview, opens on the left of the rail) === */
#swcp-preview-overlay,
#swcp-version-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: calc(var(--sw-rail-width) + 24px);
    bottom: 0;
    background:
        radial-gradient(900px circle at 18% -5%,  rgba(232, 132, 92, 0.18), transparent 55%),
        radial-gradient(1100px circle at 110% 110%, rgba(232, 184, 122, 0.14), transparent 55%),
        var(--sw-rail-bg);
    z-index: 99997;     /* below the rail and the WP admin bar */
    display: flex;
    flex-direction: column;
    box-shadow: -1px 0 24px rgba(122, 81, 56, 0.10);
    animation: swcp-preview-slide 0.42s cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* WP admin bar is fixed at top; push overlay below it so the banner is visible. */
body.admin-bar #swcp-preview-overlay,
body.admin-bar #swcp-version-preview-overlay { top: 32px; }
@media screen and (max-width: 782px) {
    body.admin-bar #swcp-preview-overlay,
    body.admin-bar #swcp-version-preview-overlay { top: 46px; }
}
/* Subtle ambient breath so the glow feels alive */
#swcp-preview-overlay::before,
#swcp-version-preview-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(600px circle at 30% 20%, rgba(232, 132, 92, 0.06), transparent 60%);
    animation: swcp-preview-breath 8s ease-in-out infinite alternate;
}
@keyframes swcp-preview-breath {
    from { opacity: 0.55; transform: translate(0, 0); }
    to   { opacity: 1;    transform: translate(8px, -6px); }
}
@keyframes swcp-preview-slide {
    from { transform: translateX(-30px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}
/* Floating action shelf — sits in the top-right of the preview overlay so
   the iframe takes the full height. No solid bar across the top, no white
   strip cutting across the admin bar / preview boundary. */
.swcp-preview-banner {
    position: absolute;
    top: 14px;
    right: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2;
    background: rgba(26, 26, 46, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 8px 8px 16px;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(26, 26, 46, 0.22);
    pointer-events: auto;
}
.swcp-preview-banner-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.swcp-preview-banner-actions {
    display: flex;
    gap: 8px;
}
.swcp-preview-btn-discard,
.swcp-preview-btn-apply {
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}
.swcp-preview-btn-discard {
    background: transparent !important;
    color: rgba(255, 255, 255, 0.78) !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
}
.swcp-preview-btn-discard:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
}
.swcp-preview-btn-apply {
    background: var(--sw-rail-coral) !important;
    color: #fff !important;
}
.swcp-preview-btn-apply:hover {
    background: var(--sw-rail-coral-dark) !important;
}
.swcp-preview-btn-apply:disabled,
.swcp-preview-btn-discard:disabled {
    opacity: 0.6;
    cursor: progress;
}
/* In-place success state — banner pivots from "preview" to "live saved"
   without navigating, so the user keeps looking at their design instead of
   getting bounced through a white intermediate page. */
.swcp-preview-banner.is-success {
    background: rgba(34, 89, 60, 0.86) !important;
}
.swcp-preview-banner.is-success .swcp-preview-banner-title {
    color: #d4ffe0 !important;
}
.swcp-preview-btn-open,
.swcp-preview-btn-close {
    display: inline-flex;
    align-items: center;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.swcp-preview-btn-open {
    background: rgba(255, 255, 255, 0.92) !important;
    color: #22593c !important;
}
.swcp-preview-btn-open:hover {
    background: #fff !important;
}
.swcp-preview-btn-close {
    background: transparent !important;
    color: rgba(255, 255, 255, 0.78) !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
}
.swcp-preview-btn-close:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}
.swcp-preview-banner-error {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 12.5px;
    border-radius: 8px;
    max-width: 320px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    white-space: normal;
}
.swcp-preview-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
    /* iOS Safari iframe scroll-fix: explicit height + touch behaviour */
    -webkit-overflow-scrolling: touch;
}

/* When the preview is open, prevent the page underneath from scrolling. */
html.swcp-preview-open {
    overflow: hidden;
}
/* Same lock when the bottom-sheet rail is open on phone. */
@media screen and (max-width: 720px) {
    html.swcp-rail-open { overflow: hidden; }
}

@media screen and (max-width: 900px) {
    #swcp-preview-overlay,
    #swcp-version-preview-overlay {
        right: 0;
        bottom: 50vh;
    }
}

/* === Action chips: tool_use blocks rendered as confirm/cancel cards === */
.sw-rail-chip {
    margin: 8px 0 12px;
    padding: 14px 16px;
    background: var(--sw-rail-card);
    border: 1px solid var(--sw-rail-coral-soft);
    border-radius: 12px;
    box-shadow: var(--sw-rail-shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sw-rail-chip[data-status="cancelled"],
.sw-rail-chip[data-status="error"] {
    border-color: var(--sw-rail-border-soft);
    box-shadow: none;
    opacity: 0.85;
}
.sw-rail-chip[data-status="done"] {
    border-color: var(--sw-rail-sage);
    box-shadow: 0 2px 8px rgba(155, 176, 116, 0.12);
}
.sw-rail-chip-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--sw-rail-text);
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.sw-rail-chip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}
.sw-rail-chip-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--sw-rail-bg-soft);
    border-radius: 999px;
    font-size: 12px;
    color: var(--sw-rail-text);
    line-height: 1.4;
}
.sw-rail-chip-subnote {
    font-size: 12px;
    color: var(--sw-rail-text-soft);
    line-height: 1.4;
    margin-top: 2px;
}
.sw-rail-chip-actions {
    display: flex;
    gap: 8px;
}
.sw-rail-chip-confirm,
.sw-rail-chip-cancel {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.12s ease, color 0.12s ease;
}
.sw-rail-chip-confirm {
    background: var(--sw-rail-coral);
    color: #fff;
    border-color: var(--sw-rail-coral);
}
.sw-rail-chip-confirm:hover {
    background: var(--sw-rail-coral-dark);
    border-color: var(--sw-rail-coral-dark);
}
.sw-rail-chip-cancel {
    background: transparent;
    color: var(--sw-rail-text-soft);
    border-color: var(--sw-rail-border);
}
.sw-rail-chip-cancel:hover {
    background: var(--sw-rail-bg-soft);
    color: var(--sw-rail-text);
    border-color: var(--sw-rail-border);
}
.sw-rail-chip-status {
    font-size: 13px;
    color: var(--sw-rail-text-soft);
    line-height: 1.4;
}
.sw-rail-chip-status-running {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--sw-rail-coral-dark);
    font-weight: 500;
}
.sw-rail-chip-thinking {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    animation: sw-rail-thinking-drift 2.4s ease-in-out infinite;
}
.sw-rail-chip-thinking .sw-rail-brand-img {
    width: 16px;
    height: 16px;
    display: block;
    object-fit: contain;
}
.sw-rail-chip-status.is-done {
    color: #5e7a3f;
}
.sw-rail-chip-status.is-error {
    color: #a85a3a;
}
.sw-rail-chip-status.is-cancelled {
    font-style: italic;
}
.sw-rail-chip-status a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-left: 8px;
}

/* tool-result pills are no longer rendered; the action chip's done/error
   state already communicates the outcome. The selectors below stay as a
   guard in case someone re-enables the rendering. */
.sw-rail-tool-result {
    display: none;
}
.sw-rail-tool-result.is-error {
    color: #a85a3a;
    background: #fbe5d3;
}

/* === Pick mode (cross-hair button on the composer) === */
.sw-rail .sw-rail-pick {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 6px;
    border-radius: 8px;
    color: #6b6e74;
    cursor: pointer;
    line-height: 0;
    transition: color 120ms, background 120ms;
}
.sw-rail .sw-rail-pick:hover,
.sw-rail .sw-rail-pick.is-active {
    color: #e8845c;
    background: rgba(232, 132, 92, 0.08);
}

/* While picking, fade everything slightly + show crosshair cursor on the
   page so the user understands they're in pick mode. */
html.sw-rail-pick-active,
html.sw-rail-pick-active body {
    cursor: crosshair !important;
}
html.sw-rail-pick-active *:not(.sw-rail-root *):not(.sw-rail-pick-hud *) {
    cursor: crosshair !important;
}

/* Outline the element under the cursor so the user can confirm what
   they'll grab. We use outline rather than border so layout doesn't shift. */
.sw-rail-pick-hover {
    outline: 3px solid #e8845c !important;
    outline-offset: 2px !important;
    background-color: rgba(232, 132, 92, 0.06) !important;
    transition: outline-color 80ms;
}

/* Click-flash: 400ms soft pulse around the just-clicked element so the
   user SEES the click landed. Joost 2026-05-17: "klik gebeurt niks" was
   really "click had no visual feedback so I assumed it failed". */
.sw-rail-pick-flash {
    animation: sw-rail-pick-flash 480ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
@keyframes sw-rail-pick-flash {
    0%   { box-shadow: 0 0 0 0   rgba(232, 132, 92, 0.55); }
    60%  { box-shadow: 0 0 0 14px rgba(232, 132, 92, 0);   }
    100% { box-shadow: 0 0 0 0   rgba(232, 132, 92, 0);    }
}

/* Floating HUD at the top of the page during pick mode */
.sw-rail-pick-hud {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
    background: #1a1a2e;
    color: #fff;
    padding: 10px 14px 10px 18px;
    border-radius: 999px;
    font: 500 14px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 6px 30px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sw-rail-pick-hud .sw-rail-pick-cancel {
    appearance: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 0;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    font: 500 13px/1 -apple-system, sans-serif;
}
.sw-rail-pick-hud .sw-rail-pick-cancel:hover {
    background: rgba(255,255,255,0.20);
}

/* Picked-element chip in the composer attachments area */
.sw-rail .sw-rail-picked {
    border-color: #e8845c;
    background: rgba(232, 132, 92, 0.08);
}

/* Quick-colour swatch row that appears under the chip when the pick is
   a background-bearing element. One click = chat turn that changes the
   bg colour. The "+" custom-swatch opens a native colour picker. */
.sw-rail-pick-swatches {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--sw-rail-card);
    border: 1px solid var(--sw-rail-border-soft);
    border-radius: 10px;
}
.sw-rail-pick-swatches-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--sw-rail-text-soft);
    margin-right: 4px;
    letter-spacing: 0.02em;
}
.sw-rail-pick-swatch {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(26, 26, 46, 0.18);
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease;
}
.sw-rail-pick-swatch:hover,
.sw-rail-pick-swatch:focus-visible {
    transform: scale(1.18);
    box-shadow: 0 0 0 2px rgba(232, 132, 92, 0.32);
    outline: none;
}
.sw-rail-pick-swatch-custom {
    background: var(--sw-rail-card);
    color: var(--sw-rail-text-soft);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sw-rail .sw-rail-picked .sw-rail-attachment-label::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e8845c;
    margin-right: 6px;
    vertical-align: middle;
}

/* =========================================================================
   In-chat upgrade card + Stripe Embedded Checkout modal
   ========================================================================= */
/* Premium coral-gradient pricing card. Stacked rows so even the longest
   line ("€190/year — 2 months free") fits inside the rail's narrow column
   without breaking. Glassmorphic buttons read as one designed surface,
   not a kit-of-parts; matches sailwp.com's hero treatment so the same
   visual vocabulary carries through from website → install → upgrade.
   The €19 conversion sits on this card — every pixel earns its place. */
.sw-rail-upgrade-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #c4592a 0%, #e8845c 52%, #f4a382 100%);
    border: none;
    border-radius: 14px;
    padding: 18px 16px 14px;
    margin-top: 2px;
    color: #fff;
    box-shadow: 0 10px 28px rgba(196, 89, 42, 0.26), 0 2px 6px rgba(0, 0, 0, 0.08);
}
/* Soft highlight bloom at the top-right — gives the gradient depth so
   the card reads as a designed surface, not a flat fill. */
.sw-rail-upgrade-card::before {
    content: "";
    position: absolute;
    top: -55%;
    right: -25%;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, rgba(255, 240, 220, 0.32) 0%, transparent 65%);
    pointer-events: none;
}
.sw-rail-upgrade-title {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.92);
}
.sw-rail-upgrade-title::before {
    content: "✦";
    font-size: 12px;
    opacity: 0.9;
}
.sw-rail-upgrade-msg {
    position: relative;
    color: rgba(255, 255, 255, 0.94);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 14px;
}
.sw-rail-upgrade-msg p { margin: 0 0 6px; }
.sw-rail-upgrade-msg p:last-child { margin-bottom: 0; }

.sw-rail-upgrade-plans {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sw-rail-upgrade-plan {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.16);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    color: #fff;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.08s ease, box-shadow 0.18s ease;
    font: inherit;
}
.sw-rail-upgrade-plan:hover {
    background: rgba(255, 255, 255, 0.26);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
.sw-rail-upgrade-plan:active { transform: translateY(0); }
.sw-rail-upgrade-plan-row {
    display: flex;
    align-items: baseline;
    gap: 1px;
}
/* "Monthly" / "Yearly" labels are redundant once the price line shows
   "€19/month" or "€190/year". Hiding them frees up the row width so the
   "2 months free" pill never crowds out the price. */
.sw-rail-upgrade-plan-label {
    display: none;
}
.sw-rail-upgrade-plan-price {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.015em;
    color: #fff;
}
.sw-rail-upgrade-plan-period {
    margin-left: 1px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}
.sw-rail-upgrade-plan-note {
    align-self: center;
    flex-shrink: 0;
    background: #fff;
    color: #c4592a;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.sw-rail-upgrade-footnote {
    position: relative;
    margin-top: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.78);
    text-align: center;
    letter-spacing: 0.01em;
}

/* Modal overlay — sits above WP admin and the rail. */
.sw-rail-upgrade-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 30, 0.55);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: sw-rail-upgrade-fade-in 0.2s ease;
}
@keyframes sw-rail-upgrade-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.sw-rail-upgrade-modal {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.28);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: sw-rail-upgrade-pop 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sw-rail-upgrade-pop {
    from { transform: scale(0.96) translateY(8px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}
.sw-rail-upgrade-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 0;
    background: rgba(0,0,0,0.04);
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: #1a1a1a;
    cursor: pointer;
    z-index: 1;
    transition: background 0.15s ease;
}
.sw-rail-upgrade-close:hover { background: rgba(0,0,0,0.08); }
.sw-rail-upgrade-header {
    padding: 24px 24px 12px;
    text-align: center;
}
.sw-rail-upgrade-header h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}
.sw-rail-upgrade-header p {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}
.sw-rail-upgrade-checkout {
    flex: 1;
    overflow-y: auto;
    padding: 4px 4px 12px;
    min-height: 380px;
}
.sw-rail-upgrade-loading,
.sw-rail-upgrade-error {
    padding: 40px 24px;
    text-align: center;
    font-size: 14px;
    color: #6b7280;
}
.sw-rail-upgrade-error {
    color: #b91c1c;
}

/* ---- Design progress bar (sailboat) ---- */
.swcp-design-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2147483646;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid rgba(26, 26, 46, 0.12);
    padding: 10px 18px 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.28s ease, opacity 0.28s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
}
.swcp-design-progress.is-visible {
    transform: translateY(0);
    opacity: 1;
}
.swcp-design-progress.is-hidden {
    transform: translateY(-100%);
    opacity: 0;
}
.swcp-design-progress-label {
    font-size: 12.5px;
    color: #1a1a2e;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 6px;
}
.swcp-design-progress-track {
    position: relative;
    height: 4px;
    background: rgba(26, 26, 46, 0.08);
    border-radius: 999px;
    overflow: visible;
}
.swcp-design-progress-fill {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #3884ff 0%, #e8845c 100%);
    border-radius: 999px;
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.6s ease-out;
}
.swcp-design-progress-boat {
    position: absolute;
    left: 0;
    top: 50%;
    width: 28px;
    height: 22px;
    transform: translate(-50%, -50%);
    transition: left 0.6s ease-out;
    animation: swcp-boat-bob 1.4s ease-in-out infinite;
}
.swcp-design-progress.is-done .swcp-design-progress-boat {
    animation: none;
}
@keyframes swcp-boat-bob {
    0%, 100% { transform: translate(-50%, -50%) rotate(-2deg); }
    50%      { transform: translate(-50%, -60%) rotate(2deg);  }
}

/* ---- Suggestion click feedback ---- */
.sw-rail-suggestion.is-busy {
    background: rgba(56, 132, 255, 0.12) !important;
    color: rgba(26, 26, 46, 0.7) !important;
    transform: scale(0.97);
    transition: transform 0.12s ease;
}
.sw-rail-suggestion:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ---- Chat history dropdown (v0.22.0) ---- */
.sw-rail-history.is-open {
    background: rgba(56, 132, 255, 0.12);
    color: #1d4ed8;
}
.sw-rail-history-panel {
    position: absolute;
    top: 100%;
    right: 14px;
    margin-top: 6px;
    width: 320px;
    max-width: calc(100vw - 30px);
    max-height: 60vh;
    overflow: auto;
    background: #ffffff;
    border: 1px solid rgba(26, 26, 46, 0.10);
    border-radius: 12px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.16);
    z-index: 5;
    padding: 8px 0;
}
.sw-rail-history-title {
    padding: 6px 14px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(26, 26, 46, 0.55);
}
.sw-rail-history-empty {
    padding: 16px 14px;
    font-size: 13px;
    color: rgba(26, 26, 46, 0.55);
    line-height: 1.45;
}
.sw-rail-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sw-rail-history-item {
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 0 6px;
}
.sw-rail-history-item:hover {
    background: rgba(56, 132, 255, 0.06);
}
.sw-rail-history-item.is-current {
    background: rgba(56, 132, 255, 0.10);
}
.sw-rail-history-open {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 9px 10px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
}
.sw-rail-history-item-title {
    font-size: 13.5px;
    font-weight: 500;
    color: #1a1a2e;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
}
.sw-rail-history-item-meta {
    font-size: 11px;
    color: rgba(26, 26, 46, 0.55);
}
.sw-rail-history-del {
    width: 28px;
    background: transparent;
    border: 0;
    color: rgba(26, 26, 46, 0.5);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    border-radius: 6px;
    margin: 6px 0;
    transition: background 0.12s ease, color 0.12s ease;
}
.sw-rail-history-del:hover {
    background: rgba(212, 69, 58, 0.12);
    color: #b03a30;
}

/* Heavy-action quota counter — subtle strip under the composer.
   Free only (heavy_limit !== null); Pro/Founder hide. v0.25.x */
.sw-rail-quota {
    padding: 7px 14px 9px;
    border-top: 1px solid rgba(26, 26, 46, 0.08);
    font-size: 11.5px;
    line-height: 1.4;
    color: rgba(26, 26, 46, 0.55);
    background: rgba(248, 244, 236, 0.65);
    text-align: center;
}
.sw-rail-quota[hidden] { display: none !important; }
.sw-rail-quota-text { white-space: nowrap; }
.sw-rail-quota a {
    color: #c4593a;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(196, 89, 58, 0.45);
    font-weight: 500;
}
.sw-rail-quota a:hover,
.sw-rail-quota a:focus {
    color: #a04528;
    text-decoration-color: rgba(196, 89, 58, 0.85);
}
