
:root {
    --blue-950: #071b42;
    --blue-900: #0a2860;
    --blue-700: #125bd4;
    --blue-600: #1d6fe8;
    --blue-100: #eaf2ff;
    --blue-50: #f5f9ff;
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-soft: #f9fbff;
    --text: #15213a;
    --muted: #6f7b91;
    --border: #dfe6f1;
    --shadow: 0 8px 28px rgba(18, 48, 90, 0.08);
    --logo-accent: #58a2ff;
    --header-height: 78px;
    --bar-height: 86px;
}

html[data-theme="dark"] {
    --logo-accent: var(--blue-700);
    --bg: #0d1421;
    --surface: #151f30;
    --surface-soft: #111a29;
    --text: #f3f6fb;
    --muted: #a7b3c7;
    --border: #2a3850;
    --blue-700: #63b3ff;
    --blue-600: #2f8cff;
    --blue-100: #17325d;
    --blue-50: #13233b;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background .2s ease, color .2s ease;
}

button, select, input { font: inherit; }
button { cursor: pointer; }

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: var(--header-height);
    background: linear-gradient(120deg, var(--blue-900), var(--blue-950));
    color: #fff;
    box-shadow: 0 2px 14px rgba(5, 26, 64, .22);
}

.header-inner {
    max-width: 1500px;
    min-height: var(--header-height);
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: 29px;
    font-weight: 800;
    font-style: italic;
    letter-spacing: -.5px;
    white-space: nowrap;
}

.logo:focus-visible {
    outline: 2px solid var(--logo-accent);
    outline-offset: 5px;
    border-radius: 4px;
}

.logo-mark { width: 50px; height: 40px; flex-shrink: 0; }
.logo-outline, .logo-lines {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.logo-lines { stroke-width: 2; opacity: .8; }
.logo-highlight { fill: var(--logo-accent); }
.logo-accent { color: var(--logo-accent); }
.header-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle, .new-site-button, .display-settings-button {
    height: 42px;
    border: 1px solid rgba(255,255,255,.28);
    color: #fff;
    background: rgba(255,255,255,.08);
    border-radius: 12px;
}

.theme-toggle { width: 42px; font-size: 22px; line-height: 1; }
.theme-toggle:hover { background: rgba(255,255,255,.16); }

.new-site-button, .display-settings-button {
    display: none;
    align-items: center;
    gap: 7px;
    padding: 0 17px;
    margin: 0;
    font-weight: 700;
    background: var(--blue-600);
    border-color: transparent;
}
.new-site-button:hover, .display-settings-button:hover { background: #3182ef; }

.display-settings-button {
    align-items: center;
    gap: 7px;
    padding: 0 17px;
    margin: 0;
    font-weight: 700;
    background: rgba(255,255,255,.12);
}

.sticky-filter-bar {
    position: sticky;
    top: var(--header-height);
    z-index: 900;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    min-height: 0;
    padding: 10px max(28px, calc((100vw - 1440px)/2));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 32px;
}

.filters-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
    padding-top: 12px;

    transition:
        max-height 550ms ease,
        opacity 450ms ease,
        padding-top 550ms ease;
}

.filters-content.filters-collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    pointer-events: none;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    min-width: 0;
    width: 100%;
}

.filters-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.filters-options .sort-box {
    flex: 0 1 auto;
}

.active-filter-section {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
	flex-wrap: wrap;
}

.active-filter-section {
    flex-wrap: wrap;
}

.toggle-filters-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 8px 2px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}

.toggle-filters-button:hover {
    color: var(--blue-700);
}

#filterToggleIcon {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 0;
}

#filterToggleIcon::after {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 550ms ease;
}

.toggle-filters-button[aria-expanded="true"] #filterToggleIcon::after {
    transform: rotate(225deg);
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    min-width: 0;
    width: 100%;

    max-height: 1000px;
    opacity: 1;
    overflow: hidden;

    transition:
        max-height 350ms ease,
        opacity 250ms ease;
}

.active-filters.filters-collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.filter-tag {
    display: inline-flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid #cbdaf0;
    border-radius: 999px;
    background: var(--surface);
    color: var(--blue-900);
    box-shadow: 0 2px 8px rgba(20, 71, 142, .05);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
html[data-theme="dark"] .filter-tag { color: #dce9ff; border-color: #36517a; }

.filter-tag-text { padding: 9px 8px 9px 14px; white-space: nowrap; }
.filter-tag:hover .filter-tag-text { background: var(--blue-50); }

.filter-tag-remove {
    width: 36px;
    padding: 0;
    margin: 0;
    border: 0;
    border-left: 1px solid var(--border);
    background: transparent;
    color: currentColor;
    font-size: 20px;
    line-height: 1;
}
.filter-tag-remove:hover { background: #ffecef; color: #b42335; opacity: 1; }

.sort-box {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin: 0;
    background: transparent;
    box-shadow: none;
    white-space: nowrap;
}
.sort-box label { font-size: 14px; font-weight: 700; color: var(--muted); }
.sort-box select, select {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    padding: 10px 36px 10px 12px;
    outline: none;
}
.sort-box select { min-width: 175px; width: auto; }
select:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(29,111,232,.12); }

#status { color: var(--muted); font-size: 13px; white-space: nowrap; }

.page-shell {
    max-width: 1500px;
    margin: 0 auto;
    padding: 24px 28px 40px;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 190px;
    gap: 22px;
    align-items: start;
}

.ad-column {
    min-height: 100%;
    align-self: stretch;
}
.ad-placeholder {
    position: sticky;
    top: calc(var(--header-height) + 70px);
    height: 600px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--blue-50), var(--surface));
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    font-size: 13px;
}
.ad-placeholder strong { font-size: 15px; letter-spacing: .4px; color: var(--text); }

/* Internal placeholder IDs are layout slots, not advertising-network IDs. */
.inline-ad {
    display: none;
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 180px;
    padding: 24px;
    flex: 0 0 auto;
}
#articles.cards-view .inline-ad { grid-column: 1 / -1; }

main { grid-column: 2; max-width: none; margin: 0; padding: 0; min-width: 0; }

.welcome-card {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 36px;
    background: linear-gradient(135deg, var(--surface), var(--blue-50));
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.welcome-icon {
    width: 92px; height: 92px; flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: 24px;
    color: var(--blue-600);
    background: var(--blue-100);
    font-size: 50px;
}
.welcome-card h2 { margin: 0 0 9px; font-size: 27px; }
.welcome-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.welcome-button, .add-button {
    border: 0;
    border-radius: 10px;
    padding: 11px 17px;
    color: #fff;
    background: var(--blue-600);
    font-weight: 800;
}
.welcome-button:hover, .add-button:hover { background: #0c5fd5; }

.add-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#articles { display: flex; flex-direction: column; gap: 14px; }

.article {
    display: flex;
    gap: 20px;
    min-height: 168px;
    margin: 0;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.article:hover {
    transform: translateY(-1px);
    border-color: #bfd2ef;
    box-shadow: 0 12px 30px rgba(18,48,90,.12);
}
.article-image {
    width: 245px;
    height: 140px;
    object-fit: cover;
    border-radius: 11px;
    flex-shrink: 0;
    background: var(--blue-50);
}
.article-content { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.article-source-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-height: 30px; margin-bottom: 7px; }
.article-site-logo {
    display: block;
    width: auto;
    height: auto;
    max-height: 28px;
    max-width: 140px;
    object-fit: contain;
    object-position: center;
}
.article-site-text { color: var(--blue-700); font-size: 15px; font-weight: 850; }
.article-category {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 12px;
    font-weight: 750;
}
.article-title {
    display: block;
    margin: 0 0 11px;
    color: var(--text);
    font-size: 21px;
    line-height: 1.25;
    font-weight: 800;
    text-decoration: none;
}
.article-title:hover { color: var(--blue-700); text-decoration: none; }
.article-meta { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 14px; min-width: 0; color: var(--muted); }
.article-author, .article-date { display: inline-flex; align-items: center; gap: 5px; color: var(--blue-700); font-size: 13px; margin: 0; }
.article-author { min-width: 0; flex: 0 1 auto; }
.article-author-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.article-date { flex: 0 0 auto; white-space: nowrap; }
.article-meta-icon { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty { padding: 48px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }

/* FILTER MODAL */
.filter-box {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    margin: 0;
    background: rgba(6, 18, 40, .58);
    backdrop-filter: blur(6px);
}
.filter-panel {
    width: min(620px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    max-height: min(760px, calc(100dvh - 48px));
    overflow: auto;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(3, 16, 39, .3);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.filter-panel > .modal-header { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.filter-title { margin: 0; font-size: 22px; }
.modal-close {
    width: 38px; height: 38px; border: 0; border-radius: 10px;
    background: var(--blue-50); color: var(--text); font-size: 25px; line-height: 1;
}
.modal-close:hover { background: var(--blue-100); }
.field { margin-bottom: 22px; }
.field label { display: block; margin-bottom: 8px; font-weight: 800; }
.field > select { width: 100%; max-width: none; }
.categories { display: flex; flex-direction: column; gap: 7px; max-height: 360px; overflow: auto; padding: 4px 6px 4px 0; }
.category-option {
    display: flex; align-items: center; gap: 9px;
    width: fit-content; min-width: 190px;
    margin: 0; padding: 8px 11px;
    border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface-soft); cursor: pointer;
}
.category-option:hover { background: var(--blue-50); border-color: #bed1ef; }
.category-option input { accent-color: var(--blue-600); cursor: pointer; }
.category-option.disabled { opacity: .42; cursor: not-allowed; }
.category-all { font-weight: 800; background: var(--blue-50); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.cancel-button { border: 1px solid var(--border); border-radius: 10px; padding: 10px 15px; color: var(--text); background: var(--surface); font-weight: 700; }
.cancel-button:hover { background: var(--blue-50); }

/* PRIKAZ VESTI MODAL */
.display-settings-list { display: flex; flex-direction: column; gap: 14px; }
.display-site-group { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface-soft); }
.display-site-row, .display-category-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.display-site-row { padding: 14px 16px; background: var(--blue-50); font-weight: 800; }
.display-category-list { display: flex; flex-direction: column; }
.display-category-list.is-collapsed { display: none; }
.display-site-expand { display: inline-flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit; text-align: left; cursor: pointer; }
.display-site-chevron { display: inline-block; font-size: 13px; transition: transform .18s ease; }
.display-site-expand[aria-expanded="true"] .display-site-chevron { transform: rotate(90deg); }
.display-site-expand:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 4px; border-radius: 4px; }
.display-category-row { padding: 11px 16px 11px 28px; border-top: 1px solid var(--border); }
.display-category-row.is-disabled { opacity: .45; }
.display-category-name { min-width: 0; overflow-wrap: anywhere; }
.display-settings-tools { display: flex; justify-content: flex-end; gap: 9px; margin-bottom: 16px; }
.display-tool-button { border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; color: var(--text); background: var(--surface); font-weight: 700; }
.display-tool-button:hover { background: var(--blue-50); }
.toggle-switch { position: relative; display: inline-flex; align-items: center; flex: 0 0 auto; width: 62px; height: 30px; border: 0; border-radius: 999px; padding: 3px; color: #fff; font-size: 11px; font-weight: 850; transition: background .18s ease, opacity .18s ease; }
.toggle-switch.on { background: #1f9d55; justify-content: flex-end; }
.toggle-switch.off { background: #d64545; justify-content: flex-start; }
.toggle-switch:disabled { cursor: not-allowed; opacity: .55; }
.toggle-knob { width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.22); }
.toggle-label { position: absolute; left: 8px; right: 8px; text-align: center; pointer-events: none; }
.toggle-switch.on .toggle-label { padding-right: 22px; }
.toggle-switch.off .toggle-label { padding-left: 22px; }

@media (max-width: 1220px) {
    .page-shell { grid-template-columns: minmax(0, 1fr); max-width: 980px; } main { grid-column: 1; }
    .ad-column { display: none; }
    .inline-ad { display: flex; }
    .sticky-filter-bar { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 820px) {
    :root { --header-height: 68px; --bar-height: auto; }
    .header-inner { min-height: 68px; padding: 0 16px; }
    .logo { font-size: 23px; }
    .logo-mark { width: 42px; height: 34px; }
    .new-site-button, .display-settings-button { padding: 0 12px; }
  .sticky-filter-bar {
    top: 68px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 14px;
	}

	.filters-options {
		display: flex;
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.filters-options .sort-box {
		width: 100%;
		justify-content: space-between;
	}

	.filters-options .sort-box label {
		display: block;
	}

	.filters-options .sort-box select {
		flex: 1;
		min-width: 0;
		max-width: 100%;
	}
    .active-filter-section {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    gap: 7px;
	}
    .sort-box {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    justify-content: stretch;
	}
	.sort-box label {
    display: none;
	}
    .sort-box select {
    width: 100%;
    min-width: 0;
    padding: 9px 24px 9px 10px;
    font-size: 12px;
	}
    #status { display: none; }
    .page-shell { padding: 16px 12px 30px; }
    .article { gap: 14px; }
    .article-image { width: 190px; height: 125px; }
    .article-title { font-size: 18px; }
}

@media (max-width: 620px) {
    .header-actions { gap: 7px; }
    .new-site-button { font-size: 0; width: 42px; padding: 0; justify-content: center; }
    .new-site-button::before { content: "+"; font-size: 24px; }
    .display-settings-button { font-size: 0; width: 42px; padding: 0; justify-content: center; }
    .display-settings-button::before { content: "☷"; font-size: 22px; }
    .welcome-card { flex-direction: column; text-align: center; padding: 28px 20px; }
    .article { flex-direction: column; }
    .article-image { width: 100%; height: 210px; }
    .filter-box { padding: 12px; }
    .filter-panel { padding: 20px; max-height: calc(100vh - 24px); }
}

/* Alternativni prikaz kartica — postojeći prikaz liste ostaje nepromenjen */
#articles.cards-view {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}
#articles.cards-view .article {
    min-width: 0;
    min-height: 0;
    padding: 0;
    gap: 0;
    flex-direction: column;
    overflow: hidden;
}
#articles.cards-view .article-image {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 0;
    object-fit: cover;
}
#articles.cards-view .article-content {
    flex: 1;
    justify-content: flex-start;
    padding: 13px 14px 15px;
}
#articles.cards-view .article-source-row { gap: 7px; margin-bottom: 9px; }
#articles.cards-view .article-site-logo { max-width: 100px; max-height: 23px; }
#articles.cards-view .article-category { font-size: 11px; overflow-wrap: anywhere; }
#articles.cards-view .article-title { font-size: 16px; line-height: 1.38; margin-bottom: 12px; }
#articles.cards-view .article-meta { margin-top: auto; justify-content: space-between; gap: 12px; }
#articles.cards-view .article-date { margin-left: auto; }
#articles.cards-view .empty { grid-column: 1 / -1; }
.view-mode-setting { margin-bottom: 20px; padding: 14px 16px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 14px; }
.view-mode-setting > label { display: block; font-weight: 800; margin-bottom: 10px; }
.view-mode-options { display: flex; gap: 9px; }
.view-mode-options button { flex: 1; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; background: var(--surface); color: var(--text); font-weight: 700; }
.view-mode-options button[aria-pressed="true"] { border-color: var(--blue-600); background: var(--blue-100); color: var(--blue-700); }
@media (max-width: 1450px) {
    #articles.cards-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1220px) {
    /* Ten cards fill complete two-column rows before each inline slot. */
    #articles.cards-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    #articles.cards-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    #articles.cards-view { grid-template-columns: minmax(0, 1fr); }
}


/* Period i sortiranje sada pripadaju meniju Prikaz vesti. */
#displaySettingsBox .filters-options { margin-bottom: 18px; align-items: stretch; }
#displaySettingsBox .filters-options .sort-box { flex: 1 1 210px; min-width: 0; }
#displaySettingsBox .filters-options .sort-box select { min-width: 0; max-width: 100%; }


/* Initial visibility; JavaScript continues to control display dynamically. */
#displaySettingsButton,
#newSiteButton,
#stickyBar,
#filterBox,
#categoryField,
#addButton,
#displaySettingsBox,
#periodBox,
#sortBox { display: none; }

/* Pagination controls stay outside both article layouts. */
.pagination-status { text-align: center; padding: 16px 0; color: var(--muted); }
.pagination-status[hidden], .pagination-status [hidden], .article-sentinel[hidden] { display: none; }
.article-sentinel { height: 1px; }

@media (max-width: 360px) {
    .logo { font-size: 18px; gap: 5px; }
    .logo-mark { width: 34px; height: 30px; }
}

/* Compact stacked controls: a horizontal 210px flex basis must not become
   the height of each field when the existing tablet layout turns vertical. */
@media (max-width: 820px) {
    #displaySettingsBox .filters-options {
        flex-flow: column nowrap;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
    }
    #displaySettingsBox .filters-options .sort-box {
        flex: 0 0 auto;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 6px;
        white-space: normal;
    }
    #displaySettingsBox .filters-options .sort-box label { display: block; }
    #displaySettingsBox .filters-options .sort-box select {
        flex: 0 0 auto;
        width: 100%;
        min-height: 42px;
    }
    .filter-box {
        --modal-top-gap: max(12px, env(safe-area-inset-top, 0px));
        --modal-bottom-gap: max(12px, env(safe-area-inset-bottom, 0px));
        padding: var(--modal-top-gap) max(12px, env(safe-area-inset-right, 0px))
                 var(--modal-bottom-gap) max(12px, env(safe-area-inset-left, 0px));
    }
    .filter-panel {
        max-height: min(760px, calc(100vh - var(--modal-top-gap) - var(--modal-bottom-gap)));
        max-height: min(760px, calc(100dvh - var(--modal-top-gap) - var(--modal-bottom-gap)));
        padding: 20px;
        overscroll-behavior: contain;
    }
    .filter-panel > .modal-header { margin-bottom: 16px; }
    .modal-close { flex: 0 0 38px; }
    .category-option { width: auto; min-width: 0; overflow-wrap: anywhere; }
    .category-option input { flex-shrink: 0; }
}

@media (max-width: 620px) {
    .header-inner {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        column-gap: 8px;
    }
    .logo { font-size: clamp(16px, 5vw, 23px); }
    .header-actions {
        min-width: 0;
        justify-content: flex-end;
        gap: 8px;
    }
    .header-actions > button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 42px;
        width: 42px;
        height: 42px;
        padding: 0;
    }
    .view-mode-setting { display: none; }
    #articles.cards-view { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 360px) {
    .logo-mark { width: 30px; }
}

/* BEGIN BORDERLESS GRID EXPERIMENT
   Remove this block (or restore the CSS backup) to recover the panel design. */
#articles.cards-view .article {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    /* Replace the old 1px border without changing the content geometry. */
    padding: 1px;
    transform: none;
    transition: none;
}
#articles.cards-view .article-image { border-radius: 16px; }
@media (hover: hover) and (pointer: fine) {
    #articles.cards-view .article:hover .article-image { filter: brightness(.97); }
}
/* END BORDERLESS GRID EXPERIMENT */

/* Inline strokes follow the same foreground color as header text. Unlike
   background-painted masks, they do not use a light CSS background as ink. */
.header-button-icon { display: none; }
@media (max-width: 620px) {
    .new-site-button, .display-settings-button { gap: 0; }
    .new-site-button::before, .display-settings-button::before { content: none; }
    .new-site-button .header-button-label,
    .display-settings-button .header-button-label { display: none; }
    .header-button-icon {
        display: block;
        width: 22px;
        height: 22px;
        flex: 0 0 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
    }
}
