:root {
    --ielts-petra-rail-compact-width: 52px;
    --ielts-petra-rail-width: 320px;
}

.ielts-qmain,
.ielts-flow-runner {
    transition: margin-right 0.24s ease;
}

.ielts-writing-result-page,
[data-ielts-petra-result-host] {
    transition: transform 0.24s ease, width 0.24s ease;
}

.ielts-nav-header .ielts-nav-container {
    transition: padding-right 0.24s ease;
}

.ielts-qmain.ielts-petra-rail-host-docked,
.ielts-flow-runner.ielts-petra-rail-host-docked {
    margin-right: var(
        --ielts-petra-current-rail-width,
        var(--ielts-petra-rail-width)
    );
}

.ielts-writing-result-page.ielts-petra-rail-host-docked,
[data-ielts-petra-result-host].ielts-petra-rail-host-docked {
    margin-left: auto;
    margin-right: auto;
    transform: translateX(
        var(--ielts-petra-current-rail-shift, -160px)
    );
    width: calc(
        100%
        - var(--ielts-petra-current-rail-width, var(--ielts-petra-rail-width))
        - 1rem
    );
}

@media (min-width: 1180px) {
    .ielts-nav-header.ielts-petra-rail-nav-docked .ielts-nav-container {
        padding-right: calc(
            var(--ielts-petra-current-rail-width, var(--ielts-petra-rail-width))
            + 1.5rem
        );
    }

    html.ielts-petra-standalone-scroll-viewport,
    html.ielts-petra-standalone-scroll-viewport body {
        height: 100%;
        overflow: hidden;
    }

    html.ielts-petra-standalone-scroll-viewport body > main {
        flex: 1 1 auto;
        margin-right: var(
            --ielts-petra-current-rail-width,
            var(--ielts-petra-rail-compact-width)
        );
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        scrollbar-gutter: stable;
        transition: margin-right 0.24s ease;
    }

    html.ielts-petra-standalone-scroll-viewport
        .ielts-writing-result-page.ielts-petra-rail-host-docked,
    html.ielts-petra-standalone-scroll-viewport
        [data-ielts-petra-result-host].ielts-petra-rail-host-docked {
        transform: none;
    }
}

.bottom-activity-bar.ielts-petra-rail {
    background: linear-gradient(
        180deg,
        var(--ielts-bg-white, #FFFFFF) 0%,
        var(--ielts-bg, #F7F4EF) 100%
    );
    border: 0;
    border-left: 1px solid var(--ielts-border, #E8E3DA);
    border-radius: 0;
    bottom: 0;
    box-shadow: -8px 0 28px rgba(26, 24, 22, 0.1);
    display: flex;
    flex-direction: column;
    font-family: 'Poppins', sans-serif;
    height: 100dvh;
    left: auto;
    max-height: none;
    overflow: hidden;
    position: fixed;
    right: 0;
    top: 0;
    transform: translateX(0);
    transition:
        width 0.24s ease,
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--ielts-petra-rail-width);
    z-index: 1004;
}

.bottom-activity-bar.ielts-petra-rail[aria-hidden="true"] {
    display: none !important;
}

.bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-header {
    align-items: center;
    display: flex;
    position: relative;
}

.bottom-activity-bar.ielts-petra-rail .petra-header-title {
    align-items: center;
    color: var(--ielts-primary, #5C6F5C);
    display: flex;
    font-size: 13px;
    font-weight: 600;
    gap: 8px;
    min-width: 0;
    padding: 0 14px;
}

.bottom-activity-bar.ielts-petra-rail .petra-title-text {
    font-family: 'Poppins', sans-serif;
    white-space: nowrap;
}

.bottom-activity-bar.ielts-petra-rail .header-right {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-left: auto;
    padding-right: 8px;
}

.bottom-activity-bar.ielts-petra-rail .activity-bar-action-btn,
.bottom-activity-bar.ielts-petra-rail .history-back-btn {
    align-items: center;
    background: var(--ielts-bg-white, #FFFFFF);
    border: 1px solid var(--ielts-border, #E8E3DA);
    border-radius: 6px;
    color: var(--ielts-text-muted, #9B9489);
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
}

.bottom-activity-bar.ielts-petra-rail .activity-bar-action-btn {
    height: 28px;
    width: 28px;
}

.bottom-activity-bar.ielts-petra-rail .activity-bar-action-btn:hover,
.bottom-activity-bar.ielts-petra-rail .history-back-btn:hover {
    background: var(--ielts-primary-light, rgba(92, 111, 92, 0.08));
    border-color: var(--ielts-primary, #5C6F5C);
    color: var(--ielts-primary, #5C6F5C);
}

.bottom-activity-bar.ielts-petra-rail .usage-badge {
    align-items: center;
    background: rgba(92, 111, 92, 0.12);
    border-radius: 999px;
    color: var(--ielts-primary, #5C6F5C);
    display: inline-flex;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
}

.bottom-activity-bar.ielts-petra-rail .petra-chat-view.hidden,
.bottom-activity-bar.ielts-petra-rail .petra-history-view.hidden {
    display: none !important;
}

.bottom-activity-bar.ielts-petra-rail .petra-chat-container,
.bottom-activity-bar.ielts-petra-rail .petra-history-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    width: 100%;
}

.bottom-activity-bar.ielts-petra-rail .petra-messages,
.bottom-activity-bar.ielts-petra-rail .petra-sessions-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.bottom-activity-bar.ielts-petra-rail .petra-empty-state,
.bottom-activity-bar.ielts-petra-rail .petra-loading,
.bottom-activity-bar.ielts-petra-rail .petra-error,
.bottom-activity-bar.ielts-petra-rail .petra-loading-state,
.bottom-activity-bar.ielts-petra-rail .petra-empty-history,
.bottom-activity-bar.ielts-petra-rail .petra-error-history {
    align-items: center;
    color: var(--ielts-text-muted, #9B9489);
    display: flex;
    font-size: 12px;
    height: 100%;
    justify-content: center;
    text-align: center;
}

.bottom-activity-bar.ielts-petra-rail .petra-empty-state,
.bottom-activity-bar.ielts-petra-rail .petra-loading,
.bottom-activity-bar.ielts-petra-rail .petra-error {
    flex-direction: column;
}

.bottom-activity-bar.ielts-petra-rail .petra-empty-state .empty-icon {
    color: var(--ielts-primary, #5C6F5C);
    margin-bottom: 12px;
    opacity: 0.5;
}

.bottom-activity-bar.ielts-petra-rail .petra-empty-state .empty-text {
    font-weight: 500;
    margin-bottom: 4px;
}

.bottom-activity-bar.ielts-petra-rail .petra-empty-state .empty-hint {
    font-size: 11px;
}

.bottom-activity-bar.ielts-petra-rail .petra-message {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    max-width: 92%;
}

.bottom-activity-bar.ielts-petra-rail .petra-message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.bottom-activity-bar.ielts-petra-rail .petra-message.system {
    justify-content: center;
    max-width: 100%;
}

.bottom-activity-bar.ielts-petra-rail .petra-avatar {
    align-items: center;
    background: linear-gradient(
        135deg,
        var(--ielts-primary, #5C6F5C),
        var(--ielts-primary-dark, #4A5A4A)
    );
    border-radius: 50%;
    color: #FFFFFF;
    display: inline-flex;
    flex: 0 0 22px;
    height: 22px;
    justify-content: center;
    width: 22px;
}

.bottom-activity-bar.ielts-petra-rail .message-bubble {
    border-radius: 11px;
    font-size: 12px;
    line-height: 1.45;
    padding: 9px 11px;
}

.bottom-activity-bar.ielts-petra-rail .petra-message.petra .message-bubble {
    background: rgba(92, 111, 92, 0.12);
    border-bottom-left-radius: 4px;
    color: var(--ielts-text, #3A3633);
}

.bottom-activity-bar.ielts-petra-rail .petra-message.user .message-bubble {
    background: var(--ielts-primary, #5C6F5C);
    border-bottom-right-radius: 4px;
    color: #FFFFFF;
}

.bottom-activity-bar.ielts-petra-rail .petra-message.system .message-bubble {
    background: rgba(220, 38, 38, 0.1);
    color: #DC2626;
}

.bottom-activity-bar.ielts-petra-rail #petra-chat-input {
    background: var(--ielts-bg-white, #FFFFFF);
    border: 1px solid var(--ielts-border, #E8E3DA);
    border-radius: 8px;
    color: var(--ielts-text, #1A1816);
    flex: 1;
    font: inherit;
    min-height: 38px;
    padding: 9px 10px;
    resize: none;
}

.bottom-activity-bar.ielts-petra-rail #petra-chat-input:focus {
    border-color: var(--ielts-primary, #5C6F5C);
    outline: none;
}

.bottom-activity-bar.ielts-petra-rail .petra-send-btn {
    align-items: center;
    background: var(--ielts-primary, #5C6F5C);
    border: 0;
    border-radius: 8px;
    color: #FFFFFF;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 38px;
    height: 38px;
    justify-content: center;
}

.bottom-activity-bar.ielts-petra-rail .petra-send-btn:hover:not(:disabled) {
    background: var(--ielts-primary-dark, #4A5A4A);
}

.bottom-activity-bar.ielts-petra-rail .petra-send-btn:disabled {
    background: #D7D1C8;
    color: #928A7F;
    cursor: not-allowed;
}

.bottom-activity-bar.ielts-petra-rail .petra-history-header {
    align-items: center;
    border-bottom: 1px solid var(--ielts-border, #E8E3DA);
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
}

.bottom-activity-bar.ielts-petra-rail .history-back-btn {
    gap: 4px;
    padding: 4px 8px;
}

.bottom-activity-bar.ielts-petra-rail .history-title,
.bottom-activity-bar.ielts-petra-rail .session-name {
    color: var(--ielts-text, #1A1816);
    font-size: 12px;
    font-weight: 600;
}

.bottom-activity-bar.ielts-petra-rail .petra-sessions-list {
    padding: 10px;
}

.bottom-activity-bar.ielts-petra-rail .petra-session-card {
    background: var(--ielts-bg-white, #FFFFFF);
    border: 1px solid var(--ielts-border, #E8E3DA);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    padding: 10px;
}

.bottom-activity-bar.ielts-petra-rail .petra-session-card:hover {
    background: var(--ielts-primary-light, rgba(92, 111, 92, 0.06));
    border-color: var(--ielts-primary, #5C6F5C);
}

.bottom-activity-bar.ielts-petra-rail .session-meta {
    align-items: center;
    color: var(--ielts-text-muted, #9B9489);
    display: flex;
    font-size: 11px;
    gap: 6px;
}

.bottom-activity-bar.ielts-petra-rail .section-badge {
    background: rgba(92, 111, 92, 0.1);
    border-radius: 999px;
    color: var(--ielts-primary, #5C6F5C);
    padding: 1px 6px;
    text-transform: capitalize;
}

.bottom-activity-bar.ielts-petra-rail .session-date {
    color: var(--ielts-text-muted, #9B9489);
    font-size: 10px;
    margin-top: 5px;
}

.bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal {
    background: var(--ielts-bg-white, #FFFFFF);
    border: 1px solid var(--ielts-border, #E8E3DA);
    border-radius: 10px;
    margin: 12px;
    padding: 20px 14px;
    text-align: center;
}

.bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-title {
    color: var(--ielts-text, #1A1816);
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px;
}

.bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-text,
.bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-hint {
    color: var(--ielts-text-secondary, #6B6157);
    font-size: 13px;
    margin: 0 0 14px;
}

.bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-btn {
    align-items: center;
    background: linear-gradient(
        135deg,
        var(--ielts-primary, #5C6F5C),
        var(--ielts-primary-dark, #4A5A4A)
    );
    border-radius: 8px;
    color: #FFFFFF;
    display: inline-flex;
    font-size: 13px;
    font-weight: 600;
    justify-content: center;
    padding: 10px 16px;
    text-decoration: none;
}

.bottom-activity-bar.ielts-petra-rail .petra-result-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    min-height: 100%;
}

.bottom-activity-bar.ielts-petra-rail .petra-result-preview-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bottom-activity-bar.ielts-petra-rail .petra-result-chat-ready {
    align-items: center;
    border: 1px solid rgba(92, 111, 92, 0.2);
    border-radius: 8px;
    display: flex;
    font-size: 12px;
    font-weight: 600;
    gap: 8px;
    line-height: 1.4;
    padding: 10px 12px;
}

.bottom-activity-bar.ielts-petra-rail .petra-result-preview-note {
    color: var(--ielts-text-muted, #9B9489);
    font-size: 11px;
    line-height: 1.45;
    text-align: center;
}

.bottom-activity-bar.ielts-petra-rail.is-overlay {
    box-shadow: -14px 0 40px rgba(26, 24, 22, 0.18);
}

.bottom-activity-bar.ielts-petra-rail.collapsed {
    height: 100dvh;
    transform: translateX(0);
    width: var(--ielts-petra-rail-compact-width);
}

@media (min-width: 769px) {
    .bottom-activity-bar.ielts-petra-rail.is-overlay {
        height: calc(100dvh - 64px);
        top: 64px;
    }
}

.bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-header {
    border-bottom: 1px solid var(--ielts-border, #E8E3DA);
    cursor: default;
    flex: 0 0 52px;
    height: 52px;
}

.bottom-activity-bar.ielts-petra-rail .petra-content-area {
    bottom: 0;
    display: flex;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 52px;
}

.bottom-activity-bar.ielts-petra-rail .petra-chat-container,
.bottom-activity-bar.ielts-petra-rail .petra-history-view {
    min-height: 0;
}

.bottom-activity-bar.ielts-petra-rail .petra-messages {
    overscroll-behavior: contain;
    padding: 18px;
}

.bottom-activity-bar.ielts-petra-rail .petra-input-area {
    align-items: flex-end;
    background: rgba(248, 244, 240, 0.72);
    border-top: 1px solid var(--ielts-border, #E8E3DA);
    display: flex;
    gap: 8px;
    padding: 12px;
}

.bottom-activity-bar.ielts-petra-rail .typing-dots {
    display: inline-flex;
    gap: 4px;
}

.bottom-activity-bar.ielts-petra-rail .typing-dots span {
    animation: ieltsPetraRailTyping 1.25s infinite ease-in-out;
    background: var(--ielts-primary, #5C6F5C);
    border-radius: 50%;
    height: 6px;
    width: 6px;
}

.bottom-activity-bar.ielts-petra-rail .typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.bottom-activity-bar.ielts-petra-rail .typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ieltsPetraRailTyping {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.bottom-activity-bar.ielts-petra-rail .expand-btn {
    display: none;
}

.bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-toggle {
    align-items: center;
    background: var(--ielts-primary, #5C6F5C);
    border: 1px solid var(--ielts-primary, #5C6F5C);
    border-radius: 6px;
    color: #FFFFFF;
    display: flex;
    height: 30px;
    justify-content: center;
    padding: 0;
    position: relative;
    width: 30px;
}

.bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-toggle:hover {
    background: var(--ielts-primary-dark, #4A5A4A);
    border-color: var(--ielts-primary-dark, #4A5A4A);
    color: #FFFFFF;
}

.bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-toggle:focus,
.bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(92, 111, 92, 0.28);
    outline: none;
}

.bottom-activity-bar.ielts-petra-rail .toggle-text-expand,
.bottom-activity-bar.ielts-petra-rail .toggle-text-collapse {
    font-size: 0;
}

.bottom-activity-bar.ielts-petra-rail .toggle-text-expand {
    align-items: center;
    display: flex;
    justify-content: center;
}

.bottom-activity-bar.ielts-petra-rail:not(.collapsed) .toggle-text-expand {
    display: none;
}

.bottom-activity-bar.ielts-petra-rail .petra-toggle-chat-icon {
    display: block;
    height: 16px;
    width: 16px;
}

.bottom-activity-bar.ielts-petra-rail .petra-collapsed-label {
    display: none;
}

.bottom-activity-bar.ielts-petra-rail.collapsed .petra-collapsed-label {
    color: var(--ielts-text, #3A3633);
    display: block;
    font-size: 11px;
    font-weight: 600;
    left: 50%;
    letter-spacing: 0.05em;
    line-height: 1;
    pointer-events: none;
    position: absolute;
    text-orientation: mixed;
    top: 60px;
    transform: translateX(-50%) rotate(180deg);
    white-space: nowrap;
    writing-mode: vertical-rl;
}

.bottom-activity-bar.ielts-petra-rail .toggle-text-collapse::before {
    content: "\203A";
    font-size: 22px;
    line-height: 1;
}

.bottom-activity-bar.ielts-petra-rail.collapsed .petra-header-title,
.bottom-activity-bar.ielts-petra-rail.collapsed .petra-title-text,
.bottom-activity-bar.ielts-petra-rail.collapsed .usage-badge,
.bottom-activity-bar.ielts-petra-rail.collapsed .petra-content-area {
    opacity: 0;
    pointer-events: none;
}

.bottom-activity-bar.ielts-petra-rail.collapsed .petra-content-area {
    display: none;
}

.bottom-activity-bar.ielts-petra-rail.collapsed .header-right {
    left: 7px;
    margin-left: 0;
    opacity: 1;
    padding-right: 0;
    pointer-events: auto;
    position: absolute;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
}

.bottom-activity-bar.ielts-petra-rail.collapsed .history-btn {
    display: none;
}

.bottom-activity-bar.ielts-petra-rail.collapsed.has-result-context
    .bottom-activity-bar-toggle::after {
    background: #B56A2D;
    border: 2px solid var(--ielts-bg-white, #FFFFFF);
    border-radius: 50%;
    content: "";
    height: 9px;
    position: absolute;
    right: -3px;
    top: -3px;
    width: 9px;
}

.bottom-activity-bar.ielts-petra-rail .petra-result-preview-kicker {
    color: var(--ielts-primary, #5C6F5C);
}

.bottom-activity-bar.ielts-petra-rail .petra-result-chat-ready {
    background: var(--ielts-primary-light, rgba(92, 111, 92, 0.08));
    border-color: rgba(92, 111, 92, 0.2);
    color: var(--ielts-primary, #5C6F5C);
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail {
    background: linear-gradient(180deg, #222222 0%, #1A1A1A 100%);
    border-left-color: rgba(127, 168, 127, 0.28);
    color: #E8E6E3;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.38);
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-header,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-history-header,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-input-area {
    border-color: rgba(127, 168, 127, 0.2);
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-input-area {
    background: rgba(26, 24, 22, 0.68);
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-header-title,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-result-preview-kicker,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .section-badge {
    color: #9BC09B;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .history-title,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .session-name,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-message.petra .message-bubble,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-title {
    color: #E8E6E3;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .activity-bar-action-btn,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .history-back-btn,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-empty-state,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-loading,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-error,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-loading-state,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-empty-history,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-error-history,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .session-meta,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .session-date,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-result-preview-note,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-text,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal .upgrade-hint {
    color: #B8B4AE;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .activity-bar-action-btn,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .history-back-btn,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-session-card,
body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-upgrade-modal {
    background: #252525;
    border-color: rgba(127, 168, 127, 0.24);
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-session-card:hover {
    background: rgba(127, 168, 127, 0.12);
    border-color: #7FA87F;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-message.petra .message-bubble {
    background: rgba(127, 168, 127, 0.15);
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail #petra-chat-input {
    background: rgba(26, 24, 22, 0.9);
    border-color: rgba(127, 168, 127, 0.3);
    color: #E8E6E3;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail #petra-chat-input:focus {
    border-color: #7FA87F;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .petra-result-chat-ready {
    background: rgba(127, 168, 127, 0.12);
    border-color: rgba(127, 168, 127, 0.26);
    color: #9BC09B;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .typing-dots span {
    background: #7FA87F;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-toggle,
body.dark-mode .bottom-activity-bar.ielts-petra-rail
    .bottom-activity-bar-toggle:hover {
    background: #7FA87F;
    border-color: #7FA87F;
    color: #1A1A1A;
}

body.dark-mode .bottom-activity-bar.ielts-petra-rail
    .bottom-activity-bar-toggle:focus,
body.dark-mode .bottom-activity-bar.ielts-petra-rail
    .bottom-activity-bar-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(127, 168, 127, 0.36);
}

@media (max-width: 1179px) {
    .ielts-qmain.ielts-petra-rail-host-docked,
    .ielts-flow-runner.ielts-petra-rail-host-docked {
        margin-right: 0;
    }

    .ielts-writing-result-page.ielts-petra-rail-host-docked,
    [data-ielts-petra-result-host].ielts-petra-rail-host-docked {
        margin-right: auto;
        transform: none;
        width: auto;
    }
}

@media (max-width: 768px) {
    .bottom-activity-bar.ielts-petra-rail {
        border-left: 0;
        border-radius: 16px 16px 0 0;
        border-top: 1px solid var(--ielts-border, #E8E3DA);
        bottom: 0;
        box-shadow: 0 -10px 32px rgba(26, 24, 22, 0.2);
        display: flex !important;
        height: min(70dvh, 600px);
        left: 0;
        max-width: none;
        right: 0;
        top: auto;
        transform: translateY(0);
        width: 100%;
    }

    .bottom-activity-bar.ielts-petra-rail[aria-hidden="true"] {
        display: none !important;
    }

    body.dark-mode .bottom-activity-bar.ielts-petra-rail {
        border-top-color: rgba(127, 168, 127, 0.28);
    }

    .bottom-activity-bar.ielts-petra-rail.collapsed {
        height: min(70dvh, 600px);
        transform: translateY(
            calc(100% - var(--ielts-petra-rail-compact-width))
        );
        width: 100%;
    }

    .bottom-activity-bar.ielts-petra-rail .toggle-text-collapse::before {
        content: "\2303";
        font-size: 18px;
    }

    .bottom-activity-bar.ielts-petra-rail.collapsed .petra-title-text {
        display: inline;
        opacity: 1;
    }

    .bottom-activity-bar.ielts-petra-rail.collapsed .petra-collapsed-label {
        display: none;
    }

    .bottom-activity-bar.ielts-petra-rail.collapsed .petra-header-title {
        opacity: 1;
        padding: 0 16px;
        pointer-events: auto;
    }

    .bottom-activity-bar.ielts-petra-rail.collapsed .header-right {
        left: auto;
        opacity: 1;
        pointer-events: auto;
        right: 8px;
    }

    .bottom-activity-bar.ielts-petra-rail .petra-input-area {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .ielts-qmain.ielts-petra-rail-host-visible,
    .ielts-flow-runner.ielts-petra-rail-host-visible {
        margin-right: 0;
        padding-bottom: calc(
            var(--ielts-petra-rail-compact-width)
            + env(safe-area-inset-bottom)
            + 1rem
        );
    }

    .ielts-writing-result-page.ielts-petra-rail-host-visible,
    [data-ielts-petra-result-host].ielts-petra-rail-host-visible {
        margin-right: auto;
        transform: none;
        width: auto;
        padding-bottom: calc(
            var(--ielts-petra-rail-compact-width)
            + env(safe-area-inset-bottom)
            + 1rem
        );
    }
}

@media (prefers-reduced-motion: reduce) {
    .bottom-activity-bar.ielts-petra-rail,
    .ielts-qmain,
    .ielts-flow-runner,
    .ielts-writing-result-page,
    [data-ielts-petra-result-host],
    .ielts-nav-header .ielts-nav-container,
    html.ielts-petra-standalone-scroll-viewport body > main {
        transition: none;
    }
}

@media (forced-colors: active) {
    .bottom-activity-bar.ielts-petra-rail {
        border: 1px solid CanvasText;
        forced-color-adjust: auto;
    }

    .bottom-activity-bar.ielts-petra-rail .bottom-activity-bar-toggle {
        border: 1px solid ButtonText;
    }

    .bottom-activity-bar.ielts-petra-rail.collapsed.has-result-context
        .bottom-activity-bar-toggle::after {
        background: Highlight;
        border-color: Canvas;
    }
}
