/* LiteSync Web — Obsidian 70% + Linear 20% 的克制风格，深色优先 */
:root,
:root[data-theme="dark"] {
	--bg: #1e1e1e;
	--bg-side: #191919;
	--bg-hover: #2a2a2a;
	--border: #333333;
	--text: #dcddde;
	--muted: #8a8a8a;
	--accent: #a882ff;
	--accent-dim: rgba(168, 130, 255, 0.15);
	--add: rgba(0, 160, 0, 0.2);
	--del: rgba(220, 60, 60, 0.18);
	--code-bg: #262626;
	--radius: 7px;
}
:root[data-theme="light"] {
	--bg: #ffffff;
	--bg-side: #f7f7f7;
	--bg-hover: #ececec;
	--border: #e5e5e5;
	--text: #222222;
	--muted: #888888;
	--accent: #7b52e0;
	--accent-dim: rgba(123, 82, 224, 0.1);
	--add: rgba(0, 150, 0, 0.14);
	--del: rgba(220, 60, 60, 0.12);
	--code-bg: #f2f2f2;
}

* {
	box-sizing: border-box;
}
html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
	font-size: 14px;
}
#app {
	height: 100%;
}
button {
	font: inherit;
	cursor: pointer;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	border-radius: var(--radius);
	padding: 6px 12px;
}
button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
button.ghost {
	background: transparent;
}
button.icon-btn {
	border: none;
	background: transparent;
	font-size: 15px;
	padding: 4px 8px;
}
button:hover {
	filter: brightness(1.1);
}
input {
	font: inherit;
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 7px 10px;
	outline: none;
}
input:focus {
	border-color: var(--accent);
}
a {
	color: var(--accent);
	text-decoration: none;
}
.muted {
	color: var(--muted);
}
.small {
	font-size: 12px;
}
.error {
	color: #e06060;
	min-height: 1em;
}
.spacer {
	flex: 1;
}

/* ---------- 居中页（登录 / 解锁 / 分享提示） ---------- */
.center-screen {
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.center-card {
	width: 340px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	text-align: center;
}
.center-card input {
	text-align: center;
}
.brand {
	font-size: 26px;
	font-weight: 650;
	letter-spacing: 0.5px;
}
.brand-small {
	font-weight: 650;
	color: var(--text);
	white-space: nowrap;
}

/* ---------- 主布局 ---------- */
.layout {
	height: 100%;
	display: grid;
	grid-template-columns: 250px minmax(0, 1fr) 220px;
	grid-template-rows: 48px minmax(0, 1fr) 28px;
	grid-template-areas:
		"header header header"
		"tree content outline"
		"footer footer footer";
}
header {
	grid-area: header;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 14px;
	border-bottom: 1px solid var(--border);
}
footer {
	grid-area: footer;
	display: flex;
	align-items: center;
	padding: 0 14px;
	border-top: 1px solid var(--border);
	color: var(--muted);
	font-size: 12px;
}

/* 搜索 */
.search-wrap {
	position: relative;
	width: 300px;
}
.search {
	width: 100%;
	background: var(--bg-side);
}
.search-results {
	position: absolute;
	top: 40px;
	left: 0;
	width: 380px;
	max-height: 50vh;
	overflow-y: auto;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
	z-index: 50;
}
.search-item {
	display: block;
	padding: 8px 12px;
	color: var(--text);
	border-bottom: 1px solid var(--border);
}
.search-item:last-child {
	border-bottom: none;
}
.search-item:hover {
	background: var(--bg-hover);
}

/* 文件树 */
.tree {
	grid-area: tree;
	overflow-y: auto;
	background: var(--bg-side);
	border-right: 1px solid var(--border);
	padding: 10px 6px;
	font-size: 13px;
}
.tree details {
	margin-left: 2px;
}
.tree summary {
	cursor: pointer;
	padding: 3px 6px;
	border-radius: 5px;
	list-style: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tree summary::-webkit-details-marker {
	display: none;
}
.tree summary:hover {
	background: var(--bg-hover);
}
.tree-children {
	margin-left: 12px;
	display: flex;
	flex-direction: column;
}
.tree-file {
	display: block;
	color: var(--text);
	padding: 3px 6px;
	border-radius: 5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tree-file:hover {
	background: var(--bg-hover);
}
.tree-file.active {
	background: var(--accent-dim);
	color: var(--accent);
}

/* 正文 */
.content {
	grid-area: content;
	overflow-y: auto;
	padding: 28px 40px 80px;
}
.note-wrap {
	max-width: 800px;
	margin: 0 auto;
}
.note-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}
.crumb {
	font-size: 12.5px;
}
.note-title {
	margin: 10px 0 4px;
	font-size: 30px;
}
.banner {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	background: var(--accent-dim);
	border: 1px solid var(--accent);
	border-radius: var(--radius);
	margin-bottom: 14px;
	flex-wrap: wrap;
}

/* 首页 */
.recent-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 10px;
	margin-top: 10px;
}
.recent-card {
	display: block;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 12px 14px;
	color: var(--text);
}
.recent-card:hover {
	background: var(--bg-hover);
}
.recent-title {
	font-weight: 600;
	margin-bottom: 4px;
}

/* Outline */
.outline {
	grid-area: outline;
	overflow-y: auto;
	border-left: 1px solid var(--border);
	padding: 16px 10px;
	font-size: 12.5px;
}
.outline-title {
	color: var(--muted);
	text-transform: uppercase;
	font-size: 11px;
	letter-spacing: 0.6px;
	margin-bottom: 8px;
}
.outline-item {
	display: block;
	color: var(--muted);
	padding: 3px 6px;
	border-radius: 5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.outline-item:hover {
	color: var(--text);
	background: var(--bg-hover);
}
.outline-item.lv2 {
	padding-left: 16px;
}
.outline-item.lv3 {
	padding-left: 28px;
}
.outline-item.lv4 {
	padding-left: 40px;
}

/* Markdown 正文排版 */
.markdown-body {
	line-height: 1.75;
	font-size: 15px;
	word-wrap: break-word;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
	margin: 1.4em 0 0.5em;
	line-height: 1.3;
}
.markdown-body h1 {
	font-size: 1.7em;
}
.markdown-body h2 {
	font-size: 1.35em;
	border-bottom: 1px solid var(--border);
	padding-bottom: 4px;
}
.markdown-body code {
	background: var(--code-bg);
	border-radius: 4px;
	padding: 1px 5px;
	font-size: 0.9em;
	font-family: Consolas, "JetBrains Mono", monospace;
}
.markdown-body pre {
	background: var(--code-bg);
	border-radius: var(--radius);
	padding: 12px 14px;
	overflow-x: auto;
}
.markdown-body pre code {
	background: none;
	padding: 0;
}
.markdown-body blockquote {
	margin: 0.6em 0;
	padding: 2px 14px;
	border-left: 3px solid var(--accent);
	color: var(--muted);
}
.markdown-body img {
	max-width: 100%;
	border-radius: var(--radius);
}
.markdown-body table {
	border-collapse: collapse;
	margin: 0.8em 0;
}
.markdown-body th,
.markdown-body td {
	border: 1px solid var(--border);
	padding: 5px 10px;
}
.markdown-body hr {
	border: none;
	border-top: 1px solid var(--border);
}
.attachment-img {
	max-width: 100%;
	border-radius: var(--radius);
}

/* Diff */
.diff-box {
	background: var(--code-bg);
	border-radius: var(--radius);
	padding: 10px;
	font-size: 12.5px;
	line-height: 1.6;
	font-family: Consolas, monospace;
	overflow-x: auto;
	white-space: pre-wrap;
	word-break: break-all;
}
.diff-add {
	background: var(--add);
}
.diff-del {
	background: var(--del);
	opacity: 0.85;
}

/* 历史抽屉 */
.drawer {
	position: fixed;
	top: 48px;
	right: 0;
	bottom: 28px;
	width: 300px;
	background: var(--bg-side);
	border-left: 1px solid var(--border);
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 60;
	overflow-y: auto;
}
.drawer-title {
	font-weight: 650;
}
.drawer-list {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.drawer-item {
	display: block;
	color: var(--text);
	padding: 7px 9px;
	border-radius: var(--radius);
	border: 1px solid transparent;
}
.drawer-item:hover {
	background: var(--bg-hover);
	border-color: var(--border);
}

/* 分享页 */
.share-card {
	width: 380px;
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.share-page {
	max-width: 860px;
	margin: 0 auto;
	padding: 20px;
}
.share-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	border-bottom: 1px solid var(--border);
	padding-bottom: 10px;
	margin-bottom: 20px;
}
/* 分享的显示名（v0.13.3 §7.4：来自密文，服务器不知道它） */
.share-name {
	flex: 1;
	min-width: 0;
	text-align: center;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 响应式 */
.menu-btn {
	display: none;
}
@media (max-width: 1100px) {
	.layout {
		grid-template-columns: 240px minmax(0, 1fr);
		grid-template-areas:
			"header header"
			"tree content"
			"footer footer";
	}
	.outline {
		display: none;
	}
}
@media (max-width: 760px) {
	.layout {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"header"
			"content"
			"footer";
	}
	.menu-btn {
		display: block;
	}
	.tree {
		position: fixed;
		top: 48px;
		bottom: 28px;
		left: 0;
		width: 260px;
		z-index: 70;
		transform: translateX(-100%);
		transition: transform 0.15s ease;
	}
	body.sidebar-open .tree {
		transform: translateX(0);
	}
	.search-wrap {
		width: 160px;
	}
	.content {
		padding: 20px 16px 60px;
	}
}

/* ---------- 备份设置页（v6） ---------- */
.settings-box {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.settings-card {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-side);
	padding: 16px 18px;
}
.settings-card h2 {
	margin: 0 0 10px;
	font-size: 15px;
}
.settings-grid {
	display: grid;
	grid-template-columns: 140px minmax(0, 1fr);
	gap: 6px 12px;
	align-items: baseline;
}
.settings-grid .ok {
	color: var(--accent);
}
.settings-label {
	display: block;
	margin: 12px 0 4px;
	color: var(--muted);
	font-size: 12px;
}
.settings-input {
	width: 100%;
	max-width: 460px;
}
.settings-row {
	display: flex;
	gap: 8px;
	align-items: center;
}
.settings-row .settings-input {
	flex: 1;
}
.settings-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 16px;
}
.settings-check {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 14px;
	cursor: pointer;
}
.settings-msg {
	min-height: 18px;
	margin: 10px 0 0;
}
.settings-msg.ok {
	color: var(--accent);
}
.settings-pw-warn {
	border: 1px solid var(--border);
	border-left: 3px solid #d9a53f;
	border-radius: var(--radius);
	padding: 8px 12px;
	margin-top: 8px;
}
.warn {
	color: #d9a53f;
}
.usage-bar {
	height: 8px;
	border-radius: 4px;
	background: var(--bg-hover);
	overflow: hidden;
	margin-top: 12px;
}
.usage-fill {
	height: 100%;
	background: var(--accent);
	transition: width 0.2s ease;
}
.usage-fill.yellow {
	background: #d9a53f;
}
.usage-fill.red {
	background: #d05050;
}
.snapshot-row {
	display: flex;
	gap: 12px;
	align-items: baseline;
	padding: 5px 0;
	border-bottom: 1px solid var(--border);
}
.snapshot-row:last-child {
	border-bottom: none;
}

/* 仓库状态横幅（v0.13.3 §7.5）：迁移中 / 完整性异常时必须显式告知用户 */
.repo-banner {
	position: sticky;
	top: 0;
	z-index: 50;
	padding: 10px 16px;
	background: #7a5b00;
	color: #fff;
	font-size: 13px;
	text-align: center;
}
.repo-banner-error {
	background: #8a1f1f;
}

/* 运维页（v0.17 / §11.3） */
.device-list,
.share-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 10px;
}
.device-list .settings-row,
.share-list .settings-row {
	align-items: center;
	justify-content: space-between;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
}
button.danger {
	background: transparent;
	color: #e5534b;
	border: 1px solid #e5534b;
	border-radius: 6px;
	padding: 4px 12px;
	cursor: pointer;
}
button.danger:hover:not(:disabled) {
	background: #e5534b;
	color: #fff;
}
button.danger:disabled {
	opacity: 0.5;
	cursor: default;
}
.restore-plan {
	margin-top: 12px;
}
.restore-plan ul {
	margin: 8px 0;
	padding-left: 20px;
}
/* 恢复命令要能一眼看清、一键复制：出事那天没人想手打一串 id */
pre.cmd {
	background: var(--bg-alt, rgba(127, 127, 127, 0.12));
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 10px 12px;
	overflow-x: auto;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 13px;
	user-select: all;
}
