.app-section {
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

:root {
    --app-surface: #ffffff;
    --app-surface-muted: #fff7f7;
    --app-border: rgba(17, 17, 17, 0.08);
    --app-table-row: #ffffff;
    --app-table-row-alt: #faf4f4;
    --app-table-hover: #f4eded;
    --app-muted-text: #666666;
    --app-thumb-surface: #f3f3f3;
}

@media (prefers-color-scheme: dark) {
    :root {
        --app-surface: #181818;
        --app-surface-muted: #201818;
        --app-border: rgba(255, 255, 255, 0.1);
        --app-table-row: #181818;
        --app-table-row-alt: #1f1f1f;
        --app-table-hover: #262626;
        --app-muted-text: #b5b5b5;
        --app-thumb-surface: #242424;
    }
}

.app-logo {
    object-fit: cover;
    border-radius: 999px;
}

.narrow-container {
    width: 100%;
    max-width: 32rem;
    margin: 0 auto;
}

.narrow-container.is-medium {
    max-width: 40rem;
}

.box,
.card {
    box-shadow: none;
    border: 0;
    background: var(--app-surface);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-actions,
.story-admin-actions,
.story-actions-group,
.media-toolbar-group,
.creator-filter-group,
.action-stack,
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.inline-form {
    display: inline-flex;
    align-items: center;
}

.filter-toggle {
    width: 100%;
    max-width: 14rem;
}

.filters-panel {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.2s ease;
}

.filters-panel.is-active {
    max-height: 72rem;
    opacity: 1;
    margin-top: 1rem;
}

.filter-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.filter-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
}

.desktop-only {
    display: table-cell;
}

.mobile-only {
    display: none;
}

.responsive-table {
    table-layout: auto;
    background: transparent;
    color: inherit;
}

.responsive-table td,
.responsive-table th {
    vertical-align: top;
    background: transparent;
    border-color: var(--app-border);
    color: inherit;
}

.responsive-table thead th {
    background: transparent;
    color: inherit;
}

.responsive-table tbody tr {
    background: var(--app-table-row);
}

.table.responsive-table.is-striped tbody tr:not(.is-selected):nth-child(even) {
    background: var(--app-table-row-alt);
}

.table.responsive-table.is-hoverable tbody tr:not(.is-selected):hover {
    background: var(--app-table-hover);
}

.summary-cell {
    white-space: normal;
    overflow-wrap: anywhere;
}

.category-badge {
    background: var(--category-color, #dbdbdb);
    color: #1f1f1f;
}

.category-label {
    color: var(--category-color, #363636);
    font-weight: 600;
}

.story-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.story-meta-grid,
.media-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.story-meta-item,
.media-detail {
    padding: 1rem;
    border-radius: 0.9rem;
    background: var(--app-surface);
}

.story-summary {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.9rem;
    background: var(--app-surface-muted);
}

.story-read-shell {
    max-width: 56rem;
    margin: 0 auto;
}

.story-tags {
    margin-bottom: 1rem;
}

.story-content {
    padding: 1.25rem;
    border-radius: 0.9rem;
    background: var(--app-surface);
    overflow-wrap: anywhere;
    line-height: 1.75;
}

.story-content > *:first-child {
    margin-top: 0;
}

.story-content > *:last-child {
    margin-bottom: 0;
}

.story-content img,
.story-content video {
    max-width: 100%;
    height: auto;
}

.story-actions,
.media-toolbar,
.creator-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.story-actions {
    margin: 1.5rem 0;
}

.page-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

.page-navigation-status {
    flex: 1 1 auto;
    text-align: center;
}

.media-viewer {
    padding: 1rem;
    border-radius: 0.9rem;
    background: var(--app-surface);
}

.media-viewer img,
.media-viewer video {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0.75rem;
}

.media-fallback {
    text-align: center;
    padding: 2rem 1rem;
}

.creator-card,
.creator-media-card {
    height: 100%;
}

.creator-media-card {
    overflow: hidden;
    background: var(--app-surface);
}

.creator-card-link,
.creator-media-link {
    display: block;
    height: 100%;
}

.creator-media-thumb {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--app-thumb-surface);
}

.creator-media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.creator-media-meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.creator-grid {
    margin-top: 1rem;
}

.legend-shell {
    max-width: 800px;
    margin: 0 auto;
}

.legend-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 1rem;
}

.legend-column {
    min-width: 0;
}

.legend-list {
    padding-left: 1.1rem;
}

.tag-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.empty-state {
    padding: 1.25rem;
    border: 1px dashed var(--app-border);
    border-radius: 0.9rem;
    text-align: center;
    background: var(--app-surface-muted);
}

.form-help-inline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tag.is-cyan {
    background-color: #00bcd4;
    color: #000;
}

.tag.is-purple {
    background-color: #9c27b0;
    color: #000;
}

.tag.is-purple-light {
    background-color: #834e8d;
    color: #000;
}

.tag.is-orange {
    background-color: #ff9800;
    color: #000;
}

@media screen and (max-width: 768px) {
    .app-section {
        padding-top: 1rem;
        padding-bottom: 1.5rem;
    }

    .page-actions,
    .story-admin-actions,
    .media-toolbar-group,
    .creator-filter-group,
    .action-stack,
    .table-actions,
    .inline-form {
        width: 100%;
    }

    .filter-toggle,
    .filter-actions .button,
    .media-toolbar .button,
    .story-actions .button,
    .page-navigation .button,
    .creator-toolbar .button {
        width: 100%;
        max-width: none;
    }

    .creator-toolbar .field.has-addons {
        width: 100%;
        flex-direction: column;
    }

    .creator-toolbar .field.has-addons .control,
    .creator-toolbar .field.has-addons .select,
    .creator-toolbar .field.has-addons .select select {
        width: 100%;
    }

    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table th,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        margin-bottom: 0.9rem;
        border: 1px solid var(--app-border);
        border-radius: 0.9rem;
        overflow: hidden;
        background: var(--app-table-row);
    }

    .responsive-table td {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--app-border);
        text-align: left;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
    }

    .responsive-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.3rem;
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--app-muted-text);
    }

    .responsive-table .buttons,
    .responsive-table .action-stack {
        flex-direction: column;
        align-items: stretch;
    }

    .responsive-table .buttons .button,
    .responsive-table .action-stack .button {
        width: 100%;
    }

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

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

    .story-actions,
    .media-toolbar,
    .creator-toolbar,
    .page-navigation {
        align-items: stretch;
    }

    .story-actions-group {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .story-title-row .title {
        font-size: 1.75rem;
    }

    .page-navigation-status {
        width: 100%;
        text-align: left;
    }

    .story-content {
        padding: 1rem;
    }

    .legend-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (min-width: 769px) {
    .desktop-only {
        display: table-cell !important;
    }

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