.nse {
    --nse-border: rgba(18, 18, 18, 0.16);
    --nse-card-border: rgba(18, 18, 18, 0.28);
    --nse-card-shadow: 0 1px 2px rgba(18, 18, 18, 0.06), 0 8px 24px rgba(18, 18, 18, 0.06);
    --nse-muted: #666;
    --nse-panel: #fffaf6;
    margin: 0 0 2.5rem;
}

.dark-theme .nse {
    --nse-border: rgba(250, 250, 250, 0.22);
    --nse-card-border: var(--nse-border);
    --nse-card-shadow: none;
    --nse-muted: #b8b8b8;
    --nse-panel: #222;
}

.nse *,
.nse *::before,
.nse *::after {
    box-sizing: border-box;
}

.nse [hidden] {
    display: none !important;
}

/* Visually hidden, but still available to screen readers. */
.nse-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.nse__filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.4fr);
    gap: 1rem;
    align-items: end;
    min-width: 0;
    padding: 1.25rem;
    margin: 0 0 1.5rem;
    background: var(--nse-panel);
    border: 0;
    border-radius: 8px;
}

.nse__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.nse__label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.2;
    text-transform: uppercase;
}

.nse__field .select-css {
    margin: 0;
}

.nse__input {
    width: 100%;
    padding: 0.75em;
    font-size: 1rem;
    color: #121212;
    background: #fff;
    border: 1px solid #121212;
    border-radius: 4px;
    transition: border-color 0.25s ease-in-out;
}

.nse__input:focus {
    border-color: #d4420c;
    outline: 2px solid #d4420c;
    outline-offset: 2px;
}

/* Same colour as the selected text in the dropdowns. */
.nse__input::placeholder {
    color: #121212;
    opacity: 1;
}

.nse__field .select-css:focus {
    border-color: #d4420c;
    outline: 2px solid #d4420c;
    outline-offset: 2px;
}

.nse__switch {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0 0;
    font-size: 0.9375rem;
    line-height: 1.3;
    cursor: pointer;
    user-select: none;
}

.nse__switch input {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: #d4420c;
}

.nse__status {
    min-height: 1.5em;
    margin: 0 0 1rem;
    color: var(--nse-muted);
    font-size: 0.875rem;
}

.nse__group + .nse__group {
    margin-top: 2rem;
}

/* The site theme styles `.content ul` with markers and item margins.
   Scope the resets with `.nse` so they win against those theme rules. */
.nse ul.nse__list,
.nse ul.nse-card__meta,
.nse ul.nse-card__badges {
    list-style: none;
    padding: 0;
}

.nse ul.nse__list,
.nse ul.nse-card__meta {
    margin: 0;
}

.nse ul.nse-card__badges {
    margin: 0;
    margin-top: auto;
}

.nse .nse__list-item,
.nse .nse-card__meta li,
.nse .nse-card__badges li {
    margin: 0;
}

.nse__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nse__list-item {
    display: flex;
    min-width: 0;
}

.nse-card {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--nse-card-border);
    border-radius: 8px;
    background: transparent;
    box-shadow: var(--nse-card-shadow);
}

.nse-card__date {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--nse-border);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
}

.nse-card__date-main {
    font-size: 1.125rem;
}

.nse-card__date-sep {
    color: var(--nse-muted);
}

.nse-card__time {
    white-space: nowrap;
    color: var(--nse-muted);
    font-weight: 300;
}

.nse-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.875rem;
}

.nse-card__title {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.25;
}

.nse-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin: 0;
    padding: 0;
    color: var(--nse-muted);
    font-size: 0.9375rem;
    line-height: 1.35;
    list-style: none;
}

.nse-card__meta li {
    position: relative;
}

.nse-card__meta li + li::before {
    content: "·";
    margin-right: 0.75rem;
}

.nse-card__teaser p {
    font-size: 1rem;
    line-height: 1.4;
}

.nse-card__teaser > :first-child {
    margin-top: 0;
}

.nse-card__teaser > :last-child {
    margin-bottom: 0;
}

.nse-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
    margin-bottom: 0;
    padding: 0;
    list-style: none;
}

.nse-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    color: inherit;
    background: var(--nse-panel);
    border: 1px solid var(--nse-border);
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1.3;
}

.nse-card__link {
    align-self: flex-start;
    margin: 0.25rem 0 0;
}

.nse__empty {
    padding: 1.5rem;
    margin: 0;
    border: 1px dashed var(--nse-border);
    border-radius: 8px;
    color: var(--nse-muted);
    text-align: center;
}

.nse__empty--filtered {
    margin-top: 1.5rem;
}

/* Dark theme: search field and dropdowns share the same dark surface, so the
   dropdowns do not appear as white boxes inside the filter panel. */
.dark-theme .nse {
    color-scheme: dark;
}

.dark-theme .nse__input,
.dark-theme .nse__field .select-css {
    color: #fafafa;
    background-color: #121212;
    border-color: rgba(250, 250, 250, 0.55);
}

/* The theme's arrow icon is black, which is invisible on the dark surface. */
.dark-theme .nse__field .select-css {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z' fill='%23fafafa'/%3E%3C/svg%3E"),
        linear-gradient(to bottom, #121212 0%, #121212 100%);
}

/* Native option lists (Windows/Linux) follow the same colours. */
.dark-theme .nse__field .select-css option {
    color: #fafafa;
    background-color: #121212;
}

.dark-theme .nse__input::placeholder {
    color: #fafafa;
}

.dark-theme .nse__input:focus,
.dark-theme .nse__field .select-css:focus {
    border-color: coral;
    outline-color: coral;
}

.dark-theme .nse__switch input {
    accent-color: coral;
}

@media (max-width: 900px) {
    .nse__filters {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    .nse__filters {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

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

    .nse-card {
        padding: 1rem;
    }
}
