/* app/web/static/feed.css */
:root {
    color-scheme: light;
    --page-bg: #f4f6fb;
    --panel-bg: #ffffff;
    --border-color: #d9e0ea;
    --text-color: #1f2937;
    --muted-color: #6b7280;
    --accent-color: #2563eb;
    --tag-bg: #eef3ff;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --content-max-width: 1420px;
    --soft-border: #e7ecf3;
    --soft-bg: #f8fbff;
    --card-hover-bg: #f9fbff;
    --detail-bg: #fcfdff;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--page-bg);
    color: var(--text-color);
    overflow-x: hidden;
    overflow-y: auto;
}

button,
input,
select {
    font: inherit;
}

.mobile-only {
    display: none !important;
}

.page {
    width: min(var(--content-max-width), calc(100% - 32px));
    min-height: calc(100vh - 32px);
    margin: 16px auto;
    display: flex;
    flex-direction: column;
}

.page-header {
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.page-header h1 {
    margin: 0 0 4px;
    font-size: 30px;
    line-height: 1.1;
}

.page-subtitle {
    margin: 0;
    color: var(--muted-color);
    font-size: 14px;
}

.page-header-actions {
    flex: 0 0 auto;
}

.toolbar-top-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    justify-content: space-between;
}

.toolbar-actions-top {
    margin-top: 0;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
}

.toolbar-actions-top .page-link-button,
.toolbar-actions-top button {
    min-height: 30px;
    padding: 0 12px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
}

#toggle-filters-button,
#feed-show-more-button {
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
}

#toggle-filters-button {
    min-width: 132px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    background: #f7faff;
    color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.06);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

#toggle-filters-button:hover {
    border-color: rgba(37, 99, 235, 0.22);
    background: #eef4ff;
    color: #1d4ed8;
}

#toggle-filters-button:focus-visible,
#feed-show-more-button:focus-visible,
#close-detail-button:focus-visible {
    outline: none;
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

#toggle-filters-button[aria-expanded="true"] {
    border-color: rgba(37, 99, 235, 0.24);
    background: #eaf2ff;
    color: #1d4ed8;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
}

.toolbar-filters-panel {
    display: block;
    margin-top: 4px;
}

.toolbar-filters-panel.is-collapsed-mobile {
    display: block;
}

.page-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--soft-border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-color);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.page-link-button:hover {
    background: var(--card-hover-bg);
    border-color: #d6deea;
}

.page-link-button:focus-visible {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.toolbar {
    background: var(--panel-bg);
    border: 1px solid var(--soft-border);
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
    padding: 6px 8px;
    margin-bottom: 8px;
}

.toolbar-search {
    margin-bottom: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.toolbar-search label,
.filter-group label {
    display: block;
    margin-bottom: 3px;
    font-size: 10px;
    color: var(--muted-color);
    font-weight: 600;
}

.toolbar-search input,
.filter-group input,
.filter-group select {
    width: 100%;
    min-height: 32px;
    border: 1px solid var(--soft-border);
    border-radius: 8px;
    background: #fff;
    padding: 0 9px;
    color: var(--text-color);
}

.toolbar-search input:focus,
.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.toolbar-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 4px 6px;
}

.filter-group {
    min-width: 0;
}

.filter-group.is-hidden {
    display: none;
}

.toolbar-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.toolbar-actions button {
    min-height: 30px;
    border: 0;
    border-radius: 8px;
    padding: 0 10px;
    cursor: pointer;
    background: var(--accent-color);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-actions .secondary-button {
    background: #eef2f7;
    color: var(--text-color);
}

.feed-load-more-slot {
    display: none;
}

#feed-show-more-button {
    display: inline-flex;
    width: auto;
    min-width: 170px;
    min-height: 34px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    background: #f7faff;
    color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.06);
}

#feed-show-more-button[hidden] {
    display: none !important;
}

.content-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.84fr);
    gap: 12px;
    align-items: start;
    min-height: 0;
    flex: 1 1 auto;
}

.section-header-feed,
.section-header-detail {
    align-items: center;
}

.section-header-feed {
    position: sticky;
    top: 0;
    z-index: 4;
    backdrop-filter: blur(8px);
}

.feed-list-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 420px;
    height: clamp(420px, calc(100vh - 220px), 900px);
    overflow: hidden;
}

.feed-list-body {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.feed-list {
    min-width: 0;
    min-height: 0;
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 0;
}

.feed-list-body > .feed-load-more-slot,
.feed-list-body > .empty-state {
    position: relative;
    z-index: 1;
}

.feed-card + .feed-card {
    margin-top: 8px;
}

.feed-card {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--soft-border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.feed-card.is-selected {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
    background: var(--soft-bg);
}

.feed-card-button {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 11px 12px;
    cursor: pointer;
}

.feed-card-button:hover {
    background: var(--card-hover-bg);
}

.feed-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted-color);
    font-size: 11px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.feed-card-title {
    margin: 0 0 5px;
    font-size: 14px;
    line-height: 1.3;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.feed-card-summary {
    margin: 0;
    color: #475569;
    line-height: 1.35;
    font-size: 11px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.feed-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    flex-wrap: wrap;
}

.feed-card-lang,
.feed-card-translation,
.detail-tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--tag-bg);
    color: #31508f;
    font-size: 10px;
    font-weight: 600;
}

.empty-state,
.empty-detail {
    color: var(--muted-color);
    font-size: 15px;
}

.empty-state {
    padding: 0 18px 18px;
    flex: 0 0 auto;
}

.empty-state[hidden] {
    display: none !important;
}

.feed-detail.empty-detail {
    padding-top: 8px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.detail-title {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.detail-summary,
.detail-original {
    margin: 0 0 10px;
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 12px;
}

.detail-block {
    border-top: 1px solid var(--soft-border);
    padding-top: 8px;
    margin-top: 10px;
}

.detail-block h3 {
    margin: 0 0 5px;
    font-size: 13px;
}

.detail-link {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 7px;
    text-decoration: none;
    background: var(--accent-color);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

#close-detail-button {
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    background: #f7faff;
    color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

#close-detail-button:hover {
    border-color: rgba(37, 99, 235, 0.22);
    background: #eef4ff;
    color: #1d4ed8;
}

.detail-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-chip {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 10px;
}

.feed-detail-section {
    position: sticky;
    top: 16px;
    align-self: start;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    background: var(--detail-bg);
}

@media (max-height: 900px) {
    .feed-list-section {
        height: clamp(340px, calc(100vh - 170px), 760px);
        min-height: 340px;
    }

    .feed-detail-section {
        max-height: calc(100vh - 20px);
    }

    .feed-detail-body {
        max-height: calc(100vh - 108px);
    }
}

.feed-detail-body {
    max-height: calc(100vh - 120px);
    padding: 12px 14px 14px;
    overflow: auto;
}

.feed-detail {
    overflow: visible;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px 10px;
    flex-wrap: wrap;
    background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(252,253,255,0.94) 100%);
    border-bottom: 1px solid var(--soft-border);
}

.section-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.section-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.section-header-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
    padding-left: 12px;
}

.feed-summary {
    color: var(--muted-color);
    font-size: 12px;
    white-space: nowrap;
    line-height: 1.3;
    font-weight: 500;
}

.mobile-preview-hint {
    margin-top: 6px;
    color: var(--muted-color);
    font-size: 11px;
    line-height: 1.35;
}

@media (max-width: 1380px) {
    .toolbar-filters {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 8px;
    }
}

@media (max-width: 1280px) {
    .content-layout {
        grid-template-columns: minmax(0, 0.98fr) minmax(300px, 0.78fr);
        gap: 10px;
    }

    .feed-detail-body {
        padding: 10px 12px 12px;
    }

    .detail-title {
        font-size: 16px;
    }

    .detail-summary,
    .detail-original {
        font-size: 11px;
    }
}

#feed-floating-actions {
    box-sizing: border-box;
}

#feed-floating-actions button {
    appearance: none;
    -webkit-appearance: none;
}

#feed-floating-actions button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

@media (max-width: 1120px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .feed-list-section {
        width: 100%;
        max-width: 100%;
        min-height: 0;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .feed-list-body {
        height: auto;
        overflow: visible;
    }

    .feed-list {
        width: 100%;
        max-width: 100%;
        height: auto;
        overflow: visible;
        max-height: none;
    }

    .feed-detail-section {
        display: none;
        position: static;
        top: auto;
        max-height: none;
    }

    .feed-detail-body {
        max-height: none;
        overflow: visible;
    }

    .section-header-feed {
        position: sticky;
        top: 8px;
        z-index: 20;
        margin-bottom: 8px;
        border: 1px solid rgba(231, 236, 243, 0.95);
        border-radius: 12px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
        backdrop-filter: blur(8px);
        transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
        will-change: transform, opacity;
    }

    body.show-feed-detail .feed-list-section {
        display: none;
    }

    body.show-feed-detail .feed-detail-section {
        display: block;
    }
}

@media (max-width: 1120px) {
    body.feed-header-hidden-mobile .section-header-feed {
        transform: translateY(calc(-100% - 10px));
        opacity: 0;
        pointer-events: none;
    }

    body.feed-header-visible-mobile .section-header-feed {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 820px) {
    .page {
        width: min(100%, calc(100% - 20px));
        margin: 12px auto;
        min-height: calc(100vh - 24px);
    }

    .page-header {
        flex-direction: column;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-link-button {
        min-height: 36px;
    }

    .toolbar {
        padding: 6px;
    }

    .toolbar-filters-panel.is-collapsed-mobile {
        display: none;
    }

    .toolbar-top-row {
        flex-direction: row;
        align-items: end;
        gap: 6px;
    }

    .toolbar-search {
        margin-bottom: 0;
    }

    .toolbar-actions-top {
        width: auto;
        justify-content: flex-end;
        flex: 0 0 auto;
        gap: 6px;
    }

    #feed-floating-actions {
        left: 10px !important;
        right: 10px !important;
        top: 10px !important;
        gap: 8px !important;
        padding: 8px !important;
        border-radius: 14px !important;
    }

    #feed-floating-actions button {
        min-height: 38px !important;
        font-size: 12px !important;
        padding: 0 12px !important;
    }

    #toggle-filters-button,
    #feed-show-more-button {
        min-height: 28px;
        padding: 0 10px;
        font-size: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1;
    }

    #close-detail-button {
        min-height: 28px;
        padding: 0 10px;
        font-size: 10px;
    }

    .toolbar-filters {
        grid-template-columns: 1fr 1fr;
        gap: 4px 6px;
    }

    .section-header-main {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .section-header-meta {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        margin-left: 0;
        padding-left: 0;
        gap: 8px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header-feed,
    .section-header-detail {
        align-items: stretch;
    }

    .section-header-feed {
        position: sticky;
        top: 8px;
        z-index: 20;
        margin-bottom: 8px;
        border: 1px solid rgba(231, 236, 243, 0.95);
        border-radius: 12px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
        backdrop-filter: blur(8px);
        transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
        will-change: transform, opacity;
    }

    .feed-summary {
        white-space: normal;
    }

    #feed-show-more-button {
        width: 100%;
        min-width: 0;
    }

    .mobile-only {
        display: inline-flex !important;
    }

    .feed-list-section {
        width: 100%;
        max-width: 100%;
        min-height: 0;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .feed-list,
    .feed-card,
    .feed-card-button {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .feed-detail-section {
        display: none;
    }

    body.show-feed-detail .feed-list-section {
        display: none;
    }

    body.show-feed-detail .feed-detail-section {
        display: block;
    }
}

@media (max-width: 560px) {
    .page {
        width: min(100%, calc(100% - 12px));
        margin: 6px auto;
        min-height: calc(100vh - 12px);
    }

    .page-header h1 {
        font-size: 24px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    .toolbar {
        border-radius: 12px;
        padding: 6px;
    }

    .toolbar-search {
        margin-bottom: 0;
    }

    .toolbar-filters-panel {
        margin-top: 6px;
    }

    .toolbar-filters {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .section-header {
        padding: 12px 12px 8px;
    }

    .section-header-feed {
        top: 6px;
        margin-bottom: 6px;
        border-radius: 10px;
        backdrop-filter: blur(8px);
        transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
    }

    .section-header-meta {
        align-items: stretch;
        gap: 8px;
    }

    #feed-show-more-button {
        width: 100%;
        min-width: 0;
    }

    #toggle-filters-button {
        width: auto;
        min-width: 116px;
    }

    #close-detail-button {
        width: 100%;
    }

    .toolbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions-top {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }

    #feed-floating-actions {
        left: 8px !important;
        right: 8px !important;
        top: 8px !important;
        gap: 6px !important;
        padding: 6px !important;
        border-radius: 12px !important;
    }

    #feed-floating-actions button {
        min-height: 36px !important;
        font-size: 11px !important;
        padding: 0 10px !important;
    }

    .toolbar-actions button,
    .toolbar-actions-top button,
    .toolbar-actions-top a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1;
    }

    .content-layout {
        gap: 10px;
    }

    .feed-list-section,
    .feed-detail-section {
        border-radius: 14px;
    }

    .feed-list {
        padding: 8px;
    }

    .section-header-main {
        gap: 8px;
    }

    .section-header-meta {
        gap: 8px;
    }

    .feed-card-meta {
        gap: 4px;
        font-size: 10px;
    }

    .feed-card-title {
        font-size: 12px;
        line-height: 1.28;
    }

    .feed-card-summary {
        font-size: 10px;
        line-height: 1.3;
    }

    .feed-card-button {
        padding: 10px;
    }

    /* Removed duplicate .feed-card-title and .feed-card-summary for mobile */

    .mobile-preview-hint {
        font-size: 10px;
    }

    .detail-title {
        font-size: 18px;
    }

    .feed-detail-body {
        padding: 12px;
    }
}