/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	--mustard:        #F5C842;
	--mustard-dark:   #E0B230;
	--mustard-light:  #FDF3C0;
	--blush:          #F5A7A7;
	--sage:           #A8D5B5;
	--sky:            #A7C7E7;
	--lavender:       #C3B1E1;
	--peach:          #FFCBA4;
	--soft-white:     #F5F5F0;
	--bg:             #FFFDF4;
	--surface:        #FFFFFF;
	--text-primary:   #2C2C2C;
	--text-secondary: #6B6B6B;
	--border:         #E8E0C8;
	--danger:         #E57373;
	--danger-dark:    #C62828;
	--success:        #81C784;
	--pro-gold:       #B8860B;
	--radius-sm:      6px;
	--radius-md:      12px;
	--radius-lg:      20px;
	--shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
	--shadow-md:      0 4px 20px rgba(0,0,0,0.12);
	--transition:     all 0.2s ease;
	--sidebar-width:  280px;
	--nav-height:     56px;
	--font:           'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Night Mode Variables ──────────────────────────────────────────────────── */
html.night-mode,
body.night-mode {
	--bg:             #1A1A1A;
	--surface:        #242424;
	--text-primary:   #F0EAD6;
	--text-secondary: #A0998A;
	--border:         #3A3A3A;
	--mustard-light:  #3A3000;
}

html, body {
	height: 100%;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	overflow: hidden;
	transition: background 0.3s ease, color 0.3s ease;
}

/* ── Accessibility: skip link ──────────────────────────────────────────────── */
.skip-link {
	position: absolute;
	top: -100%;
	left: 0;
	background: var(--mustard);
	color: #2C2C2C;
	padding: 10px 18px;
	font-weight: 700;
	font-size: 0.9rem;
	border-radius: 0 0 var(--radius-sm) 0;
	z-index: 9999;
	text-decoration: none;
	transition: top 0.15s ease;
}

.skip-link:focus {
	top: 0;
}

/* ── Accessibility: global focus indicator ─────────────────────────────────── */
*:focus-visible {
	outline: 2px solid var(--mustard-dark);
	outline-offset: 2px;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden {
	display: none !important;
}

.error-msg {
	color: var(--danger-dark);
	font-size: 0.85rem;
	margin-top: 8px;
	padding: 8px 12px;
	background: #FDECEA;
	border-radius: var(--radius-sm);
}

.success-msg {
	color: #2E7D32;
	font-size: 0.85rem;
	margin-top: 8px;
	padding: 8px 12px;
	background: #E8F5E9;
	border-radius: var(--radius-sm);
}

.msg {
	font-size: 0.85rem;
	margin-top: 8px;
	padding: 8px 12px;
	border-radius: var(--radius-sm);
	min-height: 0;
}

.msg.success {
	color: #2E7D32;
	background: #E8F5E9;
}

.msg.error {
	color: var(--danger-dark);
	background: #FDECEA;
}

/* ── Form Groups ───────────────────────────────────────────────────────────── */
.form-group {
	margin-bottom: 14px;
}

.form-group input {
	width: 100%;
	padding: 12px 14px;
	border: 2px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	transition: var(--transition);
	outline: none;
}

.form-group input:focus {
	border-color: var(--mustard);
	background: var(--surface);
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen {
	display: none;
	width: 100%;
	height: 100%;
}

.screen.active {
	display: flex;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 11px 20px;
	border: none;
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: var(--font);
	font-weight: 600;
	cursor: pointer;
	transition: var(--transition);
	gap: 6px;
}

.btn-primary {
	background: var(--mustard);
	color: #2C2C2C;
	width: 100%;
	margin-top: 4px;
}

.btn-primary:hover {
	background: var(--mustard-dark);
}

.btn-secondary {
	background: var(--border);
	color: var(--text-primary);
}

.btn-secondary:hover {
	background: #d5cdb0;
}

.btn-danger {
	background: var(--danger);
	color: #fff;
}

.btn-danger:hover {
	background: var(--danger-dark);
}

.icon-btn {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 6px;
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: var(--transition);
}

.icon-btn:hover {
	background: var(--mustard-light);
	color: var(--text-primary);
}

.icon-btn.danger:hover {
	background: #FDECEA;
	color: var(--danger-dark);
}

/* ── Pin button active state ───────────────────────────────────────────────── */
#pin-note-btn.active {
	color: var(--mustard-dark);
}

#pin-note-btn.active:hover {
	background: var(--mustard-light);
	color: var(--mustard-dark);
}

/* ── PRO badge ─────────────────────────────────────────────────────────────── */
.pro-badge {
	display: inline-block;
	background: var(--mustard);
	color: #2C2C2C;
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 2px 6px;
	border-radius: 4px;
	line-height: 1.4;
	vertical-align: middle;
	margin-left: 4px;
	flex-shrink: 0;
}

/* ── App Screen ────────────────────────────────────────────────────────────── */
#app-screen {
	flex-direction: column;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
}

/* ── Top Navigation ────────────────────────────────────────────────────────── */
.top-nav {
	height: var(--nav-height);
	background: var(--mustard);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 16px;
	box-shadow: var(--shadow-sm);
	z-index: 100;
	flex-shrink: 0;
}

body.night-mode .top-nav {
	background: #2A2200;
}

.nav-title {
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--text-primary);
	letter-spacing: -0.5px;
}

body.night-mode .nav-title {
	color: var(--mustard);
}

.nav-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.nav-btn {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 8px;
	border-radius: var(--radius-sm);
	color: var(--text-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: var(--transition);
}

body.night-mode .nav-btn {
	color: var(--mustard);
}

.nav-btn:hover {
	background: var(--mustard-dark);
}

body.night-mode .nav-btn:hover {
	background: #3A3000;
}

/* ── App Body ──────────────────────────────────────────────────────────────── */
.app-body {
	display: flex;
	flex: 1;
	overflow: hidden;
	position: relative;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
	width: var(--sidebar-width);
	background: var(--surface);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	height: 100%;
	overflow: hidden;
	transition: transform 0.3s ease, width 0.3s ease;
	z-index: 90;
}

.sidebar.collapsed {
	width: 0;
	border-right: none;
}

.sidebar-header {
	padding: 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 1px solid var(--border);
	background: var(--mustard-light);
}

.user-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* ── User avatar ───────────────────────────────────────────────────────────── */
.user-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--mustard);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 1rem;
	color: #2C2C2C;
	text-transform: uppercase;
	flex-shrink: 0;
	cursor: pointer;
	position: relative;
	transition: background 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

/* ── Pro tier avatar ───────────────────────────────────────────────────────── */
.user-avatar.tier-pro {
	background: linear-gradient(160deg, #F5D060 0%, #C9940D 45%, #8B6508 100%);
	color: #FFFFFF;
	box-shadow:
		0 0 0 2px #B8860B,
		0 0 0 3px rgba(245, 208, 96, 0.35),
		0 0 12px 3px rgba(184, 134, 11, 0.50);
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.40);
}

/* ── Supporter tier avatar ─────────────────────────────────────────────────── */
.user-avatar.tier-supporter {
	background: conic-gradient(
		from 0deg,
		#ff6b6b, #ffd93d, #6bcb77, #4d96ff, #c77dff, #ff6b6b
	);
	color: #FFFFFF;
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
	animation:
		sulata-aurora  4s linear infinite,
		sulata-glow    3s ease-in-out infinite alternate;
}

.user-avatar.tier-supporter::after {
	content: '\2736';
	position: absolute;
	bottom: -4px;
	right: -4px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #2C2C2C;
	border: 1.5px solid rgba(255, 255, 255, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.5rem;
	line-height: 14px;
	text-align: center;
	color: #F5D060;
	text-shadow: none;
	pointer-events: none;
}

body.night-mode .user-avatar.tier-supporter::after {
	background: #1A1A1A;
	border-color: rgba(255, 255, 255, 0.3);
}

@keyframes sulata-aurora {
	from { filter: hue-rotate(0deg)   brightness(1.05); }
	to   { filter: hue-rotate(360deg) brightness(1.05); }
}

@keyframes sulata-glow {
	from {
		box-shadow:
			0 0 0 2px rgba(255, 255, 255, 0.55),
			0 0  8px 2px rgba(109, 203, 119, 0.55),
			0 0 18px 4px rgba(77,  150, 255, 0.35);
	}
	to {
		box-shadow:
			0 0 0 2px rgba(255, 255, 255, 0.75),
			0 0 14px 5px rgba(199, 125, 255, 0.65),
			0 0 28px 8px rgba(255, 107, 107, 0.35);
	}
}

/* ── Tooltip for the tier badge ────────────────────────────────────────────── */
.user-avatar[data-tooltip]::before {
	content: attr(data-tooltip);
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	transform: none;
	background: #2C2C2C;
	color: #FFFFFF;
	font-size: 0.72rem;
	font-weight: 600;
	white-space: normal;
	max-width: 200px;
	width: max-content;
	max-width: min(200px, calc(100vw - 32px));
	padding: 5px 10px;
	border-radius: var(--radius-sm);
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.15s ease;
	z-index: 300;
	line-height: 1.45;
	box-sizing: border-box;
}

.user-avatar[data-tooltip]:hover::before,
.user-avatar[data-tooltip]:focus::before {
	opacity: 1;
}

/* ── User tagline ───────────────────────────────────────────────────────────── */
.user-tagline {
	font-size: 0.82rem;
	color: var(--text-secondary);
	font-style: italic;
}

.sidebar-search {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
}

.sidebar-search input {
	width: 100%;
	padding: 8px 12px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.88rem;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	outline: none;
	transition: var(--transition);
}

.sidebar-search input:focus {
	border-color: var(--mustard);
}

.sidebar-notes {
	flex: 1;
	overflow-y: auto;
	padding: 8px;
	min-height: 0;
}

.sidebar-notes::-webkit-scrollbar {
	width: 4px;
}

.sidebar-notes::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

/* ── Sidebar empty state ───────────────────────────────────────────────────── */
.sidebar-empty-msg {
	text-align: center;
	color: var(--text-secondary);
	font-size: 0.85rem;
	padding: 24px 16px;
}

/* ── Note Item in Sidebar ──────────────────────────────────────────────────── */
.note-item {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	cursor: pointer;
	margin-bottom: 6px;
	transition: var(--transition);
	border: 2px solid transparent;
	position: relative;
}

.note-item:hover {
	filter: brightness(0.95);
}

.note-item.active {
	border-color: var(--mustard-dark);
	box-shadow: var(--shadow-sm);
}

.note-item:focus-visible {
	outline: 2px solid var(--mustard-dark);
	outline-offset: 2px;
}

.note-item-title-row {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-bottom: 4px;
	overflow: hidden;
}

.pin-icon {
	width: 11px;
	height: 11px;
	flex-shrink: 0;
	opacity: 0.55;
	color: #2C2C2C;
}

.note-item-title {
	font-weight: 600;
	font-size: 0.9rem;
	color: #2C2C2C;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.note-item-preview {
	font-size: 0.78rem;
	color: #555555;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	white-space: pre-wrap;
	word-break: break-word;
	line-height: 1.5;
	max-height: 3.6em;
}

.note-item-date {
	font-size: 0.72rem;
	color: #777777;
	margin-top: 6px;
}

/* ── Sidebar Footer ────────────────────────────────────────────────────────── */
.sidebar-footer {
	padding: 12px 16px;
	border-top: 1px solid var(--border);
	flex-shrink: 0;
	background: var(--surface);
}

.sidebar-footer-actions {
	display: flex;
	gap: 8px;
	align-items: center;
}

.sidebar-app-footer {
	margin-top: 12px;
	padding-top: 10px;
	border-top: 1px solid var(--border);
	text-align: center;
}

.footer-copy {
	font-size: 0.72rem;
	color: var(--text-secondary);
	line-height: 1.5;
}

.footer-version {
	font-size: 0.68rem;
	color: var(--text-secondary);
	margin-top: 3px;
	line-height: 1.5;
	opacity: 0.8;
}

/* ── Footer links row ──────────────────────────────────────────────────────── */
.footer-links {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-top: 8px;
	flex-wrap: wrap;
}

.footer-link {
	font-size: 0.69rem;
	color: var(--text-secondary);
	text-decoration: none;
	cursor: pointer;
	transition: color 0.15s ease;
	white-space: nowrap;
}

.footer-link:hover {
	color: var(--text-primary);
	text-decoration: underline;
}

.footer-link-sep {
	font-size: 0.69rem;
	color: var(--text-secondary);
	opacity: 0.5;
	user-select: none;
}

.footer-link-pro {
	color: var(--pro-gold);
	font-weight: 600;
}

.footer-link-pro:hover {
	color: var(--mustard-dark);
}

body.night-mode .footer-link-pro {
	color: var(--mustard);
}

/* ── Sidebar dropdown groups ───────────────────────────────────────────────── */
.sidebar-dropdown-group {
	position: relative;
	flex: 1;
}

.btn-sidebar-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: 100%;
	padding: 9px 12px;
	border: 2px solid var(--border);
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-secondary);
	font-size: 0.88rem;
	font-family: var(--font);
	font-weight: 600;
	cursor: pointer;
	transition: var(--transition);
	white-space: nowrap;
}

.btn-sidebar-action:hover {
	border-color: var(--mustard-dark);
	color: var(--mustard-dark);
	background: var(--mustard-light);
}

body.night-mode .btn-sidebar-action:hover {
	background: #3A3000;
}

.sidebar-dropdown {
	position: absolute;
	bottom: calc(100% + 6px);
	left: 0;
	min-width: 200px;
	width: max-content;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	z-index: 160;
	overflow: hidden;
}

#receive-dropdown-group .sidebar-dropdown {
	left: auto;
	right: 0;
}

/* ── Sidebar Overlay (mobile) ──────────────────────────────────────────────── */
.sidebar-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.35);
	z-index: 80;
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
	flex: 1;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
}

/* ── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 40px;
	text-align: center;
}

.empty-icon {
	font-size: 3.5rem;
}

.empty-state h2 {
	font-size: 1.3rem;
	color: var(--text-primary);
}

.empty-state p {
	color: var(--text-secondary);
	font-size: 0.9rem;
	max-width: 280px;
}

.empty-state .btn-primary {
	width: auto;
	margin-top: 8px;
	padding: 11px 24px;
}

/* ── Note Editor ───────────────────────────────────────────────────────────── */
.note-editor {
	flex: 1;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}

/* ── Editor Toolbar ────────────────────────────────────────────────────────── */
.editor-toolbar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 4px;
	padding: 8px 12px;
	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 4px;
}

.tool-btn {
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	padding: 5px 8px;
	cursor: pointer;
	font-size: 0.88rem;
	font-family: var(--font);
	color: var(--text-primary);
	transition: var(--transition);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	height: 28px;
}

.tool-btn:hover {
	background: var(--mustard-light);
	border-color: var(--mustard);
}

.tool-btn.active {
	background: var(--mustard);
	border-color: var(--mustard-dark);
	color: #2C2C2C;
}

#font-size-select {
	padding: 4px 8px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.85rem;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	cursor: pointer;
	outline: none;
	height: 28px;
}

#font-size-select:focus {
	border-color: var(--mustard);
}

#font-size-select:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.tool-label {
	font-size: 0.8rem;
	color: var(--text-secondary);
	margin-right: 4px;
}

.color-options {
	display: flex;
	gap: 6px;
	align-items: center;
}

/* ── Color dots ────────────────────────────────────────────────────────────── */
.color-dot {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid transparent;
	transition: var(--transition);
	flex-shrink: 0;
	padding: 0;
	appearance: none;
	-webkit-appearance: none;
}

.color-dot:hover {
	transform: scale(1.2);
	border-color: var(--text-secondary);
}

.color-dot.active,
.color-dot[aria-pressed="true"] {
	border-color: var(--text-primary);
	transform: scale(1.2);
}

/* ── Table Picker ──────────────────────────────────────────────────────────── */
.table-picker {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 10px;
	box-shadow: var(--shadow-md);
	z-index: 150;
	min-width: 160px;
}

.table-picker-grid {
	display: grid;
	grid-template-columns: repeat(8, 18px);
	grid-template-rows: repeat(8, 18px);
	gap: 3px;
}

.table-cell-selector {
	width: 18px;
	height: 18px;
	border: 1px solid var(--border);
	border-radius: 2px;
	cursor: pointer;
	background: var(--bg);
	transition: var(--transition);
}

.table-cell-selector.highlighted {
	background: var(--mustard);
	border-color: var(--mustard-dark);
}

.table-picker-label {
	text-align: center;
	font-size: 0.78rem;
	color: var(--text-secondary);
	margin-top: 8px;
	font-weight: 600;
}

/* ── Note Title Bar ────────────────────────────────────────────────────────── */
.note-title-bar {
	display: flex;
	align-items: center;
	padding: 10px 16px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	gap: 10px;
	flex-shrink: 0;
}

#note-title-input {
	flex: 1;
	border: none;
	outline: none;
	font-size: 1.2rem;
	font-weight: 700;
	font-family: var(--font);
	background: transparent;
	color: var(--text-primary);
	min-width: 0;
}

#note-title-input::placeholder {
	color: var(--text-secondary);
	font-weight: 400;
}

.note-actions {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}

/* ── Note title bar export dropdown ───────────────────────────────────────── */
.export-dropdown-group {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.export-dropdown {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	z-index: 160;
	min-width: 180px;
	overflow: hidden;
}

/* ── Shared dropdown item ──────────────────────────────────────────────────── */
.dropdown-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 11px 16px;
	border: none;
	background: transparent;
	color: var(--text-primary);
	font-size: 0.88rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition);
	white-space: nowrap;
}

.dropdown-item:hover {
	background: var(--mustard-light);
	color: var(--text-primary);
}

.dropdown-item + .dropdown-item {
	border-top: 1px solid var(--border);
}

body.night-mode .dropdown-item:hover {
	background: #3A3000;
}

/* ── Note Canvas ───────────────────────────────────────────────────────────── */
.note-canvas {
	flex: 1;
	padding: 32px 36px;
	overflow-y: auto;
	outline: none;
	font-size: 0.97rem;
	line-height: 1.7;
	color: #2C2C2C;
	word-break: break-word;
	transition: background 0.3s ease;
}

.note-canvas:empty::before {
	content: attr(data-placeholder);
	color: var(--text-secondary);
	pointer-events: none;
	font-style: italic;
}

.note-canvas::-webkit-scrollbar {
	width: 6px;
}

.note-canvas::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 6px;
}

/* ── Table Styles inside Canvas ────────────────────────────────────────────── */
.note-canvas table {
	border-collapse: collapse;
	width: 100%;
	margin: 12px 0;
	font-size: 0.95rem;
}

.note-canvas table td,
.note-canvas table th {
	border: 1px solid var(--border);
	padding: 8px 12px 8px 28px;
	min-width: 80px;
	vertical-align: top;
}

.note-canvas table th {
	background: var(--mustard-light);
	font-weight: 600;
}

.note-canvas table td ul,
.note-canvas table td ol,
.note-canvas table th ul,
.note-canvas table th ol {
	padding-left: 20px;
	margin: 0;
}

body.night-mode .note-canvas table th {
	background: #3A3000;
}

.note-canvas table tr:nth-child(even) td {
	background: rgba(0,0,0,0.02);
}

body.night-mode .note-canvas table tr:nth-child(even) td {
	background: rgba(255,255,255,0.02);
}

/* ── Save Indicator ────────────────────────────────────────────────────────── */
.save-indicator {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 16px;
	background: var(--surface);
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}

#save-status {
	font-size: 0.78rem;
	color: var(--text-secondary);
}

.note-counts {
	font-size: 0.75rem;
	color: var(--text-secondary);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
	opacity: 0.85;
}

/* ── Modals ────────────────────────────────────────────────────────────────── */
.modal {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.4);
}

.modal-box {
	position: relative;
	background: var(--surface);
	border-radius: var(--radius-lg);
	width: 100%;
	max-width: 460px;
	box-shadow: var(--shadow-md);
	z-index: 1;
	overflow: hidden;
}

.modal-box-sm {
	max-width: 340px;
}

/* ── Wider modal box for Pro, FAQ, and Privacy modals ─────────────────────── */
.modal-box-pro {
	max-width: 560px;
}

/* ── Landing Page / Pricing modal — widest modal ──────────────────────────── */
.modal-box-landing {
	max-width: 740px;
	max-height: 92vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.modal-box-landing .modal-body {
	flex: 1;
	overflow-y: auto;
	padding: 24px 28px 20px;
}

.modal-box-landing .modal-body::-webkit-scrollbar {
	width: 5px;
}

.modal-box-landing .modal-body::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px 16px;
	border-bottom: 1px solid var(--border);
}

.modal-header h2 {
	font-size: 1.15rem;
	font-weight: 700;
}

.modal-close {
	background: transparent;
	border: none;
	font-size: 1.5rem;
	cursor: pointer;
	color: var(--text-secondary);
	line-height: 1;
	padding: 2px 6px;
	border-radius: var(--radius-sm);
	transition: var(--transition);
}

.modal-close:hover {
	background: var(--border);
	color: var(--text-primary);
}

.modal-body {
	padding: 20px 24px;
}

/* ── Scrollable modal body ─────────────────────────────────────────────────── */
.modal-body-scroll {
	max-height: 70vh;
	overflow-y: auto;
}

.modal-body-scroll::-webkit-scrollbar {
	width: 5px;
}

.modal-body-scroll::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

.modal-footer {
	padding: 16px 24px;
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	border-top: 1px solid var(--border);
}

.settings-section h3 {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 14px;
	color: var(--text-primary);
}

.settings-divider {
	height: 1px;
	background: var(--border);
	margin: 20px 0;
}

/* ── About modal styles ────────────────────────────────────────────────────── */
.about-hero {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 18px;
}

.about-hero-icon {
	font-size: 2.4rem;
	flex-shrink: 0;
}

.about-product-name {
	font-size: 1.2rem;
	font-weight: 800;
	color: var(--text-primary);
	margin-bottom: 2px;
}

.about-tagline {
	font-size: 0.85rem;
	color: var(--text-secondary);
	font-style: italic;
}

.about-body-text {
	font-size: 0.88rem;
	color: var(--text-secondary);
	line-height: 1.7;
	margin-bottom: 10px;
}

.about-body-text strong {
	color: var(--text-primary);
}

.about-action-row {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 14px;
}

.about-footer-note {
	font-size: 0.78rem;
	color: var(--text-secondary);
	text-align: center;
	line-height: 1.6;
}

/* ── Pro comparison table ──────────────────────────────────────────────────── */
.pro-comparison-table {
	width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	overflow: hidden;
	margin-bottom: 20px;
	font-size: 0.86rem;
}

.pro-table-header {
	display: grid;
	grid-template-columns: 1fr 72px 72px;
	background: var(--mustard-light);
	border-bottom: 2px solid var(--mustard-dark);
}

body.night-mode .pro-table-header {
	background: #3A3000;
}

.pro-table-row {
	display: grid;
	grid-template-columns: 1fr 72px 72px;
	border-bottom: 1px solid var(--border);
}

.pro-table-row:last-child {
	border-bottom: none;
}

.pro-table-row-highlight {
	background: rgba(245, 200, 66, 0.06);
}

body.night-mode .pro-table-row-highlight {
	background: rgba(245, 200, 66, 0.04);
}

.pro-table-cell {
	padding: 9px 12px;
	display: flex;
	align-items: center;
	color: var(--text-primary);
}

.pro-table-feature-col {
	font-weight: 500;
	gap: 6px;
	flex-wrap: wrap;
}

.pro-table-free-col,
.pro-table-pro-col {
	justify-content: center;
	font-weight: 700;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-secondary);
}

.pro-table-header .pro-table-pro-col {
	background: var(--mustard);
	color: #2C2C2C;
	font-weight: 800;
}

body.night-mode .pro-table-header .pro-table-pro-col {
	background: var(--mustard-dark);
	color: #1A1A1A;
}

.pro-check {
	font-size: 1rem;
	line-height: 1;
}

.pro-check-yes {
	color: #2E7D32;
}

body.night-mode .pro-check-yes {
	color: #81C784;
}

.pro-check-no {
	color: var(--text-secondary);
	opacity: 0.45;
}

/* ── "Coming soon" tag ─────────────────────────────────────────────────────── */
.pro-coming-soon {
	display: inline-block;
	font-size: 0.62rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--pro-gold);
	background: rgba(184, 134, 11, 0.1);
	padding: 1px 5px;
	border-radius: 3px;
	white-space: nowrap;
}

body.night-mode .pro-coming-soon {
	color: var(--mustard);
	background: rgba(245, 200, 66, 0.12);
}

/* ── Pro modal guarantee strip ─────────────────────────────────────────────── */
.pro-modal-guarantee {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.82rem;
	color: var(--text-secondary);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 10px 14px;
	margin-bottom: 16px;
	line-height: 1.5;
}

.pro-modal-cta {
	font-size: 0.95rem;
	padding: 13px 20px;
}

.pro-modal-purchase-note {
	text-align: center;
	font-size: 0.82rem;
	color: var(--text-secondary);
	margin-top: 10px;
	line-height: 1.5;
}

.pro-modal-buy-link {
	color: var(--pro-gold);
	font-weight: 600;
	text-decoration: none;
	transition: color 0.15s ease;
}

.pro-modal-buy-link:hover {
	color: var(--mustard-dark);
	text-decoration: underline;
}

body.night-mode .pro-modal-buy-link {
	color: var(--mustard);
}

/* ── FAQ Modal styles ──────────────────────────────────────────────────────── */
.faq-item {
	padding-bottom: 18px;
	margin-bottom: 18px;
	border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.faq-question {
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 8px;
	line-height: 1.4;
}

.faq-answer {
	font-size: 0.86rem;
	color: var(--text-secondary);
	line-height: 1.7;
	margin-bottom: 6px;
}

.faq-answer:last-child {
	margin-bottom: 0;
}

.faq-answer strong {
	color: var(--text-primary);
}

.faq-list {
	font-size: 0.86rem;
	color: var(--text-secondary);
	line-height: 1.7;
	padding-left: 20px;
	margin-top: 4px;
}

.faq-list li {
	margin-bottom: 4px;
}

.faq-list li strong {
	color: var(--text-primary);
}

.faq-code {
	font-family: 'Courier New', Courier, monospace;
	font-size: 0.84em;
	background: var(--mustard-light);
	color: var(--text-primary);
	padding: 1px 5px;
	border-radius: 3px;
	border: 1px solid var(--border);
}

/* ── Privacy Policy Modal styles ───────────────────────────────────────────── */
.privacy-effective {
	font-size: 0.78rem;
	color: var(--text-secondary);
	margin-bottom: 16px;
	opacity: 0.8;
}

.privacy-section {
	margin-bottom: 18px;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--border);
}

.privacy-section:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.privacy-heading {
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 8px;
}

.privacy-body {
	font-size: 0.86rem;
	color: var(--text-secondary);
	line-height: 1.7;
	margin-bottom: 6px;
}

.privacy-body:last-child {
	margin-bottom: 0;
}

.privacy-body strong {
	color: var(--text-primary);
}

.privacy-list {
	font-size: 0.86rem;
	color: var(--text-secondary);
	line-height: 1.7;
	padding-left: 20px;
	margin-top: 6px;
	margin-bottom: 6px;
}

.privacy-list li {
	margin-bottom: 4px;
}

.privacy-list li strong {
	color: var(--text-primary);
}

/* ── Terms of Service Modal styles ─────────────────────────────────────────── */
/* Mirrors the privacy section styling for visual consistency.                 */
.tos-section {
	margin-bottom: 18px;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--border);
}

.tos-section:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.tos-heading {
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 8px;
}

.tos-body {
	font-size: 0.86rem;
	color: var(--text-secondary);
	line-height: 1.7;
	margin-bottom: 6px;
}

.tos-body:last-child {
	margin-bottom: 0;
}

.tos-body strong {
	color: var(--text-primary);
}

/* ── Landing Page Hero ─────────────────────────────────────────────────────── */
.landing-hero {
	text-align: center;
	padding: 8px 0 24px;
}

.landing-hero-icon {
	font-size: 2.8rem;
	display: block;
	margin-bottom: 10px;
}

.landing-hero-headline {
	font-size: 1.6rem;
	font-weight: 800;
	color: var(--text-primary);
	letter-spacing: -0.5px;
	margin-bottom: 4px;
}

.landing-hero-tagline {
	font-size: 0.95rem;
	color: var(--text-secondary);
	font-style: italic;
	margin-bottom: 20px;
}

/* ── Value proposition pills ───────────────────────────────────────────────── */
.landing-value-props {
	display: flex;
	align-items: stretch;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
}

.landing-value-pill {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	background: var(--mustard-light);
	border: 1px solid var(--mustard-dark);
	border-radius: var(--radius-md);
	padding: 10px 16px;
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--text-primary);
	min-width: 120px;
	text-align: center;
}

body.night-mode .landing-value-pill {
	background: #3A3000;
	border-color: #5A4800;
}

.landing-value-sub {
	font-size: 0.72rem;
	font-weight: 400;
	color: var(--text-secondary);
}

/* ── Pricing Table ─────────────────────────────────────────────────────────── */
.pricing-table {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 14px;
	margin-bottom: 28px;
}

/* ── Pricing Column ────────────────────────────────────────────────────────── */
.pricing-col {
	display: flex;
	flex-direction: column;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-md);
	overflow: hidden;
	position: relative;
	background: var(--surface);
	transition: box-shadow 0.2s ease;
}

.pricing-col:hover {
	box-shadow: var(--shadow-md);
}

/* ── Featured (Pro) column ─────────────────────────────────────────────────── */
.pricing-col-featured {
	border-color: var(--mustard-dark);
	box-shadow: 0 0 0 2px var(--mustard), var(--shadow-sm);
}

.pricing-col-featured:hover {
	box-shadow: 0 0 0 2px var(--mustard), var(--shadow-md);
}

/* ── Supporter column ──────────────────────────────────────────────────────── */
.pricing-col-supporter {
	border-color: #C3B1E1;
}

body.night-mode .pricing-col-supporter {
	border-color: #6B5A8A;
}

/* ── "Most Popular" badge on Pro column ────────────────────────────────────── */
.pricing-col-featured-badge {
	background: var(--mustard);
	color: #2C2C2C;
	font-size: 0.65rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	text-align: center;
	padding: 4px 0;
}

body.night-mode .pricing-col-featured-badge {
	background: var(--mustard-dark);
}

/* ── Column Header ─────────────────────────────────────────────────────────── */
.pricing-col-header {
	padding: 16px 16px 12px;
	border-bottom: 1px solid var(--border);
	background: var(--bg);
}

.pricing-tier-name {
	font-size: 0.9rem;
	font-weight: 800;
	color: var(--text-primary);
	margin-bottom: 4px;
	letter-spacing: -0.2px;
}

.pricing-tier-price {
	font-size: 1.65rem;
	font-weight: 800;
	color: var(--text-primary);
	letter-spacing: -1px;
	line-height: 1;
	margin-bottom: 4px;
}

.pricing-tier-desc {
	font-size: 0.72rem;
	color: var(--text-secondary);
	line-height: 1.4;
}

/* ── Feature List ──────────────────────────────────────────────────────────── */
.pricing-feature-list {
	list-style: none;
	padding: 12px 16px;
	flex: 1;
}

.pricing-feature-item {
	font-size: 0.8rem;
	color: var(--text-secondary);
	padding: 4px 0 4px 20px;
	position: relative;
	line-height: 1.45;
}

.pricing-feature-item::before {
	position: absolute;
	left: 0;
	top: 4px;
	font-size: 0.8rem;
	line-height: 1.45;
}

.pricing-feature-yes {
	color: var(--text-primary);
}

.pricing-feature-yes::before {
	content: '✓';
	color: #2E7D32;
	font-weight: 700;
}

body.night-mode .pricing-feature-yes::before {
	color: #81C784;
}

.pricing-feature-no {
	opacity: 0.45;
}

.pricing-feature-no::before {
	content: '—';
	color: var(--text-secondary);
}

.pricing-feature-soon {
	color: var(--text-secondary);
}

.pricing-feature-soon::before {
	content: '◷';
	color: var(--pro-gold);
}

body.night-mode .pricing-feature-soon::before {
	color: var(--mustard);
}

/* ── Donation Disclaimer ───────────────────────────────────────────────────── */
.pricing-donation-disclaimer {
	margin: 0 12px 12px;
	padding: 10px 12px;
	background: rgba(195, 177, 225, 0.15);
	border: 1px solid #C3B1E1;
	border-radius: var(--radius-sm);
	font-size: 0.74rem;
	color: var(--text-secondary);
	line-height: 1.55;
}

.pricing-donation-disclaimer strong {
	color: var(--text-primary);
}

body.night-mode .pricing-donation-disclaimer {
	background: rgba(107, 90, 138, 0.18);
	border-color: #6B5A8A;
}

/* ── CTA Area ──────────────────────────────────────────────────────────────── */
.pricing-cta-area {
	padding: 12px 16px 16px;
	margin-top: auto;
}

.pricing-cta-btn {
	display: block;
	width: 100%;
	padding: 11px 16px;
	border-radius: var(--radius-sm);
	font-size: 0.88rem;
	font-family: var(--font);
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: var(--transition);
	border: none;
}

.pricing-cta-btn-pro {
	background: var(--mustard);
	color: #2C2C2C;
}

.pricing-cta-btn-pro:hover {
	background: var(--mustard-dark);
	color: #2C2C2C;
}

.pricing-cta-btn-supporter {
	background: linear-gradient(135deg, #C3B1E1 0%, #A7C7E7 50%, #A8D5B5 100%);
	color: #2C2C2C;
}

.pricing-cta-btn-supporter:hover {
	filter: brightness(0.92);
}

body.night-mode .pricing-cta-btn-supporter {
	color: #1A1A1A;
}

.pricing-current-plan {
	text-align: center;
	font-size: 0.78rem;
	color: var(--text-secondary);
	padding: 6px 0;
	font-style: italic;
}

.pricing-cta-note {
	text-align: center;
	font-size: 0.7rem;
	color: var(--text-secondary);
	margin-top: 6px;
	line-height: 1.4;
}

/* ── License Key Section inside pricing modal ─────────────────────────────── */
.pricing-license-section {
	background: var(--bg);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-md);
	padding: 18px 20px;
	margin-bottom: 20px;
}

.pricing-license-heading {
	font-size: 0.88rem;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 12px;
}

.pricing-license-row {
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

.pricing-license-input {
	flex: 1;
	min-width: 0;
	padding: 10px 12px;
	border: 2px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.9rem;
	font-family: var(--font);
	background: var(--surface);
	color: var(--text-primary);
	transition: var(--transition);
	outline: none;
	letter-spacing: 0.03em;
}

.pricing-license-input:focus {
	border-color: var(--mustard);
}

.pricing-license-input::placeholder {
	color: var(--text-secondary);
	letter-spacing: normal;
}

.pricing-activate-btn {
	width: auto;
	margin-top: 0;
	padding: 10px 20px;
	white-space: nowrap;
	flex-shrink: 0;
}

/* ── Compliance Footer inside pricing modal ────────────────────────────────── */
.modal-compliance-footer {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
	padding: 14px 0 4px;
	border-top: 1px solid var(--border);
	font-size: 0.76rem;
	color: var(--text-secondary);
}

.compliance-link {
	color: var(--text-secondary);
	text-decoration: none;
	font-weight: 500;
	transition: color 0.15s ease;
	cursor: pointer;
}

.compliance-link:hover {
	color: var(--text-primary);
	text-decoration: underline;
}

.compliance-sep {
	opacity: 0.4;
	user-select: none;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: #2C2C2C;
	color: #fff;
	padding: 12px 24px;
	border-radius: var(--radius-md);
	font-size: 0.88rem;
	font-weight: 500;
	z-index: 300;
	box-shadow: var(--shadow-md);
	transition: opacity 0.3s ease;
	white-space: nowrap;
	display: flex;
	align-items: center;
	gap: 14px;
}

.toast.success {
	background: #2E7D32;
}

.toast.error {
	background: var(--danger-dark);
}

.toast.update {
	background: #2C2C2C;
}

.toast-action-btn {
	background: var(--mustard);
	color: #2C2C2C;
	border: none;
	border-radius: var(--radius-sm);
	padding: 5px 12px;
	font-size: 0.82rem;
	font-weight: 700;
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
	transition: var(--transition);
}

.toast-action-btn:hover {
	background: var(--mustard-dark);
}

/* ── QR Modal ──────────────────────────────────────────────────────────────── */
.qr-instructions {
	font-size: 0.88rem;
	color: var(--text-secondary);
	line-height: 1.6;
	margin-bottom: 18px;
}

.qr-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 24px 0;
	font-size: 0.9rem;
	color: var(--text-secondary);
}

.qr-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid var(--border);
	border-top-color: var(--mustard-dark);
	border-radius: 50%;
	animation: qr-spin 0.8s linear infinite;
	flex-shrink: 0;
}

@keyframes qr-spin {
	to { transform: rotate(360deg); }
}

.qr-result {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	padding: 8px 0;
}

.qr-image {
	width: 250px;
	height: 250px;
	border-radius: var(--radius-md);
	border: 3px solid var(--border);
	display: block;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
}

.qr-token-text {
	font-family: 'Courier New', Courier, monospace;
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--text-primary);
	letter-spacing: 0.08em;
	background: var(--mustard-light);
	padding: 8px 16px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	word-break: break-all;
	text-align: center;
}

/* ── Triplet token display ─────────────────────────────────────────────────── */
.qr-triplet-text {
	font-family: 'Courier New', Courier, monospace;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--text-primary);
	letter-spacing: 0.06em;
	background: var(--mustard-light);
	padding: 10px 18px;
	border-radius: var(--radius-sm);
	border: 2px solid var(--mustard-dark);
	word-break: break-all;
	text-align: center;
	margin-top: 4px;
}

.qr-triplet-label {
	font-size: 0.75rem;
	color: var(--text-secondary);
	text-align: center;
	margin-top: 2px;
}

.qr-expire-note {
	font-size: 0.78rem;
	color: var(--text-secondary);
	text-align: center;
}

/* ── Token input row ───────────────────────────────────────────────────────── */
.token-input-row {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 14px;
}

.token-word-input {
	flex: 1;
	min-width: 0;
	padding: 11px 10px;
	border: 2px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: 'Courier New', Courier, monospace;
	background: var(--bg);
	color: var(--text-primary);
	text-align: center;
	text-transform: lowercase;
	transition: var(--transition);
	outline: none;
	letter-spacing: 0.04em;
}

.token-word-input:focus {
	border-color: var(--mustard);
	background: var(--surface);
}

.token-word-input::placeholder {
	color: var(--text-secondary);
	letter-spacing: normal;
}

.token-hyphen {
	font-size: 1.3rem;
	font-weight: 700;
	color: var(--text-secondary);
	flex-shrink: 0;
	line-height: 1;
	user-select: none;
}

#qr-token-input {
	width: 100%;
	padding: 12px 14px;
	border: 2px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: 'Courier New', Courier, monospace;
	background: var(--bg);
	color: var(--text-primary);
	transition: var(--transition);
	outline: none;
	letter-spacing: 0.05em;
}

#qr-token-input:focus {
	border-color: var(--mustard);
	background: var(--surface);
}

#qr-modal .modal-body {
	max-height: 75vh;
	overflow-y: auto;
}

/* ── Injected modal fast-render: opacity gate ──────────────────────────────── */
/* Applied by openInjectedModal() on frame 1 so the browser can parse and lay
   out the DOM invisibly. Removed on frame 2 so the modal appears at full
   opacity with zero perceived delay. The transition gives a subtle fade-in
   rather than an abrupt pop — 120 ms is fast enough not to feel sluggish. */
.modal-injecting {
	opacity: 0;
	pointer-events: none;
}

.modal-injecting .modal-box {
	transform: translateY(6px);
}

.modal-revealing .modal-box {
	transform: translateY(0);
	transition: transform 0.12s ease;
}

/* ── Responsive — portrait mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {

	/* ── Standard modal boxes: scrollable and height-constrained ─────────────
	   On small screens, modal content can exceed the viewport height. Setting
	   max-height + overflow-y: auto on .modal-box makes all standard modals
	   (license, settings, about, upgrade nudge, QR, confirm, FAQ, privacy, ToS)
	   independently scrollable without any content being permanently clipped.
	   The .modal-box-landing variant manages its own internal scroll via
	   .modal-body and must be excluded here to avoid double scroll bars. */
	.modal-box:not(.modal-box-landing) {
		max-height: 90vh;
		overflow-y: auto;
	}

	/* ── Sidebar: fully scrollable on mobile ─────────────────────────────────
	   The entire sidebar is a scrollable container so the .sidebar-footer
	   (containing the Upgrade link) is always reachable by scrolling.
	   padding-bottom uses max() to take the larger of the iOS safe-area inset
	   and 72px — 72px is generous enough to clear any Android system nav bar
	   configuration (3-button, 2-button, or full gesture). On iOS the safe-area
	   inset will typically win on newer devices; on Android the 72px fallback
	   wins because env(safe-area-inset-bottom) is 0 in most Android browsers. */
	.sidebar {
		position: fixed;
		top: var(--nav-height);
		left: 0;
		bottom: 0;
		transform: translateX(-100%);
		width: 85%;
		max-width: 300px;
		transition: transform 0.3s ease;
		overflow-y: auto;
		overflow-x: hidden;
		padding-bottom: max(env(safe-area-inset-bottom, 0px), 72px);
	}

	.sidebar.open {
		transform: translateX(0);
		width: 85%;
	}

	.sidebar.collapsed {
		width: 85%;
		border-right: 1px solid var(--border);
	}

	/* On mobile the sidebar itself scrolls, so .sidebar-notes no longer needs
	   to be an independent scroll container. It sizes to its content instead,
	   allowing the flex column to flow naturally down to the footer. */
	.sidebar-notes {
		flex: none;
		overflow-y: visible;
		min-height: 80px;
	}

	.sidebar-footer {
		flex-shrink: 0;
	}

	.sidebar-overlay.active {
		display: block;
	}

	.editor-toolbar {
		padding: 6px 8px;
		gap: 2px;
	}

	.toolbar-divider {
		display: none;
	}

	.note-canvas {
		padding: 20px 18px;
	}

	.modal-box {
		max-width: 100%;
	}

	.modal-box-pro {
		max-width: 100%;
	}

	/* Landing modal takes full width and height on mobile */
	.modal-box-landing {
		max-width: 100%;
		max-height: 96vh;
		border-radius: var(--radius-md);
	}

	.modal-box-landing .modal-body {
		padding: 16px 16px 16px;
	}

	/* Stack pricing columns vertically on mobile */
	.pricing-table {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	/* Value props wrap and shrink on narrow screens */
	.landing-value-props {
		gap: 8px;
	}

	.landing-value-pill {
		min-width: 100px;
		padding: 8px 12px;
	}

	/* License row stacks on mobile */
	.pricing-license-row {
		flex-direction: column;
	}

	.pricing-activate-btn {
		width: 100%;
	}

	.color-picker-group {
		margin-top: 4px;
	}

	.table-picker {
		left: auto;
		right: 0;
	}

	.export-dropdown {
		right: 0;
		left: auto;
	}

	.toast {
		white-space: normal;
		max-width: calc(100vw - 32px);
		text-align: left;
	}

	.token-input-row {
		flex-wrap: nowrap;
	}

	.token-word-input {
		padding: 10px 6px;
		font-size: 0.88rem;
	}

	.note-actions {
		flex-shrink: 0;
	}

	#note-title-input {
		min-width: 0;
	}

	.about-action-row {
		flex-direction: column;
	}

	.about-action-row .btn {
		width: 100%;
	}

	.pro-table-header,
	.pro-table-row {
		grid-template-columns: 1fr 56px 56px;
	}

	.pro-table-cell {
		padding: 8px 8px;
		font-size: 0.82rem;
	}

	/* Compliance footer wraps gracefully */
	.modal-compliance-footer {
		gap: 6px;
	}
}

/* ── Responsive — landscape phones ────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
	.sidebar-header {
		padding: 8px 12px;
	}

	.sidebar-search {
		padding: 6px 12px;
	}

	.sidebar-footer {
		padding: 8px 12px;
	}

	.sidebar-notes {
		min-height: 80px;
	}

	.sidebar-app-footer {
		display: none;
	}
}