/**
 * FWD AI Search Frontend Styles (Matching UI Design)
 */

/* Hide WordPress page title and breadcrumb when search app is present */
body:has(.fwd-search-app) .entry-title,
body:has(.fwd-search-app) .page-title,
body:has(.fwd-search-app) .wp-block-post-title,
body:has(.fwd-search-app) h1.has-text-align-center {
    display: none !important;
}

/* Hide title container above entry-content */
main .wp-block-group.has-global-padding.is-layout-constrained + .entry-content ~ * .wp-block-group.has-global-padding.is-layout-constrained {
    display: block !important; /* Keep other groups visible */
}

main .wp-block-group.has-global-padding.is-layout-constrained:has(+ .entry-content) {
    display: none !important;
}

/* ===== Override WordPress Theme Constraints ===== */
/* Keep parent padding to align with header, only override max-width */
.is-layout-constrained:has(.fwd-search-app),
.wp-block-post-content:has(.fwd-search-app),
.entry-content:has(.fwd-search-app) {
    max-width: none !important;
}
.page-content-sec:has(.fwd-search-app) {
    overflow: visible !important;
}

/* Fallback for browsers without :has() support - use 100vw */
.fwd-search-app {
    width: 100vw !important;
    max-width: 100vw !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Negative margin to pull out of constrained container */
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
}

.fwd-bg {
    background-color: #f5f5f5;
    flex: 1;
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.fwd-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    /* Match WordPress alignwide: 1280px centered */
    width: 100%;
    max-width: var(--wp--style--global--wide-size, 1280px);
    margin: 0 auto;
    box-sizing: border-box;
}

@media (max-width: 1320px) {
    .fwd-container {
        padding: 12px 20px;
    }
}

/* Desktop: Bottom row with icons, date, breadcrumb - force single line */
@media (min-width: 769px) {
    /* Target the bottom row flex container (icons | date | breadcrumb) */
    /* This targets the flex container with gap-[8px] and items-center inside result items */
    .content-stretch.flex-col.gap-\[24px\] > .content-stretch.flex-col.gap-\[8px\] > .flex.gap-\[8px\].items-center {
        flex-wrap: nowrap !important;
    }
}

@media (max-width: 768px) {
    .fwd-container {
        padding: 16px 24px;
    }

    /* Mobile: Snippet should be block to prevent inline flow with meta */
    .fwd-result-snippet {
        display: -webkit-box;
        width: 100%;
    }

    /* Mobile: Meta area - stack layout */
    .fwd-result-meta {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
        margin-top: 8px;
    }

    /* Mobile: Date on its own line */
    .fwd-result-meta .fwd-result-date {
        display: block;
    }

    /* Mobile: Hide separator */
    .fwd-result-meta .fwd-separator {
        display: none;
    }

    /* Mobile: Icons at bottom left - wrap in a container */
    .fwd-result-meta .fwd-meta-spacer {
        display: none;
    }

    /* Mobile: Icons wrapper - keeps icons on same line */
    .fwd-icons-wrapper {
        display: flex;
        flex-direction: row;
        gap: 8px;
        margin-top: 4px;
    }

    /* Mobile: Icons row container */
    .fwd-result-meta .fwd-preview-btn,
    .fwd-result-meta .fwd-download-btn,
    .fwd-result-meta .fwd-link-btn {
        position: static;
        transform: none;
        display: inline-flex;
        width: 24px;
        height: 24px;
    }

    .fwd-result-meta .fwd-preview-btn img,
    .fwd-result-meta .fwd-download-btn img,
    .fwd-result-meta .fwd-link-btn img {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .fwd-container {
        padding: 12px 16px;
    }
}

/* ===== Search Card ===== */
.fwd-search-card {
    background: white;
    width: 100%;
    padding: 16px;
    position: relative;
    border-radius: 8px;
    border: 1px solid #eaeaea;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .fwd-search-card {
        padding: 24px;
    }
}

.fwd-search-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    position: relative;
    width: 100%;
}

@media (min-width: 640px) {
    .fwd-search-row {
        flex-direction: row;
        gap: 8px;
        align-items: flex-start;
    }
}

/* ===== Search Input Wrapper (input + error container) ===== */
.fwd-input-wrapper {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .fwd-input-wrapper {
        min-width: 300px;
    }
}

.fwd-search-app .fwd-search-error {
    grid-column: 1;
    grid-row: 2;
}

/* ===== Search Input Container ===== */
.fwd-search-input-container {
    width: 100%;
    min-width: 0;
    position: relative;
    flex: 1;
}

.fwd-search-app .fwd-search-input-wrapper {
    height: 44px !important;
    position: relative;
    border-radius: 6px;
    border: 1px solid #eaeaea;
    transition: border-color 0.2s;
    background: white !important;
    box-sizing: border-box !important;
    width: 100%;
}

.fwd-search-app .fwd-search-input-wrapper.focused {
    border-color: #f87722 !important;
}

.fwd-search-app .fwd-search-input-inner {
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    padding: 10px 16px !important;
    height: 100%;
    position: relative;
    box-sizing: border-box !important;
}

/* Search Icon */
.fwd-search-app .fwd-search-icon {
    width: 24px !important;
    height: 24px !important;
    flex-shrink: 0 !important;
    display: block !important;
}

/* Input Separator */
.fwd-search-app .fwd-input-separator {
    background: #e87722 !important;
    height: 20px !important;
    width: 1px !important;
    flex-shrink: 0 !important;
    display: block !important;
}

/* Input Field */
.fwd-search-app .fwd-search-input {
    flex: 1 !important;
    min-width: 0 !important;
    font-family: 'Inter', "Microsoft YaHei", 'Noto Sans JP', Arial, sans-serif !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    color: #183028 !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    line-height: normal !important;
    height: auto !important;
}

.fwd-search-app .fwd-search-input::placeholder {
    color: #8b8e8f !important;
}

.fwd-search-app .fwd-search-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Error state for empty input */
.fwd-search-app .fwd-search-input-wrapper.error {
    border-color: #dc3545 !important;
    border-radius: 6px;
}

/* Error message - inside .fwd-input-wrapper */
.fwd-search-app .fwd-search-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 6px;
    padding-left: 2px;
    width: 100%;
    box-sizing: border-box;
}

.fwd-search-app .fwd-search-error span {
    font-weight: bold;
}

/* Clear Button */
.fwd-search-app .fwd-clear-btn {
    width: 16px !important;
    height: 16px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    display: block !important;
    margin: 0 !important;
}

.fwd-search-app .fwd-clear-btn svg {
    width: 16px !important;
    height: 16px !important;
    display: block !important;
    transition: opacity 0.2s ease;
}

.fwd-search-app .fwd-clear-btn:hover svg path {
    fill: #8B8E8F !important;
}

.fwd-search-app .fwd-clear-btn:hover {
    opacity: 0.8;
}

/* ===== Search Button ===== */
.fwd-search-btn {
    display: flex;
    height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    position: relative;
    border-radius: 6px;
    flex-shrink: 0;
    width: 100%;
    cursor: pointer;
    background: #f87722;
    border: none;
    transition: opacity 0.2s;
}

@media (min-width: 640px) {
    .fwd-search-btn {
        width: 200px;
    }
}

.fwd-search-btn:hover {
    opacity: 0.9;
}

.fwd-search-btn:disabled {
    background: #FAE4D3;
    cursor: not-allowed;
}

.fwd-search-btn:disabled .fwd-search-btn-text {
    color: #f87722;
}

.fwd-search-btn-text {
    font-family: 'Inter', 'Noto Sans JP', Arial, sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: white;
    text-align: center;
}

/* Loading spinner */
.fwd-search-btn .fwd-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: fwd-spin 0.8s linear infinite;
}

/* Loading spinner in disabled state (orange color) */
.fwd-search-btn:disabled .fwd-loading-spinner {
    border-top-color: #f87722;
}

@keyframes fwd-spin {
    to { transform: rotate(360deg); }
}

/* ===== Typeahead Dropdown ===== */
.fwd-typeahead {
    position: absolute;
    background: #FEF9F4;
    left: 0;
    right: 0;
    top: 44px;
    z-index: 10;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    border: 1px solid #f87722;
    border-top: none;
}

.fwd-typeahead-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

.fwd-typeahead-item {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    margin: -8px;
    transition: background 0.2s;
}

.fwd-typeahead-item:hover {
    background: #FFF4E8;
}

.fwd-typeahead-text {
    flex: 1;
    font-family: 'Inter', "Microsoft YaHei", 'Noto Sans JP', Arial, sans-serif;
    font-size: 14px;
    color: #183028;
}

.fwd-typeahead-delete {
    opacity: 0;
    padding: 4px;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    transition: opacity 0.2s;
    line-height: 1;
}

.fwd-typeahead-item:hover .fwd-typeahead-delete {
    opacity: 1;
}

/* ===== Search History Buttons ===== */
.fwd-history-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eaeaea;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.fwd-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    width: 100%;
}

.fwd-history-title {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #f87722;
    margin-bottom: 0;
}

.fwd-clear-all-history {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #0097A8;
}

.fwd-clear-all-history:hover {
    opacity: 0.8;
}

.fwd-clear-all-history img {
    width: 16px;
    height: 16px;
}

.fwd-history-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-family: Arial, "Microsoft YaHei", 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #333333;
    background: #FFF4E8;
    border: 1px solid #f87722;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.fwd-history-btn:hover {
    background: #ffe8d6;
}

.fwd-history-btn-text {
    max-width: min(300px, calc(100vw - 130px));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fwd-history-btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.fwd-history-btn-delete:hover {
    background-color: rgba(0, 0, 0, 0.08);
    transform: scale(1.15);
}

.fwd-history-btn-delete svg {
    width: 16px;
    height: 16px;
}

/* ===== Results Area ===== */
#fwd-results-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fwd-results-list.fwd-results-disabled {
    pointer-events: none;
    opacity: 0.4;
}

.fwd-results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.fwd-results-count {
    font-family: 'Inter', 'Noto Sans JP', Arial, sans-serif;
    font-size: 14px;
    color: #828282;
    margin-top: 8px;
}

.fwd-results-count.fwd-results-count-filtered {
    font-weight: 700;
    color: #183028;
}

/* Disabled header controls when no results */
.fwd-results-list-header.fwd-header-disabled {
    pointer-events: none;
    opacity: 0.4;
}

/* Disabled mobile controls when no results after filtering */
.fwd-mobile-control-disabled {
    pointer-events: none;
    opacity: 0.4;
}

/* No results body - centered message aligned with filter sidebar height */
.fwd-no-results-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 300px;
    padding: 40px 20px;
}

.fwd-no-results-title {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #183028;
    margin: 0 0 16px;
    text-align: center;
    padding-bottom: 0 !important;
}

.fwd-no-results-subtitle {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #828282;
    margin: 0;
    text-align: center;
}

@media (max-width: 767px) {
    .fwd-spell-revert-wrap {
        display: block;
        margin-top: 4px;
    }
}

/* Spell Correction Message */
.fwd-spell-correction {
    display: none; /* Hidden - message shown in results count */
}

.fwd-spell-revert-link {
    color: #f87722;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

.fwd-spell-revert-link:hover {
    color: #e5651a;
    text-decoration: underline;
}

.fwd-filter-btn-mobile {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-radius: 6px;
    background: transparent;
    border: none;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #B74701;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    margin-top: 8px;
    align-self: flex-start;
}

.fwd-filter-btn-mobile.visible {
    display: flex;
}

.fwd-filter-btn-mobile:hover {
    background: #fff5ed;
}

@media (min-width: 768px) {
    .fwd-filter-btn-mobile {
        display: none !important;
    }
}

/* ===== Results Grid ===== */
.fwd-results-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

@media (min-width: 768px) {
    .fwd-results-grid {
        flex-direction: row;
        gap: 16px;
    }
}

/* Wrapper for results header + results with overlay */
.fwd-results-main-wrapper {
    position: relative;
}

/* Overlay for desktop filter changes (inside .fwd-results-main-wrapper) */
.fwd-results-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 99;
}

.fwd-results-overlay.active {
    display: block;
}

.fwd-results-list {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 16px;
    background: white;
    border-radius: 6px;
    border: 1px solid #eaeaea;
    order: 1;
}

@media (min-width: 768px) {
    .fwd-results-list {
        position: relative;
        padding: 24px;
    }
}

/* ===== Result Item ===== */
.fwd-results {
    position: relative;
}

.fwd-result-item {
    padding: 0;
}

.fwd-result-item:first-child {
    padding-top: 24px;
}

.fwd-result-item + .fwd-result-item {
    margin-top: 36px;
}

/* Title - Orange Color */
.fwd-result-title {
    margin: 0 0 4px;
    font-family: Arial, "Microsoft YaHei", 'Noto Sans JP', sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
}

.fwd-result-title a {
    /*标题字体加粗*/
    font-weight: 700;
    color: #183028;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.fwd-result-title a:hover {
    opacity: 0.8;
}

/* Keyword Highlight in Title */
.fwd-result-title mark,
.fwd-result-title .fwd-highlight {
    background-color: transparent;
    font-weight: 700;
    color: #0097A8;
}

/* Content Snippet - character-based truncation (240 English / 120 Chinese) */
.fwd-result-snippet {
    margin: 0 0 16px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #183028;
    line-height: 22px;
    clear: both;
}

/* Keyword Highlight in Snippet */
.fwd-result-snippet mark,
.fwd-result-snippet .fwd-highlight {
    background-color: transparent;
    color: #0097A8;
    font-weight: 700;
}

/* Keyword Highlight in AI Summary */
.fwd-ai-summary-text mark {
    background-color: transparent;
    color: #0097A8;
    font-weight: 700;
}

/* Meta Info - Bottom Row with Icons */
.fwd-result-meta {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 12px;
    position: relative;
    min-height: 24px;
    width: 100%;
    margin-top: 15px;
}

.fwd-ai-summary-box + .fwd-result-meta {
    margin-top: 0;
}

/* Desktop: Meta row layout - ensure icons stay on same line as date/breadcrumb */
@media (min-width: 769px) {
    .fwd-result-meta {
        display: flex;
        align-items: flex-start;
        gap: 4px;
        flex-wrap: nowrap;
    }
}

/* Spacer to push icons to the right - desktop only */
.fwd-meta-spacer {
    flex: 1;
}

/* Preview/Download/Link buttons - desktop: positioned at right edge */
.fwd-result-meta .fwd-preview-btn,
.fwd-result-meta .fwd-download-btn,
.fwd-result-meta .fwd-link-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 769px) {
    /* Desktop: Icons wrapper - flex row layout */
    .fwd-icons-wrapper {
        display: flex;
        flex-direction: row;
        gap: 8px;
        margin-left: auto;
        flex-shrink: 0;
    }

    /* Desktop: Spacer is not needed with flex layout */
    .fwd-meta-spacer {
        display: none;
    }

    .fwd-result-meta .fwd-preview-btn,
    .fwd-result-meta .fwd-download-btn,
    .fwd-result-meta .fwd-link-btn {
        position: static;
        transform: none;
    }
}

/* Icon Buttons (Zoom, Download) */
.fwd-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s;
}

.fwd-icon-btn:hover {
    opacity: 0.7;
}

/* Separator */
.fwd-separator {
    color: #828282;
    margin: 0 4px;
    line-height: 1.5;
}

/* Date */
.fwd-result-date {
    color: #183028;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.5;
}

/* ===== Breadcrumb =====
 * Default (collapsed): first > second > … > last  (click "…" to expand)
 * Expanded: full path shown, auto-collapses on setting changes
 */

.fwd-breadcrumb-wrapper {
    color: #183028;
    font-size: 14px;
    line-height: 1.5;
    min-width: 0;
}

.fwd-breadcrumb-segment {
    color: #183028;
}

.fwd-breadcrumb-last {
    color: #B74701;
    text-decoration: underline;
    text-underline-offset: 2px;
}

a.fwd-breadcrumb-last {
    cursor: pointer;
}

a.fwd-breadcrumb-last:hover {
    opacity: 0.8;
}

.fwd-breadcrumb-sep {
    color: #828282;
}

.fwd-breadcrumb-ellipsis {
    color: #B74701;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.fwd-breadcrumb-ellipsis:hover {
    opacity: 0.8;
}

/* --- Collapsed state: show abbreviated, hide full --- */
.fwd-breadcrumb-wrapper[data-state="collapsed"] .fwd-breadcrumb-full {
    display: none;
}

.fwd-breadcrumb-wrapper[data-state="collapsed"] .fwd-breadcrumb-pc-collapsed {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Expanded state: show full, hide abbreviated --- */
.fwd-breadcrumb-wrapper[data-state="expanded"] .fwd-breadcrumb-pc-collapsed {
    display: none;
}

.fwd-breadcrumb-wrapper[data-state="expanded"] .fwd-breadcrumb-full {
    display: block;
    white-space: normal;
    word-break: break-word;
}

/* ---------- Desktop ( >= 769px ) ---------- */
@media (min-width: 769px) {
    .fwd-breadcrumb-wrapper {
        flex: 1 1 auto;
        min-width: 0;
    }
}

/* ---------- Mobile + Tablet ( <= 1024px ) ---------- */
@media (max-width: 1024px) {
    .fwd-breadcrumb-wrapper {
        display: block;
        width: 100%;
    }

    .fwd-breadcrumb-wrapper[data-state="collapsed"] .fwd-breadcrumb-pc-collapsed {
        white-space: normal;
        word-break: break-word;
    }
}

/* Title: always show full text */
.fwd-result-title a {
    display: block;
    word-break: break-word;
}

/* ===== Desktop Controls (Sort & Per Page) ===== */
.fwd-desktop-controls {
    display: none;
}

@media (min-width: 768px) {
    .fwd-desktop-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 32px;
        align-items: center;
    }
}

.fwd-sort-wrapper,
.fwd-per-page-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.fwd-control-label {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
}

.fwd-sort-control {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    position: relative;
}

#fwd-sort-label:hover {
    opacity: 0.8;
}

#fwd-sort-label {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
}

.fwd-sort-dropdown {
    position: absolute;
    top: 28px;
    right: 0;
    background-color: #ffffff !important;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
}

.fwd-sort-option {
    padding: 12px 16px;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
    cursor: pointer;
    background-color: #ffffff !important;
}

.fwd-sort-option:hover {
    background-color: #f9fafb !important;
}

.fwd-sort-option.active {
    color: #ffffff;
    font-weight: 700;
    background-color: #f87722 !important;
}

.fwd-per-page-value {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #213833;
    opacity: 0.5;
}

/* Per-page dropdown control (desktop) */
.fwd-per-page-control {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.fwd-per-page-display {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fwd-per-page-arrow {
    transition: transform 0.2s;
}

.fwd-per-page-dropdown {
    position: absolute;
    top: 28px;
    right: 0;
    background-color: #ffffff !important;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
    min-width: 80px;
}

.fwd-per-page-option {
    padding: 12px 16px;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
    cursor: pointer;
    background-color: #ffffff !important;
}

.fwd-per-page-option:hover {
    background-color: #f9fafb !important;
}

.fwd-per-page-option.active {
    color: #ffffff;
    font-weight: 700;
    background-color: #f87722 !important;
}

/* ===== Mobile Sort Control ===== */
.fwd-mobile-sort {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 6px;
    box-sizing: border-box;
}

.fwd-mobile-sort-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.fwd-mobile-ai-row {
    display: flex;
    flex-direction: column;
}

.fwd-ai-disclaimer-mobile {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 10px;
    color: #8B8E8F;
    line-height: 1.5;
    padding-left: 30px;
}

@media (min-width: 768px) {
    .fwd-mobile-sort {
        display: none;
    }
}

/* Mobile-only styles (max-width: 767px) */
@media (max-width: 767px) {


    /* Hide select text, show only the label text */
    .fwd-mobile-sort-select {
        color: transparent;
        -webkit-text-fill-color: transparent;
    }

    /* Per-page control - hide the old value span */
    .fwd-per-page-value-mobile {
        display: none;
    }

    /* Per-page select - make text transparent too */
    .fwd-per-page-select-mobile {
        color: transparent;
        -webkit-text-fill-color: transparent;
    }
}

.fwd-mobile-sort-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.fwd-mobile-sort-select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 36px 8px 12px;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    background: white;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #183028;
    color: transparent;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    cursor: pointer;
}

.fwd-mobile-sort-arrow {
    pointer-events: none;
}

.fwd-mobile-sort-label {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #183028;
    white-space: nowrap;
}

.fwd-per-page-value-mobile {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #213833;
    opacity: 0.5;
}

.fwd-mobile-per-page-label {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #183028;
    white-space: nowrap;
}


/* Mobile per-page control */
.fwd-per-page-control-mobile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fwd-per-page-select-mobile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ===== Filter Sidebar (Desktop) ===== */
.fwd-filter-sidebar {
    display: none;
}

@media (min-width: 768px) {
    .fwd-filter-sidebar {
        display: flex;
        flex-direction: column;
        width: 280px;
        flex-shrink: 0;
        border: 1px solid #eaeaea;
        border-radius: 6px;
        align-self: flex-start;
        background: white;
        order: 2;
        position: sticky;
        top: 16px;
        height: calc(100vh - 240px);
        max-height: calc(100vh - 240px);
        overflow: hidden;
    }
}

/* Scrollable content area inside sidebar */
.fwd-filter-sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 0 16px;
    /* Thin scrollbar for modern browsers */
    scrollbar-width: thin;
    scrollbar-color: #d0d0d0 transparent;
}

.fwd-filter-sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.fwd-filter-sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.fwd-filter-sidebar-scroll::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 2px;
}

/* Sidebar footer (Reset/Confirm) — outside scroll, always visible */
.fwd-sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid #eaeaea;
    border-radius: 0 0 6px 6px;
    position: static !important;
}

/* Filter Section */
.fwd-filter-section {
    border-bottom: 1px solid #eaeaea;
    padding-bottom: 24px;
}

.fwd-filter-section:last-child {
    border-bottom: none;
}

.fwd-filter-section-title {
    padding: 24px 24px 10px;
    margin: 0;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #183028;
    background: white;
}

.fwd-filter-section:first-child .fwd-filter-section-title {
    padding-top: 16px;
}

/* Filter Item with Checkbox */
.fwd-filter-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 6px 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.fwd-filter-item:nth-child(odd) {
    background: #ffffff;
}

.fwd-filter-item:nth-child(even) {
    background: #ffffff;
}

.fwd-filter-item:hover {
    background: #f0f0f0;
}

/* Disabled filter items (0-count file_type / date options) */
.fwd-filter-item-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* No-results message shown when active filters return 0 results */
.fwd-no-results-filtered {
    text-align: center;
    padding: 60px 20px;
    color: #828282;
}

/* Year-Month Hierarchical Filter */
.fwd-year-group {
    margin-bottom: 0;
}

.fwd-year-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fwd-year-row .fwd-filter-item {
    flex: 1;
}

.fwd-year-label-wrapper {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.fwd-year-toggle,
#fwd-search-app .fwd-year-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    color: #f87722 !important;
    font-size: 12px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.fwd-year-toggle:hover {
    color: #f87722;
}

.fwd-toggle-icon {
    margin-left: 4px;
}

/* 向下箭頭（展開狀態）- 旋轉180度 */
.fwd-year-toggle.expanded .fwd-toggle-icon {
    transform: rotate(180deg);
}

/* 向上箭頭（收起狀態）- 默認方向 */
.fwd-year-toggle:not(.expanded) .fwd-toggle-icon {
    transform: none;
}

.fwd-month-list {
    margin-left: 24px;
    border-left: 1px solid #eaeaea;
}

.fwd-month-item {
    padding-left: 16px !important;
}

.fwd-month-label {
    color: #8b8e8f !important;
}

/* Custom Checkbox */
.fwd-checkbox {
    position: relative;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.fwd-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    margin: 0;
    z-index: 1;
}

.fwd-checkbox-icon {
    width: 24px;
    height: 24px;
}

/* Unchecked state */
.fwd-checkbox-icon .unchecked {
    display: block;
}

.fwd-checkbox-icon .checked {
    display: none;
}

/* Checked state */
.fwd-checkbox input:checked ~ .fwd-checkbox-icon .unchecked {
    display: none;
}

.fwd-checkbox input:checked ~ .fwd-checkbox-icon .checked {
    display: block;
}

/* Indeterminate state (partial selection) */
.fwd-checkbox-icon .indeterminate {
    display: none;
}

.fwd-checkbox input[data-indeterminate="true"] ~ .fwd-checkbox-icon .unchecked {
    display: none;
}

.fwd-checkbox input[data-indeterminate="true"] ~ .fwd-checkbox-icon .checked {
    display: none;
}

.fwd-checkbox input[data-indeterminate="true"] ~ .fwd-checkbox-icon .indeterminate {
    display: block;
}


.fwd-filter-label {
    flex: 1;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
    line-height: 24px;
}

.fwd-filter-count {
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #8b8e8f;
}

/* ===== Mobile Filter Popup ===== */
.fwd-filter-popup {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
}

@media (min-width: 768px) {
    .fwd-filter-popup {
        display: none !important;
    }
}

.fwd-filter-popup-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.fwd-filter-popup-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    background: white;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.fwd-filter-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #eaeaea;
    background: white;
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.fwd-filter-popup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #183028;
}

.fwd-filter-popup-title-icon {
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0;
}

.fwd-filter-popup-close {
    padding: 8px;
    margin: -8px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fwd-filter-popup-close:hover {
    background: #f5f5f5;
}

.fwd-filter-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Mobile filter section */
.fwd-filter-popup-body .fwd-filter-section-title {
    padding: 12px 8px;
    border-bottom: none;
}

.fwd-filter-popup-body .fwd-filter-item {
    padding: 12px 8px;
    border-radius: 8px;
}

.fwd-filter-popup-footer {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid #eaeaea;
    background: white;
    position: sticky;
    bottom: 0;
}

.fwd-filter-reset-btn {
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #f87722;
    border-radius: 6px;
    background: white;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #f87722;
    cursor: pointer;
    transition: background 0.2s;
}

.fwd-filter-reset-btn:hover:not(:disabled) {
    background: #fff5ed;
}

.fwd-filter-reset-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fwd-filter-apply-btn {
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: #f87722;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: white;
    cursor: pointer;
    transition: opacity 0.2s;
}

.fwd-filter-apply-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.fwd-filter-apply-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fwd-filter-apply-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.fwd-filter-apply-btn.loading .fwd-btn-text {
    visibility: hidden;
}

.fwd-filter-apply-btn .fwd-btn-spinner {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: fwd-spin 0.8s linear infinite;
}

.fwd-filter-apply-btn.loading .fwd-btn-spinner {
    display: block;
}

@keyframes fwd-spin {
    to { transform: rotate(360deg); }
}

/* ===== Show-All / Show-Less Buttons (Filter collapsible sections) ===== */
.fwd-show-all-btn,
.fwd-show-less-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 24px;
    background: none;
    border: none;
    text-align: left;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #0097A8;
    cursor: pointer;
    transition: color 0.2s;
}

.fwd-show-all-btn:hover,
.fwd-show-less-btn:hover {
    color: #0097A8;
    text-decoration: underline;
}

.fwd-show-toggle-icon {
    width: 11px !important;
    height: 7px !important;
    flex-shrink: 0;
}

.fwd-show-all-icon {
    transform: rotate(180deg);
}

/* Mobile popup variant: indent to match items */
#fwd-filter-popup-body .fwd-show-all-btn,
#fwd-filter-popup-body .fwd-show-less-btn {
    padding: 10px 8px;
}

/* ===== Loading & Empty States ===== */
.fwd-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.fwd-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #828282;
}

.fwd-no-categories {
    padding: 16px 24px;
    color: #8b8e8f;
    font-size: 14px;
}

/* ===== AI Summary Toggle ===== */
.fwd-ai-summary-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.fwd-ai-summary-toggle:hover .fwd-ai-summary-label {
    color: #f87722;
}

.fwd-ai-summary-icon {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
}

.fwd-ai-summary-label {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
    transition: color 0.2s;
}

/* ===== AI Disclaimer ===== */
.fwd-ai-disclaimer {
    display: none;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 10px;
    color: #8B8E8F;
    line-height: 1.5;
    padding-left: 32px;
    width: 400px;
}

@media (min-width: 768px) {
    .fwd-ai-disclaimer.fwd-ai-disclaimer-visible {
        display: block;
    }
}



/* Mobile AI Summary Toggle */
.fwd-ai-summary-toggle-mobile {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.fwd-ai-summary-toggle-mobile .fwd-ai-summary-label {
    font-size: 13px;
    white-space: nowrap;
    color: #183028;
}

@media (min-width: 768px) {
    .fwd-ai-summary-toggle-mobile {
        display: none;
    }
}

/* ===== Content Snippet ===== */
.fwd-snippet-wrapper {
    position: relative;
}

.fwd-result-snippet {
    font-family: Arial, "Microsoft YaHei", 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #666;
    line-height: 22px;
    margin: 0;
    word-break: break-word;
}

.fwd-result-snippet mark {
    background-color: transparent;
    color: #0097A8;
    font-weight: 700;
}

/* ===== AI Summary Box ===== */
.fwd-ai-summary-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    margin-top: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    border: none;
    background: #F8F9F9;
    box-sizing: border-box;
    position: relative;
}

.fwd-ai-summary-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 6px;
    padding: 1px;
    background: linear-gradient(90deg, #FED141 2%, #6ECEB2 51%, #0097A8 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}


.fwd-ai-summary-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.fwd-ai-summary-text-wrapper {
    position: relative;
    max-height: 66px;
    overflow: hidden;
}

.fwd-ai-summary-text-wrapper.has-overflow {
    /* When content overflows, ensure proper clipping */
}

.fwd-ai-summary-text {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #183028;
    line-height: 22px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.fwd-ai-summary-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 22px;
    background: linear-gradient(to bottom, transparent 0%, #F8F9F9 100%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.fwd-ai-summary-expand {
    position: absolute;
    bottom: 0;
    right: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #0097A8;
    font-size: 13px;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.fwd-ai-summary-expand:hover {
    opacity: 0.7;
}

.fwd-ai-summary-expand .fwd-ai-summary-arrow {
    transition: transform 0.3s ease;
}

.fwd-ai-summary-expand.hidden {
    display: none;
}

.fwd-ai-summary-text-wrapper.expanded {
    max-height: none;
}

.fwd-ai-summary-text-wrapper.expanded .fwd-ai-summary-text {
    display: block;
    -webkit-line-clamp: unset;
}

.fwd-ai-summary-text-wrapper.expanded .fwd-ai-summary-gradient {
    opacity: 0;
}

@media (min-width: 1440px) {
    .fwd-ai-summary-text-wrapper {
        max-height: none;
    }
    .fwd-ai-summary-text {
        -webkit-line-clamp: unset;
        display: block;
    }
    .fwd-ai-summary-gradient,
    .fwd-ai-summary-expand {
        display: none !important;
    }
}

.fwd-ai-summary-expand.expanded .fwd-ai-summary-arrow {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .fwd-ai-summary-box {
        margin-top: 16px;
        margin-bottom: 16px;
    }

    .fwd-result-meta {
        display: flex;
        flex-direction: column;
        gap: 0;
        margin-top: 8px;
    }

    .fwd-result-meta .fwd-breadcrumb-wrapper {
        margin-top: 8px;
    }

    .fwd-result-meta .fwd-icons-wrapper {
        margin-top: 16px;
    }
}

/* ===== Results Header Controls (Desktop) ===== */
.fwd-results-list-header {
    display: none;
}

@media (min-width: 768px) {
    .fwd-results-list-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        width: 100%;
    }
}

/* Tablet: stack into two rows — Sort+PerPage on top, AI Summary below */
@media (min-width: 768px) and (max-width: 1023px) {
    .fwd-results-list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .fwd-results-list-header .fwd-desktop-controls {
        order: -1;
    }

    .fwd-ai-disclaimer {
        width: auto;
    }
}

/* ===== Empty State ===== */
.fwd-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    width: 100%;
}

.fwd-empty-state-icon {
    margin-bottom: 24px;
}

.fwd-empty-state-title {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: #183028;
    margin-bottom: 12px;
}

.fwd-empty-state-text {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #828282;
    text-align: center;
}

/* ===== Skeleton Loading ===== */
@keyframes fwd-skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.fwd-skeleton {
    animation: fwd-skeleton-pulse 1.5s ease-in-out infinite;
}

.fwd-skeleton-line {
    background: #e0e0e0;
    border-radius: 4px;
}

/* Skeleton Result Item - Basic Version */
.fwd-skeleton-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 0;
    border-bottom: 1px solid #eaeaea;
    animation: fwd-skeleton-pulse 1.5s ease-in-out infinite;
}

.fwd-skeleton-item:last-child {
    border-bottom: none;
}

.fwd-skeleton-title {
    height: 24px;
    background: #e0e0e0;
    border-radius: 4px;
    width: 75%;
    margin-bottom: 8px;
}

.fwd-skeleton-text {
    height: 18px;
    background: #e0e0e0;
    border-radius: 4px;
    width: 100%;
    margin-bottom: 4px;
}

.fwd-skeleton-text-short {
    height: 18px;
    background: #e0e0e0;
    border-radius: 4px;
    width: 85%;
    margin-bottom: 12px;
}

.fwd-skeleton-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.fwd-skeleton-icon {
    width: 20px;
    height: 20px;
    background: #e0e0e0;
    border-radius: 4px;
}

.fwd-skeleton-meta-text {
    height: 12px;
    background: #e0e0e0;
    border-radius: 4px;
    width: 180px;
    margin-left: 8px;
}

/* Skeleton Result Item - With Thumbnail (for image/video) */
.fwd-skeleton-item-thumb {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #eaeaea;
    animation: fwd-skeleton-pulse 1.5s ease-in-out infinite;
}

.fwd-skeleton-item-thumb:last-child {
    border-bottom: none;
}

.fwd-skeleton-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    background: #e0e0e0;
    border-radius: 6px;
}

.fwd-skeleton-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Skeleton Sidebar - now uses #fwd-filter-sidebar directly */
.fwd-skeleton-pulse {
    animation: fwd-skeleton-pulse 1.5s ease-in-out infinite;
}

.fwd-skeleton-section {
    border-bottom: 1px solid #eaeaea;
}

.fwd-skeleton-section:last-child {
    border-bottom: none;
}

.fwd-skeleton-section-title {
    height: 20px;
    background: #e0e0e0;
    border-radius: 4px;
    width: 80px;
    margin: 16px 24px 8px;
}

.fwd-skeleton-filter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid #f5f5f5;
}

.fwd-skeleton-filter-item:last-child {
    border-bottom: none;
}

.fwd-skeleton-checkbox {
    width: 16px;
    height: 16px;
    background: #e0e0e0;
    border-radius: 3px;
    flex-shrink: 0;
}

.fwd-skeleton-filter-label {
    height: 16px;
    background: #e0e0e0;
    border-radius: 4px;
    flex: 1;
}

/* ===== Pagination ===== */
.fwd-pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 20px 0;
}

.fwd-pagination-center {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fwd-page-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 4px;
}

.fwd-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #E0E0E0;
    background: white;
    color: #183028;
    border-radius: 4px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fwd-page-btn:hover:not(.active) {
    border-color: #F87722;
    color: #F87722;
}

.fwd-page-btn.active {
    background: #F87722;
    border-color: #F87722;
    color: white;
}

.fwd-page-ellipsis {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8F959A;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.fwd-pagination-info {
    display: flex;
    align-items: center;
}

.fwd-pagination-text {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #828282;
}

/* ===== Pagination Navigation Arrows ===== */
.fwd-page-nav-btn {
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #828282;
    transition: color 0.15s ease;
}

.fwd-page-nav-btn:hover:not(:disabled) {
    color: #F87722;
}

.fwd-page-nav-btn:disabled {
    cursor: not-allowed;
    color: #8F959A;
}

.fwd-page-nav-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ===== Tablet Pagination ===== */
@media (min-width: 768px) and (max-width: 1024px) {
    .fwd-pagination-center {
        gap: 2px;
    }

    .fwd-page-numbers {
        gap: 2px;
        margin: 0 2px;
    }

    .fwd-page-btn {
        min-width: 28px;
        height: 32px;
        padding: 0 4px;
        font-size: 13px;
        border-radius: 3px;
    }

    .fwd-page-ellipsis {
        min-width: 20px;
        font-size: 13px;
    }

    .fwd-page-nav-btn {
        padding: 4px;
    }

    .fwd-page-nav-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* ===== Mobile Pagination ===== */
@media (max-width: 767px) {
    .fwd-pagination-wrapper {
        padding: 16px 8px;
        gap: 10px;
    }

    .fwd-pagination-center {
        gap: 2px;
    }

    .fwd-page-numbers {
        gap: 2px;
        margin: 0 2px;
    }

    .fwd-page-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 6px;
        font-size: 13px;
        border-radius: 3px;
    }

    .fwd-page-ellipsis {
        min-width: 24px;
        height: 32px;
        font-size: 13px;
    }

    .fwd-page-nav-btn {
        padding: 6px;
    }

    .fwd-page-nav-btn svg {
        width: 14px;
        height: 14px;
    }

    .fwd-pagination-text {
        font-size: 13px;
    }
}

/* ===== Image/Video Preview Modal ===== */
html.fwd-preview-scroll-lock,
body.fwd-preview-scroll-lock {
    overflow: hidden;
    height: 100%;
}

body.fwd-preview-scroll-lock {
    position: fixed;
    width: 100%;
    top: var(--fwd-preview-scroll-y, 0);
}

.fwd-preview-modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fwd-preview-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.6);
}

.fwd-preview-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}


.fwd-preview-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
}

.fwd-preview-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 50px 0px rgba(0, 0, 0, 0.25);
}

.fwd-preview-video {
    max-width: 100%;
    max-height: 90vh;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 25px 50px 0px rgba(0, 0, 0, 0.25);
}

/* PDF Preview Styles */
.fwd-preview-pdf-content {
    width: 90vw;
    height: 90vh;
    max-width: 1200px;
}

.fwd-preview-pdf {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: white;
}

/* Mobile PDF canvas rendering (PDF.js) */
.fwd-pdf-canvas-scroll {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #525659;
    border-radius: 8px;
    padding: 8px 0;
}

.fwd-pdf-canvas-page {
    display: block;
    margin: 0 auto 8px;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.fwd-pdf-canvas-page:last-child {
    margin-bottom: 0;
}

.fwd-preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 8px;
}

.fwd-preview-error svg {
    margin-bottom: 16px;
}

.fwd-preview-error p {
    font-size: 16px;
    line-height: 1.5;
    max-width: 400px;
    margin: 0 0 20px;
}

.fwd-preview-error-btn {
    display: inline-block;
    padding: 10px 24px;
    background: #e8750a;
    color: white !important;
    border-radius: 6px;
    text-decoration: none !important;
    font-weight: 500;
    transition: background 0.2s;
}

.fwd-preview-error-btn:hover {
    background: #d06a09;
}

/* Office Document Preview Styles */
.fwd-preview-office-content {
    width: 90vw;
    height: 90vh;
    max-width: 1200px;
}

.fwd-preview-office {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: white;
}

/* Office Document Preview Content */
.fwd-office-content {
    width: 90vw;
    max-width: 800px;
    background: white;
    border-radius: 12px;
    padding: 48px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.fwd-office-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
}

.fwd-office-icon {
    opacity: 0.8;
}

.fwd-office-note {
    color: #666;
    font-size: 14px;
    margin: 0;
    max-width: 300px;
}

.fwd-office-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #F87722;
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}

.fwd-office-download-btn:hover {
    background: #e56a1a;
}

/* Office Document Content Styles */
.fwd-office-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.fwd-office-docx,
.fwd-office-xlsx {
    width: 90vw;
    max-width: 1000px;
    max-height: 85vh;
    padding: 0;
}

.fwd-office-pptx {
    width: 95vw;
    max-width: 1200px;
    max-height: 90vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.fwd-office-pptx-container {
    flex: 1;
    overflow: auto;
    background: #444;
    min-height: 500px;
}

/* PPTX slide styles - vertical stack like demo3 */
.fwd-pptx-slides {
    height: 100%;
    overflow-y: auto;
    padding: 10px;
}

.fwd-pptx-toolbar {
    background: #f5f5f5;
    padding: 10px 16px;
    border-bottom: 1px solid #ddd;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.fwd-pptx-counter {
    font-size: 14px;
    color: #333;
}

.fwd-pptx-all-slides {
    /* Scale transform applied via JS */
}

.fwd-pptx-all-slides .slide {
    background: white;
    margin: 10px auto;
    padding: 20px;
    max-width: 960px;
    min-height: 540px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
}

/* Scaled slides (50%) */
.fwd-pptx-all-slides.scaled-50 .slide {
    transform: scale(0.5);
    transform-origin: top center;
    margin-bottom: -270px; /* Compensate for scaled height */
}

.fwd-pptx-slide-inner {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
}

.fwd-pptx-slide-inner p {
    margin: 0 0 12px 0;
}

.fwd-pptx-slide-inner img {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
}

.fwd-office-scrollable {
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    line-height: 1.6;
}

.fwd-office-scrollable p { margin: 0 0 12px 0; }

.fwd-office-scrollable table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
}

.fwd-office-scrollable th,
.fwd-office-scrollable td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.fwd-office-scrollable th {
    background: #f5f5f5;
    font-weight: 600;
}

/* Sheet Navigation */
.fwd-office-sheet-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-bottom: 1px solid #eaeaea;
}

.fwd-office-sheet-tab {
    padding: 8px 16px;
    border: none;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    transition: all 0.2s;
}

.fwd-office-sheet-tab:hover { background: #e0e0e0; }

.fwd-office-sheet-tab.active {
    background: #F87722;
    color: white;
}

.fwd-office-sheet-content {
    padding: 16px;
    overflow: auto;
    max-height: calc(85vh - 60px);
}

.fwd-office-sheet-content table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}

.fwd-office-sheet-content th,
.fwd-office-sheet-content td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}

.fwd-office-sheet-content th {
    background: #f9f9f9;
    font-weight: 600;
}

/* Office Error */
.fwd-office-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    gap: 16px;
}

.fwd-office-error-msg {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.fwd-preview-title-bar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Preview Loading Indicator */
.fwd-preview-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    padding: 24px 32px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fwd-preview-loader span {
    color: #666;
    font-size: 14px;
}

/* Loading Spinner */
.fwd-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f0f0f0;
    border-top-color: #f87722;
    border-radius: 50%;
    animation: fwd-spin 1s linear infinite;
}

@keyframes fwd-spin {
    to { transform: rotate(360deg); }
}

/* Preview Status Message */
.fwd-preview-status {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    z-index: 100;
    white-space: nowrap;
}

.fwd-preview-status.error {
    background: rgba(220, 53, 69, 0.9);
}

/* Preview Actions (Download button fallback) */
.fwd-preview-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.fwd-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #f87722;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.fwd-btn-download:hover {
    background: #e56a1a;
}

/* Download Hint Modal */
.fwd-download-hint-content {
    position: relative;
    background: white;
    padding: 32px;
    border-radius: 8px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 1001;
}

.fwd-download-hint-content h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #333;
}

.fwd-download-hint-content p {
    margin: 0 0 20px 0;
    color: #666;
    line-height: 1.5;
    font-size: 16px;
}

/* Manual download link - de-emphasized to avoid left-click confusion */
.fwd-download-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #f5f5f5;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    word-break: break-all;
    border: 1px dashed #ccc;
    cursor: context-menu;
}

.fwd-download-link-btn:hover {
    background: #eee;
    border-color: #999;
}

.fwd-download-link-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.fwd-download-hint-note {
    font-size: 13px;
    color: #999;
    margin: 0;
}

.fwd-download-hint-content .fwd-preview-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

/* ===== Thumbnail Styles ===== */
.fwd-result-thumbnail-wrapper {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    width: 100%;
}

.fwd-result-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.2s;
    background: #f5f5f5;
}

.fwd-result-thumbnail:hover {
    opacity: 0.9;
}

.fwd-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.fwd-result-thumbnail .fwd-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.fwd-result-thumbnail .fwd-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fwd-result-thumbnail .fwd-play-btn svg {
    width: 20px;
    height: 20px;
    fill: #f87722;
    margin-left: 2px;
}

.fwd-result-title-wrapper {
    flex: 1;
    min-width: 0;
}

/* ===== Preview / Download / Link Buttons in Meta ===== */
.fwd-preview-btn,
.fwd-download-btn,
.fwd-link-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
    text-decoration: none;
}

.fwd-preview-btn:hover,
.fwd-download-btn:hover,
.fwd-link-btn:hover {
    opacity: 1;
}

/* ===== To Top Button (Theme Element) ===== */
.to-top {
    opacity: 0.5 !important;
    transition: opacity 0.3s ease, transform 0.3s ease, bottom 0.3s ease !important;
    bottom: 65px !important;
    width: 25px !important;
    height: 25px !important;
    line-height: 25px !important;
    transform: translateY(0) !important;
}

.to-top:hover {
    opacity: 1 !important;
    transform: translateY(-4px) !important;
    bottom: 70px !important;
}

.to-top i.fa {
    font-size: 14px !important;
    line-height: 25px !important;
}

/* ===== Timeout Error Modal ===== */
.fwd-timeout-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.fwd-timeout-modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px 40px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
}

.fwd-timeout-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.fwd-timeout-close-btn:hover {
    opacity: 1;
}

.fwd-timeout-modal-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
}

.fwd-timeout-modal-title {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #183028;
    margin: 0 0 8px;
}

.fwd-timeout-modal-message {
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    color: #5c6b5c;
    margin: 0 0 24px;
    line-height: 1.5;
    text-align: center;
}

.fwd-timeout-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: #f87722;
    color: white;
    border: none;
    border-radius: 6px;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.fwd-timeout-modal-btn:hover {
    background: #e5651a;
}

/* ===== Error Log Toggle (inside Timeout Modal) ===== */
.fwd-error-log-wrapper {
    margin: 0 0 20px;
    text-align: center;
}

.fwd-error-log-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 13px;
    color: #5c6b5c;
    transition: color 0.2s;
}

.fwd-error-log-toggle:hover {
    color: #183028;
}

.fwd-error-log-toggle-icon {
    transition: transform 0.2s;
}

.fwd-error-log-toggle.expanded .fwd-error-log-toggle-icon {
    transform: rotate(180deg);
}

.fwd-error-log-content {
    margin-top: 8px;
    max-height: 160px;
    overflow-y: auto;
    border-radius: 6px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
}

.fwd-error-log-pre {
    margin: 0;
    padding: 10px 12px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #d32f2f;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
}

.fwd-error-log-copy-btn {
    display: block;
    margin: 0 0 0 auto;
    padding: 4px 12px;
    background: none;
    border: none;
    border-top: 1px solid #e0e0e0;
    cursor: pointer;
    font-family: Arial, 'Noto Sans JP', sans-serif;
    font-size: 12px;
    color: #5c6b5c;
    transition: color 0.2s, background 0.2s;
    width: 100%;
    text-align: right;
}

.fwd-error-log-copy-btn:hover {
    color: #183028;
    background: #ebebeb;
}

.fwd-error-log-copy-btn.copied {
    color: #2e7d32;
}

/* ===== Permission Error Modal (Download + Preview 403) ===== */
.fwd-permission-error-content {
    padding: 32px 40px;
}

.fwd-permission-error-title {
    font-family: 'FWD Circular', Arial, 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 100%;
    letter-spacing: 0;
    text-align: center;
    color: #183028;
    margin: 0 0 12px;
}

.fwd-permission-error-desc {
    font-family: 'FWD Circular', Arial, 'Noto Sans JP', sans-serif;
    font-weight: 450;
    font-size: 14px;
    line-height: 100%;
    letter-spacing: 0;
    text-align: center;
    color: #5c6b5c;
    margin: 0 0 24px;
}

.fwd-permission-error-content .fwd-timeout-modal-btn {
    font-family: 'FWD Circular', Arial, 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 14px;
    line-height: 100%;
    letter-spacing: 0;
}
