:root {
	--bg: #ffffff;
	--bg-side: #f3f3f5;
	--bg-bar: rgba(255, 255, 255, 0.92);
	--bg-hover: rgba(0, 0, 0, 0.05);
	--bg-selected: #dbe7fb;
	--text: #1d1d1f;
	--text-dim: #6e6e73;
	--text-read: #8a8a8f;
	--border: #e2e2e6;
	--accent: #2f6fde;
	--star: #e8a317;
	--error: #c2410c;
	--radius: 6px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
	--font-reading: var(--font);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1c1c1e;
		--bg-side: #232326;
		--bg-bar: rgba(28, 28, 30, 0.92);
		--bg-hover: rgba(255, 255, 255, 0.06);
		--bg-selected: #23395f;
		--text: #e8e8ed;
		--text-dim: #9a9aa1;
		--text-read: #7d7d84;
		--border: #38383c;
		--accent: #6c9ef8;
		--star: #f0b429;
		--error: #fb923c;
	}
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.4 var(--font);
	-webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Layout: three columns on wide screens. */

.app {
	display: grid;
	grid-template-columns: minmax(200px, 260px) minmax(280px, 400px) 1fr;
	height: 100vh;
	height: 100dvh;
}

.pane {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	border-right: 1px solid var(--border);
}

.pane > .scroll {
	flex: 1;
	overflow-y: auto;
}
.pane > .scroll:focus { outline: none; }

.bar {
	display: flex;
	align-items: center;
	gap: 6px;
	min-height: 48px;
	padding: 6px 10px;
	padding-top: max(6px, env(safe-area-inset-top));
	border-bottom: 1px solid var(--border);
	background: var(--bg-bar);
}

.bar h1, .bar h2 {
	flex: 1;
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--radius);
	background: none;
	color: var(--text-dim);
	cursor: pointer;
}
.icon:hover { background: var(--bg-hover); color: var(--text); }
.icon:disabled { opacity: 0.4; cursor: default; }

.back { display: none; }

/* Sidebar */

.sidebar { background: var(--bg-side); }

.nav {
	list-style: none;
	margin: 0;
	padding: 4px 6px;
}

.sidebar a[data-source] {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	border-radius: var(--radius);
}
.sidebar a[data-source]:hover { background: var(--bg-hover); }
.sidebar a[data-source].active { background: var(--bg-selected); }
.sidebar a[data-source].error .name::after { content: " ⚠"; color: var(--error); }

.sidebar .name {
	flex: 1;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.count {
	color: var(--text-dim);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.smart { border-bottom: 1px solid var(--border); padding-bottom: 6px; }

.folder > summary {
	display: flex;
	align-items: center;
	padding: 0 6px 0 0;
	margin-top: 4px;
	list-style: none;
	cursor: pointer;
}
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before {
	content: "▸";
	flex: none;
	width: 20px;
	text-align: center;
	color: var(--text-dim);
	font-size: 11px;
	transition: transform 0.1s;
}
.folder[open] > summary::before { transform: rotate(90deg); }
.folder > summary a { flex: 1; }
.folder > .nav { padding-left: 20px; padding-top: 0; }
.folder > summary .name { font-weight: 600; }

.refresh-status { color: var(--text-dim); font-size: 13px; }

/* Entry list */

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

.row { border-bottom: 1px solid var(--border); }

.row > a {
	display: block;
	padding: 10px 14px 10px 22px;
	position: relative;
}
.row > a:hover { background: var(--bg-hover); }
.row.selected > a { background: var(--bg-selected); }

.row.unread > a::before {
	content: "";
	position: absolute;
	left: 8px;
	top: 16px;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--accent);
}
.row.starred > a::after {
	content: "★";
	position: absolute;
	left: 6px;
	top: 30px;
	font-size: 11px;
	color: var(--star);
}

.row .meta {
	display: flex;
	gap: 8px;
	color: var(--text-dim);
	font-size: 12px;
}
.row .feed { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row .title { font-weight: 600; margin: 2px 0; }
.row .summary {
	color: var(--text-dim);
	font-size: 13px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.row:not(.unread) .title { color: var(--text-read); font-weight: 500; }

.more, .empty, .placeholder {
	padding: 24px;
	color: var(--text-dim);
	text-align: center;
}
.placeholder { margin: auto; }

/* Reader */

.reader { border-right: 0; }
.reader .bar { justify-content: flex-end; }
.actions { display: flex; gap: 2px; }
.actions [data-action="read"].on { color: var(--accent); }
.actions [data-action="read"].on circle { fill: currentColor; }
.actions [data-action="star"].on { color: var(--star); }
.actions [data-action="star"].on path { fill: currentColor; }

.article {
	max-width: 42em;
	margin: 0 auto;
	padding: 20px 24px 80px;
	font: 17px/1.6 var(--font-reading);
	overflow-wrap: break-word;
}
.article .byline, .article .date { margin: 0; color: var(--text-dim); font-size: 14px; }
.article .byline a:hover { text-decoration: underline; }
.article h1 { margin: 6px 0; font-size: 26px; line-height: 1.25; }
.article h1 a:hover { color: var(--accent); }
.article .date { margin-bottom: 20px; }

.content a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }
.content img, .content video, .content iframe { max-width: 100%; height: auto; }
.content figure { margin: 1em 0; }
.content figcaption { color: var(--text-dim); font-size: 14px; }
.content pre {
	overflow-x: auto;
	padding: 12px;
	border-radius: var(--radius);
	background: var(--bg-side);
	font-size: 14px;
	line-height: 1.45;
}
.content code { font-size: 0.9em; }
.content blockquote {
	margin: 1em 0;
	padding-left: 1em;
	border-left: 3px solid var(--border);
	color: var(--text-dim);
}
.content table { display: block; overflow-x: auto; border-collapse: collapse; }
.content td, .content th { padding: 4px 8px; border: 1px solid var(--border); }

/* Forms */

input[type="text"], input[type="password"], input:not([type]) {
	display: block;
	width: 100%;
	max-width: 32em;
	margin: 4px 0 14px;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--text);
	font: inherit;
	font-size: 16px; /* stops iOS zooming on focus */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button:not(.icon):not(.link) {
	padding: 8px 16px;
	border: 0;
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }

button.link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--text-dim);
	font: inherit;
	cursor: pointer;
}
button.link:hover { color: var(--text); text-decoration: underline; }

label { font-weight: 600; font-size: 14px; }
.hint { color: var(--text-dim); font-weight: normal; font-size: 14px; }
.error { color: var(--error); }

.form { font-size: 15px; }
.form form + form { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.form h3 { margin: 0 0 4px; font-size: 16px; }
.form fieldset { margin: 0 0 14px; padding: 0; border: 0; }
.form legend { margin-bottom: 8px; }
.form .choice { display: block; margin: 6px 0; font-weight: normal; overflow-wrap: anywhere; }
.form input[type="file"] { margin: 8px 0; }

/* htmx's own indicator styles are off (they'd need inline styles). */
.htmx-indicator { display: none; color: var(--text-dim); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.sidebar-footer { padding: 16px 14px; font-size: 13px; }

.reader .bar h2 { flex: 1; }

/* Login */

.login-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	min-height: 100dvh;
	padding: 16px;
	background: var(--bg-side);
}
.login-page .card {
	width: 100%;
	max-width: 22em;
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg);
}
.login-page h1 { margin: 0 0 16px; font-size: 20px; }
.login-page button { width: 100%; }

/* Narrow screens: one pane at a time, chosen by data-pane. */

/* The page itself scrolls here, rather than each pane, so mobile browsers'
   native behaviour (collapsing toolbars, tap status bar for top) works. */
@media (max-width: 760px) {
	html, body { height: auto; }
	.app { display: block; height: auto; }
	.pane { display: none; min-height: 100vh; min-height: 100dvh; border-right: 0; }
	.pane > .scroll { flex: none; overflow: visible; }
	.bar {
		position: sticky;
		top: 0;
		z-index: 1;
		-webkit-backdrop-filter: blur(12px);
		backdrop-filter: blur(12px);
	}
	.app[data-pane="sidebar"] .sidebar,
	.app[data-pane="list"] .list,
	.app[data-pane="article"] .reader { display: flex; }
	.back {
		display: inline-flex;
		align-items: center;
		width: 36px;
		height: 36px;
		color: var(--accent);
	}
	.reader .bar { justify-content: space-between; }
	.sidebar a[data-source] { padding: 10px 8px; }
	.row > a { padding: 12px 14px 12px 24px; }
	.article { padding: 16px 18px 80px; }
	.article h1 { font-size: 23px; }
}
