:root {
    --pfm-bg: #ffffff;
    --pfm-border: #d7dce2;
    --pfm-text: #1c1f23;
    --pfm-muted: #5a6472;
    --pfm-primary: #1f6feb;
    --pfm-primary-hover: #185ec7;
    --pfm-selection-overlay: rgba(59, 130, 246, 0.24);
    --pfm-selection-outline: #3b82f6;
    --pfm-selection-ring: rgba(59, 130, 246, 0.32);
    --pfm-success-bg: #e8f7ee;
    --pfm-success-text: #0f5132;
    --pfm-success-border: #95d5b2;
    --pfm-warning-bg: #fff4d6;
    --pfm-warning-border: #f0cf79;
    --pfm-error: #b42318;
}

.pfm-mode-active #pfm-panel,
.pfm-mode-active #pfm-add-selection-btn,
.pfm-mode-active #pfm-modal,
.pfm-review-active #pfm-review-panel,
.pfm-review-active #pfm-review-bubble {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#pfm-panel {
    position: fixed;
    top: 16px;
    right: 16px;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    z-index: 2147482500;
    background: var(--pfm-bg);
    color: var(--pfm-text);
    border: 1px solid var(--pfm-border);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
    padding: 14px;
}

#pfm-review-panel {
    position: fixed;
    top: 16px;
    right: 16px;
    width: min(380px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    z-index: 2147482500;
    background: var(--pfm-bg);
    color: var(--pfm-text);
    border: 1px solid var(--pfm-border);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
    padding: 14px;
}

.pfm-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.pfm-panel-header h2 {
    font-size: 17px;
    margin: 0;
    line-height: 1.2;
}

.pfm-panel-hint {
    margin: 0 0 12px;
    color: var(--pfm-muted);
    font-size: 13px;
    line-height: 1.4;
}

.pfm-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--pfm-text);
    font-weight: 600;
    background: #f4f6fa;
    border: 1px solid var(--pfm-border);
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pfm-nav-toggle:hover {
    background: #eaeef5;
}

.pfm-nav-toggle-text {
    flex: 1;
    line-height: 1.2;
}

.pfm-nav-toggle-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.pfm-nav-toggle-switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #c1c8d4;
    transition: background-color 0.18s ease;
}

.pfm-nav-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transition: transform 0.18s ease;
}

.pfm-nav-toggle-input:checked ~ .pfm-nav-toggle-switch {
    background: var(--pfm-primary);
}

.pfm-nav-toggle-input:checked ~ .pfm-nav-toggle-switch .pfm-nav-toggle-thumb {
    transform: translateX(20px);
}

.pfm-nav-toggle-input:focus-visible ~ .pfm-nav-toggle-switch {
    outline: 2px solid var(--pfm-primary);
    outline-offset: 2px;
}

.pfm-nav-hint {
    margin: 0 0 10px;
    color: var(--pfm-muted);
    font-size: 12px;
    line-height: 1.4;
}

.pfm-email-field {
    display: block;
    margin: 0 0 10px;
}

.pfm-email-field span {
    display: block;
    font-size: 12px;
    color: var(--pfm-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.pfm-email-field input {
    width: 100%;
    border: 1px solid var(--pfm-border);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 13px;
    line-height: 1.3;
    color: var(--pfm-text);
    background: #ffffff;
}

.pfm-panel-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.pfm-status {
    min-height: 22px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--pfm-muted);
    margin-bottom: 8px;
}

.pfm-status.pfm-error {
    color: var(--pfm-error);
}

.pfm-primary-btn,
.pfm-secondary-btn,
.pfm-link-btn,
.pfm-floating-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    padding: 8px 11px;
    cursor: pointer;
}

.pfm-primary-btn {
    background: var(--pfm-primary);
    color: #ffffff;
}

.pfm-primary-btn:hover {
    background: var(--pfm-primary-hover);
}

.pfm-primary-btn:disabled,
.pfm-secondary-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.pfm-secondary-btn {
    border-color: var(--pfm-border);
    background: #ffffff;
    color: var(--pfm-text);
}

.pfm-link-btn {
    border-color: transparent;
    background: transparent;
    color: var(--pfm-primary);
    padding: 0;
    font-size: 12px;
}

.pfm-suggestion-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}

.pfm-page-group {
    list-style: none;
    border: 1px solid var(--pfm-border);
    border-radius: 8px;
    background: #ffffff;
    padding: 8px;
    min-width: 0;
}

.pfm-page-group-current {
    border-color: var(--pfm-primary);
    background: #f4f8ff;
}

.pfm-page-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.pfm-page-group-title {
    font-size: 12px;
    color: var(--pfm-text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}

.pfm-page-group-open {
    flex-shrink: 0;
    font-size: 12px;
    text-decoration: none;
}

.pfm-page-group-open:hover {
    text-decoration: underline;
}

.pfm-page-group-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.pfm-item-warning {
    color: var(--pfm-error);
}

.pfm-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.pfm-minimise-btn {
    margin-top: 10px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    appearance: none;
    border: 1px solid var(--pfm-border);
    background: #ffffff;
    color: var(--pfm-muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pfm-minimise-btn:hover {
    background: #f4f6fa;
    color: var(--pfm-text);
}

.pfm-minimise-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 6px solid currentColor;
    transition: transform 0.18s ease;
}

#pfm-panel.pfm-panel-minimised .pfm-minimise-chevron {
    transform: rotate(180deg);
}

#pfm-panel.pfm-panel-minimised .pfm-panel-hint,
#pfm-panel.pfm-panel-minimised .pfm-nav-toggle,
#pfm-panel.pfm-panel-minimised .pfm-nav-hint,
#pfm-panel.pfm-panel-minimised .pfm-email-field,
#pfm-panel.pfm-panel-minimised .pfm-panel-actions,
#pfm-panel.pfm-panel-minimised .pfm-status,
#pfm-panel.pfm-panel-minimised .pfm-suggestion-list {
    display: none !important;
}

#pfm-panel.pfm-panel-minimised {
    padding: 10px 12px;
}

#pfm-panel.pfm-panel-minimised .pfm-panel-header {
    margin-bottom: 0;
}

#pfm-panel.pfm-panel-minimised .pfm-minimise-btn {
    margin-top: 8px;
}

.pfm-empty {
    border: 1px dashed var(--pfm-border);
    border-radius: 8px;
    color: var(--pfm-muted);
    padding: 10px;
    font-size: 13px;
}

.pfm-item {
    border: 1px solid var(--pfm-border);
    border-radius: 8px;
    padding: 8px;
    background: #fbfcfe;
}

.pfm-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.pfm-item-top strong {
    font-size: 12px;
    color: var(--pfm-muted);
}

.pfm-item p {
    margin: 6px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--pfm-text);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pfm-item-suggested {
    color: #1f6f45;
}

.pfm-item-note {
    color: var(--pfm-muted);
}

.pfm-review-missing {
    border-style: dashed;
    opacity: 0.75;
}

#pfm-add-selection-btn {
    position: absolute;
    z-index: 2147482600;
    background: var(--pfm-primary);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(31, 111, 235, 0.35);
}

#pfm-add-selection-btn:hover {
    background: var(--pfm-primary-hover);
}

.pfm-modal {
    position: fixed;
    inset: 0;
    z-index: 2147482700;
}

.pfm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
}

.pfm-modal-dialog {
    position: relative;
    width: min(620px, calc(100vw - 24px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    margin: 20px auto;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 22px 40px rgba(15, 23, 42, 0.25);
    border: 1px solid var(--pfm-border);
    padding: 14px;
}

.pfm-modal-dialog h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.pfm-field {
    display: block;
    margin-top: 10px;
}

.pfm-field span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--pfm-muted);
}

.pfm-field textarea {
    width: 100%;
    border: 1px solid var(--pfm-border);
    border-radius: 8px;
    padding: 8px;
    font-size: 14px;
    line-height: 1.4;
    resize: vertical;
    color: var(--pfm-text);
    background: #ffffff;
}

.pfm-field textarea[readonly] {
    background: #f8fafc;
}

.pfm-field input[type="file"] {
    display: block;
    width: 100%;
    font-size: 13px;
    color: var(--pfm-text);
}

.pfm-attachment-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.pfm-attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--pfm-border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    color: var(--pfm-text);
}

.pfm-attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pfm-modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

body mark.pfm-pending-highlight[data-pfm-pending-id],
body mark.pfm-highlight[data-pfm-suggestion-id] {
    display: inline !important;
    background-color: var(--pfm-selection-overlay) !important;
    color: inherit !important;
    font-weight: inherit !important;
    font-style: inherit !important;
    font-family: inherit !important;
    letter-spacing: inherit !important;
    line-height: inherit !important;
    outline: none !important;
    border: 1px solid var(--pfm-selection-outline) !important;
    border-radius: 3px !important;
    box-shadow: none !important;
    padding: 0 0.02em !important;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

body mark.pfm-review-highlight[data-pfm-review-id] {
    display: inline !important;
    background-color: var(--pfm-selection-overlay) !important;
    color: inherit !important;
    font-weight: inherit !important;
    font-style: inherit !important;
    font-family: inherit !important;
    letter-spacing: inherit !important;
    line-height: inherit !important;
    outline: none !important;
    border: 1px solid var(--pfm-selection-outline) !important;
    border-radius: 3px !important;
    box-shadow: none !important;
    padding: 0 0.02em !important;
    cursor: pointer;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

body .pfm-image-highlight-overlay {
    position: fixed !important;
    pointer-events: none;
    background-color: var(--pfm-selection-overlay) !important;
    border: 2px solid var(--pfm-selection-outline);
    box-shadow: 0 0 0 1px var(--pfm-selection-ring);
    box-sizing: border-box;
    z-index: 2147482400;
}

body .pfm-image-highlight-overlay.pfm-review-image-highlight[data-pfm-review-id] {
    pointer-events: auto;
    cursor: pointer;
}

body .pfm-image-highlight-overlay.pfm-review-button-highlight[data-pfm-review-id] {
    pointer-events: auto;
    cursor: pointer;
}

body .pfm-image-highlight-overlay.pfm-image-highlight[data-pfm-suggestion-id],
body .pfm-image-highlight-overlay.pfm-button-highlight[data-pfm-suggestion-id] {
    pointer-events: auto;
    cursor: pointer;
}

body mark.pfm-highlight[data-pfm-suggestion-id] {
    cursor: pointer;
}

.pfm-item[data-suggestion-id] {
    cursor: pointer;
}

.pfm-item[data-suggestion-id]:hover {
    border-color: var(--pfm-primary);
}

@keyframes pfm-flash {
    0% {
        background-color: rgba(255, 217, 0, 0.7);
        box-shadow: 0 0 0 3px rgba(255, 217, 0, 0.55);
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 0 rgba(255, 217, 0, 0);
    }
}

.pfm-flash {
    animation: pfm-flash 1.4s ease-out;
}

body .pfm-image-highlight-overlay.pfm-flash {
    background-color: rgba(255, 217, 0, 0.55) !important;
    border-color: #d97706 !important;
}

html.pfm-mode-active body mark.pfm-highlight[data-pfm-suggestion-id],
html.pfm-review-active body mark.pfm-review-highlight[data-pfm-review-id] {
    background-color: var(--pfm-selection-overlay) !important;
}

html.pfm-mode-active body mark.pfm-pending-highlight[data-pfm-pending-id] {
    background-color: var(--pfm-selection-overlay) !important;
}

html.pfm-mode-active ::selection,
html.pfm-review-active ::selection {
    background-color: var(--pfm-selection-overlay) !important;
}

html.pfm-mode-active ::-moz-selection,
html.pfm-review-active ::-moz-selection {
    background-color: var(--pfm-selection-overlay) !important;
}

html.pfm-mode-active .swiper .slide-text-container,
html.pfm-mode-active .swiper .slide-text-container *,
html.pfm-mode-active .swiper .slide-text,
html.pfm-mode-active .swiper .slide-text *,
html.pfm-mode-active .slick-slider .slide-text-container,
html.pfm-mode-active .slick-slider .slide-text-container *,
html.pfm-mode-active .slick-slider .slide-text,
html.pfm-mode-active .slick-slider .slide-text * {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    user-select: text !important;
    touch-action: auto !important;
}

.pfm-review-highlight:focus {
    outline: 2px solid #2563eb;
}

.pfm-review-bubble {
    position: absolute;
    z-index: 2147482850;
    width: min(460px, calc(100vw - 24px));
    background: #ffffff;
    border: 1px solid var(--pfm-border);
    border-radius: 10px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.24);
    padding: 10px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.pfm-review-bubble.pfm-review-bubble-visible {
    opacity: 1;
    transform: translateY(0);
}

.pfm-review-bubble h4 {
    margin: 0 0 8px;
    font-size: 14px;
}

.pfm-review-bubble .pfm-review-label {
    margin: 8px 0 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--pfm-muted);
}

.pfm-review-bubble pre {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    font-family: inherit;
}

.pfm-toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2147482800;
    max-width: min(420px, calc(100vw - 24px));
    border: 1px solid var(--pfm-success-border);
    background: var(--pfm-success-bg);
    color: var(--pfm-success-text);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.pfm-toast.pfm-toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.pfm-toast.pfm-toast-error {
    border-color: #f3b0ab;
    background: #fff1f0;
    color: #8f2d27;
}

.pfm-hidden {
    display: none !important;
}

@media (max-width: 900px) {
    #pfm-panel {
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 8px;
        max-height: 42vh;
        width: auto;
    }

    #pfm-review-panel {
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 8px;
        max-height: 46vh;
        width: auto;
    }

    .pfm-modal-dialog {
        margin: 12px auto;
    }

    .pfm-toast {
        left: 8px;
        right: 8px;
        bottom: 56vh;
        max-width: none;
    }

    .pfm-review-bubble {
        left: 8px !important;
        right: 8px;
        width: auto;
    }
}
