* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
	--bg: #f5f5f5;
	--bg-content: white;
	--bg-header: #333;
	--bg-sidebar: #fafafa;
	--text: #333;
	--text-muted: #666;
	--text-faint: #999;
	--text-header: white;
	--border: #ddd;
	--code-bg: #f0f0f0;
	--highlight: #fff3cd;
	--highlight-active: #ffe69c;
	--highlight-border: #ffc107;
	--btn-bg: #555;
	--btn-primary: #4285f4;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #1a1a1a;
		--bg-content: #242424;
		--bg-header: #1e1e1e;
		--bg-sidebar: #1e1e1e;
		--text: #e0e0e0;
		--text-muted: #aaa;
		--text-faint: #777;
		--text-header: #e0e0e0;
		--border: #444;
		--code-bg: #2d2d2d;
		--highlight: #5c4a00;
		--highlight-active: #7a6200;
		--highlight-border: #ffc107;
		--btn-bg: #444;
		--btn-primary: #4285f4;
	}
}

[data-theme="dark"] {
	--bg: #1a1a1a;
	--bg-content: #242424;
	--bg-header: #1e1e1e;
	--bg-sidebar: #1e1e1e;
	--text: #e0e0e0;
	--text-muted: #aaa;
	--text-faint: #777;
	--text-header: #e0e0e0;
	--border: #444;
	--code-bg: #2d2d2d;
	--highlight: #5c4a00;
	--highlight-active: #7a6200;
	--highlight-border: #ffc107;
	--btn-bg: #444;
	--btn-primary: #4285f4;
}

body {
	font-family: system-ui, sans-serif;
	background: var(--bg);
	color: var(--text);
}

a { color: var(--btn-primary); }

.btn {
	padding: 0.5rem 1rem;
	background: var(--btn-bg);
	color: white;
	text-decoration: none;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	font-size: 1rem;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--btn-primary); }
.btn-secondary { background: var(--text-muted); }
.btn-small { padding: 0.4rem 0.75rem; font-size: 0.875rem; }
.btn-danger { background: #dc3545; }
.btn-danger:hover { background: #c82333; }

.theme-toggle {
	position: fixed;
	top: 1rem;
	right: 1rem;
	background: var(--bg-content);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 0.5rem;
	cursor: pointer;
	font-size: 1rem;
	z-index: 100;
}

/* Home & Login pages */
.page-center {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
}
.page-center .container {
	text-align: center;
}
.page-center h1 {
	margin-bottom: 1rem;
}
.page-center p {
	color: var(--text-muted);
	margin-bottom: 2rem;
}

/* Docs list page */
.page-docs {
	padding: 2rem;
}
.page-docs header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 2rem;
}
.page-docs h1 {
	font-size: 1.5rem;
}
.page-docs .actions {
	display: flex;
	gap: 1rem;
}
.docs {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.doc {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem;
	background: var(--bg-content);
	border-radius: 4px;
	border: 1px solid var(--border);
}
.doc-info {
	flex: 1;
}
.doc-title {
	font-weight: 500;
	margin-bottom: 0.25rem;
}
.doc-meta {
	font-size: 0.875rem;
	color: var(--text-muted);
}
.doc-actions {
	display: flex;
	gap: 0.5rem;
}
.empty {
	text-align: center;
	color: var(--text-muted);
	padding: 2rem;
}

/* Edit page */
.page-edit {
	height: 100vh;
	display: flex;
	flex-direction: column;
}
.page-edit header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem 1rem;
	background: var(--bg-header);
	color: var(--text-header);
}
.page-edit header input#title {
	background: transparent;
	border: none;
	color: var(--text-header);
	font-size: 1rem;
	font-weight: 500;
	outline: none;
	width: 300px;
}
.page-edit header input#title::placeholder {
	color: var(--text-muted);
}
.page-edit .actions {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}
.page-edit .status {
	font-size: 0.75rem;
	color: var(--text-muted);
}
.page-edit .share-link {
	font-size: 0.75rem;
	color: var(--text-muted);
}
.page-edit .share-link a {
	color: var(--btn-primary);
}
.page-edit .theme-toggle {
	position: static;
	background: transparent;
	border: none;
	padding: 0.25rem;
}
.editor-container {
	flex: 1;
	display: flex;
	overflow: hidden;
}
.editor, .preview {
	flex: 1;
	overflow: auto;
}
.editor textarea {
	width: 100%;
	height: 100%;
	padding: 1rem;
	border: none;
	resize: none;
	font-family: monospace;
	font-size: 0.9rem;
	line-height: 1.6;
	outline: none;
	background: var(--bg-content);
	color: var(--text);
}
.preview {
	padding: 1rem;
	border-left: 1px solid var(--border);
	background: var(--bg);
}
.preview h1, .preview h2, .preview h3 {
	margin-top: 1rem;
	margin-bottom: 0.5rem;
}
.preview h1:first-child {
	margin-top: 0;
}
.preview p {
	margin-bottom: 1rem;
	line-height: 1.6;
}
.preview code {
	background: var(--code-bg);
	padding: 0.2rem 0.4rem;
	border-radius: 3px;
	font-size: 0.9em;
}
.preview pre {
	background: var(--code-bg);
	padding: 1rem;
	border-radius: 4px;
	overflow-x: auto;
	margin-bottom: 1rem;
}
.preview pre code {
	background: none;
	padding: 0;
}
.preview ul, .preview ol {
	margin-bottom: 1rem;
	padding-left: 1.5rem;
}
.preview blockquote {
	border-left: 3px solid var(--border);
	padding-left: 1rem;
	color: var(--text-muted);
	margin-bottom: 1rem;
}

/* View page */
.page-view .layout {
	display: flex;
	max-width: 1200px;
	margin: 0 auto;
	min-height: 100vh;
}
.page-view .content {
	flex: 1;
	max-width: 800px;
	padding: 2rem;
	background: var(--bg-content);
}
.page-view .content h1, .page-view .content h2, .page-view .content h3 {
	margin-top: 1.5rem;
	margin-bottom: 0.5rem;
}
.page-view .content h1:first-child {
	margin-top: 0;
}
.page-view .content p {
	margin-bottom: 1rem;
	line-height: 1.7;
}
.page-view .content code {
	background: var(--code-bg);
	padding: 0.2rem 0.4rem;
	border-radius: 3px;
	font-size: 0.9em;
}
.page-view .content pre {
	background: var(--code-bg);
	padding: 1rem;
	border-radius: 4px;
	overflow-x: auto;
	margin-bottom: 1rem;
}
.page-view .content pre code {
	background: none;
	padding: 0;
}
.page-view .content ul, .page-view .content ol {
	margin-bottom: 1rem;
	padding-left: 1.5rem;
}
.page-view .content blockquote {
	border-left: 3px solid var(--border);
	padding-left: 1rem;
	color: var(--text-muted);
	margin-bottom: 1rem;
}
.highlight {
	background: var(--highlight);
	cursor: pointer;
	border-bottom: 2px solid var(--highlight-border);
}
.highlight:hover {
	background: var(--highlight-active);
}
.highlight.active {
	background: var(--highlight-active);
}
.sidebar {
	width: 300px;
	padding: 1rem;
	border-left: 1px solid var(--border);
	background: var(--bg-sidebar);
	overflow-y: auto;
}
.sidebar h3 {
	font-size: 0.875rem;
	color: var(--text-muted);
	margin-bottom: 1rem;
}
.comment {
	background: var(--bg-content);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 0.75rem;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
	cursor: pointer;
}
.comment:hover {
	border-color: var(--highlight-border);
}
.comment.active {
	border-color: var(--highlight-border);
	background: var(--highlight);
}
.comment-quote {
	background: var(--highlight);
	padding: 0.25rem 0.5rem;
	border-radius: 2px;
	margin-bottom: 0.5rem;
	font-style: italic;
	color: var(--text-muted);
}
.comment-text {
	margin-bottom: 0.25rem;
}
.comment-author {
	font-size: 0.75rem;
	color: var(--text-faint);
}
.comment-popup {
	position: absolute;
	background: var(--bg-content);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 0.75rem;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
	z-index: 100;
	width: 280px;
	display: none;
}
.comment-popup textarea {
	width: 100%;
	height: 60px;
	margin-bottom: 0.5rem;
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: 3px;
	resize: none;
	font-family: inherit;
	font-size: 0.875rem;
	background: var(--bg);
	color: var(--text);
}
.comment-popup input {
	width: 100%;
	margin-bottom: 0.5rem;
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: 3px;
	font-family: inherit;
	font-size: 0.875rem;
	background: var(--bg);
	color: var(--text);
}
.comment-popup .btns {
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
}
.comment-popup button {
	padding: 0.4rem 0.75rem;
	border: none;
	border-radius: 3px;
	cursor: pointer;
	font-size: 0.875rem;
}
.comment-popup .cancel {
	background: var(--code-bg);
	color: var(--text);
}
.comment-popup .submit {
	background: var(--btn-primary);
	color: white;
}
.add-comment-btn {
	position: absolute;
	background: var(--btn-primary);
	color: white;
	border: none;
	padding: 0.25rem 0.5rem;
	border-radius: 3px;
	cursor: pointer;
	font-size: 0.75rem;
	display: none;
	z-index: 99;
}

/* Home & Login */
.page-center {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
}
.page-center .container {
	text-align: center;
}
.page-center h1 {
	margin-bottom: 1rem;
}
.page-center p {
	color: var(--text-muted);
	margin-bottom: 2rem;
}

/* Docs list */
.page-docs {
	padding: 2rem;
}
.page-docs header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 2rem;
}
.page-docs h1 {
	font-size: 1.5rem;
}
.page-docs .actions {
	display: flex;
	gap: 1rem;
}
.docs {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.doc {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem;
	background: var(--bg-content);
	border-radius: 4px;
	border: 1px solid var(--border);
}
.doc-info {
	flex: 1;
}
.doc-title {
	font-weight: 500;
	margin-bottom: 0.25rem;
}
.doc-meta {
	font-size: 0.875rem;
	color: var(--text-muted);
}
.doc-actions {
	display: flex;
	gap: 0.5rem;
}
.empty {
	text-align: center;
	color: var(--text-muted);
	padding: 2rem;
}

/* Editor */
.page-edit {
	height: 100vh;
	display: flex;
	flex-direction: column;
}
.page-edit header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem 1rem;
	background: var(--bg-header);
	color: var(--text-header);
}
.page-edit header input#title {
	background: transparent;
	border: none;
	color: var(--text-header);
	font-size: 1rem;
	font-weight: 500;
	outline: none;
	width: 300px;
}
.page-edit header input#title::placeholder {
	color: var(--text-muted);
}
.page-edit .actions {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}
.page-edit .status {
	font-size: 0.75rem;
	color: var(--text-muted);
}
.page-edit .share-link {
	font-size: 0.75rem;
	color: var(--text-muted);
}
.page-edit .share-link a {
	color: var(--btn-primary);
}
.page-edit .theme-toggle {
	position: static;
	background: transparent;
	border: none;
	padding: 0.25rem;
}
.editor-container {
	flex: 1;
	display: flex;
	overflow: hidden;
}
.editor, .preview {
	flex: 1;
	overflow: auto;
}
.editor textarea {
	width: 100%;
	height: 100%;
	padding: 1rem;
	border: none;
	resize: none;
	font-family: monospace;
	font-size: 0.9rem;
	line-height: 1.6;
	outline: none;
	background: var(--bg-content);
	color: var(--text);
}
.preview {
	padding: 1rem;
	border-left: 1px solid var(--border);
	background: var(--bg);
}
.preview h1, .preview h2, .preview h3 {
	margin-top: 1rem;
	margin-bottom: 0.5rem;
}
.preview h1:first-child {
	margin-top: 0;
}
.preview p {
	margin-bottom: 1rem;
	line-height: 1.6;
}
.preview code {
	background: var(--code-bg);
	padding: 0.2rem 0.4rem;
	border-radius: 3px;
	font-size: 0.9em;
}
.preview pre {
	background: var(--code-bg);
	padding: 1rem;
	border-radius: 4px;
	overflow-x: auto;
	margin-bottom: 1rem;
}
.preview pre code {
	background: none;
	padding: 0;
}
.preview ul, .preview ol {
	margin-bottom: 1rem;
	padding-left: 1.5rem;
}
.preview blockquote {
	border-left: 3px solid var(--border);
	padding-left: 1rem;
	color: var(--text-muted);
	margin-bottom: 1rem;
}

/* View */
.page-view .layout {
	display: flex;
	max-width: 1200px;
	margin: 0 auto;
	min-height: 100vh;
}
.page-view .content {
	flex: 1;
	max-width: 800px;
	padding: 2rem;
	background: var(--bg-content);
}
.page-view .content h1, .page-view .content h2, .page-view .content h3 {
	margin-top: 1.5rem;
	margin-bottom: 0.5rem;
}
.page-view .content h1:first-child {
	margin-top: 0;
}
.page-view .content p {
	margin-bottom: 1rem;
	line-height: 1.7;
}
.page-view .content code {
	background: var(--code-bg);
	padding: 0.2rem 0.4rem;
	border-radius: 3px;
	font-size: 0.9em;
}
.page-view .content pre {
	background: var(--code-bg);
	padding: 1rem;
	border-radius: 4px;
	overflow-x: auto;
	margin-bottom: 1rem;
}
.page-view .content pre code {
	background: none;
	padding: 0;
}
.page-view .content ul, .page-view .content ol {
	margin-bottom: 1rem;
	padding-left: 1.5rem;
}
.page-view .content blockquote {
	border-left: 3px solid var(--border);
	padding-left: 1rem;
	color: var(--text-muted);
	margin-bottom: 1rem;
}
.highlight {
	background: var(--highlight);
	cursor: pointer;
	border-bottom: 2px solid var(--highlight-border);
}
.highlight:hover {
	background: var(--highlight-active);
}
.highlight.active {
	background: var(--highlight-active);
}
.sidebar {
	width: 300px;
	padding: 1rem;
	border-left: 1px solid var(--border);
	background: var(--bg-sidebar);
	overflow-y: auto;
}
.sidebar h3 {
	font-size: 0.875rem;
	color: var(--text-muted);
	margin-bottom: 1rem;
}
.comment {
	background: var(--bg-content);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 0.75rem;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
	cursor: pointer;
}
.comment:hover {
	border-color: var(--highlight-border);
}
.comment.active {
	border-color: var(--highlight-border);
	background: var(--highlight);
}
.comment-quote {
	background: var(--highlight);
	padding: 0.25rem 0.5rem;
	border-radius: 2px;
	margin-bottom: 0.5rem;
	font-style: italic;
	color: var(--text-muted);
}
.comment-text {
	margin-bottom: 0.25rem;
}
.comment-author {
	font-size: 0.75rem;
	color: var(--text-faint);
}
.comment-popup {
	position: absolute;
	background: var(--bg-content);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 0.75rem;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
	z-index: 100;
	width: 280px;
	display: none;
}
.comment-popup textarea {
	width: 100%;
	height: 60px;
	margin-bottom: 0.5rem;
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: 3px;
	resize: none;
	font-family: inherit;
	font-size: 0.875rem;
	background: var(--bg);
	color: var(--text);
}
.comment-popup input {
	width: 100%;
	margin-bottom: 0.5rem;
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: 3px;
	font-family: inherit;
	font-size: 0.875rem;
	background: var(--bg);
	color: var(--text);
}
.comment-popup .btns {
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
}
.comment-popup button {
	padding: 0.4rem 0.75rem;
	border: none;
	border-radius: 3px;
	cursor: pointer;
	font-size: 0.875rem;
}
.comment-popup .cancel {
	background: var(--code-bg);
	color: var(--text);
}
.comment-popup .submit {
	background: var(--btn-primary);
	color: white;
}
.add-comment-btn {
	position: absolute;
	background: var(--btn-primary);
	color: white;
	border: none;
	padding: 0.25rem 0.5rem;
	border-radius: 3px;
	cursor: pointer;
	font-size: 0.75rem;
	display: none;
	z-index: 99;
}