/* ════════════════════════════════════════════════════════════════════════════ */
/* ── components.css — Note cards, folders, transfer, settings, tables ──────── */
/* ════════════════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── NOTE ITEMS — refined premium cards with subtle color accent ───────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
.note-item {
	padding: 0;
	border-radius: var(--radius-md);
	cursor: pointer;
	margin-bottom: 6px;
	transition: var(--transition);
	border: 1px solid var(--border);
	position: relative;
	display: flex;
	align-items: stretch;
	overflow: hidden;
	background: var(--surface);
	box-shadow: var(--shadow-xs);
}
.note-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

/* ── v1.2.1 adaptive active-note indicator ──────────────────────────────────── */
/* The active row derives its border, ring, and a subtle background tint from     */
/* the row's own --note-accent (set inline by JS). A color-mix() tint provides    */
/* the soft wash where supported; an @supports fallback keeps a solid accent      */
/* border + ring so the active state is always visible, including dark mode and   */
/* the Soft White note color. Keyboard :focus-visible remains distinct.           */
.note-item.active {
	border-color: var(--note-accent, var(--accent));
	box-shadow:
		0 0 0 2px var(--note-accent, var(--accent)),
		var(--shadow-sm);
	background:
		color-mix(in srgb, var(--note-accent, var(--accent)) 12%, var(--surface));
}
/* Strengthen the left color band for the active row (structural cue). */
.note-item.active::before {
	width: 6px;
	box-shadow: inset 1px 0 0 rgba(0,0,0,0.12);
}
/* Contrast-safe fallback for Soft White in light mode: rely on a strong border  */
/* and ring plus a neutral tint rather than the near-white accent color.          */
.note-item.active[style*="#F5F5F0"] {
	border-color: var(--border-strong);
	box-shadow:
		0 0 0 2px var(--accent),
		var(--shadow-sm);
	background: var(--accent-soft);
}
html.night-mode .note-item.active {
	background:
		color-mix(in srgb, var(--note-accent, var(--accent)) 22%, var(--surface));
}
/* Fallback for browsers without color-mix(): keep accent border + ring, and a    */
/* soft accent background so the active state remains clearly visible.            */
@supports not (background: color-mix(in srgb, #000 10%, #fff)) {
	.note-item.active {
		background: var(--accent-soft);
		border-color: var(--note-accent, var(--accent));
		box-shadow:
			0 0 0 2px var(--note-accent, var(--accent)),
			var(--shadow-sm);
	}
}
/* Keyboard focus must remain distinct from persistent active selection. */
.note-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ── Color accent band on the left edge (uses inline --note-accent set by JS) ─ */
.note-item::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 4px;
	background: var(--note-accent, var(--note-mustard));
	border-radius: var(--radius-md) 0 0 var(--radius-md);
	box-shadow: inset 1px 0 0 rgba(0,0,0,0.06);
}

.note-item-content { flex: 1; min-width: 0; padding: 12px 14px 12px 18px; }

.note-item-title-row { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; overflow: hidden; }

.pin-icon { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.75; color: var(--accent-hover); }

.note-item-title {
	font-weight: 700;
	font-size: 0.9rem;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	letter-spacing: -0.2px;
}

.note-item-preview {
	font-size: 0.78rem;
	color: var(--text-secondary);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	white-space: nowrap;
	text-overflow: ellipsis;
	word-break: break-word;
	line-height: 1.5;
	max-height: 1.5em;
}

/* ── Note-card tag summary (v1.2.3) — safe text chips ──────────────────────── */
.note-item-tags {
	display: flex;
	flex-wrap: nowrap;
	gap: 5px;
	margin-top: 5px;
	overflow: hidden;
	min-width: 0;
}
.note-item-tag {
	font-size: 0.66rem;
	font-weight: 600;
	color: var(--text-secondary);
	background: var(--accent-soft);
	border: 1px solid var(--border);
	border-radius: var(--radius-pill);
	padding: 1px 8px;
	line-height: 1.5;
	max-width: 120px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex-shrink: 1;
}
.note-item-tag-more {
	flex-shrink: 0;
	background: var(--border);
	font-variant-numeric: tabular-nums;
}
.note-item-owner-ref { font-style: italic; }

.note-item-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 5px;
	min-width: 0;
}
.note-item-date { font-size: 0.68rem; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }
.note-item-folder {
	font-size: 0.68rem;
	color: var(--text-secondary);
	min-width: 0;
	flex-shrink: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: right;
	opacity: 0.9;
}

/* ── Pinned separator ──────────────────────────────────────────────────────── */
.note-list-separator {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 8px 4px 10px;
	padding: 0 2px;
	user-select: none;
}
.note-list-separator::before,
.note-list-separator::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.note-list-separator-label {
	font-size: 0.64rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	color: var(--text-muted);
	flex-shrink: 0;
}

/* ── Kebab ─────────────────────────────────────────────────────────────────── */
.note-kebab-wrapper { position: relative; display: flex; align-items: center; flex-shrink: 0; }

.note-kebab-btn {
	background: transparent;
	border: none;
	cursor: pointer;
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text-muted);
	font-size: 1.2rem;
	border-radius: var(--radius-sm);
	transition: var(--transition);
	margin-right: 6px;
	flex-shrink: 0;
	align-self: center;
}
.note-kebab-btn:hover { background: var(--accent-soft); color: var(--text-primary); }

/* ── Floating layer ────────────────────────────────────────────────────────── */
#floating-layer {
	position: fixed;
	inset: 0;
	z-index: var(--z-floating);
	pointer-events: none;
	overflow: visible;
}

.note-kebab-menu,
.floating-menu {
	position: fixed;
	top: 0;
	left: 0;
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	z-index: var(--z-floating);
	min-width: 190px;
	max-width: min(260px, calc(100vw - 24px));
	max-height: calc(100vh - 24px);
	overflow-y: auto;
	pointer-events: auto;
	padding: 6px;
}

.kebab-item,
.floating-menu-item {
	display: flex;
	align-items: center;
	gap: 9px;
	width: 100%;
	padding: 10px 12px;
	border: none;
	background: transparent;
	color: var(--text-primary);
	font-size: 0.86rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition-fast);
	white-space: nowrap;
	border-radius: var(--radius-sm);
}
.kebab-item:hover,
.floating-menu-item:hover { background: var(--accent-soft); }
.kebab-item svg,
.floating-menu-item svg { flex-shrink: 0; opacity: 0.8; }
.kebab-item-danger,
.floating-menu-item-danger { color: var(--danger-dark); }
.kebab-item-danger:hover,
.floating-menu-item-danger:hover { background: var(--danger-soft) !important; color: var(--danger-dark); }
.floating-menu-item:disabled { opacity: 0.4; cursor: not-allowed; }
.floating-menu-item:disabled:hover { background: transparent; }

.floating-menu-divider { height: 1px; background: var(--border); margin: 5px 6px; }
.floating-menu-label {
	font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
	color: var(--text-muted); padding: 8px 12px 4px;
}

/* ── Shared dropdown item ──────────────────────────────────────────────────── */
.dropdown-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 11px 14px;
	border: none;
	background: transparent;
	color: var(--text-primary);
	font-size: 0.87rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition-fast);
	white-space: nowrap;
	border-radius: var(--radius-sm);
}
.dropdown-item:hover { background: var(--accent-soft); color: var(--text-primary); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── FOLDERS PANEL — bounded two-region layout ─────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
#folders-content {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	overflow: hidden;
}

/* Folder list occupies an upper bounded region with its own scroll. */
.folders-list-section {
	flex: 0 0 auto;
	max-height: 38%;
	min-height: 120px;
	overflow-y: auto;
	overflow-x: hidden;
	border-bottom: 1px solid var(--border);
	padding: 4px 10px 10px;
}

.folders-header-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px; flex-shrink: 0; }
.folders-header-row h3 {
	font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
	text-transform: uppercase; letter-spacing: 0.07em;
}

.new-folder-btn {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 5px 10px;
	font-size: 0.74rem;
	font-family: var(--font);
	font-weight: 600;
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition);
	white-space: nowrap;
}
.new-folder-btn:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }

.folder-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 9px 11px;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: var(--transition);
	border: 1px solid transparent;
	margin-bottom: 3px;
}
.folder-item:hover { background: var(--accent-soft); }
.folder-item.active { background: var(--accent-soft); border-color: var(--accent); }

.folder-item-icon { flex-shrink: 0; color: var(--text-secondary); display: inline-flex; }
.folder-item.active .folder-item-icon { color: var(--accent-hover); }

.folder-item-name {
	flex: 1; font-size: 0.86rem; font-weight: 600; color: var(--text-primary);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.folder-item-count {
	font-size: 0.7rem; color: var(--text-secondary); background: var(--border);
	padding: 2px 8px; border-radius: var(--radius-pill); flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.folder-item-actions { display: flex; gap: 2px; flex-shrink: 0; }
.folder-item-unfiled .folder-item-actions { display: none; }

.folder-action-btn {
	background: transparent; border: none; cursor: pointer; padding: 5px 6px;
	border-radius: var(--radius-xs); font-size: 0.8rem; color: var(--text-muted);
	transition: var(--transition); line-height: 1; min-width: 32px; min-height: 32px;
	display: inline-flex; align-items: center; justify-content: center;
}
.folder-action-btn:hover { background: var(--border); color: var(--text-primary); }
.folder-action-btn-danger { color: var(--danger-dark); }
.folder-action-btn-danger:hover { background: var(--danger-soft); color: var(--danger-dark); }

/* Selected-folder notes fill the remaining panel height with own scroll. */
.folder-notes-section {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	overflow: hidden;
}
.folder-notes-header {
	padding: 12px 14px 6px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}
.folder-notes-header h3 {
	font-size: 0.8rem;
	font-weight: 800;
	color: var(--text-primary);
	letter-spacing: -0.2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}
.folder-notes-header-count {
	font-size: 0.68rem;
	color: var(--text-secondary);
	background: var(--border);
	padding: 2px 8px;
	border-radius: var(--radius-pill);
	flex-shrink: 0;
	font-variant-numeric: tabular-nums;
}

/* ── Mobile folder drill-down back button ──────────────────────────────────── */
.folder-back-btn {
	display: none;
	align-items: center;
	gap: 6px;
	background: transparent;
	border: none;
	color: var(--accent-hover);
	font-family: var(--font);
	font-size: 0.84rem;
	font-weight: 700;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: var(--radius-sm);
	transition: var(--transition-fast);
	flex-shrink: 0;
}
.folder-back-btn:hover { background: var(--accent-soft); }
html.night-mode .folder-back-btn { color: var(--accent); }

/* ── Locked panel ──────────────────────────────────────────────────────────── */
.panel-locked {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	flex: 1;
	min-height: 0;
	padding: 36px 26px;
	text-align: center;
	gap: 14px;
}
.panel-locked-icon { font-size: 2.8rem; opacity: 0.9; }
.panel-locked-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.panel-locked-body { font-size: 0.86rem; color: var(--text-secondary); line-height: 1.7; max-width: 230px; }
.panel-locked-btn {
	background: var(--accent); color: var(--accent-contrast); border: none;
	border-radius: var(--radius-sm); padding: 11px 24px; font-size: 0.9rem;
	font-weight: 700; font-family: var(--font); cursor: pointer; transition: var(--transition);
	box-shadow: var(--shadow-xs);
}
.panel-locked-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── TRANSFER & SETTINGS PANELS — grouped cards ────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
.panel-scroll-content {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 4px 14px 18px;
}

.panel-group {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 14px;
	margin-bottom: 14px;
	box-shadow: var(--shadow-xs);
}
.panel-group-title {
	font-size: 0.7rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--text-muted);
	margin-bottom: 10px;
}
.panel-group-desc {
	font-size: 0.78rem;
	color: var(--text-secondary);
	line-height: 1.6;
	margin-bottom: 12px;
}

.panel-action-btn {
	display: flex;
	align-items: center;
	gap: 11px;
	width: 100%;
	padding: 12px 13px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--text-primary);
	font-family: var(--font);
	font-size: 0.88rem;
	font-weight: 600;
	cursor: pointer;
	text-align: left;
	transition: var(--transition);
	margin-bottom: 8px;
}
.panel-action-btn:last-child { margin-bottom: 0; }
.panel-action-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.panel-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.panel-action-btn:disabled:hover { border-color: var(--border); background: var(--bg); }
.panel-action-btn-icon {
	flex-shrink: 0;
	width: 34px; height: 34px;
	border-radius: var(--radius-sm);
	background: var(--accent-soft);
	color: var(--accent-hover);
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
html.night-mode .panel-action-btn-icon { color: var(--accent); }
.panel-action-btn-body { flex: 1; min-width: 0; }
.panel-action-btn-label { font-size: 0.88rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.panel-action-btn-sub { font-size: 0.74rem; font-weight: 500; color: var(--text-secondary); line-height: 1.45; margin-top: 2px; }
.panel-action-btn-danger .panel-action-btn-icon { background: var(--danger-soft); color: var(--danger-dark); }
.panel-action-btn-danger .panel-action-btn-label { color: var(--danger-dark); }
.panel-action-btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }

/* ── Settings section subheadings ──────────────────────────────────────────── */
.settings-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 8px 0;
}
.settings-row-label { font-size: 0.86rem; font-weight: 600; color: var(--text-primary); }
.settings-plan-badge {
	font-size: 0.72rem; font-weight: 800; padding: 3px 10px;
	border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-hover);
}
html.night-mode .settings-plan-badge { color: var(--accent); }

.settings-link-btn {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 11px 4px;
	border: none;
	background: transparent;
	color: var(--text-primary);
	font-family: var(--font);
	font-size: 0.87rem;
	font-weight: 600;
	cursor: pointer;
	text-align: left;
	transition: var(--transition-fast);
	border-bottom: 1px solid var(--border);
}
.settings-link-btn:last-child { border-bottom: none; }
.settings-link-btn:hover { color: var(--accent-hover); }
html.night-mode .settings-link-btn:hover { color: var(--accent); }
.settings-link-btn .chev { color: var(--text-muted); flex-shrink: 0; }

.settings-footer-note {
	font-size: 0.72rem;
	color: var(--text-muted);
	line-height: 1.5;
	text-align: center;
	padding: 8px 4px 0;
}

.transfer-scope-note {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	font-size: 0.76rem;
	color: var(--text-secondary);
	line-height: 1.55;
	background: var(--accent-soft);
	border-radius: var(--radius-sm);
	padding: 10px 12px;
	margin-top: 4px;
}
.transfer-scope-note svg { flex-shrink: 0; margin-top: 1px; color: var(--accent-hover); }
html.night-mode .transfer-scope-note svg { color: var(--accent); }

/* ── Info popover (v1.3.8) — compressed panel text with full text on tap ──── */
/* A small info button toggles a floating bubble on click or tap (identical on */
/* desktop and mobile, never hover-only), closing on outside interaction and  */
/* on Escape. Token-derived colors keep light and dark correct.               */
.info-popover { position: relative; display: inline-flex; }
.info-popover-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: -6px 0 -6px 2px;
	padding: 0;
	border: none;
	border-radius: var(--radius-pill);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	vertical-align: middle;
	transition: var(--transition-fast);
	flex-shrink: 0;
}
.info-popover-btn:hover { background: var(--accent-soft); color: var(--accent-hover); }
html.night-mode .info-popover-btn:hover { color: var(--accent); }
.info-popover-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-hover); }
html.night-mode .info-popover-btn[aria-expanded="true"] { color: var(--accent); }
.info-popover-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.info-popover-btn svg { width: 14px; height: 14px; margin-top: 0; color: inherit; }
.info-popover-bubble {
	position: fixed;
	top: 0;
	left: 0;
	width: max-content;
	max-width: min(280px, calc(100vw - 32px));
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-md);
	padding: 10px 12px;
	font-size: 0.78rem;
	font-weight: 500;
	line-height: 1.55;
	color: var(--text-secondary);
	z-index: var(--z-floating);
	pointer-events: auto;
}

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── EDITOR — toolbar, title, canvas, tables ───────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */

/* ── v1.2.1 note-accent wash: gentle color-derived tint at top of editor ───── */
/* The workspace paints a soft wash from the active note color into the bg, plus */
/* a restrained accent bar on the title area. color-mix keeps it subtle; the     */
/* @supports fallback provides a faint solid band for older browsers. */
.editor-workspace.has-note-accent {
	background:
		linear-gradient(180deg,
			color-mix(in srgb, var(--note-active-accent, var(--accent)) var(--note-wash-strength), var(--bg)) 0%,
			var(--bg) var(--note-wash-depth));
}
.editor-workspace.has-note-accent .note-title-bar {
	box-shadow: inset 0 3px 0 0 var(--note-active-accent, var(--accent));
}
@supports not (background: color-mix(in srgb, #000 10%, #fff)) {
	.editor-workspace.has-note-accent {
		background:
			linear-gradient(180deg,
				var(--note-active-accent, var(--accent)) 0%,
				var(--bg) 3px,
				var(--bg) 100%);
	}
}

.editor-toolbar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 4px;
	padding: 10px 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}
.toolbar-group { display: flex; align-items: center; gap: 2px; position: relative; }
.toolbar-divider { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }

/* ── v1.2.1 larger toolbar buttons (~40×40 desktop) & clearer icons ────────── */
.tool-btn {
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	padding: 6px 10px;
	cursor: pointer;
	font-size: 0.95rem;
	font-family: var(--font);
	color: var(--text-secondary);
	transition: var(--transition-fast);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	flex-shrink: 0;
}
.tool-btn svg { width: 19px; height: 19px; }
.tool-btn:hover { background: var(--accent-soft); color: var(--text-primary); }
.tool-btn.active { background: var(--accent); border-color: var(--accent-hover); color: var(--accent-contrast); }
/* Contextual highlight when the table button is in "inside a table" mode. */
.tool-btn.table-context-active { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
html.night-mode .tool-btn.table-context-active { color: var(--accent); }
.tool-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

#font-size-select {
	padding: 5px 9px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.84rem;
	font-family: var(--font);
	background: var(--surface);
	color: var(--text-primary);
	cursor: pointer;
	outline: none;
	height: 40px;
	flex-shrink: 0;
}
#font-size-select:focus { border-color: var(--accent); }
#font-size-select:disabled { opacity: 0.45; cursor: not-allowed; }

.tool-label { font-size: 0.78rem; color: var(--text-secondary); margin-right: 5px; }

.color-options { display: flex; gap: 7px; align-items: center; }

.color-dot {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid transparent;
	box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12), var(--shadow-xs);
	transition: var(--transition);
	flex-shrink: 0;
	padding: 0;
	appearance: none;
	-webkit-appearance: none;
}
.color-dot:hover { transform: scale(1.18); }
.color-dot.active,
.color-dot[aria-pressed="true"] {
	border-color: var(--text-primary);
	transform: scale(1.18);
	box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
/* Soft White needs a visible outline against light surfaces. */
.color-dot[data-color="#F5F5F0"] {
	box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-xs);
}

/* ── Table Picker ──────────────────────────────────────────────────────────── */
.table-picker {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 12px;
	box-shadow: var(--shadow-md);
	z-index: var(--z-floating);
	min-width: 170px;
	max-width: calc(100vw - 24px);
}
.table-picker-grid {
	display: grid;
	grid-template-columns: repeat(8, 22px);
	grid-template-rows: repeat(8, 22px);
	gap: 3px;
}
/* Picker cells are now real buttons (keyboard accessible). */
.table-cell-selector {
	width: 22px; height: 22px; border: 1px solid var(--border);
	border-radius: 3px; cursor: pointer; background: var(--bg); transition: var(--transition-fast);
	padding: 0;
	appearance: none;
	-webkit-appearance: none;
}
.table-cell-selector.highlighted { background: var(--accent); border-color: var(--accent-hover); }
.table-cell-selector:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.table-picker-label { text-align: center; font-size: 0.78rem; color: var(--text-secondary); margin-top: 9px; font-weight: 600; }

/* ── Contextual table-edit menu ────────────────────────────────────────────── */
.table-edit-menu {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	z-index: var(--z-floating);
	min-width: 210px;
	max-width: calc(100vw - 24px);
	padding: 6px;
}

/* ── Find in Note bar (v1.4.1) ─────────────────────────────────────────────── */
/* A compact, non-modal strip between the toolbar and the title bar. Tokens     */
/* only, so both themes are correct, and it never changes the editor layout     */
/* while hidden.                                                               */
.find-bar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}
.find-bar-icon { flex-shrink: 0; color: var(--text-muted); }
.find-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 34px;
	padding: 6px 12px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-pill);
	font-size: 0.86rem;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	outline: none;
	transition: var(--transition);
}
.find-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.find-count {
	flex-shrink: 0;
	min-width: 62px;
	text-align: right;
	font-size: 0.74rem;
	font-weight: 600;
	color: var(--text-secondary);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.find-nav-btn,
.find-close-btn {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-secondary);
	font-family: var(--font);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	transition: var(--transition-fast);
}
.find-nav-btn:hover,
.find-close-btn:hover { background: var(--accent-soft); color: var(--text-primary); }
.find-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.find-nav-btn:disabled:hover { background: transparent; color: var(--text-secondary); }
.find-nav-btn:focus-visible,
.find-close-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Match highlighting uses the CSS Custom Highlight API. Where it is            */
/* unavailable these rules are simply inert: the counter and next/previous      */
/* still work, because they need only the string search and the selection.      */
/* The current match is registered second with a higher priority, so it stays   */
/* visibly stronger where the two registrations overlap.                        */
::highlight(sn-find-all) {
	background-color: var(--accent-soft);
	color: var(--text-primary);
}
::highlight(sn-find-current) {
	background-color: var(--accent);
	color: var(--accent-contrast);
}

/* ── Note Title Bar ────────────────────────────────────────────────────────── */
.note-title-bar {
	display: flex;
	align-items: flex-start;
	padding: 10px 24px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	gap: 12px;
	flex-shrink: 0;
}
.note-title-bar-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.note-title-primary-row { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

/* Compact Tags control is used only by the mobile title row. */
.mobile-tags-btn {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 4px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text-primary);
	font-family: var(--font);
	font-size: 0.72rem;
	font-weight: 700;
	cursor: pointer;
	transition: var(--transition-fast);
}
.mobile-tags-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.mobile-tags-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: var(--radius-pill);
	background: var(--border);
	color: var(--text-secondary);
	font-size: 0.65rem;
	font-variant-numeric: tabular-nums;
}
.mobile-tags-btn[aria-expanded="true"] {
	background: var(--accent-soft);
	border-color: var(--accent);
}

/* ── Tag editor secondary row (v1.2.3) — full width within the title area ──── */
.note-tag-editor {
	display: flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	min-width: 0;
}
.note-tag-scroll {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	width: 100%;
	min-width: 0;
}
.note-tag-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	min-width: 0;
}
.mobile-tag-overflow-indicator { display: none; }
.tag-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--accent-soft);
	border: 1px solid var(--border);
	border-radius: var(--radius-pill);
	padding: 2px 4px 2px 10px;
	font-size: 0.74rem;
	font-weight: 600;
	color: var(--text-primary);
	max-width: 220px;
}
.tag-chip-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}
.tag-chip-remove {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border: none;
	background: transparent;
	color: var(--text-muted);
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	transition: var(--transition-fast);
}
.tag-chip-remove:hover { background: var(--danger-soft); color: var(--danger-dark); }
.tag-chip-remove:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.note-tag-input {
	flex: 1;
	min-width: 110px;
	height: 36px;
	box-sizing: border-box;
	align-self: center;
	padding: 7px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-pill);
	font-size: 0.78rem;
	line-height: 20px;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	outline: none;
	transition: var(--transition);
}
.note-tag-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-tag-input::placeholder { color: var(--text-muted); }

/* ── Folder group headings (v1.2.3) ────────────────────────────────────────── */
.folder-group-heading {
	font-size: 0.66rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--text-muted);
	padding: 10px 4px 6px;
	margin: 0;
}
.folder-group-heading-tagged {
	border-top: 1px solid var(--border);
	margin-top: 6px;
}

/* ── Rename hint ───────────────────────────────────────────────────────────── */
.folder-rename-hint {
	font-size: 0.76rem;
	color: var(--text-muted);
	line-height: 1.5;
	margin-top: 8px;
}

#note-title-input {
	flex: 1;
	border: none;
	outline: none;
	font-size: 1.4rem;
	font-weight: 800;
	font-family: var(--font);
	background: transparent;
	color: var(--text-primary);
	min-width: 0;
	width: 100%;
	letter-spacing: -0.4px;
}
#note-title-input::placeholder { color: var(--text-muted); font-weight: 500; }

/* ── v1.2.5 clipped-title indicator ────────────────────────────────────────── */
/* Native single-line inputs clip overflow with no ellipsis, and CSS            */
/* text-overflow does not apply to form fields. JS toggles .title-clipped only  */
/* while scrollWidth exceeds clientWidth. A background image is used instead of */
/* an extra element so nothing is inserted into the mobile title-bar grid, and  */
/* so the indicator can never intercept clicks or keyboard traversal of the     */
/* title. A data URI cannot read a custom property, so the stroke colour is the */
/* literal --text-secondary value for each theme (light #6B675E, dark #A8A296). */
#note-title-input.title-clipped {
	padding-right: 20px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236B675E'%3E%3Ccircle cx='5' cy='12' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='19' cy='12' r='2'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right center;
	background-size: 16px 16px;
}
html.night-mode #note-title-input.title-clipped {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23A8A296'%3E%3Ccircle cx='5' cy='12' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='19' cy='12' r='2'/%3E%3C/svg%3E");
}

/* ── Breadcrumb ────────────────────────────────────────────────────────────── */
.note-folder-breadcrumb {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 0.72rem;
	font-weight: 600;
	color: var(--text-muted);
	line-height: 1.2;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
}
.note-folder-breadcrumb .breadcrumb-icon { flex-shrink: 0; opacity: 0.75; }
.note-folder-breadcrumb .breadcrumb-root { flex-shrink: 0; opacity: 0.85; }
.note-folder-breadcrumb .breadcrumb-sep { flex-shrink: 0; opacity: 0.5; user-select: none; }
.note-folder-breadcrumb .breadcrumb-folder {
	min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	color: var(--text-secondary); font-weight: 700;
}

.note-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.note-actions .icon-btn { min-width: 42px; min-height: 42px; padding: 9px; }
.note-actions .icon-btn svg { width: 19px; height: 19px; }

/* ── Note Canvas ───────────────────────────────────────────────────────────── */
.note-canvas {
	flex: 1;
	padding: 36px 48px;
	overflow-y: auto;
	outline: none;
	font-size: 1.02rem;
	line-height: 1.75;
	color: var(--text-primary);
	/* v1.3.6: the caret always uses the theme's primary text color, so it
	   stays clearly visible next to checkboxes in dark mode. */
	caret-color: var(--text-primary);
	word-break: break-word;
	background: transparent;
	font-family: var(--font-editor);
	max-width: 860px;
	width: 100%;
	margin: 0 auto;
}
.note-canvas:empty::before {
	content: attr(data-placeholder);
	color: var(--text-muted);
	pointer-events: none;
}

.note-canvas.logical-select-all-active {
	box-shadow: inset 0 0 0 3px var(--accent);
	background-image: linear-gradient(rgba(245, 200, 66, 0.1), rgba(245, 200, 66, 0.1));
	border-radius: var(--radius-md);
}

/* ── Editor list indentation ───────────────────────────────────────────────── */
.note-canvas ul, .note-canvas ol { padding-left: 26px; margin: 8px 0; list-style-position: inside; }

/* ── v1.4.0 ordered-list marker spacing ──────────────────────────────────── */
/* With inside markers, Chrome separates an ordered marker from its text with */
/* a wider fixed gap than the single space a bullet marker receives, and that */
/* gap is not addressable through CSS. The native ordered marker is switched  */
/* off and re-rendered as a ::before pseudo-element with the same explicit  */
/* 12px gap used by every list marker, so numbered markers get the same gap as */
/* bullets. counter(list-item) is the browser's own list counter, so decimal  */
/* numbering, the start attribute and li value attributes all keep working,   */
/* and the pseudo-element is an ordinary inline box that still follows text   */
/* alignment. It exists only in CSS, never in the DOM, so Copy as Plain Text, */
/* word and character counts, and Markdown export are unaffected.            */
.note-canvas ol { list-style: none; }
.note-canvas ul:not(:has(> li > input[type="checkbox"])) { list-style-type: none; }
.note-canvas ol > li::before { content: counter(list-item) '.'; padding-right: 12px; }
.note-canvas ul:not(:has(> li > input[type="checkbox"])) > li::before { content: '\2022'; padding-right: 12px; }

/* ── Task (checkbox) lists in the canvas (v1.3.6) ─────────────────────────── */
/* Themed checkboxes matching the selection-picker pattern: token-derived       */
/* colors only, accent fill with a contrast check when checked, and the shared  */
/* focus ring. The left padding matches the existing ul/ol rule. Checked items  */
/* read as done through muted text — a purely visual cue that is never written  */
/* into the note HTML, so unchecking restores the text untouched.              */
.note-canvas ul:has(> li > input[type="checkbox"]) {
	list-style: none;
	padding-left: 26px;
}
.note-canvas li > input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 30px;
	height: 18px;
	margin: 0;
	vertical-align: -0.25em;
	border: none;
	background: transparent;
	cursor: pointer;
	position: relative;
	padding: 0;
	flex-shrink: 0;
	outline: none;
}
/* The visible square is drawn at the left edge of the element by the          */
/* ::before pseudo-element; the rest of the element is a transparent hit and    */
/* paint area that supplies the entire gap between the box and the text. A      */
/* caret at the very start of an empty item paints at the element's edge and    */
/* ignores margins, so the whole gap lives inside the element itself and the    */
/* caret and typed text start at exactly the same point. The square keeps its   */
/* size, shape and token-derived colors in both themes.                         */
.note-canvas li > input[type="checkbox"]::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	width: 18px;
	height: 18px;
	border: 1.5px solid var(--border-strong);
	border-radius: var(--radius-xs);
	background: var(--surface);
	transition: var(--transition-fast);
}
.note-canvas li > input[type="checkbox"]:hover::before { border-color: var(--accent); }
.note-canvas li > input[type="checkbox"]:checked::before {
	background: var(--accent);
	border-color: var(--accent);
}
.note-canvas li > input[type="checkbox"]:checked::after {
	content: '';
	position: absolute;
	left: 5px;
	top: 1.5px;
	width: 5px;
	height: 10px;
	border: solid var(--accent-contrast);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}
.note-canvas li > input[type="checkbox"]:focus-visible::before {
	outline: 2px solid var(--focus-ring);
	outline-offset: 2px;
}
.note-canvas li:has(> input[type="checkbox"]:checked) { color: var(--text-muted); caret-color: var(--text-primary); }

/* ── Editor block spacing (v1.3.2) ─────────────────────────────────────────── */
/* The global reset zeroes margins, so paragraphs, generic block wrappers and   */
/* headings pasted or converted into the canvas stacked with no gap. Margins    */
/* follow the existing block-spacing scale (ul/ol 8px, pre 10px, blockquote     */
/* 11px, table 14px). The table scroll wrapper and everything inside table      */
/* cells are explicitly reset below, so table layout is unchanged.              */
.note-canvas p,
.note-canvas div { margin: 8px 0; }
.note-canvas h1, .note-canvas h2, .note-canvas h3,
.note-canvas h4, .note-canvas h5, .note-canvas h6 { margin: 12px 0 8px; }
.note-canvas .table-scroll { margin: 0; }
.note-canvas table td p, .note-canvas table td div,
.note-canvas table td h1, .note-canvas table td h2,
.note-canvas table td h3, .note-canvas table td h4,
.note-canvas table td h5, .note-canvas table td h6,
.note-canvas table th p, .note-canvas table th div,
.note-canvas table th h1, .note-canvas table th h2,
.note-canvas table th h3, .note-canvas table th h4,
.note-canvas table th h5, .note-canvas table th h6 { margin: 0; }

/* ── Code formatting (v1.3.0) — inline code and fenced code blocks ─────────── */
.note-canvas code {
	font-family: var(--font-mono);
	font-size: 0.88em;
	background: var(--accent-soft);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	padding: 1px 5px;
	word-break: break-word;
}
.note-canvas pre {
	font-family: var(--font-mono);
	font-size: 0.85rem;
	line-height: 1.6;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 12px 14px;
	margin: 10px 0;
	overflow-x: auto;
	white-space: pre-wrap;
	word-break: break-word;
}
.note-canvas pre code {
	background: transparent;
	border: none;
	padding: 0;
	font-size: inherit;
}

/* ── Horizontal rules and hyperlinks in the canvas (v1.3.0) ────────────────── */
.note-canvas hr {
	border: none;
	border-top: 1px solid var(--border-strong);
	margin: 16px 0;
}
.note-canvas a {
	color: var(--accent-hover);
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}
html.night-mode .note-canvas a { color: var(--accent); }

/* ── Blockquotes in the canvas (v1.3.1) ──────────────────────────────────── */
/* A single rule styles every nesting level: each nested blockquote carries   */
/* its own bar and indent. Token-only colors keep light and dark correct.     */
.note-canvas blockquote {
	margin: 11px 0;
	padding-left: 15px;
	border-left: 3px solid var(--border-strong);
	color: var(--text-secondary);
}

/* ── Table scroll wrapper ──────────────────────────────────────────────────── */
/* v1.4.1: the wrapper previously had no height cap, so it was exactly as tall  */
/* as its table: the horizontal scrollbar sat at the very bottom of a tall      */
/* table and the header row scrolled out of view. It is now capped and scrolls  */
/* on both axes. The cap only engages for tables taller than it, so short       */
/* tables render exactly as before.                                            */
.table-scroll {
	overflow: auto;
	max-width: 100%;
	max-height: 60vh;
	-webkit-overflow-scrolling: touch;
}

.note-canvas table {
	border-collapse: collapse;
	width: auto;
	min-width: 100%;
	margin: 14px 0;
	font-size: 0.95rem;
	border-radius: var(--radius-sm);
	overflow: hidden;
}
.note-canvas table td, .note-canvas table th {
	border: 1px solid var(--border-strong);
	padding: 9px 13px;
	min-width: 140px;
	word-break: normal;
	overflow-wrap: break-word;
	/* v1.2.4: empty cells now contain only a <br> placeholder instead of a       */
	/* non-breaking space. The placeholder already guarantees a line box, and     */
	/* this minimum is defence in depth so a cell can never collapse to zero      */
	/* height and become unclickable or unreachable by the caret.                 */
	min-height: 1.75em;
	vertical-align: top;
}
.note-canvas table th { background: var(--accent-soft); font-weight: 700; }
.note-canvas table td ul, .note-canvas table td ol,
.note-canvas table th ul, .note-canvas table th ol { padding-left: 18px; margin: 0; }
.note-canvas table tr:nth-child(even) td { background: rgba(0,0,0,0.015); }
html.night-mode .note-canvas table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
/* Highlight the cell containing the caret when table editing is active. */
.note-canvas table td.table-active-cell,
.note-canvas table th.table-active-cell {
	box-shadow: inset 0 0 0 2px var(--accent);
}

/* ── v1.4.1 sticky table header and first column ───────────────────────────── */
/* CSS only: no stored table HTML is rewritten and no normalization pass is     */
/* changed. Copy as Plain Text and Markdown export work on detached clones and  */
/* plain HTML strings, the table edit menu positions itself off the toolbar     */
/* button, and the Tab-out-of-last-cell caret jump walks the DOM — none of them */
/* read layout from this wrapper, so all remain unaffected.                     */

/* A table with overflow: hidden is its own scroll container, which makes       */
/* position: sticky on its cells completely inert. Inside a scroll wrapper the  */
/* table must therefore not clip; the only loss is radius clipping on collapsed */
/* borders, which is imperceptible. Tables outside a wrapper are untouched.     */
.note-canvas .table-scroll table { overflow: visible; }

/* Two header shapes exist in stored notes: a real thead (Markdown paste and    */
/* the changelog table) and a first tbody row of th cells (editor insertTable). */
/* Both stick. The :not(:has(> thead)) scoping keeps a legitimate first-column  */
/* th in a thead-bearing table from being treated as a header row; where :has() */
/* is unsupported that one shape simply does not stick, with nothing else       */
/* affected.                                                                   */
.note-canvas .table-scroll thead > tr > th,
.note-canvas .table-scroll table:not(:has(> thead)) > tbody > tr:first-child > th {
	position: sticky;
	top: 0;
	z-index: 2;
	background: var(--accent-soft);
}

/* First-column cells stay visible while the table scrolls horizontally, so row */
/* labels remain readable. Sticky is inert in a container that does not scroll, */
/* so this needs no class toggling.                                            */
.note-canvas .table-scroll tr > td:first-child,
.note-canvas .table-scroll tr > th:first-child {
	position: sticky;
	left: 0;
	z-index: 1;
}

/* The corner cell paints above the header row, which paints above the first    */
/* column, which paints above ordinary cells.                                  */
.note-canvas .table-scroll thead > tr > th:first-child,
.note-canvas .table-scroll table:not(:has(> thead)) > tbody > tr:first-child > th:first-child {
	z-index: 3;
}

/* ── Borders inside a scroll wrapper ───────────────────────────────────────── */
/* Under border-collapse: collapse a border between two cells is a single       */
/* shared line owned by the TABLE's collapsed border grid, not by either cell.  */
/* A sticky cell translates with its background and content but leaves that     */
/* shared line behind with the table layout, so the first column's right edge   */
/* disappears as soon as the table is scrolled horizontally, and the header     */
/* row's bottom edge disappears while merged cells scroll beneath it (the grid  */
/* assigns that line to the spanning cell below).                               */
/*                                                                              */
/* Redrawing the missing edges with an inset shadow was tried and rejected: the */
/* shadow sits just inside the collapsed border, so wherever the collapsed      */
/* border IS painted the edge renders at about twice the thickness of every     */
/* other cell.                                                                  */
/*                                                                              */
/* Inside a scroll wrapper the table therefore uses border-collapse: separate   */
/* with zero spacing, and every cell owns its own edges: each cell draws its    */
/* right and bottom border, first-column cells additionally draw their left     */
/* border, and first-row cells additionally draw their top border. Every grid   */
/* line is drawn exactly once, by exactly one cell, in the same token and at    */
/* the same 1px width as before — so nothing doubles, and no line can be left   */
/* behind by a sticky cell, merged cells included. Tables outside a wrapper     */
/* keep border-collapse: collapse and render exactly as they always have.       */
.note-canvas .table-scroll table {
	border-collapse: separate;
	border-spacing: 0;
}
.note-canvas .table-scroll table td,
.note-canvas .table-scroll table th {
	border: none;
	border-right: 1px solid var(--border-strong);
	border-bottom: 1px solid var(--border-strong);
}
.note-canvas .table-scroll table tr > td:first-child,
.note-canvas .table-scroll table tr > th:first-child {
	border-left: 1px solid var(--border-strong);
}
/* tbody:first-child matches only when no thead precedes it, so the two header  */
/* shapes present in stored notes are mutually exclusive and a top border is    */
/* never stacked under a thead's bottom border. Neither selector needs :has(),  */
/* so the grid is correct on every engine.                                      */
.note-canvas .table-scroll table > thead > tr:first-child > th,
.note-canvas .table-scroll table > thead > tr:first-child > td,
.note-canvas .table-scroll table > tbody:first-child > tr:first-child > th,
.note-canvas .table-scroll table > tbody:first-child > tr:first-child > td {
	border-top: 1px solid var(--border-strong);
}

/* Sticky cells must be opaque or scrolled rows show through them. Header cells */
/* already carry the opaque accent tint; first-column body cells take the       */
/* canvas background. The workspace paints a wash of the active note colour     */
/* behind the transparent canvas (.editor-workspace.has-note-accent), so a      */
/* solid token background cannot match that backdrop pixel-for-pixel near the   */
/* top of a note; --bg is the least intrusive choice and a faint seam there is  */
/* accepted. A merged cell that begins in column 1 or in the header row sticks  */
/* correctly; a cell pushed into visual column 1 by a rowspan above it is not   */
/* :first-child, so it scrolls behind the opaque sticky column, which reads     */
/* correctly.                                                                  */
.note-canvas .table-scroll tr > td:first-child { background: var(--bg); }

/* The even-row tint is a translucent overlay, so it is reproduced as a solid   */
/* colour on the sticky column. Browsers without color-mix() keep plain --bg.   */
.note-canvas .table-scroll table tr:nth-child(even) td:first-child {
	background: color-mix(in srgb, #000 1.5%, var(--bg));
}
html.night-mode .note-canvas .table-scroll table tr:nth-child(even) td:first-child {
	background: color-mix(in srgb, #fff 2%, var(--bg));
}
@supports not (background: color-mix(in srgb, #000 10%, #fff)) {
	.note-canvas .table-scroll table tr:nth-child(even) td:first-child {
		background: var(--bg);
	}
}

/* No sticky-specific caret-cell rule is needed: with the border reconstruction */
/* gone, the shared .table-active-cell ring above is the only box-shadow on any */
/* cell, so the caret highlight is identical inside and outside a scroll        */
/* wrapper.                                                                    */

/* ── Save Indicator ────────────────────────────────────────────────────────── */
.save-indicator {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 24px;
	background: var(--surface);
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}
#save-status { font-size: 0.76rem; color: var(--text-muted); font-weight: 500; }
.note-counts { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── Folder picker items ───────────────────────────────────────────────────── */
.folder-picker-item {
	display: flex;
	align-items: center;
	width: 100%;
	padding: 11px 14px;
	border: 1.5px solid transparent;
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--text-primary);
	font-size: 0.88rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition);
	margin-bottom: 5px;
}
.folder-picker-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.folder-picker-item.active { background: var(--accent-soft); border-color: var(--accent-hover); font-weight: 700; }
.folder-picker-empty { font-size: 0.84rem; color: var(--text-muted); text-align: center; padding: 14px 0; font-style: italic; }

.folder-name-input {
	width: 100%;
	padding: 11px 13px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	outline: none;
	transition: var(--transition);
}
.folder-name-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Wide desktop title metadata row ───────────────────────────────────────── */
/* Where the editor workspace is wide enough, place the title, full tag editor, */
/* and quick actions on one restrained row. Narrow desktop widths retain the     */
/* existing stacked title/tag layout so neither the title nor actions are        */
/* compressed into an unusable space.                                            */
@media (min-width: 1200px) {
	.note-title-bar { align-items: center; }
	.note-title-bar-main { display: contents; }
	.note-title-primary-row {
		flex: 1 1 240px;
		min-width: 160px;
	}
	.note-tag-editor {
		flex: 0 1 420px;
		align-self: center;
		width: clamp(220px, 30vw, 420px);
		height: 42px;
		min-width: 160px;
		max-width: 420px;
		padding-right: 12px;
		border-right: 1px solid var(--border);
	}
	.note-tag-scroll {
		flex: 1 1 auto;
		flex-wrap: nowrap;
		align-items: center;
		gap: 6px;
		height: 42px;
		min-height: 42px;
		overflow: hidden;
	}
	.note-tag-chips {
		flex: 1 1 auto;
		flex-wrap: nowrap;
		align-items: center;
		min-width: 0;
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-inline: contain;
		scroll-padding-inline: 6px;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}
	.note-tag-chips .tag-chip:first-child { margin-left: auto; }
	.tag-chip { flex: 0 0 auto; }
	.note-tag-input {
		flex: 0 0 130px;
		min-width: 130px;
		height: 42px;
		margin-left: 0;
		padding: 10px 12px;
	}
}

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── RESPONSIVE — folder panel drill-down (≤1920px, v1.2.8) ────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
/* At CSS widths up to and including 1920px the Folders panel uses the          */
/* drill-down model: the folder list fills the panel, and opening a folder      */
/* swaps it for that folder's notes with a back button. Above 1920px — that is, */
/* 1440p-class and wider screens — the desktop split view is untouched.         */
/* Controlled by app-shell classes.                                             */
@media (max-width: 1920px) {
	.folders-list-section { max-height: none; flex: 1; }
	.app-shell.folder-drill-open .folders-list-section { display: none; }
	.app-shell.folder-drill-open .folder-notes-section { flex: 1; }
	.app-shell:not(.folder-drill-open) .folder-notes-section { display: none; }
	.app-shell.folder-drill-open .folder-back-btn { display: inline-flex; }
}

/* ── Narrow-desktop folder labels (769px–1920px) ───────────────────────────── */
/* The desktop section panel is 296px wide — narrower than most phones — so a   */
/* single-line ellipsis can hide a folder name almost entirely. In drill-down   */
/* ranges, folder list names wrap to a maximum of two lines. The open-folder    */
/* header is always exactly two lines: back button and folder name on the first */
/* row (name right-aligned, truncated with an ellipsis when too long), and the  */
/* note counts on the second row. Mobile (≤768px) and the wide split view       */
/* (>1920px) are untouched.                                                     */
@media (min-width: 769px) and (max-width: 1920px) {
	.folder-item-name {
		white-space: normal;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		word-break: break-word;
	}
	.folder-notes-header {
		display: grid;
		grid-template-columns: auto 1fr;
		align-items: center;
		column-gap: 8px;
		row-gap: 2px;
	}
	.folder-back-btn { grid-column: 1; grid-row: 1; }
	.folder-notes-header h3 {
		grid-column: 2;
		grid-row: 1;
		justify-self: end;
		max-width: 100%;
		min-width: 0;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.folder-notes-header-count {
		grid-column: 1 / -1;
		grid-row: 2;
		justify-self: start;
	}
}

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── RESPONSIVE — mobile editor ────────────────────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
	.editor-toolbar { padding: 8px 10px; gap: 2px; overflow-x: auto; flex-wrap: nowrap; }
	.toolbar-divider { display: none; }
	.toolbar-group { flex-shrink: 0; }

	/* Keep touch targets at least 44×44 without shrinking below accessible size. */
	.tool-btn { min-width: 44px; height: 44px; }
	.tool-btn svg { width: 20px; height: 20px; }
	#font-size-select { height: 44px; }

	.note-canvas { padding: 22px 20px; font-size: 1rem; }

	/* Task-list checkboxes keep a comfortable touch target on mobile, with the */
	/* check mark repositioned to match the larger box. */
	.note-canvas li > input[type="checkbox"] { width: 32px; height: 20px; vertical-align: -0.3em; }
	.note-canvas li > input[type="checkbox"]::before { width: 20px; height: 20px; }
	.note-canvas li > input[type="checkbox"]:checked::after { left: 6px; top: 2px; width: 5px; height: 10px; }

	.note-actions { gap: 4px; }
	.note-actions .icon-btn { min-width: 44px; min-height: 44px; padding: 10px; }
	.note-actions .icon-btn svg { width: 20px; height: 20px; }

	/* Fixed mobile title row: title, Tags, Share, More. The existing tag editor */
	/* becomes a separate bounded row only while the Tags control is expanded. */
	.note-title-bar {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(54px, auto) 44px 44px 44px;
		grid-template-areas:
			"title tags copy share more"
			"tag-editor tag-editor tag-editor tag-editor tag-editor";
		align-items: center;
		gap: 6px;
		padding: 8px 10px;
	}
	.note-title-bar-main,
	.note-title-primary-row,
	.note-actions { display: contents; }
	#note-title-input {
		grid-area: title;
		min-width: 0;
		width: 100%;
		font-size: 1.08rem;
	}
	.mobile-tags-btn {
		grid-area: tags;
		display: inline-flex;
		min-width: 54px;
		height: 44px;
		padding: 0 6px;
		flex-shrink: 0;
	}
	#copy-note-btn { grid-area: copy; }
	#share-note-btn { grid-area: share; }
	#more-note-btn { grid-area: more; }
	#pin-note-btn,
	#delete-note-btn { display: none !important; }
	.note-actions .icon-btn {
		min-width: 44px;
		min-height: 44px;
		width: 44px;
		height: 44px;
		padding: 10px;
		flex-shrink: 0;
	}
	.note-actions .icon-btn svg { width: 20px; height: 20px; }

	.note-tag-editor {
		grid-area: tag-editor;
		display: none;
		align-items: stretch;
		gap: 0;
		height: 44px;
		min-height: 44px;
		max-height: 44px;
		min-width: 0;
		width: 100%;
		border: 1px solid var(--border);
		border-radius: var(--radius-sm);
		background: var(--bg);
		overflow: hidden;
	}
	.note-tag-editor.mobile-expanded { display: flex; }
	.note-tag-scroll {
		flex: 1 1 auto;
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		gap: 5px;
		width: auto;
		min-width: 0;
		height: 42px;
		padding: 5px 8px;
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-inline: contain;
		scroll-behavior: smooth;
		scroll-padding-inline: 8px;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}
	.note-tag-chips {
		flex: 0 0 auto;
		flex-wrap: nowrap;
		align-items: center;
	}
	.tag-chip { flex: 0 0 auto; max-width: 180px; }
	/* Keep tag remove targets comfortably tappable and keyboard reachable. */
	.tag-chip-remove { width: 28px; height: 28px; }
	.note-tag-input {
		flex: 0 0 132px;
		min-width: 132px;
		height: 32px;
		padding: 5px 9px;
		background: var(--surface);
	}
	.mobile-tag-overflow-indicator {
		flex: 0 0 18px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		height: 42px;
		color: var(--text-muted);
		background: linear-gradient(90deg, transparent, var(--bg) 45%);
		font-size: 1.15rem;
		font-weight: 700;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.15s ease;
		pointer-events: none;
	}
	.note-tag-editor.has-tag-overflow-right .mobile-tag-overflow-indicator {
		opacity: 0.8;
		visibility: visible;
	}

	.note-folder-breadcrumb { font-size: 0.68rem; gap: 3px; }
	.note-folder-breadcrumb .breadcrumb-icon { width: 12px; height: 12px; }

	.note-canvas table td, .note-canvas table th { padding: 7px 9px; font-size: 0.9rem; }
	.note-canvas .table-scroll table td,
	.note-canvas .table-scroll table th { min-width: 92px; }

	/* v1.4.1: a shorter table viewport cap on phones, so a tall table never
	   swallows the whole editor area. */
	.table-scroll { max-height: 50vh; }

	/* v1.4.1: touch-sized find-bar controls. */
	.find-bar { padding: 8px 10px; gap: 4px; }
	.find-input { height: 40px; }
	.find-count { min-width: 54px; font-size: 0.7rem; }
	.find-nav-btn,
	.find-close-btn { width: 44px; height: 44px; }

	/* v1.3.6: editor floating menus (table picker, table edit menu, Lists menu) */
	/* open centered on the screen, like the Insert Link dialog, instead of     */
	/* docking to the bottom edge. */
	.table-picker,
	.table-edit-menu {
		position: fixed;
		left: 50%;
		top: 50%;
		right: auto;
		bottom: auto;
		transform: translate(-50%, -50%);
		max-width: calc(100vw - 24px);
		max-height: calc(100vh - 96px);
		overflow: auto;
	}
	.table-picker-grid {
		grid-template-columns: repeat(8, minmax(22px, 24px));
		grid-template-rows: repeat(8, minmax(22px, 24px));
	}

	.save-indicator { padding: 7px 16px; }
}

/* ── Landscape phones ──────────────────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
	.panel-header { padding: 10px 14px 8px; }
	.panel-search { padding: 4px 14px 8px; }
	.table-picker, .table-edit-menu { max-height: calc(100vh - 32px); }
}

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── QR TEXT PREVIEW + SELECTION PICKER — token-derived colors only ────────── */
/* ════════════════════════════════════════════════════════════════════════════ */

/* ── QR text fallback preview ──────────────────────────────────────────────── */
/* Presentation moved out of app.js inline styles: colors come from design      */
/* tokens so the accent is correct in both the light and dark themes.           */
.qr-text-preview {
	white-space: pre-wrap;
	word-break: break-word;
	margin: 0 0 8px 0;
	padding: 10px 12px;
	border-left: 3px solid var(--accent);
	background: var(--accent-soft);
	border-radius: 6px;
	max-height: 220px;
	overflow-y: auto;
}

/* ── Shared selection picker (bulk share; reusable by later flows) ─────────── */
.selection-picker-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 8px;
}
.selection-picker-select-all {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.84rem;
	font-weight: 600;
	color: var(--text-primary);
	cursor: pointer;
}
.selection-picker-count {
	font-size: 0.76rem;
	color: var(--text-secondary);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.selection-picker-groups {
	max-height: 320px;
	overflow-y: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	padding: 4px;
	margin-bottom: 12px;
}
.selection-picker-group-heading {
	font-size: 0.66rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--text-muted);
	padding: 8px 8px 4px;
}
.selection-picker-item {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 7px 8px;
	border-radius: var(--radius-sm);
	transition: var(--transition-fast);
}
.selection-picker-item:hover { background: var(--accent-soft); }
.selection-picker-item-disabled { opacity: 0.55; }
.selection-picker-item-disabled:hover { background: transparent; }

/* ── Themed checkboxes — token-derived colors, light and dark correct ──────── */
.selection-picker-item input[type="checkbox"],
.selection-picker-select-all input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	margin: 0;
	flex-shrink: 0;
	border: 1.5px solid var(--border-strong);
	border-radius: var(--radius-xs);
	background: var(--surface);
	cursor: pointer;
	position: relative;
	transition: var(--transition-fast);
	padding: 0;
}
.selection-picker-item input[type="checkbox"]:hover:not(:disabled),
.selection-picker-select-all input[type="checkbox"]:hover:not(:disabled) { border-color: var(--accent); }
.selection-picker-item input[type="checkbox"]:disabled,
.selection-picker-select-all input[type="checkbox"]:disabled { cursor: default; }
.selection-picker-item input[type="checkbox"]:checked,
.selection-picker-select-all input[type="checkbox"]:checked,
.selection-picker-item input[type="checkbox"]:indeterminate,
.selection-picker-select-all input[type="checkbox"]:indeterminate {
	background: var(--accent);
	border-color: var(--accent);
}
.selection-picker-item input[type="checkbox"]:checked::after,
.selection-picker-select-all input[type="checkbox"]:checked::after {
	content: '';
	position: absolute;
	left: 5px;
	top: 1.5px;
	width: 5px;
	height: 10px;
	border: solid var(--accent-contrast);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}
.selection-picker-item input[type="checkbox"]:indeterminate::after,
.selection-picker-select-all input[type="checkbox"]:indeterminate::after {
	content: '';
	position: absolute;
	left: 4px;
	top: 6.5px;
	width: 7px;
	height: 2px;
	background: var(--accent-contrast);
	border-radius: 1px;
}
.selection-picker-item input[type="checkbox"]:focus-visible,
.selection-picker-select-all input[type="checkbox"]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.selection-picker-item-label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 0.86rem;
	font-weight: 500;
	color: var(--text-primary);
	cursor: pointer;
}
.selection-picker-item-disabled .selection-picker-item-label { cursor: default; }
.selection-picker-item-meta {
	font-size: 0.7rem;
	color: var(--text-secondary);
	flex-shrink: 0;
	font-variant-numeric: tabular-nums;
}

/* ── Nested parent rows (expand/collapse arrow) ────────────────────────────── */
.selection-picker-toggle {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: var(--radius-xs);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: var(--transition-fast);
	padding: 0;
}
.selection-picker-toggle:hover { background: var(--border); color: var(--text-primary); }
.selection-picker-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.selection-picker-toggle svg { transition: transform 0.15s ease; }
.selection-picker-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.selection-picker-children {
	margin: 0 4px 4px 17px;
	padding-left: 10px;
	border-left: 1px solid var(--border);
}
.selection-picker-children .selection-picker-item-label { color: var(--text-secondary); font-weight: 500; }

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── RECYCLE BIN — token-derived colors only ───────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
.recycle-bin-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 10px;
}
.recycle-bin-list {
	max-height: 320px;
	overflow-y: auto;
}
.recycle-bin-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 11px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	margin-bottom: 6px;
}
.recycle-bin-item-main { flex: 1; min-width: 0; }
.recycle-bin-item-title {
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--text-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.recycle-bin-item-date { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.recycle-bin-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.recycle-bin-btn {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 6px 10px;
	font-size: 0.76rem;
	font-family: var(--font);
	font-weight: 600;
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition-fast);
	white-space: nowrap;
}
.recycle-bin-btn:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }
.recycle-bin-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.recycle-bin-btn:disabled:hover { border-color: var(--border); color: var(--text-secondary); background: var(--surface); }
.recycle-bin-btn-danger { color: var(--danger-dark); }
.recycle-bin-btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-dark); }
.recycle-bin-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.recycle-bin-empty {
	font-size: 0.84rem;
	color: var(--text-muted);
	text-align: center;
	padding: 18px 0;
	font-style: italic;
}