/*
 * SyncriTab User's Guide - self-contained styles.
 * No external fonts or frameworks, so a downloaded copy renders the same offline.
 */

:root {
	--bg: #ffffff;
	--bg-sidebar: #f5f7fa;
	--bg-code: #f0f2f5;
	--bg-note: #eef5fc;
	--border: #dde2e8;
	--text: #1f2933;
	--text-muted: #5b6776;
	--accent: #1565c0;
	--accent-hover: #0d47a1;
	--accent-soft: #e3eefb;
	--sidebar-width: 280px;
	--header-height: 56px;
	--font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: Consolas, "SFMono-Regular", Menlo, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #15191e;
		--bg-sidebar: #1c2127;
		--bg-code: #232931;
		--bg-note: #1b2835;
		--border: #2e353e;
		--text: #e3e7ec;
		--text-muted: #9aa5b1;
		--accent: #64a8f0;
		--accent-hover: #90c2f5;
		--accent-soft: #1f3247;
	}
}

:root[data-theme="dark"] {
	--bg: #15191e;
	--bg-sidebar: #1c2127;
	--bg-code: #232931;
	--bg-note: #1b2835;
	--border: #2e353e;
	--text: #e3e7ec;
	--text-muted: #9aa5b1;
	--accent: #64a8f0;
	--accent-hover: #90c2f5;
	--accent-soft: #1f3247;
}

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

html {
	scroll-padding-top: 16px;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 16px;
	line-height: 1.6;
}

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover {
	color: var(--accent-hover);
	text-decoration: underline;
}

code, kbd, pre {
	font-family: var(--font-mono);
	font-size: 0.9em;
}

code {
	background: var(--bg-code);
	padding: 1px 5px;
	border-radius: 4px;
}

/* ---------- Sidebar ---------- */

.sidebar {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: var(--sidebar-width);
	background: var(--bg-sidebar);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	z-index: 20;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	height: var(--header-height);
	padding: 0 20px;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.brand a {
	font-size: 1.3rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--text);
}

.brand a:hover {
	color: var(--accent);
	text-decoration: none;
}

.brand .brand-sub,
.brand a.brand-sub {
	font-size: 0.8rem;
	font-weight: 400;
	color: var(--text-muted);
	padding-top: 4px;
}

.toc {
	overflow-y: auto;
	padding: 12px 0 32px;
	flex: 1;
}

.toc-section + .toc-section {
	margin-top: 8px;
}

.toc-heading {
	margin: 8px 0 2px;
	font-size: 0.72rem;
}

.toc-heading button {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 6px 20px;
	background: none;
	border: 0;
	font: inherit;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	text-align: left;
	color: var(--text-muted);
	cursor: pointer;
}

.toc-heading button:hover {
	color: var(--text);
}

.toc-heading button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

/* A small chevron that points down when the section is open and right when it's collapsed. */
.toc-chevron {
	flex: 0 0 auto;
	width: 6px;
	height: 6px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	margin-top: -3px;
	transition: transform 0.15s ease;
}

.toc-section.collapsed .toc-chevron {
	transform: rotate(-45deg);
	margin-top: 0;
}

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

.toc li a {
	display: block;
	padding: 5px 20px 5px 48px;
	border-left: 3px solid transparent;
	font-size: 0.92rem;
	color: var(--text);
}

.toc li a:hover {
	background: var(--accent-soft);
	text-decoration: none;
}

.toc li a.active {
	border-left-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
}

/* ---------- Main content ---------- */

.topbar {
	display: none;
}

.content {
	margin-left: var(--sidebar-width);
	padding: 40px 48px 80px;
	max-width: calc(var(--sidebar-width) + 900px);
}

.content h1 {
	font-size: 2rem;
	line-height: 1.25;
	margin: 0 0 8px;
}

.content h2 {
	font-size: 1.35rem;
	margin: 40px 0 12px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--border);
}

.content h3 {
	font-size: 1.08rem;
	margin: 28px 0 4px;
}

.lead {
	font-size: 1.1rem;
	color: var(--text-muted);
	margin-top: 0;
}

.note {
	background: var(--bg-note);
	border-left: 4px solid var(--accent);
	padding: 12px 16px;
	border-radius: 0 6px 6px 0;
	margin: 20px 0;
}

.note p {
	margin: 0;
}

.topic-list {
	margin: 0;
}

.topic-list dt {
	font-weight: 600;
	margin-top: 18px;
}

.topic-list dt a {
	color: var(--text);
}

.topic-list dd {
	margin: 2px 0 0;
	color: var(--text-muted);
}

.content ul, .content ol {
	padding-left: 24px;
}

.content li + li {
	margin-top: 4px;
}

.content table {
	width: 100%;
	border-collapse: collapse;
	margin: 16px 0;
	font-size: 0.95rem;
}

.content th, .content td {
	text-align: left;
	vertical-align: top;
	padding: 8px 12px;
	border-bottom: 1px solid var(--border);
}

.content th {
	background: var(--bg-sidebar);
	font-weight: 600;
}

.table-wrap {
	overflow-x: auto;
}

.ui {
	font-weight: 600;
}

pre {
	background: var(--bg-code);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 12px 16px;
	overflow-x: auto;
	line-height: 1.5;
}

pre code {
	background: none;
	padding: 0;
	font-size: 0.9rem;
}

.note.warning {
	border-left-color: #c77700;
	background: #fff5e5;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .note.warning {
		background: #33270f;
	}
}

:root[data-theme="dark"] .note.warning {
	background: #33270f;
}

.steps > li {
	margin-bottom: 10px;
}

/* Simple left-to-right diagram: boxes joined by arrows; stacks vertically on phones. */
.flow {
	display: flex;
	align-items: stretch;
	gap: 0;
	margin: 24px 0 8px;
}

.flow-box {
	flex: 1;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 12px 14px;
	background: var(--bg-sidebar);
}

.flow-box.primary {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.flow-box strong {
	display: block;
	margin-bottom: 4px;
}

.flow-box span {
	font-size: 0.88rem;
	color: var(--text-muted);
}

.flow-arrow {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 72px;
	font-size: 0.75rem;
	color: var(--text-muted);
	text-align: center;
	position: relative;
}

.flow-arrow::after {
	content: "";
	position: absolute;
	left: 8px;
	right: 8px;
	top: 50%;
	border-top: 2px solid var(--text-muted);
}

.flow-arrow::before {
	content: "";
	position: absolute;
	right: 6px;
	top: calc(50% - 5px);
	border: 6px solid transparent;
	border-left-color: var(--text-muted);
	border-right: 0;
}

.flow-arrow span {
	position: relative;
	top: -14px;
	background: var(--bg);
	padding: 0 4px;
	z-index: 1;
}

.figure {
	margin: 24px 0;
}

.figure img {
	display: block;
	max-width: 100%;
	height: auto;
	border: 1px solid var(--border);
	border-radius: 6px;
}

.figure figcaption {
	font-size: 0.88rem;
	color: var(--text-muted);
	margin-top: 8px;
}

.figure-caption {
	font-size: 0.88rem;
	color: var(--text-muted);
	margin: 0 0 24px;
}

@media (max-width: 640px) {
	.flow {
		flex-direction: column;
	}

	.flow-arrow {
		flex-basis: 40px;
	}

	.flow-arrow::after {
		left: 50%;
		right: auto;
		top: 6px;
		bottom: 6px;
		border-top: 0;
		border-left: 2px solid var(--text-muted);
	}

	.flow-arrow::before {
		right: auto;
		left: calc(50% - 5px);
		top: auto;
		bottom: 4px;
		border: 6px solid transparent;
		border-top-color: var(--text-muted);
		border-bottom: 0;
	}

	.flow-arrow span {
		position: absolute;
		top: 11px;
		left: calc(50% + 12px);
		background: none;
		padding: 0;
	}
}

.breadcrumb {
	font-size: 0.85rem;
	color: var(--text-muted);
	margin-bottom: 6px;
}

.pager {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	margin-top: 56px;
}

.pager a {
	flex: 0 1 48%;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 16px;
	font-weight: 600;
}

.pager a:hover {
	border-color: var(--accent);
	text-decoration: none;
}

.pager a span {
	display: block;
	font-size: 0.78rem;
	font-weight: 400;
	color: var(--text-muted);
}

.pager .pager-next {
	margin-left: auto;
	text-align: right;
}

.content footer {
	margin-top: 64px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
	font-size: 0.85rem;
	color: var(--text-muted);
}

/* ---------- Narrow screens: sidebar becomes a drawer ---------- */

@media (max-width: 860px) {
	.topbar {
		display: flex;
		align-items: center;
		gap: 12px;
		position: sticky;
		top: 0;
		height: var(--header-height);
		padding: 0 16px;
		background: var(--bg-sidebar);
		border-bottom: 1px solid var(--border);
		z-index: 10;
	}

	.topbar .brand-link {
		font-size: 1.2rem;
		font-weight: 700;
		color: var(--text);
	}

	.toc-toggle {
		background: none;
		border: 1px solid var(--border);
		border-radius: 6px;
		color: var(--text);
		font-size: 1.1rem;
		width: 40px;
		height: 36px;
		cursor: pointer;
	}

	.sidebar {
		transform: translateX(-100%);
		transition: transform 0.2s ease;
		width: min(var(--sidebar-width), 85vw);
	}

	body.toc-open .sidebar {
		transform: translateX(0);
		box-shadow: 4px 0 16px rgba(0, 0, 0, 0.25);
	}

	.content {
		margin-left: 0;
		padding: 24px 16px 64px;
	}

	.content h1 {
		font-size: 1.6rem;
	}
}

@media print {
	.sidebar, .topbar {
		display: none;
	}

	.content {
		margin-left: 0;
		padding: 0;
	}
}
