/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
	--sidebar-width: 220px;
	--header-height: 35px;
	--footer-height: 22px;
	--radius: 6px;
	--radius-sm: 4px;
	--transition: 0.12s ease;

	/* Light theme — warm neutral, not washed-out */
	--bg-primary: #FAFAFA;
	--bg-secondary: #F2F2F3;
	--bg-tertiary: #E8E8EA;
	--bg-hover: #EAEAEC;
	--text-primary: #1A1A1E;
	--text-secondary: #52525B;
	--text-muted: #A1A1AA;
	--border-color: #E4E4E7;
	--border-subtle: #ECECEE;
	--accent-color: #10B981;
	--accent-hover: #059669;
	--accent-dim: rgba(16, 185, 129, 0.10);
	--accent-border: rgba(16, 185, 129, 0.30);
	--selection: rgba(16, 185, 129, 0.22);
	--hover-bg: #F0FDF4;
	--active-bg: rgba(16, 185, 129, 0.14);
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
	--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
	--danger: #EF4444;
	--danger-hover: #DC2626;

	--editor-font-size: 13px;
	--editor-line-height: 1.65;
}

[data-theme="dark"] {
	--bg-primary: #111214;
	--bg-secondary: #17181B;
	--bg-tertiary: #1F2025;
	--bg-hover: #1C1D21;
	--text-primary: #ECEEF2;
	--text-secondary: #8B93A5;
	--text-muted: #525866;
	--border-color: #2A2C33;
	--border-subtle: #222429;
	--accent-color: #10B981;
	--accent-hover: #34D399;
	--accent-dim: rgba(16, 185, 129, 0.09);
	--accent-border: rgba(16, 185, 129, 0.22);
	--selection: rgba(16, 185, 129, 0.22);
	--hover-bg: #1A1D22;
	--active-bg: rgba(16, 185, 129, 0.13);
	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.28);
	--shadow-md: 0 6px 24px rgba(0, 0, 0, 0.40);
	--danger: #F87171;
	--danger-hover: #EF4444;

	--editor-font-size: 13px;
	--editor-line-height: 1.65;
}

/* ============================================================
   RESET
   ============================================================ */
*,
*::before,
*::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html {
	height: 100%;
}

body {
	height: 100vh;
	background: var(--bg-primary);
	color: var(--text-primary);
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 14px;
	overflow: hidden;
	transition: background var(--transition), color var(--transition);
}

button {
	font-family: inherit;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app {
	display: flex;
	height: 100vh;
	width: 100vw;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
	width: var(--sidebar-width);
	min-width: 180px;
	background: var(--bg-secondary);
	border-right: 1px solid var(--border-color);
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	z-index: 10;
	overflow: hidden;
}

.sidebar.resizing {
	transition: none;
}

/* ── Sidebar Header / Workspace Switcher ── */
.sidebar-header {
	padding: 8px;
	border-bottom: 1px solid var(--border-color);
}

.ws-switcher-btn {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 6px;
	border: 1px solid transparent;
	background: transparent;
	color: var(--text-primary);
	cursor: pointer;
	text-align: left;
}

.ws-switcher-btn:hover {
	background: var(--bg-hover);
	border-color: var(--border-color);
}

.sidebar-logo-img {
	width: 25px;
	object-fit: contain;
	flex-shrink: 0;
}

.ws-name-wrap {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.sidebar-ws-name {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.2;
}

.sidebar-ws-folder {
	font-size: 11px;
	color: var(--text-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.3;
	margin-top: 1px;
}

.sidebar-ws-folder.has-folder {
	color: var(--text-secondary);
}

.ws-switch-icon {
	color: var(--text-muted);
	flex-shrink: 0;
}

/* ── GitHub Style Workspace Dropdown ── */
.ws-dropdown {
	position: absolute;
	top: 100%;
	left: 8px;
	width: calc(100% - 16px);
	min-width: 0;
	box-sizing: border-box;
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	box-shadow: var(--shadow-md);
	z-index: 1000;
	margin-top: 4px;
	padding: 4px;
	animation: modalIn 0.12s ease;
}

.ws-dropdown-header {
	padding: 6px 8px 4px;
	font-size: 11px;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.ws-dropdown-search {
	padding: 4px;
}

.ws-dropdown-search input {
	width: 100%;
	padding: 5px 8px;
	font-size: 12px;
	border-radius: 5px;
	border: 1px solid var(--border-color);
	background: var(--bg-secondary);
	color: var(--text-primary);
	outline: none;
	font-family: inherit;
}

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

.ws-dropdown-list {
	max-height: 200px;
	overflow-y: auto;
	padding: 2px 0;
}

.ws-dropdown-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	font-size: 12.5px;
	color: var(--text-secondary);
	border-radius: 5px;
	cursor: pointer;
	transition: background var(--transition), color var(--transition);
}

.ws-dropdown-item:hover {
	background: var(--hover-bg);
	color: var(--text-primary);
}

.ws-dropdown-item.active {
	font-weight: 600;
	color: var(--accent-color);
	background: var(--active-bg);
}

.ws-dropdown-item .ws-item-icon {
	color: var(--text-muted);
	flex-shrink: 0;
}

.ws-dropdown-item.active .ws-item-icon {
	color: var(--accent-color);
}

.ws-dropdown-item .ws-item-name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ws-dropdown-item .ws-item-check {
	color: var(--accent-color);
	flex-shrink: 0;
}

.ws-dropdown-divider {
	height: 1px;
	background: var(--border-color);
	margin: 4px 0;
}

.ws-dropdown-action {
	color: var(--text-primary);
}

.ws-dropdown-action i {
	color: var(--accent-color);
}

/* ── Section Header & Actions ── */
.section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 8px 4px 10px;
	user-select: none;
}

.section-title-wrap {
	display: flex;
	align-items: center;
	gap: 4px;
	cursor: pointer;
}

.section-title {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
	color: var(--text-muted);
	text-transform: uppercase;
}

.section-chevron {
	color: var(--text-muted);
	transition: transform var(--transition);
}

.section-actions {
	display: flex;
	align-items: center;
	gap: 5px;
	opacity: 0;
	transition: opacity var(--transition);
}

.sidebar-section:hover .section-actions {
	opacity: 1;
}

.icon-btn {
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 3px;
	border: none;
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: color var(--transition), background var(--transition);
}

.icon-btn:hover {
	color: var(--text-primary);
	background: var(--bg-tertiary);
}

/* ── Search ── */
.search {
	padding: 2px 10px 6px;
}

.search-container {
	position: relative;
	display: flex;
	align-items: center;
}

.search input {
	width: 100%;
	padding: 5px 8px;
	font-size: 12px;
	border-radius: 5px;
	border: 1px solid var(--border-color);
	background: var(--bg-primary);
	color: var(--text-primary);
	outline: none;
	transition: border-color var(--transition), box-shadow var(--transition);
	font-family: inherit;
}

.search input:focus {
	border-color: var(--accent-color);
	box-shadow: 0 0 0 2px var(--accent-dim);
}

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

/* ── Sidebar Sections ── */
.sidebar-section {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.section-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}

.section-body.collapsed {
	display: none;
}

/* File Tree */
.file-tree {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 4px 0;
}

.file-tree::-webkit-scrollbar {
	width: 4px;
}

.file-tree::-webkit-scrollbar-thumb {
	background: var(--border-color);
	border-radius: 2px;
}

.file-item {
	display: flex;
	align-items: center;
	padding: 4px 8px 4px 10px;
	cursor: pointer;
	font-size: 12.5px;
	color: var(--text-secondary);
	border-radius: 5px;
	margin: 1px 5px;
	position: relative;
	user-select: none;
	min-height: 28px;
	transition: background var(--transition), color var(--transition);
}

.file-item:hover {
	background: var(--hover-bg);
	color: var(--text-primary);
}

.file-item.active {
	background: var(--active-bg);
	color: var(--accent-color);
	font-weight: 500;
}

.file-item.dragging {
	opacity: 0.4;
}

.file-item.drag-over {
	background: var(--selection);
	outline: 1px dashed var(--accent-color);
}

.file-item .icon {
	margin-right: 10px;
	flex-shrink: 0;
	color: var(--text-muted);
	width: 16px;
	text-align: center;
}

.file-item.active .icon {
	color: var(--accent-color);
}

.item-name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Inline rename input */
.inline-rename-input {
	flex: 1;
	min-width: 0;
	padding: 1px 5px;
	font-size: 13px;
	font-family: inherit;
	background: var(--bg-primary);
	color: var(--text-primary);
	border: 1px solid var(--accent-color);
	border-radius: 4px;
	outline: none;
}

/* Actions */
.actions {
	margin-left: 4px;
	display: flex;
	gap: 2px;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--transition);
	flex-shrink: 0;
}

.file-item:hover .actions {
	opacity: 1;
	pointer-events: auto;
}

.action-btn {
	padding: 3px;
	border-radius: 4px;
	cursor: pointer;
	color: var(--text-muted);
	display: flex;
	align-items: center;
	transition: color var(--transition), background var(--transition);
}

.action-btn:hover {
	color: var(--text-primary);
	background: var(--bg-tertiary);
}

.action-btn-danger:hover {
	color: var(--danger);
}

/* Empty state */
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 32px 16px;
	color: var(--text-muted);
	text-align: center;
}

.empty-state p {
	font-size: 13px;
	font-weight: 500;
}

.empty-state small {
	font-size: 11px;
}

/* Workspace Footer */
.workspace-footer {
	padding: 10px 12px 12px;
	border-top: 1px solid var(--border-color);
}

.storage-quota-banner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 6px 10px;
	margin-bottom: 8px;
	border-radius: var(--radius);
	font-size: 11.5px;
	line-height: 1.3;
	transition: all var(--transition);
}

.storage-quota-banner.warning {
	background: rgba(234, 179, 8, 0.12);
	border: 1px solid rgba(234, 179, 8, 0.35);
	color: #ca8a04;
}

[data-theme="dark"] .storage-quota-banner.warning {
	background: rgba(234, 179, 8, 0.15);
	border: 1px solid rgba(234, 179, 8, 0.35);
	color: #facc15;
}

.storage-quota-banner.danger {
	background: rgba(239, 68, 68, 0.12);
	border: 1px solid rgba(239, 68, 68, 0.35);
	color: #dc2626;
}

[data-theme="dark"] .storage-quota-banner.danger {
	background: rgba(239, 68, 68, 0.15);
	border: 1px solid rgba(239, 68, 68, 0.35);
	color: #f87171;
}

.storage-quota-text-wrap {
	display: flex;
	align-items: center;
	gap: 6px;
	font-weight: 500;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.storage-quota-btn {
	background: var(--bg-primary);
	border: 1px solid currentColor;
	color: inherit;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 4px;
	cursor: pointer;
	white-space: nowrap;
	font-family: inherit;
	flex-shrink: 0;
}

.storage-quota-btn:hover {
	opacity: 0.85;
}

.save-workspace-btn {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 8px 12px;
	background: var(--bg-primary);
	color: var(--text-secondary);
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: color var(--transition), border-color var(--transition), background var(--transition);
	font-family: inherit;
}

.save-workspace-btn:hover {
	border-color: var(--accent-color);
	color: var(--accent-color);
	background: var(--accent-dim);
}

.save-workspace-btn.disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.browser-support-message {
	font-size: 11px;
	color: var(--text-muted);
	margin-top: 6px;
	text-align: center;
	line-height: 1.4;
}

/* ============================================================
   RESIZE HANDLE
   ============================================================ */
.sidebar-resize-handle {
	width: 3px;
	height: 100vh;
	background: var(--border-color);
	cursor: col-resize;
	user-select: none;
	flex-shrink: 0;
	transition: background var(--transition);
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
	background: var(--accent-color);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
	flex: 1;
	display: flex;
	flex-direction: column;
	background: var(--bg-primary);
	min-width: 0;
	min-height: 0;
	height: 100%;
	overflow: hidden;
}

/* ── Editor Tabs Bar (VS Code Style) ── */
.editor-tabs-bar {
	display: flex;
	align-items: center;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border-color);
	height: 31px;
	overflow-x: auto;
	overflow-y: hidden;
	flex-shrink: 0;
	user-select: none;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	scrollbar-color: var(--border-color) transparent;
}

.editor-tabs-bar::-webkit-scrollbar {
	height: 4px;
}

.editor-tabs-bar::-webkit-scrollbar-track {
	background: transparent;
}

.editor-tabs-bar::-webkit-scrollbar-thumb {
	background: var(--border-color);
	border-radius: 4px;
}

.editor-tabs-bar::-webkit-scrollbar-thumb:hover {
	background: var(--accent-color);
}

.tabs-list {
	display: flex;
	align-items: center;
	height: 100%;
}

.tab-item {
	display: flex;
	align-items: center;
	gap: 5px;
	height: 100%;
	padding: 0 10px;
	font-size: 11.5px;
	color: var(--text-secondary);
	border-right: 1px solid var(--border-color);
	background: var(--bg-secondary);
	cursor: pointer;
	position: relative;
	transition: background var(--transition), color var(--transition);
	max-width: 170px;
}

.tab-item:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.tab-item.active {
	background: var(--bg-primary);
	color: var(--text-primary);
	font-weight: 500;
	border-top: 2px solid var(--accent-color);
}

.tab-item .tab-icon {
	color: var(--text-muted);
	flex-shrink: 0;
}

.tab-item.active .tab-icon {
	color: var(--accent-color);
}

.tab-item .tab-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
}

.tab-item .tab-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	border-radius: 3px;
	color: var(--text-muted);
	opacity: 0.6;
	transition: opacity var(--transition), background var(--transition), color var(--transition);
}

.tab-item:hover .tab-close {
	opacity: 1;
}

.tab-item .tab-close:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

/* Top bar */
.topbar {
	height: var(--header-height);
	border-bottom: 1px solid var(--border-color);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 12px;
	background: var(--bg-primary);
	gap: 10px;
	flex-shrink: 0;
}

#breadcrumb {
	flex: 1;
	min-width: 0;
	font-size: 12px;
	color: var(--text-secondary);
	display: flex;
	align-items: center;
	gap: 4px;
	overflow: hidden;
	white-space: nowrap;
}

.breadcrumb-item {
	flex-shrink: 0;
	cursor: pointer;
}

.breadcrumb-item:hover {
	color: var(--text-primary);
}

.breadcrumb-item:not(:last-child)::after {
	content: "/";
	margin-left: 4px;
	color: var(--text-muted);
}

.breadcrumb-item:last-child {
	color: var(--text-primary);
	font-weight: 500;
}

.controls {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-shrink: 0;
}

/* Mode switch */
.mode-switch-group {
	display: flex;
	background: var(--bg-tertiary);
	border: 1px solid var(--border-color);
	border-radius: 6px;
	padding: 2px;
	gap: 1px;
}

.mode-btn {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	font-size: 11.5px;
	font-weight: 500;
	border: none;
	background: transparent;
	color: var(--text-muted);
	border-radius: 4px;
	cursor: pointer;
	transition: all var(--transition);
	font-family: inherit;
}

.mode-btn:hover {
	color: var(--text-primary);
}

.mode-btn.active {
	background: var(--bg-primary);
	color: var(--accent-color);
	box-shadow: var(--shadow-sm);
	font-weight: 600;
}

.control-btn {
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 5px;
	border: 1px solid var(--border-color);
	background: transparent;
	color: var(--text-secondary);
	cursor: pointer;
	transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.control-btn:hover {
	color: var(--text-primary);
	border-color: var(--accent-color);
	background: var(--accent-dim);
}

/* ============================================================
   EDITOR
   ============================================================ */
.editor-container {
	flex: 1;
	display: flex;
	overflow: hidden;
	position: relative;
	min-height: 0;
	min-width: 0;
	height: 100%;
}

/* Editor Loading Overlay */
.editor-loading-overlay {
	position: absolute;
	inset: 0;
	background: var(--bg-primary);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	z-index: 25;
	transition: opacity 0.15s ease, visibility 0.15s ease;
	user-select: none;
}

.editor-loading-spinner {
	width: 26px;
	height: 26px;
	border: 2.5px solid var(--border-color);
	border-top-color: var(--accent-color);
	border-radius: 50%;
	animation: editorSpin 0.7s linear infinite;
}

.editor-loading-text {
	font-size: 13px;
	font-weight: 500;
	color: var(--text-secondary);
	letter-spacing: 0.2px;
}

@keyframes editorSpin {
	to { transform: rotate(360deg); }
}

/* Editor Empty State */
.editor-empty-state {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	color: var(--text-muted);
	text-align: center;
	padding: 40px 20px;
	user-select: none;
	width: 100%;
	height: 100%;
}

.editor-empty-state .empty-state-icon {
	color: var(--text-muted);
	opacity: 0.35;
	margin-bottom: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.editor-empty-state p {
	font-size: 15px;
	font-weight: 500;
	color: var(--text-secondary);
	margin: 0;
}

.editor-empty-state small {
	font-size: 12px;
	color: var(--text-muted);
}

.editor-empty-state small b {
	color: var(--text-secondary);
	font-weight: 600;
}

.empty-state-link {
	color: var(--accent-color);
	text-decoration: underline;
	cursor: pointer;
	font-weight: 500;
	transition: opacity var(--transition);
}

.empty-state-link:hover {
	opacity: 0.8;
}

/* Image Viewer */
.image-viewer-wrapper {
	display: flex;
	flex-direction: column;
	flex: 1;
	height: 100%;
	overflow: hidden;
	background: var(--bg-primary);
}

.text-controls-group {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.image-viewer-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 16px;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border-color);
	font-size: 13px;
	color: var(--text-secondary);
	flex-shrink: 0;
	gap: 16px;
	min-height: 44px;
	box-sizing: border-box;
}

.image-viewer-info {
	font-family: var(--font-mono, monospace);
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
	min-width: 0;
}

.image-viewer-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.image-viewer-actions .control-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	width: auto;
	min-width: fit-content;
	height: 30px;
	font-size: 12px;
	white-space: nowrap;
	flex-shrink: 0;
	border-radius: var(--radius-sm, 4px);
	border: 1px solid var(--border-color);
	background: var(--bg-primary);
	color: var(--text-primary);
	cursor: pointer;
	transition: background var(--transition);
}

.image-viewer-actions .control-btn:hover {
	background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.image-viewer-body {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: auto;
	padding: 24px;
	background:
		repeating-conic-gradient(var(--bg-secondary) 0% 25%, transparent 0% 50%) 50% / 20px 20px,
		var(--bg-primary);
}

.image-viewer-img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 6px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Plain text editor */
.plain-editor-wrapper {
	display: flex;
	flex: 1;
	height: 100%;
	overflow: hidden;
}

.line-numbers {
	width: 36px;
	flex-shrink: 0;
	background: var(--bg-secondary);
	border-right: 1px solid var(--border-color);
	color: var(--text-muted);
	text-align: right;
	padding: 12px 6px 0 0;
	font-family: "JetBrains Mono", monospace;
	font-size: 12px;
	white-space: pre;
	user-select: none;
	overflow: hidden;
	box-sizing: border-box;
	cursor: pointer;
}

.code-editor-area {
	flex: 1;
	height: 100%;
	position: relative;
	overflow: hidden;
	cursor: text;
}

#codeHighlightPre {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 12px 16px;

	font-family: "JetBrains Mono", "Fira Code", monospace;
	font-size: var(--editor-font-size);
	line-height: calc(var(--editor-font-size) * 1.5385);
	letter-spacing: normal;

	white-space: pre;
	word-wrap: normal;
	overflow: hidden;
	scrollbar-gutter: stable;
	pointer-events: none;

	background: var(--bg-primary);
	border: none;
	z-index: 1;
	box-sizing: border-box;
}

#codeHighlightPre code {
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	letter-spacing: inherit;
	background: transparent !important;
	padding: 0 !important;
}

#editor {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 12px 16px;

	font-family: "JetBrains Mono", "Fira Code", monospace;
	font-size: var(--editor-font-size);
	line-height: calc(var(--editor-font-size) * 1.5385);
	letter-spacing: normal;
	white-space: pre;
	tab-size: 4;

	overflow: auto;
	scrollbar-gutter: stable;
	box-sizing: border-box;
	z-index: 2;

	background: transparent;
	color: transparent;
	caret-color: var(--accent-color);

	resize: none;
	border: none;
	outline: none;
	cursor: text;
}

/* Word Wrap Mode */
.word-wrap-active #codeHighlightPre,
.word-wrap-active #codeHighlightPre code,
.word-wrap-active #editor {
	white-space: pre-wrap !important;
	word-wrap: break-word !important;
	overflow-wrap: break-word !important;
	word-break: normal !important;
	overflow-x: hidden !important;
}

.word-wrap-active .line-numbers {
	display: none;
}

/* Custom Modern Thin Scrollbars */
#codeHighlightPre::-webkit-scrollbar,
#editor::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

#codeHighlightPre::-webkit-scrollbar-track,
#editor::-webkit-scrollbar-track {
	background: transparent;
}

#codeHighlightPre::-webkit-scrollbar-thumb,
#editor::-webkit-scrollbar-thumb {
	background: rgba(160, 160, 160, 0.25);
	border-radius: 4px;
}

#codeHighlightPre::-webkit-scrollbar-thumb:hover,
#editor::-webkit-scrollbar-thumb:hover {
	background: rgba(160, 160, 160, 0.45);
}

.control-btn.active {
	background: var(--accent-dim);
	border-color: var(--accent-color);
	color: var(--accent-color);
}

#editor::selection {
	background: var(--selection);
	color: transparent;
}

#editor::placeholder {
	color: var(--text-muted);
}

/* Editor.js */
.editorjs-wrapper {
	flex: 1;
	height: 100%;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 32px 0;
	scrollbar-width: thin;
	scrollbar-color: rgba(160, 160, 160, 0.3) transparent;
}

.editorjs-wrapper ::selection {
	background: var(--selection);
	/* color: var(--text-primary); */
}

.editorjs-wrapper::-webkit-scrollbar {
	width: 8px;
}

.editorjs-wrapper::-webkit-scrollbar-track {
	background: transparent;
}

.editorjs-wrapper::-webkit-scrollbar-thumb {
	background: rgba(160, 160, 160, 0.28);
	border-radius: 4px;
}

.editorjs-wrapper::-webkit-scrollbar-thumb:hover {
	background: rgba(160, 160, 160, 0.48);
}

#editorjs-holder {
	max-width: 780px;
	margin: 0 auto;
	padding: 0 32px;
}

.codex-editor__redactor {
	padding-bottom: 200px !important;
}

.ce-block__content,
.ce-toolbar__content {
	max-width: 100% !important;
}

.ce-paragraph {
	font-size: var(--editor-font-size) !important;
	line-height: var(--editor-line-height);
	color: var(--text-primary);
}

/* Editor.js blocks follow the selected editor font size */
.editorjs-wrapper {
	font-size: var(--editor-font-size);
}

.editorjs-wrapper .ce-block,
.editorjs-wrapper .ce-block__content,
.editorjs-wrapper .cdx-block:not(.ce-header) {
	font-size: var(--editor-font-size) !important;
}

/* Code blocks */
.editorjs-wrapper .ce-code-wrapper {
	position: relative;
	margin: 6px 0;
}

.editorjs-wrapper .ce-code__lang-input {
	display: block;
	width: auto;
	max-width: 180px;
	padding: 4px 8px;
	margin-bottom: 6px;
	font-family: var(--font-mono, monospace);
	font-size: 11px;
	color: var(--text-secondary);
	background: var(--bg-tertiary);
	border: 1px solid var(--border-color);
	border-radius: 4px;
	outline: none;
	transition: border-color var(--transition);
}

.editorjs-wrapper .ce-code__lang-input:focus {
	border-color: var(--accent);
	color: var(--text-primary);
}

.editorjs-wrapper .ce-code__textarea,
.editorjs-wrapper .ce-rawtool__textarea,
.editorjs-wrapper .ce-rawinput {
	font-size: var(--editor-font-size) !important;
	line-height: 1.5385;
}

/* Quotes */
.editorjs-wrapper .cdx-quote {
	font-size: var(--editor-font-size);
}

/* Lists */
.editorjs-wrapper .cdx-list {
	font-size: var(--editor-font-size);
}

/* Checklists */
.editorjs-wrapper .cdx-checklist {
	font-size: var(--editor-font-size);
}

/* Tables */
.editorjs-wrapper .tc-table {
	font-size: var(--editor-font-size);
}

.editorjs-wrapper .tc-cell {
	font-size: var(--editor-font-size);
}

/* Delimiter / Horizontal rule */
.editorjs-wrapper .ce-delimiter {
	line-height: 1.6em;
	width: 100%;
	text-align: center;
	padding: 12px 0;
}
.editorjs-wrapper .ce-delimiter:before {
	content: "";
	display: block;
	width: 100%;
	height: 1px;
	background: var(--border-color);
}

/* Callout / Warning block */
.editorjs-wrapper .cdx-warning {
	position: relative;
	border-radius: var(--radius);
	padding: 12px 16px 12px 42px;
	margin: 8px 0;
	background: rgba(245, 158, 11, 0.07);
	border: 1px solid rgba(245, 158, 11, 0.25);
}
.editorjs-wrapper .cdx-warning:before {
	top: 12px;
	left: 12px;
}
.editorjs-wrapper .cdx-warning__title {
	font-weight: 600;
	font-size: var(--editor-font-size);
	color: #D97706;
	margin-bottom: 4px;
}
.editorjs-wrapper .cdx-warning__message {
	font-size: var(--editor-font-size);
	min-height: auto !important;
	color: var(--text-primary);
}

/* Images */
.editorjs-wrapper .cdx-simple-image {
	margin: 12px 0;
}
.editorjs-wrapper .cdx-simple-image img {
	max-width: 100%;
	border-radius: var(--radius);
	display: block;
}
.editorjs-wrapper .cdx-simple-image__caption {
	font-size: 12px;
	color: var(--text-secondary);
	text-align: center;
	margin-top: 6px;
}
.editorjs-wrapper .ce-image-url-input {
	font-size: 12px;
	font-family: inherit;
}

/* Marker (Highlight) & Underline */
.cdx-marker {
	background: rgba(253, 224, 71, 0.45);
	color: inherit;
	padding: 1px 3px;
	border-radius: 2px;
}
.cdx-underline {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.editorjs-wrapper a {
	color: #60A5FA;
	text-decoration: underline;
	text-underline-offset: 3px;
	transition: color var(--transition);
}

.editorjs-wrapper a:hover {
	color: #93C5FD;
}

[data-theme="light"] .editorjs-wrapper a {
	color: #2563EB;
}

[data-theme="light"] .editorjs-wrapper a:hover {
	color: #1D4ED8;
}

/* Dark mode Editor.js overrides */
[data-theme="dark"] .ce-block--selected .ce-block__content {
	background: var(--hover-bg);
}

[data-theme="dark"] .ce-inline-toolbar,
[data-theme="dark"] .ce-popover,
[data-theme="dark"] .ce-popover--inline,
[data-theme="dark"] .ce-conversion-toolbar {
	background: var(--bg-secondary) !important;
	border-color: var(--border-color) !important;
	color: var(--text-primary) !important;
	box-shadow: var(--shadow-md) !important;
}

[data-theme="dark"] .ce-popover__item-label,
[data-theme="dark"] .ce-popover__item-secondary-label {
	color: var(--text-secondary) !important;
}

[data-theme="dark"] .ce-popover__item:hover {
	background: var(--hover-bg) !important;
}

[data-theme="dark"] .ce-toolbar__plus,
[data-theme="dark"] .ce-toolbar__settings-btn {
	color: var(--text-muted) !important;
	background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .ce-toolbar__plus:hover,
[data-theme="dark"] .ce-toolbar__settings-btn:hover {
	color: var(--accent-color) !important;
	background: var(--accent-dim) !important;
}

[data-theme="dark"] .cdx-input,
[data-theme="dark"] .ce-rawinput {
	background: var(--bg-secondary) !important;
	color: var(--text-primary) !important;
	border-color: var(--border-color) !important;
}

[data-theme="dark"] .cdx-quote {
	border-left-color: var(--accent-color) !important;
	background: var(--bg-secondary) !important;
	color: var(--text-primary) !important;
}

[data-theme="dark"] .ce-code__textarea {
	background: var(--bg-secondary) !important;
	color: var(--text-primary) !important;
	border-color: var(--border-color) !important;
}

[data-theme="dark"] .editorjs-wrapper .cdx-warning {
	background: rgba(245, 158, 11, 0.08);
	border-color: rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .editorjs-wrapper .cdx-warning:before {
	filter: invert(75%) sepia(60%) saturate(1000%) hue-rotate(5deg);
}

[data-theme="dark"] .editorjs-wrapper .cdx-warning__title {
	color: #FBBF24;
}

[data-theme="dark"] .editorjs-wrapper .cdx-simple-image__picture--with-background {
	background: var(--bg-secondary) !important;
}

[data-theme="dark"] .editorjs-wrapper .cdx-simple-image__picture--with-border {
	border-color: var(--border-color) !important;
}

[data-theme="dark"] .cdx-marker {
	background: rgba(234, 179, 8, 0.28);
	color: inherit;
}

[data-theme="dark"] .ce-inline-tool {
	color: var(--text-secondary) !important;
}

[data-theme="dark"] .ce-inline-tool:hover {
	background: var(--hover-bg) !important;
	color: var(--text-primary) !important;
}

[data-theme="dark"] .ce-inline-tool--active {
	color: var(--accent-color) !important;
	background: var(--accent-dim) !important;
}


/* new code */
/* Editor.js block-type popover (the "+" menu) — newer popover markup */
[data-theme="dark"] .ce-popover__container,
[data-theme="dark"] .ce-popover__items {
	background: var(--bg-secondary) !important;
	border-color: var(--border-color) !important;
}

[data-theme="dark"] .ce-popover-item {
	color: var(--text-primary) !important;
}

[data-theme="dark"] .ce-popover-item:hover,
[data-theme="dark"] .ce-popover-item--focused,
[data-theme="dark"] .ce-popover-item--active {
	background: var(--hover-bg) !important;
}

[data-theme="dark"] .ce-popover-item__icon {
	background: var(--bg-tertiary) !important;
	color: var(--text-secondary) !important;
}

[data-theme="dark"] .ce-popover-item__title {
	color: var(--text-primary) !important;
}

[data-theme="dark"] .ce-popover-item__secondary-title {
	color: var(--text-muted) !important;
}

/* Search/filter field at the top of the popover */
[data-theme="dark"] .cdx-search-field {
	background: var(--bg-primary) !important;
	border-color: var(--border-color) !important;
}

[data-theme="dark"] .cdx-search-field__input {
	background: transparent !important;
	color: var(--text-primary) !important;
}

[data-theme="dark"] .cdx-search-field__icon svg {
	fill: var(--text-muted) !important;
}

/* Scrollable items list background + divider lines */
[data-theme="dark"] .ce-popover__custom-content,
[data-theme="dark"] .ce-popover-item-separator__line {
	background: var(--border-color) !important;
}

/* Editor.js Table Styling */
.tc-wrap {
	--color-background: var(--bg-secondary) !important;
	--color-text-secondary: var(--text-muted) !important;
	--color-border: var(--border-color) !important;
	border-radius: var(--radius);
	overflow: hidden;
	margin: 12px 0;
}

.tc-table {
	border-color: var(--border-color) !important;
	background: var(--bg-secondary) !important;
	border-radius: var(--radius);
	font-size: var(--editor-font-size) !important;
}

.tc-row {
	border-bottom: 1px solid var(--border-color) !important;
}

.tc-row--header {
	background: var(--bg-tertiary) !important;
	font-weight: 600;
	color: var(--text-primary) !important;
}

.tc-row--header .tc-cell {
	background: var(--bg-tertiary) !important;
	color: var(--text-primary) !important;
	font-weight: 600;
}

.tc-cell {
	border-right: 1px solid var(--border-color) !important;
	padding: 8px 12px !important;
	color: var(--text-primary) !important;
	font-size: var(--editor-font-size) !important;
	outline: none !important;
}

.tc-cell:focus {
	background: var(--accent-dim) !important;
}

.tc-add-column,
.tc-add-row {
	color: var(--text-muted) !important;
	background: var(--bg-tertiary) !important;
	border-color: var(--border-color) !important;
	transition: background var(--transition), color var(--transition);
}

.tc-add-column:hover,
.tc-add-row:hover {
	color: var(--accent-color) !important;
	background: var(--active-bg) !important;
}

.tc-toolbox {
	background: var(--bg-secondary) !important;
	border: 1px solid var(--border-color) !important;
	box-shadow: var(--shadow-md) !important;
	border-radius: var(--radius-sm);
}

.tc-toolbox__button {
	color: var(--text-secondary) !important;
}

.tc-toolbox__button:hover {
	color: var(--danger) !important;
	background: rgba(239, 68, 68, 0.12) !important;
}

.editorjs-wrapper .ce-header {
	font-size: calc(var(--editor-font-size) * 1.8) !important;
}

.editorjs-wrapper h1.ce-header {
	font-size: calc(var(--editor-font-size) * 2.2) !important;
}

.editorjs-wrapper h2.ce-header {
	font-size: calc(var(--editor-font-size) * 1.9) !important;
}

.editorjs-wrapper h3.ce-header {
	font-size: calc(var(--editor-font-size) * 1.6) !important;
}

.editorjs-wrapper h4.ce-header {
	font-size: calc(var(--editor-font-size) * 1.4) !important;
}

.editorjs-wrapper h5.ce-header {
	font-size: calc(var(--editor-font-size) * 1.2) !important;
}

.editorjs-wrapper h6.ce-header {
	font-size: var(--editor-font-size) !important;
}

/* ============================================================
   STATUS BAR
   ============================================================ */
.statusbar {
	height: var(--footer-height);
	border-top: 1px solid var(--border-color);
	display: flex;
	align-items: center;
	padding: 0 14px;
	font-size: 11px;
	color: var(--text-muted);
	background: var(--bg-primary);
	gap: 8px;
	flex-shrink: 0;
}

.status-left {
	flex: 1;
}

.status-right {
	flex-shrink: 0;
}

.ws-status-badge {
	font-size: 11px;
	padding: 2px 8px;
	border-radius: 10px;
	background: var(--bg-tertiary);
	color: var(--text-muted);
	border: 1px solid var(--border-color);
	flex-shrink: 0;
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: all var(--transition);
}

.ws-status-badge.connected {
	background: var(--accent-dim);
	color: var(--accent-color);
	border-color: var(--accent-color);
}

.ws-status-badge.needs-permission {
	background: rgba(234, 179, 8, 0.15);
	color: #eab308;
	border-color: rgba(234, 179, 8, 0.5);
	cursor: pointer;
	font-weight: 500;
	animation: pulse-badge 2.5s infinite ease-in-out;
}

.ws-status-badge.needs-permission:hover {
	background: rgba(234, 179, 8, 0.25);
	color: #facc15;
}

@keyframes pulse-badge {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.7; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 1000;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(3px);
}

.modal-overlay.active {
	display: flex;
}

.modal-container {
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	border-radius: 12px;
	padding: 24px;
	width: 400px;
	max-width: 90vw;
	box-shadow: var(--shadow-md);
	animation: modalIn 0.15s ease;
}

@keyframes modalIn {
	from {
		opacity: 0;
		transform: translateY(-8px) scale(0.98);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.modal-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 14px;
}

.modal-input {
	width: 100%;
	padding: 9px 12px;
	font-size: 14px;
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	background: var(--bg-secondary);
	color: var(--text-primary);
	outline: none;
	font-family: inherit;
	transition: border-color var(--transition);
}

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

.modal-message {
	font-size: 13px;
	color: var(--text-secondary);
	line-height: 1.5;
}

.modal-actions {
	margin-top: 16px;
}

.modal-hint {
	font-size: 12px;
	color: var(--text-muted);
}

.modal-buttons {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

.modal-btn {
	padding: 8px 18px;
	font-size: 13px;
	font-weight: 500;
	border-radius: var(--radius);
	border: 1px solid var(--border-color);
	cursor: pointer;
	font-family: inherit;
	transition: all var(--transition);
}

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

.modal-btn.primary:hover {
	background: var(--accent-hover);
}

.modal-btn.secondary {
	background: transparent;
	color: var(--text-secondary);
}

.modal-btn.secondary:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

.modal-btn.danger {
	background: var(--danger);
	color: #fff;
	border-color: var(--danger);
}

.modal-btn.danger:hover {
	background: var(--danger-hover);
}

/* Modal Choice Option Buttons (Smart Prompt) */
.modal-choices {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 14px;
}

.modal-choice-btn {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	padding: 10px 14px;
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	background: var(--bg-secondary);
	color: var(--text-primary);
	cursor: pointer;
	text-align: left;
	font-family: inherit;
	transition: all var(--transition);
	width: 100%;
}

.modal-choice-btn:hover {
	border-color: var(--accent-color);
	background: var(--hover-bg);
}

.modal-choice-btn.primary {
	border-color: var(--accent-border);
	background: var(--active-bg);
}

.modal-choice-btn.primary:hover {
	border-color: var(--accent-color);
	background: var(--accent-dim);
}

.modal-choice-btn.danger {
	border-color: var(--border-color);
}

.modal-choice-btn.danger:hover {
	border-color: var(--danger);
	background: rgba(239, 68, 68, 0.08);
}

.modal-choice-btn-title {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--text-primary);
}

.modal-choice-btn.primary .modal-choice-btn-title {
	color: var(--accent-color);
}

.modal-choice-btn.danger:hover .modal-choice-btn-title {
	color: var(--danger);
}

.modal-choice-btn-desc {
	font-size: 11.5px;
	color: var(--text-muted);
	margin-top: 3px;
	line-height: 1.35;
}

/* ============================================================
   HELP / ONBOARDING MODAL
   ============================================================ */
.help-modal-container {
	width: 680px;
	max-width: 92vw;
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	padding: 0;
	overflow: hidden;
}

.help-modal-header {
	padding: 18px 24px 16px;
	border-bottom: 1px solid var(--border-color);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-shrink: 0;
}

.help-brand-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
}

.help-logo-img {
	width: 34px;
	height: 34px;
	object-fit: contain;
	flex-shrink: 0;
}

.help-modal-title {
	font-size: 17px;
	font-weight: 700;
	color: var(--text-primary);
	margin: 0;
	line-height: 1.25;
}

.help-modal-title span {
	color: var(--accent-color);
}

.help-modal-subtitle {
	font-size: 12.5px;
	color: var(--text-secondary);
	margin: 3px 0 0;
	line-height: 1.4;
}

.help-close-btn {
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius);
	border: 1px solid var(--border-color);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	flex-shrink: 0;
	transition: all var(--transition);
}

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

.help-modal-body {
	padding: 20px 24px;
	overflow-y: auto;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.help-section-title {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-muted);
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
}

.help-features-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
}

.help-feature-card {
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	padding: 12px 14px;
	display: flex;
	gap: 12px;
	align-items: flex-start;
	transition: border-color var(--transition), background var(--transition);
}

.help-feature-card:hover {
	border-color: var(--accent-border);
	background: var(--bg-hover);
}

.help-feature-icon {
	width: 32px;
	height: 32px;
	border-radius: var(--radius-sm);
	background: var(--accent-dim);
	color: var(--accent-color);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.help-feature-content h4 {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-primary);
	margin: 0 0 3px;
}

.help-feature-content p {
	font-size: 12px;
	color: var(--text-secondary);
	margin: 0;
	line-height: 1.45;
}

.help-feature-content code {
	background: var(--bg-tertiary);
	border: 1px solid var(--border-subtle);
	padding: 1px 4px;
	border-radius: 3px;
	font-size: 11px;
	font-family: 'JetBrains Mono', monospace;
}

.help-shortcuts-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 8px;
}

.help-shortcut-row {
	background: var(--bg-secondary);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-sm);
	padding: 8px 12px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	transition: border-color var(--transition);
}

.help-shortcut-row:hover {
	border-color: var(--border-color);
}

.help-shortcut-keys {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	color: var(--text-muted);
	font-weight: 500;
	flex-wrap: wrap;
}

.help-shortcut-keys kbd,
.help-footer-hint kbd {
	font-family: 'JetBrains Mono', monospace;
	font-size: 11px;
	font-weight: 600;
	background: var(--bg-tertiary);
	border: 1px solid var(--border-color);
	border-bottom-width: 2px;
	border-radius: 4px;
	padding: 1px 6px;
	color: var(--text-primary);
	line-height: 1.4;
}

.help-shortcut-desc {
	font-size: 11.5px;
	color: var(--text-secondary);
	line-height: 1.35;
}

.help-modal-footer {
	padding: 14px 24px;
	border-top: 1px solid var(--border-color);
	background: var(--bg-secondary);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-shrink: 0;
}

.help-footer-hint {
	font-size: 12px;
	color: var(--text-muted);
	display: flex;
	align-items: center;
	gap: 6px;
}

.help-footer-hint i {
	color: var(--accent-color);
	flex-shrink: 0;
}

.help-got-it-btn {
	padding: 7px 18px;
	font-size: 13px;
	cursor: pointer;
}

/* Welcome tip clickable help link */
.welcome-tip-help {
	cursor: pointer;
	border-radius: var(--radius-sm);
	padding: 2px 4px;
	margin-left: -4px;
	transition: background var(--transition), color var(--transition);
}

.welcome-tip-help:hover {
	background: var(--accent-dim);
	color: var(--accent-color);
}

.welcome-tip-help:hover i {
	color: var(--accent-color);
}

/* Status bar help button */
.status-help-btn {
	background: transparent;
	border: none;
	color: var(--text-muted);
	font-size: 11px;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	cursor: pointer;
	padding: 1px 6px;
	border-radius: var(--radius-sm);
	font-family: inherit;
	transition: all var(--transition);
}

.status-help-btn:hover {
	color: var(--accent-color);
	background: var(--accent-dim);
}

/* ============================================================
   CONTEXT MENU
   ============================================================ */
.context-menu {
	position: fixed;
	min-width: 160px;
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	box-shadow: var(--shadow-md);
	padding: 4px;
	z-index: 2000;
}

.context-menu-item {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 8px 10px;
	font-size: 13px;
	color: var(--text-secondary);
	cursor: pointer;
	border-radius: 6px;
	transition: background var(--transition), color var(--transition);
}

.context-menu-item:hover {
	background: var(--hover-bg);
	color: var(--text-primary);
}

.context-menu-danger {
	color: var(--danger) !important;
}

.context-menu-danger:hover {
	background: rgba(239, 68, 68, 0.1) !important;
	color: var(--danger) !important;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
	display: none !important;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(3px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* File type color coding */
.file-item[data-id] .icon [data-lucide="file-code"] {
	color: #60A5FA;
}

.file-item[data-id] .icon [data-lucide="file-text"] {
	color: var(--text-muted);
}

.file-item[data-id] .icon [data-lucide="braces"] {
	color: #F59E0B;
}

.file-item[data-id] .icon [data-lucide="terminal"] {
	color: #A78BFA;
}

.file-item[data-id] .icon [data-lucide="database"] {
	color: #34D399;
}

.file-item.active .icon i {
	color: var(--accent-color) !important;
}

/* ============================================================
   WELCOME SCREEN
   ============================================================ */
.welcome-screen {
	position: fixed;
	inset: 0;
	display: flex;
	background: var(--bg-primary);
	z-index: 200;
	overflow: hidden;
}

/* ── Left panel ── */
.welcome-left {
	width: 380px;
	flex-shrink: 0;
	background: var(--bg-secondary);
	border-right: 1px solid var(--border-color);
	display: flex;
	flex-direction: column;
	padding: 40px 32px 32px;
	overflow-y: auto;
}

.welcome-brand {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 40px;
}

.welcome-logo-img {
	width: 56px;
	height: 56px;
	object-fit: contain;
	flex-shrink: 0;
	filter: drop-shadow(0 4px 10px rgba(16, 185, 129, 0.2));
}

.welcome-app-name {
	font-size: 26px;
	font-weight: 700;
	letter-spacing: -0.5px;
	color: var(--text-primary);
	line-height: 1;
}

.welcome-app-name span {
	color: var(--accent-color);
}

.welcome-tagline {
	font-size: 12px;
	color: var(--text-muted);
	margin-top: 4px;
}

/* Action buttons */
.welcome-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 36px;
}

.welcome-action-btn {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 16px;
	border-radius: 10px;
	border: 1px solid var(--border-color);
	background: var(--bg-primary);
	color: var(--text-primary);
	cursor: pointer;
	text-align: left;
	transition: border-color var(--transition), background var(--transition);
	font-family: inherit;
}

.welcome-action-btn i {
	color: var(--text-muted);
	flex-shrink: 0;
	transition: color var(--transition);
}

.welcome-action-btn:hover {
	border-color: var(--accent-color);
	background: var(--accent-dim);
}

.welcome-action-btn:hover i {
	color: var(--accent-color);
}

.welcome-action-btn.primary {
	background: var(--accent-color);
	border-color: transparent;
	color: #fff;
}

.welcome-action-btn.primary i {
	color: rgba(255, 255, 255, 0.85);
}

.welcome-action-btn.primary:hover {
	background: var(--accent-hover);
}

.welcome-action-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.action-btn-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.action-btn-text span {
	font-size: 14px;
	font-weight: 500;
}

.action-btn-text small {
	font-size: 11px;
	opacity: 0.7;
}

/* Tips */
.welcome-tips {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: auto;
	padding-top: 24px;
	border-top: 1px solid var(--border-color);
}

.welcome-tip {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	color: var(--text-muted);
}

.welcome-tip i {
	color: var(--accent-color);
	flex-shrink: 0;
}

.welcome-tip b {
	color: var(--text-secondary);
}

/* FS banner */
.welcome-fs-banner {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 14px;
	padding: 10px 12px;
	background: rgba(239, 68, 68, 0.08);
	border: 1px solid rgba(239, 68, 68, 0.2);
	border-radius: 8px;
	font-size: 12px;
	color: var(--danger);
}

/* ── Right panel ── */
.welcome-right {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: 40px 40px 32px;
	overflow: hidden;
}

.welcome-right-header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 24px;
}

.welcome-right-header h2 {
	font-size: 20px;
	font-weight: 600;
	color: var(--text-primary);
}

.ws-count-badge {
	padding: 2px 8px;
	border-radius: 10px;
	font-size: 12px;
	font-weight: 600;
	background: var(--bg-tertiary);
	color: var(--text-muted);
	border: 1px solid var(--border-color);
}

/* search on the welcome screen */
.welcome-right-header {
	position: relative;
	gap: 8px;
}

.ws-card-search-btn {
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	border: 1px solid var(--border-color);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: color var(--transition), border-color var(--transition), background var(--transition);
	flex-shrink: 0;
}

.ws-card-search-btn:hover {
	color: var(--accent-color);
	border-color: var(--accent-color);
	background: var(--accent-dim);
}

.ws-card-search-input {
	border: 1px solid var(--border-color);
	outline: none;
	background: var(--bg-secondary);
	color: var(--text-primary);
	font-size: 12.5px;
	font-family: inherit;
	width: 220px;
	padding: 6px 10px;
	border-radius: 8px;
	flex-shrink: 0;
	transition: border-color var(--transition), box-shadow var(--transition);
	animation: fadeIn 0.12s ease;
}

.ws-card-search-input.hidden {
	display: none;
}

.ws-card-search-input:focus {
	border-color: var(--accent-color);
	box-shadow: 0 0 0 2px var(--accent-dim);
}

.ws-card-search-input::placeholder {
	color: var(--text-muted);
}

/* Workspace cards */
.workspaces-list {
	flex: 1;
	overflow-y: auto;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 14px;
	align-content: start;
	padding-right: 4px;
}

.workspaces-list::-webkit-scrollbar {
	width: 5px;
}

.workspaces-list::-webkit-scrollbar-thumb {
	background: var(--border-color);
	border-radius: 3px;
}

.ws-card {
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 12px;
	padding: 18px 18px 16px;
	cursor: pointer;
	display: flex;
	align-items: flex-start;
	gap: 14px;
	transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
	position: relative;
	animation: fadeIn 0.25s ease;
}

.ws-card:hover {
	border-color: var(--accent-color);
	box-shadow: 0 0 0 1px var(--accent-color), var(--shadow-md);
	background: var(--hover-bg);
}

.ws-card:hover .ws-card-actions {
	opacity: 1;
	pointer-events: auto;
}

.ws-card-icon {
	width: 42px;
	height: 42px;
	border-radius: 10px;
	background: var(--accent-dim);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: var(--accent-color);
}

.ws-card-body {
	flex: 1;
	min-width: 0;
}

.ws-card-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--text-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	margin-bottom: 8px;
}

.ws-card-meta {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.ws-card-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 7px;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 500;
}

.folder-badge {
	background: rgba(16, 185, 129, 0.12);
	color: var(--accent-color);
	border: 1px solid rgba(16, 185, 129, 0.25);
}

.local-badge {
	background: var(--bg-tertiary);
	color: var(--text-muted);
	border: 1px solid var(--border-color);
}

.ws-card-files,
.ws-card-time {
	font-size: 11px;
	color: var(--text-muted);
}

.ws-card-actions {
	position: absolute;
	top: 12px;
	right: 12px;
	display: flex;
	gap: 4px;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--transition);
}

.ws-card-btn {
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border-color);
	border-radius: 6px;
	background: var(--bg-primary);
	color: var(--text-muted);
	cursor: pointer;
	transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.ws-card-btn:hover {
	color: var(--text-primary);
	border-color: var(--text-secondary);
}

.ws-card-btn.danger:hover {
	color: var(--danger);
	border-color: var(--danger);
	background: rgba(239, 68, 68, 0.08);
}

/* Empty workspaces state */
.workspaces-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	flex: 1;
	color: var(--text-muted);
	text-align: center;
	padding: 60px 0;
}

.workspaces-empty p {
	font-size: 16px;
	font-weight: 500;
	color: var(--text-secondary);
}

.workspaces-empty small {
	font-size: 13px;
}

/* ============================================================
   RESPONSIVENESS & MOBILE LAYOUT (A11Y-01)
   ============================================================ */
.sidebar-backdrop {
	display: none;
}

.mobile-sidebar-toggle {
	display: none;
}

.mobile-sidebar-close-btn {
	display: none;
}

.sidebar-header-row {
	display: flex;
	align-items: center;
	width: 100%;
}

@media (max-width: 768px) {
	/* Welcome screen vertical stack */
	.welcome-screen {
		flex-direction: column;
		overflow-y: auto;
	}

	.welcome-left {
		width: 100%;
		max-width: 100%;
		border-right: none;
		border-bottom: 1px solid var(--border-color);
		padding: 24px 20px 20px;
		overflow-y: visible;
		flex-shrink: 0;
	}

	.welcome-brand {
		margin-bottom: 24px;
	}

	.welcome-actions {
		margin-bottom: 20px;
	}

	.welcome-right {
		width: 100%;
		padding: 24px 20px;
		overflow-y: visible;
		flex: none;
	}

	.workspaces-list {
		grid-template-columns: 1fr;
		overflow-y: visible;
		max-height: none;
	}

	/* Sidebar drawer */
	.sidebar {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 280px;
		max-width: 85vw;
		height: 100vh;
		z-index: 1000;
		transform: translateX(-100%);
		transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
		box-shadow: none;
	}

	.sidebar.mobile-open {
		transform: translateX(0);
		box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
	}

	.sidebar-resize-handle {
		display: none !important;
	}

	.sidebar-backdrop {
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.5);
		backdrop-filter: blur(2px);
		z-index: 999;
		display: block;
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.25s ease;
	}

	.sidebar-backdrop.active {
		opacity: 1;
		pointer-events: auto;
	}

	.mobile-sidebar-toggle {
		display: flex !important;
		align-items: center;
		justify-content: center;
		width: 28px;
		height: 28px;
		border-radius: var(--radius);
		border: 1px solid var(--border-color);
		background: transparent;
		color: var(--text-primary);
		cursor: pointer;
		flex-shrink: 0;
		margin-right: 4px;
	}

	.mobile-sidebar-toggle:hover {
		background: var(--bg-hover);
	}

	.mobile-sidebar-close-btn {
		display: flex !important;
		align-items: center;
		justify-content: center;
		width: 28px;
		height: 28px;
		border-radius: var(--radius);
		border: 1px solid var(--border-color);
		background: transparent;
		color: var(--text-muted);
		cursor: pointer;
		flex-shrink: 0;
	}

	.mobile-sidebar-close-btn:hover {
		background: var(--bg-hover);
		color: var(--text-primary);
	}

	/* Topbar & Editor adjustments on mobile */
	.topbar {
		padding: 0 8px;
		gap: 6px;
	}

	.topbar .controls {
		gap: 4px;
	}

	.modal-container {
		width: calc(100vw - 32px);
		max-width: 100%;
		padding: 20px 16px;
	}

	.editorjs-wrapper {
		padding: 20px 12px;
	}

	.help-modal-container {
		width: calc(100vw - 20px) !important;
		max-height: 94vh;
		padding: 0 !important;
	}

	.help-modal-header {
		padding: 14px 16px 12px;
	}

	.help-modal-body {
		padding: 14px 16px;
		gap: 14px;
	}

	.help-features-grid {
		grid-template-columns: 1fr;
	}

	.help-shortcuts-grid {
		grid-template-columns: 1fr;
	}

	.help-modal-footer {
		padding: 12px 16px;
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.help-footer-hint {
		justify-content: center;
	}

	.help-got-it-btn {
		width: 100%;
		text-align: center;
	}
}

/* ============================================================
   LIVE COLLABORATION (P2P TRYSTERO + YJS)
   ============================================================ */

.collab-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 8px;
	border-radius: 12px;
	background: var(--active-bg);
	border: 1px solid var(--accent-border);
	color: var(--accent-color);
	font-size: 11px;
	font-weight: 500;
	cursor: pointer;
	transition: background var(--transition), border-color var(--transition);
}

.collab-badge:hover {
	background: var(--hover-bg);
}

.collab-badge-pulse {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent-color);
	box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
	animation: collabPulse 1.8s infinite;
}

@keyframes collabPulse {
	0% {
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
	}
	70% {
		box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
	}
}

.collab-peer-avatars {
	display: flex;
	align-items: center;
	margin-left: 2px;
}

.collab-avatar-bubble {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	border: 2px solid var(--accent-color);
	background: var(--bg-tertiary);
	color: var(--text-primary);
	font-size: 9px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-left: -4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.control-btn.active#collabBtn {
	color: var(--accent-color);
	background: var(--active-bg);
}

.collab-status-badge {
	color: var(--accent-color);
}

/* Collab Modal Specifics */
.collab-modal-container {
	width: 480px;
	max-width: 95vw;
	padding: 0 !important;
	overflow: hidden;
}

.collab-logo-icon {
	width: 32px;
	height: 32px;
	border-radius: var(--radius);
	background: var(--active-bg);
	color: var(--accent-color);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.collab-modal-tabs {
	display: flex;
	border-bottom: 1px solid var(--border-color);
	background: var(--bg-secondary);
}

.collab-tab-btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 14px;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--text-muted);
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	cursor: pointer;
	transition: all var(--transition);
}

.collab-tab-btn:hover {
	color: var(--text-primary);
}

.collab-tab-btn.active {
	color: var(--accent-color);
	border-bottom-color: var(--accent-color);
	background: var(--bg-primary);
}

.collab-modal-section {
	padding: 20px 22px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.collab-form-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.collab-label {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.collab-input-action-row {
	display: flex;
	gap: 8px;
}

.collab-input-action-row input {
	flex: 1;
}

.collab-select {
	cursor: pointer;
	appearance: auto;
}

.collab-modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 6px;
}

/* Active Session In-Modal View */
.collab-active-indicator {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border-radius: var(--radius);
	background: var(--active-bg);
	border: 1px solid var(--accent-border);
	color: var(--accent-color);
	font-size: 13px;
	font-weight: 500;
}

.collab-active-pulse {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--accent-color);
	animation: collabPulse 1.8s infinite;
}

.collab-invite-box {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.collab-peers-wrap {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.collab-peers-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	max-height: 140px;
	overflow-y: auto;
	padding: 4px;
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	background: var(--bg-secondary);
}

.collab-peer-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	border-radius: var(--radius-sm);
	background: var(--bg-primary);
	font-size: 12.5px;
	color: var(--text-primary);
}

.collab-peer-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
}

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

.collab-peer-role {
	font-size: 10px;
	font-weight: 600;
	padding: 2px 6px;
	border-radius: 10px;
	background: var(--active-bg);
	color: var(--accent-color);
	text-transform: uppercase;
}

.collab-insecure-banner {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	margin: 12px 20px 0;
	border-radius: var(--radius);
	background: rgba(239, 68, 68, 0.12);
	border: 1px solid rgba(239, 68, 68, 0.35);
	color: var(--danger);
	font-size: 12px;
	line-height: 1.5;
}

.collab-insecure-banner i {
	flex-shrink: 0;
	margin-top: 2px;
}

.collab-insecure-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.collab-insecure-text code {
	background: var(--bg-secondary);
	padding: 1px 4px;
	border-radius: 3px;
	color: var(--text-primary);
	font-size: 11px;
}

.collab-insecure-action {
	margin-top: 4px;
}

.collab-insecure-btn {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 4px;
	background: var(--danger);
	color: #fff;
	text-decoration: none;
	font-weight: 600;
	font-size: 11px;
	transition: opacity var(--transition);
}

.collab-insecure-btn:hover {
	opacity: 0.9;
}