/* Edicola — text only, calm, readable.
   Three looks (data-style: quotidiano | moderno | notte), each with a light and a dark mode
   (data-theme: light | dark, or follow the system). Fonts are downloaded only when used. */

@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader-italic.woff2") format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Literata"; src: url("../fonts/literata.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("../fonts/literata-italic.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

/* ---------- Quotidiano (default): white paper, ink, cardinal red ---------- */

:root {
	--bg: #fbfaf7;
	--surface: #ffffff;
	--text: #15171c;
	--muted: #4d525d;
	--faint: #8b8f98;
	--line: #e6e3dc;
	--strong-line: #15171c;
	--accent: #b4232a;
	--accent-soft: rgba(180, 35, 42, 0.07);
	--read: #8b8f98;
	--ok: #2f7a45;
	--serif: "Newsreader", "Iowan Old Style", Charter, Georgia, serif;
	--sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--title-weight: 600;
	--title-tracking: -0.01em;
	--brand-font: var(--serif);
	--brand-style: normal;
	--brand-weight: 600;
	--brand-case: uppercase;
	--brand-tracking: 0.32em;
	--brand-size: 1.25rem;
	--meta-case: uppercase;
	--meta-tracking: 0.08em;
	--meta-size: 0.7rem;
	--bar-rule: 3px double var(--strong-line);
	--radius: 4px;
	--pill: 999px;
	--scale: 1;
	--w: 42rem;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #121316;
		--surface: #1a1c20;
		--text: #eceae4;
		--muted: #abaeb5;
		--faint: #777b84;
		--line: #2a2c31;
		--strong-line: #8e9199;
		--accent: #f06a66;
		--accent-soft: rgba(240, 106, 102, 0.1);
		--read: #7a7e87;
		--ok: #6cc28a;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #121316;
	--surface: #1a1c20;
	--text: #eceae4;
	--muted: #abaeb5;
	--faint: #777b84;
	--line: #2a2c31;
	--strong-line: #8e9199;
	--accent: #f06a66;
	--accent-soft: rgba(240, 106, 102, 0.1);
	--read: #7a7e87;
	--ok: #6cc28a;
	color-scheme: dark;
}

/* ---------- Moderno: cool greys, ink blue, all Inter ---------- */

:root[data-style="moderno"] {
	--bg: #f5f6f8;
	--surface: #ffffff;
	--text: #0f172a;
	--muted: #475569;
	--faint: #94a3b8;
	--line: #e2e8f0;
	--strong-line: #e2e8f0;
	--accent: #2b59c3;
	--accent-soft: rgba(43, 89, 195, 0.08);
	--read: #94a3b8;
	--ok: #15803d;
	--serif: var(--sans);
	--title-weight: 650;
	--title-tracking: -0.018em;
	--brand-font: var(--sans);
	--brand-style: normal;
	--brand-weight: 750;
	--brand-case: none;
	--brand-tracking: -0.03em;
	--brand-size: 1.35rem;
	--meta-case: none;
	--meta-tracking: 0;
	--meta-size: 0.78rem;
	--bar-rule: 1px solid var(--line);
	--radius: 12px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root[data-style="moderno"]:not([data-theme="light"]) {
		--bg: #0b0f17;
		--surface: #121826;
		--text: #e6eaf1;
		--muted: #9aa4b2;
		--faint: #64748b;
		--line: #1e2633;
		--strong-line: #1e2633;
		--accent: #7aa2ff;
		--accent-soft: rgba(122, 162, 255, 0.12);
		--read: #64748b;
		--ok: #4ade80;
		color-scheme: dark;
	}
}

:root[data-style="moderno"][data-theme="dark"] {
	--bg: #0b0f17;
	--surface: #121826;
	--text: #e6eaf1;
	--muted: #9aa4b2;
	--faint: #64748b;
	--line: #1e2633;
	--strong-line: #1e2633;
	--accent: #7aa2ff;
	--accent-soft: rgba(122, 162, 255, 0.12);
	--read: #64748b;
	--ok: #4ade80;
	color-scheme: dark;
}

/* ---------- Notte: night blue and amber, Literata; dark unless asked otherwise ---------- */

:root[data-style="notte"] {
	--bg: #0e1420;
	--surface: #151c2a;
	--text: #ece6d8;
	--muted: #b5ae9e;
	--faint: #7f7a6c;
	--line: #222b3a;
	--strong-line: #2f3a4d;
	--accent: #e8a33d;
	--accent-soft: rgba(232, 163, 61, 0.11);
	--read: #7f7a6c;
	--ok: #8fcf8f;
	--serif: "Literata", Georgia, serif;
	--title-weight: 560;
	--title-tracking: -0.005em;
	--brand-font: var(--serif);
	--brand-style: italic;
	--brand-weight: 500;
	--brand-case: none;
	--brand-tracking: 0;
	--brand-size: 1.5rem;
	--meta-case: none;
	--meta-tracking: 0.01em;
	--meta-size: 0.78rem;
	--bar-rule: 1px solid var(--line);
	--radius: 10px;
	color-scheme: dark;
}

:root[data-style="notte"][data-theme="light"] {
	--bg: #eceef1;
	--surface: #f7f8fa;
	--text: #1c2230;
	--muted: #4b5365;
	--faint: #8a90a0;
	--line: #d8dce3;
	--strong-line: #c6ccd6;
	--accent: #a8650f;
	--accent-soft: rgba(168, 101, 15, 0.09);
	--read: #8a90a0;
	--ok: #2f7a45;
	color-scheme: light;
}

:root[data-size="s"] { --scale: 0.92; }
:root[data-size="l"] { --scale: 1.1; }
:root[data-size="xl"] { --scale: 1.22; }

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

html {
	font-size: calc(100% * var(--scale));
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	min-height: 100vh;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); }

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

[hidden] { display: none !important; }

.wrap, .view {
	max-width: var(--w);
	margin: 0 auto;
	padding: 0 1rem;
}

.view { outline: none; padding-bottom: 5rem; }

/* ---------- Top bar ---------- */

.bar {
	position: sticky;
	top: 0;
	z-index: 10;
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: saturate(1.4) blur(10px);
	-webkit-backdrop-filter: saturate(1.4) blur(10px);
	border-bottom: var(--bar-rule);
	padding-top: env(safe-area-inset-top);
}

.bar-in {
	max-width: var(--w);
	margin: 0 auto;
	padding: 0.7rem 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

.brand {
	font-family: var(--brand-font);
	font-size: var(--brand-size);
	font-style: var(--brand-style);
	font-weight: var(--brand-weight);
	text-transform: var(--brand-case);
	letter-spacing: var(--brand-tracking);
	line-height: 1.2;
	text-decoration: none;
	color: var(--text);
}

.bar-nav { display: flex; align-items: center; gap: 1.1rem; }

.bar-nav a {
	font-size: 0.9rem;
	color: var(--muted);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
}

.bar-nav a:hover, .bar-nav a[aria-current="page"] { color: var(--accent); }

/* ---------- Filters ---------- */

.tools { padding: 1rem 0 0.25rem; }

.search {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	border-bottom: 1px solid var(--line);
	padding: 0.25rem 0 0.5rem;
}

.search svg { color: var(--faint); flex: none; }

.search input {
	flex: 1;
	min-width: 0;
	border: 0;
	background: transparent;
	padding: 0.35rem 0;
	font-size: 1rem;
	outline: none;
}

.search input::placeholder { color: var(--faint); }

.chips {
	display: flex;
	gap: 0.4rem;
	overflow-x: auto;
	padding: 0.85rem 0 0.35rem;
	scrollbar-width: none;
	mask-image: linear-gradient(90deg, #000 92%, transparent);
	-webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
}

.chips::-webkit-scrollbar { display: none; }

.chip {
	flex: none;
	border: 1px solid var(--line);
	background: transparent;
	border-radius: 999px;
	padding: 0.28rem 0.8rem;
	font-size: 0.85rem;
	color: var(--muted);
	cursor: pointer;
	white-space: nowrap;
	transition: color .15s, border-color .15s, background .15s;
}

@media (hover: hover) { .chip:hover { color: var(--text); } }

.chip[aria-pressed="true"] {
	background: var(--text);
	border-color: var(--text);
	color: var(--bg);
}

.subtools {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.4rem 0 0;
	font-size: 0.82rem;
	color: var(--faint);
}

.select {
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: transparent;
	color: var(--muted);
	font-size: 0.82rem;
	padding: 0.2rem 1rem 0.2rem 0;
	max-width: 55%;
	cursor: pointer;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: right 4px center, right 0 center;
	background-size: 4px 4px, 4px 4px;
	background-repeat: no-repeat;
	text-overflow: ellipsis;
}

.linkbtn {
	border: 0;
	background: none;
	padding: 0;
	color: var(--muted);
	cursor: pointer;
	text-decoration: underline;
	text-decoration-color: var(--line);
	text-underline-offset: 3px;
	font-size: inherit;
}

.linkbtn:hover { color: var(--accent); }

/* ---------- News list ---------- */

.day {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 2rem 0 0.25rem;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--faint);
}

.day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.dateline {
	margin: 0;
	padding: 0.7rem 0 0;
	font-size: 0.72rem;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--faint);
}

.list { list-style: none; margin: 0; padding: 0; }

.item { border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }

.item a {
	display: block;
	padding: 1.05rem 0 1.1rem;
	text-decoration: none;
}

.meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 0.45rem;
	font-size: var(--meta-size);
	text-transform: var(--meta-case);
	letter-spacing: var(--meta-tracking);
	color: var(--faint);
	margin-bottom: 0.3rem;
}

.meta .src { color: var(--accent); font-weight: 600; }
.meta .dot::before { content: "·"; }

.item h2 {
	margin: 0;
	font-family: var(--serif);
	font-weight: var(--title-weight);
	font-size: 1.22rem;
	line-height: 1.28;
	letter-spacing: var(--title-tracking);
	text-wrap: pretty;
}

.item p {
	margin: 0.35rem 0 0;
	font-size: 0.92rem;
	line-height: 1.55;
	color: var(--muted);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

@media (hover: hover) { .item a:hover h2 { color: var(--accent); } }
.item.read h2 { color: var(--read); font-weight: 500; }
.item.read p { opacity: 0.8; }

mark {
	background: var(--accent-soft);
	color: inherit;
	border-radius: 2px;
	padding: 0 1px;
}

.more {
	display: block;
	margin: 1.5rem auto 0;
}

.empty {
	text-align: center;
	color: var(--muted);
	padding: 4rem 1rem;
	font-size: 0.95rem;
}

.empty strong {
	display: block;
	font-family: var(--serif);
	font-size: 1.3rem;
	font-weight: 500;
	color: var(--text);
	margin-bottom: 0.5rem;
}

.loading { color: var(--faint); padding: 3rem 0; text-align: center; }

/* ---------- Article ---------- */

.article { padding-top: 1.25rem; }

.article-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	font-size: 0.88rem;
}

.back {
	color: var(--muted);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	background: none;
	border: 0;
	padding: 0.3rem 0;
	cursor: pointer;
	font-size: inherit;
}

.back:hover { color: var(--accent); }

.article .meta { margin: 2rem 0 0.75rem; font-size: 0.82rem; }

.article h1 {
	font-family: var(--serif);
	font-weight: var(--title-weight);
	font-size: clamp(1.65rem, 5.5vw, 2.25rem);
	line-height: 1.14;
	letter-spacing: calc(var(--title-tracking) - 0.005em);
	margin: 0;
	text-wrap: balance;
}

.byline {
	margin: 1rem 0 0;
	font-size: 0.88rem;
	color: var(--muted);
}

.byline .author { color: var(--text); font-weight: 500; }

.prose {
	margin-top: 2rem;
	padding-top: 1.75rem;
	border-top: 1px solid var(--line);
	font-family: var(--serif);
	font-size: 1.16rem;
	line-height: 1.72;
	overflow-wrap: break-word;
}

.prose p { margin: 0 0 1.15em; }

.prose .lead { font-size: 1.05em; }

.note {
	font-family: var(--sans);
	font-size: 0.85rem;
	color: var(--faint);
	margin: 1.5rem 0 0;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--text);
	border-radius: 999px;
	padding: 0.55rem 1.1rem;
	font-size: 0.9rem;
	text-decoration: none;
	cursor: pointer;
	transition: border-color .15s, color .15s, background .15s;
}

@media (hover: hover) { .btn:hover { border-color: var(--accent); color: var(--accent); } }

.btn.primary {
	background: var(--text);
	border-color: var(--text);
	color: var(--bg);
}

@media (hover: hover) { .btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; } }

.btn:disabled { opacity: 0.5; cursor: default; }

.btn.small { padding: 0.32rem 0.8rem; font-size: 0.82rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }

/* ---------- AI ---------- */

.ai-box {
	margin-top: 1.75rem;
	padding: 1rem 1.15rem;
	border-radius: var(--radius);
	background: var(--accent-soft);
	font-size: 0.97rem;
	line-height: 1.6;
}

.ai-box .label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--accent);
	margin-bottom: 0.4rem;
}

.ai-box .label .linkbtn { letter-spacing: 0; text-transform: none; font-weight: 400; font-size: 0.8rem; }

.ai-out p { margin: 0 0 0.75em; }
.ai-out p:last-child { margin-bottom: 0; }
.ai-out h3 {
	font-family: var(--serif);
	font-size: 1.15rem;
	font-weight: 600;
	margin: 1.6em 0 0.4em;
}
.ai-out h3:first-child { margin-top: 0.2em; }
.ai-out ul, .ai-out ol { margin: 0 0 0.9em; padding-left: 1.2em; }
.ai-out li { margin: 0.3em 0; }

.ai-err { color: var(--accent); font-size: 0.9rem; }

.recap .ai-out { font-family: var(--serif); font-size: 1.1rem; line-height: 1.68; }

.cursor::after {
	content: "▍";
	color: var(--accent);
	animation: blink 1s steps(2) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- Pages (sources, settings, welcome) ---------- */

.page { padding-top: 2rem; }

.page h1 {
	font-family: var(--serif);
	font-weight: 500;
	font-size: clamp(1.8rem, 6vw, 2.4rem);
	letter-spacing: -0.015em;
	line-height: 1.15;
	margin: 0 0 0.6rem;
}

.page h1 em { color: var(--accent); }

.page .lede {
	color: var(--muted);
	margin: 0 0 1.75rem;
	font-size: 0.98rem;
	line-height: 1.6;
}

.page h2 {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--faint);
	margin: 2.5rem 0 0.75rem;
}

.group {
	border-top: 1px solid var(--line);
}

.group:last-of-type { border-bottom: 1px solid var(--line); }

.group summary {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.9rem 0;
}

.group summary::-webkit-details-marker { display: none; }

.group summary .name {
	flex: 1;
	font-family: var(--serif);
	font-size: 1.12rem;
}

.group summary .count { font-size: 0.8rem; color: var(--faint); font-variant-numeric: tabular-nums; }

.group summary::after {
	content: "";
	width: 7px;
	height: 7px;
	border-right: 1.5px solid var(--faint);
	border-bottom: 1.5px solid var(--faint);
	transform: rotate(45deg) translateY(-3px);
	transition: transform .2s;
}

.group[open] summary::after { transform: rotate(-135deg) translateX(-2px); }

.group .rows { padding: 0 0 0.9rem; }

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.45rem 0;
	cursor: pointer;
	font-size: 0.95rem;
}

.row .grow { flex: 1; min-width: 0; }
.row small { color: var(--faint); font-size: 0.75rem; margin-left: 0.35rem; }
.row .warn { color: var(--accent); }

.row .x {
	border: 0;
	background: none;
	color: var(--faint);
	cursor: pointer;
	padding: 0.2rem 0.4rem;
	font-size: 1.1rem;
	line-height: 1;
}

.row .x:hover { color: var(--accent); }

input[type="checkbox"], input[type="radio"] {
	accent-color: var(--accent);
	width: 1.05rem;
	height: 1.05rem;
	margin: 0;
	flex: none;
}

.toggle-all {
	font-size: 0.8rem;
	color: var(--muted);
	padding: 0.2rem 0 0.5rem;
}

.field { display: block; margin: 0 0 1rem; }

.field > span {
	display: block;
	font-size: 0.82rem;
	color: var(--muted);
	margin-bottom: 0.35rem;
}

.input {
	width: 100%;
	border: 1px solid var(--line);
	background: var(--surface);
	border-radius: min(var(--radius), 10px);
	padding: 0.6rem 0.75rem;
	font-size: 0.95rem;
	outline: none;
	transition: border-color .15s;
}

.input:focus { border-color: var(--accent); }

select.input {
	appearance: none;
	-webkit-appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: right 16px center, right 11px center;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-right: 2rem;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }

@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.help {
	font-size: 0.84rem;
	color: var(--muted);
	line-height: 1.6;
	margin: 0.25rem 0 1rem;
}

.help code, .prose code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.85em;
	background: var(--accent-soft);
	padding: 0.1em 0.35em;
	border-radius: 4px;
	word-break: break-all;
}

.seg {
	display: inline-flex;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 3px;
	gap: 2px;
	flex-wrap: wrap;
}

.seg button {
	border: 0;
	background: transparent;
	border-radius: 999px;
	padding: 0.3rem 0.85rem;
	font-size: 0.85rem;
	color: var(--muted);
	cursor: pointer;
}

.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.status { font-size: 0.85rem; margin: 0.5rem 0 0; min-height: 1.3em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--accent); }

.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
	gap: 0.5rem;
}

.tile {
	text-align: left;
	border: 1px solid var(--line);
	background: var(--surface);
	border-radius: var(--radius);
	padding: 0.75rem 0.85rem;
	cursor: pointer;
	font-family: var(--serif);
	font-size: 1rem;
	line-height: 1.25;
	transition: border-color .15s, background .15s;
}

@media (hover: hover) { .tile:hover { border-color: var(--faint); } }

.tile[aria-pressed="true"] {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--text);
}

.tile small { display: block; font-family: var(--sans); font-size: 0.75rem; color: var(--faint); margin-top: 0.2rem; }

.sticky-cta {
	position: sticky;
	bottom: 0;
	padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom));
	background: linear-gradient(transparent, var(--bg) 35%);
	margin-top: 1.5rem;
	display: flex;
	align-items: center;
	gap: 1rem;
}

.sticky-cta .hint { font-size: 0.84rem; color: var(--muted); }

.foot {
	margin-top: 3rem;
	font-size: 0.8rem;
	color: var(--faint);
	line-height: 1.6;
}

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(1.25rem + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	background: var(--text);
	color: var(--bg);
	padding: 0.55rem 1rem;
	border-radius: 999px;
	font-size: 0.85rem;
	z-index: 20;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
	max-width: calc(100% - 2rem);
}

/* ---------- Settings ---------- */

.ic { flex: none; display: block; }

.settings .lede { display: flex; align-items: center; gap: 0.45rem; }
.settings .lede .ic { color: var(--ok); }

.settings h2 { display: flex; align-items: baseline; gap: 0.6rem; margin-top: 2.25rem; }
.h2-note { font-weight: 400; letter-spacing: 0.02em; text-transform: none; font-size: 0.78rem; }

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: max(var(--radius), 8px);
	overflow: hidden;
}

.card + .card { margin-top: 0.75rem; }
.card-pad { padding: 1rem; }

.set-row {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	width: 100%;
	padding: 0.8rem 1rem;
	border: 0;
	border-top: 1px solid var(--line);
	background: none;
	color: inherit;
	text-align: left;
	text-decoration: none;
	font: inherit;
	cursor: default;
	flex-wrap: wrap;
}

.card > .set-row:first-child, .card > :first-child .set-row, summary .set-row { border-top: 0; }
.card > .set-details, .card > .set-row ~ .set-details { border-top: 1px solid var(--line); }
a.set-row, button.set-row, label.set-row, summary .set-row { cursor: pointer; }
@media (hover: hover) { a.set-row:hover, button.set-row:hover, label.set-row:hover, summary:hover .set-row { background: var(--accent-soft); } }

.set-ic {
	width: 2.1rem;
	height: 2.1rem;
	flex: none;
	display: grid;
	place-items: center;
	border-radius: max(calc(var(--radius) - 2px), 6px);
	background: var(--accent-soft);
	color: var(--accent);
}

.set-text { flex: 1; min-width: 8rem; display: flex; flex-direction: column; }
.set-title { font-size: 0.95rem; font-weight: 500; }
.set-sub { font-size: 0.8rem; color: var(--faint); line-height: 1.4; }
.set-chev { color: var(--faint); transition: transform .2s; }
.set-row .seg { margin-left: auto; }
.set-row.danger { color: light-dark(#b42318, #f2827a); }
.set-row.danger .set-ic { color: inherit; background: color-mix(in srgb, currentColor 10%, transparent); }
.set-row.danger .set-sub { color: var(--faint); }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary .set-chev { transform: rotate(90deg); }
.about { margin-top: 2.25rem; }
.about .card-pad, .set-details .card-pad { padding-top: 0; }

.seg button { display: inline-flex; align-items: center; justify-content: center; min-width: 2.4rem; min-height: 2rem; }

/* Look picker */

.looks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }

.look {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.1rem;
	text-align: left;
	border: 1px solid var(--line);
	background: transparent;
	border-radius: max(var(--radius), 8px);
	padding: 0.5rem 0.5rem 0.7rem;
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s;
}

.look[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.look-name { font-weight: 600; font-size: 0.88rem; padding: 0 0.2rem; }
.look-desc { font-size: 0.74rem; color: var(--faint); line-height: 1.35; padding: 0 0.2rem; }

/* A miniature of each look: its background, a title glyph and two text lines. */
.look-sample {
	position: relative;
	display: block;
	height: 4.2rem;
	border-radius: max(calc(var(--radius) - 3px), 5px);
	margin-bottom: 0.45rem;
	padding: 0.5rem 0.6rem;
	overflow: hidden;
	border: 1px solid rgba(127, 127, 127, 0.18);
}
.look-sample b { display: block; font-size: 1.35rem; line-height: 1; font-weight: 600; }
.look-sample i { display: block; height: 4px; border-radius: 2px; margin-top: 6px; opacity: 0.35; }
.look-sample i:last-child { width: 60%; }
.look-sample::after { content: ""; position: absolute; top: 0.6rem; right: 0.6rem; width: 0.55rem; height: 0.55rem; border-radius: 50%; }

.look-quotidiano { background: #fbfaf7; color: #15171c; }
.look-quotidiano b { font-family: "Newsreader", Georgia, serif; }
.look-quotidiano i { background: #15171c; }
.look-quotidiano::after { background: #b4232a; }
.look-moderno { background: #f5f6f8; color: #0f172a; }
.look-moderno b { font-family: "Inter", system-ui, sans-serif; font-weight: 700; letter-spacing: -0.03em; }
.look-moderno i { background: #0f172a; }
.look-moderno::after { background: #2b59c3; }
.look-notte { background: #0e1420; color: #ece6d8; }
.look-notte b { font-family: "Literata", Georgia, serif; font-style: italic; font-weight: 500; }
.look-notte i { background: #ece6d8; }
.look-notte::after { background: #e8a33d; }

/* AI mode picker */

.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }

.mode {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.15rem;
	text-align: left;
	border: 1px solid var(--line);
	background: transparent;
	border-radius: max(var(--radius), 8px);
	padding: 0.8rem 0.85rem 0.85rem;
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s, background .15s;
}

.mode[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.mode-top { display: flex; width: 100%; align-items: center; justify-content: space-between; margin-bottom: 0.35rem; }
.mode-ic { color: var(--muted); }
.mode[aria-checked="true"] .mode-ic { color: var(--accent); }
.mode-name { font-weight: 600; font-size: 0.92rem; }
.mode-desc { font-size: 0.76rem; color: var(--faint); line-height: 1.35; }

.badge {
	font-size: 0.66rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 0.15rem 0.45rem;
	border-radius: 999px;
}
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.badge.warn { color: var(--muted); background: color-mix(in srgb, var(--muted) 13%, transparent); }

.panel { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.panel > .seg { margin-bottom: 0.25rem; }
.panel .field > span { display: flex; align-items: center; gap: 0.35rem; }
.inline { display: flex; gap: 0.5rem; }
.panel .btn .ic { margin-right: 0.1rem; }

.models { display: grid; gap: 0.5rem; margin: 0.25rem 0 0.5rem; }
.model {
	display: flex;
	gap: 0.7rem;
	align-items: flex-start;
	border: 1px solid var(--line);
	border-radius: max(var(--radius), 8px);
	padding: 0.65rem 0.75rem;
	cursor: pointer;
}
.model:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.model input { margin-top: 0.2rem; }
.model-text { display: flex; flex-direction: column; }
.model-name { font-size: 0.92rem; font-weight: 500; }
.model-name small { font-weight: 400; color: var(--faint); font-size: 0.76rem; }
.model-name small.ok { color: var(--ok); }

.switch-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.85rem 0 0.25rem;
	margin-top: 0.5rem;
	border-top: 1px solid var(--line);
	cursor: pointer;
}
.switch-row > span { display: flex; flex-direction: column; }

input.switch {
	appearance: none;
	-webkit-appearance: none;
	width: 2.7rem;
	height: 1.6rem;
	border-radius: 999px;
	background: var(--line);
	position: relative;
	cursor: pointer;
	flex: none;
	transition: background .2s;
}
input.switch::before {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: calc(1.6rem - 6px);
	height: calc(1.6rem - 6px);
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	transition: transform .2s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::before { transform: translateX(1.1rem); }

.adv { margin-top: 0.75rem; }
.adv summary { font-size: 0.84rem; color: var(--muted); cursor: pointer; padding: 0.35rem 0; }
.adv summary::before { content: "+ "; color: var(--faint); }
.adv[open] summary::before { content: "− "; }
.adv[open] summary { margin-bottom: 0.5rem; }

@media (max-width: 520px) {
	.looks { gap: 0.4rem; }
	.look-desc { display: none; }
	.look-sample { height: 3.6rem; }
	.set-row .seg { margin-left: 2.95rem; margin-top: 0.1rem; }
	.set-row:has(.seg) .set-text { min-width: calc(100% - 3rem); }
}

/* ---------- Style details ---------- */

/* Quotidiano: a newspaper front page. */
[data-style="quotidiano"] .chip { border-radius: 3px; font-size: 0.78rem; letter-spacing: 0.04em; }
[data-style="quotidiano"] .day { color: var(--text); letter-spacing: 0.16em; }
[data-style="quotidiano"] .day::after { border-top-color: var(--strong-line); }
[data-style="quotidiano"] .btn, [data-style="quotidiano"] .seg, [data-style="quotidiano"] .seg button { border-radius: 3px; }
[data-style="quotidiano"] .byline { font-family: var(--serif); font-style: italic; font-size: 1rem; }
[data-style="quotidiano"] .article h1 { font-weight: 650; }
[data-style="quotidiano"] .prose { font-size: 1.2rem; }
[data-style="quotidiano"] .prose .lead { font-style: italic; color: var(--muted); }
[data-style="quotidiano"] .page h1 { font-weight: 600; }
[data-style="quotidiano"] .page h1 em { font-style: italic; font-weight: 500; }

/* Moderno: light cards, app-like. */
[data-style="moderno"] .item { border-bottom: 0; }
[data-style="moderno"] .item a {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 14px;
	padding: 1rem 1.1rem 1.05rem;
	margin: 0 0 0.6rem;
	transition: border-color .15s, transform .15s;
}
@media (hover: hover) { [data-style="moderno"] .item a:hover { border-color: var(--accent); } }
[data-style="moderno"] .meta .src::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	margin-right: 0.45rem;
	vertical-align: 1px;
}
[data-style="moderno"] .day { margin-top: 1.6rem; margin-bottom: 0.7rem; }
[data-style="moderno"] .day::after { display: none; }
[data-style="moderno"] .prose { font-size: 1.08rem; line-height: 1.75; }
[data-style="moderno"] .page h1 { font-weight: 700; letter-spacing: -0.03em; }
[data-style="moderno"] .page h1 em { font-style: normal; }
[data-style="moderno"] .group summary .name { font-weight: 550; }

/* Notte: long, quiet reading. */
[data-style="notte"] .prose { font-size: 1.15rem; line-height: 1.85; }
[data-style="notte"] .item p { line-height: 1.6; }
[data-style="notte"] .page h1 em { font-weight: 400; }

/* ---------- Model picker ---------- */

.model-row { align-items: flex-start; }
.model-row input { margin-top: 0.2rem; }
.row .sub { display: block; font-size: 0.8rem; color: var(--faint); }
.row small.ok { color: var(--ok); }

progress {
	width: 100%;
	height: 4px;
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	border-radius: 99px;
	background: var(--line);
	overflow: hidden;
	margin: 0.25rem 0 0.5rem;
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); transition: width .3s; }
progress::-moz-progress-bar { background: var(--accent); }

/* ---------- Desktop ---------- */

.side { display: none; }

kbd {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.72rem;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 5px;
	padding: 0.05rem 0.35rem;
	color: var(--muted);
	background: var(--surface);
}

@media (min-width: 960px) {
	html { font-size: calc(106.25% * var(--scale)); }

	.bar-in { max-width: 70rem; padding: 0.85rem 2rem; }
	.brand { font-size: 1.6rem; }

	.view { padding: 0 2rem 6rem; }
	.view.wide { max-width: 70rem; }

	.layout {
		display: grid;
		grid-template-columns: 13.5rem minmax(0, 46rem);
		gap: 4.5rem;
		align-items: start;
	}

	.side {
		display: block;
		position: sticky;
		top: 4.5rem;
		padding-top: 1.6rem;
		max-height: calc(100vh - 5rem);
		overflow-y: auto;
		scrollbar-width: thin;
	}

	.side-h {
		font-size: 0.7rem;
		font-weight: 600;
		letter-spacing: 0.12em;
		text-transform: uppercase;
		color: var(--faint);
		margin: 0 0 0.6rem;
	}

	.side-h:not(:first-child) { margin-top: 2.25rem; }

	.side-link {
		display: flex;
		width: 100%;
		justify-content: space-between;
		gap: 0.75rem;
		border: 0;
		background: none;
		text-align: left;
		padding: 0.38rem 0.6rem;
		margin: 0 -0.6rem;
		width: calc(100% + 1.2rem);
		border-radius: 8px;
		font-family: var(--serif);
		font-size: 1rem;
		color: var(--muted);
		cursor: pointer;
	}

	.side-link .n { font-family: var(--sans); font-size: 0.75rem; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 0.15rem; }
	.side-link:hover { color: var(--text); background: var(--accent-soft); }
	.side-link[aria-pressed="true"] { color: var(--text); background: var(--accent-soft); }
	.side-link[aria-pressed="true"] .n { color: var(--accent); }

	.side-more {
		display: inline-block;
		margin-top: 0.9rem;
		font-size: 0.82rem;
		color: var(--muted);
		text-decoration: none;
	}
	.side-more:hover { color: var(--accent); }

	.keys {
		display: grid;
		grid-template-columns: auto 1fr;
		gap: 0.45rem 0.75rem;
		margin: 0;
		font-size: 0.78rem;
		color: var(--faint);
	}
	.keys dt { white-space: nowrap; }
	.keys dd { margin: 0; padding-top: 0.05rem; }

	.main .chips { display: none; }
	.main .tools { padding-top: 1.6rem; }

	.item a { padding: 1.25rem 0 1.3rem; }
	.item h2 { font-size: 1.32rem; }
	.item p { font-size: 0.95rem; -webkit-line-clamp: 2; }
	.item a:focus-visible {
		outline: none;
		background: var(--accent-soft);
		box-shadow: -1rem 0 0 var(--accent-soft), 1rem 0 0 var(--accent-soft);
		border-radius: 2px;
	}

	[data-style="moderno"] .item a { padding: 1.15rem 1.35rem 1.2rem; }
	[data-style="moderno"] .item a:focus-visible { box-shadow: none; background: var(--surface); border-color: var(--accent); }
	[data-style="quotidiano"] .item h2 { font-size: 1.42rem; }

	.article { max-width: 40rem; margin: 0 auto; padding-top: 2rem; }
	.article h1 { font-size: 2.6rem; }
	.prose { font-size: 1.22rem; line-height: 1.75; }

	.page { max-width: 42rem; margin: 0 auto; padding-top: 3rem; }
}

@media (min-width: 1280px) {
	.layout { grid-template-columns: 15rem minmax(0, 48rem); gap: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
}

/* ---------- On-request summaries ---------- */

.tldr-link {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-left: auto;
	font-size: 0.88rem;
	color: var(--faint);
	text-decoration: none;
}
.tldr-link:hover { color: var(--accent); }
.tldr-link:disabled { opacity: 0.5; cursor: default; }
.actions:has(.tldr-link) { align-items: center; }
#tldr { margin-top: 1.25rem; }

.ai-note {
	display: flex;
	gap: 0.45rem;
	align-items: flex-start;
	font-size: 0.8rem;
	line-height: 1.5;
	color: var(--muted);
	margin: 0.75rem 0 0;
}
.ai-note .ic { margin-top: 0.15rem; color: var(--faint); }
.ai-out .ai-note { display: block; }

/* ---------- Freshness ---------- */

.fresh { display: inline-flex; align-items: center; gap: 0.3rem; }

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 1.9rem;
	height: 1.9rem;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--muted);
	cursor: pointer;
}
@media (hover: hover) { .icon-btn:hover { color: var(--accent); background: var(--accent-soft); } }
.icon-btn:disabled { cursor: default; }
.icon-btn.spin .ic { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons with icons ---------- */

.btn .ic { margin: 0 -0.05rem; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
@media (hover: hover) { .btn.ghost:hover { color: var(--accent); background: var(--accent-soft); } }
.btn.stop { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.back .ic, .article-nav .btn .ic { flex: none; }

/* ---------- Article: actions and summary ---------- */

.article-actions { margin-top: 2.25rem; display: grid; gap: 0.6rem; }
.btn-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.6rem; }
.article-actions .btn { min-height: 2.9rem; }
@media (min-width: 600px) {
	.article-actions { grid-template-columns: auto auto; justify-content: start; }
	.btn.wide { width: auto; }
	.btn-row { grid-auto-columns: auto; }
}

.ai-box {
	margin-top: 1.5rem;
	padding: 1rem 1.15rem 1.1rem 1.2rem;
	border-radius: max(var(--radius), 8px);
	background: var(--accent-soft);
	border-left: 3px solid var(--accent);
}
.ai-box .label { margin-bottom: 0.6rem; }
.ai-box .label > span { display: inline-flex; align-items: center; gap: 0.4rem; }
.ai-box .icon-btn { width: 1.7rem; height: 1.7rem; margin: -0.35rem -0.45rem -0.35rem 0; }
.ai-out ul, .ai-out ol { padding-left: 1.15em; }
.ai-out li::marker { color: var(--accent); }
.ai-source { font-family: var(--sans); font-size: 0.78rem; color: var(--faint); margin: 0.75rem 0 0; }

/* ---------- Status, spinner, notices ---------- */

.ai-status {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	font-family: var(--sans);
	font-size: 0.88rem;
	color: var(--muted);
	padding: 0.25rem 0;
}
.spinner {
	width: 1.05rem;
	height: 1.05rem;
	flex: none;
	border-radius: 50%;
	border: 2px solid var(--line);
	border-top-color: var(--accent);
	animation: spin 0.9s linear infinite;
}
.ai-status + progress { margin-top: 0.5rem; }

.notice {
	display: flex;
	gap: 0.8rem;
	align-items: flex-start;
	padding: 1rem 1.1rem;
	border: 1px solid var(--line);
	border-radius: max(var(--radius), 8px);
	background: var(--surface);
	font-family: var(--sans);
	margin: 0.5rem 0;
}
.notice-ic { color: var(--accent); margin-top: 0.1rem; }
.notice strong { display: block; font-size: 0.95rem; font-weight: 600; }
.notice p { margin: 0.25rem 0 0.8rem; font-size: 0.86rem; line-height: 1.55; color: var(--muted); }
.ai-box .notice { background: var(--surface); margin: 0; }

/* ---------- Daily recap ---------- */

.recap-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.25rem 0 1.25rem; }
.recap-bar .btn { min-height: 2.9rem; }
#recap-status:not(:empty) { margin-bottom: 1rem; }
.recap-out:not(:empty) {
	padding: 1.25rem 1.3rem 1.35rem 1.4rem;
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 3px solid var(--accent);
	border-radius: max(var(--radius), 8px);
}
.recap-out h3 { display: flex; align-items: baseline; gap: 0.5rem; }
.recap-out h3:not(:first-child) { padding-top: 1.1rem; border-top: 1px solid var(--line); }
.recap-out li { margin: 0.45em 0; padding-left: 0.15em; }
.recap .ai-note { margin-top: 1.25rem; }

.ai-source { display: flex; gap: 0.4rem; align-items: flex-start; line-height: 1.45; }
.ai-source .ic { margin-top: 0.1rem; flex: none; }

.row small.full { color: var(--accent); white-space: nowrap; }
.row small.full .ic { display: inline; vertical-align: -1px; }
.help .ic { display: inline; vertical-align: -1px; }
