/* ── 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;
	--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;
}

html, body {
	height: 100%;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	overflow: hidden;
}

/* ── 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);
}

.msg.success {
	color: #2E7D32;
	background: #E8F5E9;
}

.msg.error {
	color: var(--danger-dark);
	background: #FDECEA;
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen {
	display: none;
	width: 100%;
	height: 100%;
}

.screen.active {
	display: flex;
}

/* ── Auth Screen ───────────────────────────────────────────────────────────── */
#auth-screen {
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--mustard-light) 0%, var(--mustard) 100%);
	padding: 20px;
	min-height: 100vh;
}

.auth-container {
	background: var(--surface);
	border-radius: var(--radius-lg);
	padding: 40px 36px;
	width: 100%;
	max-width: 400px;
	box-shadow: var(--shadow-md);
}

.auth-logo {
	text-align: center;
	margin-bottom: 32px;
}

.auth-logo h1 {
	font-size: 2.4rem;
	font-weight: 800;
	color: var(--mustard-dark);
	letter-spacing: -1px;
}

.auth-logo p {
	color: var(--text-secondary);
	font-size: 0.9rem;
	margin-top: 4px;
}

.auth-form {
	display: none;
}

.auth-form.active {
	display: block;
}

.auth-form h2 {
	font-size: 1.3rem;
	font-weight: 700;
	margin-bottom: 20px;
	color: var(--text-primary);
}

.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);
}

.auth-switch {
	margin-top: 16px;
	font-size: 0.88rem;
	color: var(--text-secondary);
	text-align: center;
}

.auth-switch span {
	color: var(--mustard-dark);
	font-weight: 600;
	cursor: pointer;
	text-decoration: underline;
}

/* ── 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: var(--text-primary);
	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);
}

.btn-logout {
	width: 100%;
	background: transparent;
	border: 2px solid var(--border);
	color: var(--text-secondary);
	font-size: 0.88rem;
	padding: 9px 16px;
}

.btn-logout:hover {
	border-color: var(--danger);
	color: 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);
}

/* ── App Screen ────────────────────────────────────────────────────────────── */
#app-screen {
	flex-direction: column;
	height: 100vh;
	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;
}

.nav-title {
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--text-primary);
	letter-spacing: -0.5px;
}

.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);
}

.nav-btn:hover {
	background: var(--mustard-dark);
}

.hamburger {
	display: block;
	width: 20px;
	height: 2px;
	background: var(--text-primary);
	margin: 3px 0;
	border-radius: 2px;
	transition: var(--transition);
}

/* ── 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;
	z-index: 90;
}

.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 {
	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: var(--text-primary);
	text-transform: uppercase;
	flex-shrink: 0;
}

#sidebar-username {
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 150px;
}

.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);
	outline: none;
	transition: var(--transition);
}

.sidebar-search input:focus {
	border-color: var(--mustard);
}

.sidebar-notes {
	flex: 1;
	overflow-y: auto;
	padding: 8px;
}

.sidebar-notes::-webkit-scrollbar {
	width: 4px;
}

.sidebar-notes::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

/* ── 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-title {
	font-weight: 600;
	font-size: 0.9rem;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 4px;
}

.note-item-preview {
	font-size: 0.78rem;
	color: var(--text-secondary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.note-item-date {
	font-size: 0.72rem;
	color: var(--text-secondary);
	margin-top: 6px;
}

.sidebar-footer {
	padding: 12px 16px;
	border-top: 1px solid var(--border);
}

/* ── 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;
}

.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);
}

#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);
	cursor: pointer;
	outline: none;
	height: 28px;
}

#font-size-select:focus {
	border-color: var(--mustard);
}

.tool-label {
	font-size: 0.8rem;
	color: var(--text-secondary);
	margin-right: 4px;
}

.color-options {
	display: flex;
	gap: 6px;
	align-items: center;
}

.color-dot {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid transparent;
	transition: var(--transition);
	flex-shrink: 0;
}

.color-dot:hover {
	transform: scale(1.2);
	border-color: var(--text-secondary);
}

.color-dot.active {
	border-color: var(--text-primary);
	transform: scale(1.2);
}

/* ── 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);
}

#note-title-input::placeholder {
	color: var(--text-secondary);
	font-weight: 400;
}

.note-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* ── Note Canvas ───────────────────────────────────────────────────────────── */
.note-canvas {
	flex: 1;
	padding: 20px 24px;
	overflow-y: auto;
	outline: none;
	font-size: 0.97rem;
	line-height: 1.7;
	color: var(--text-primary);
	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;
}

/* ── Save Indicator ────────────────────────────────────────────────────────── */
.save-indicator {
	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);
}

/* ── 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;
}

.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;
}

.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;
}

.settings-section .btn-primary {
	width: auto;
	padding: 10px 20px;
}

/* ── 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;
}

.toast.success {
	background: #2E7D32;
}

.toast.error {
	background: var(--danger-dark);
}

/* ── Mobile Cards View ─────────────────────────────────────────────────────── */
.mobile-cards-view {
	display: none;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
	.sidebar {
		position: fixed;
		top: var(--nav-height);
		left: 0;
		bottom: 0;
		transform: translateX(-100%);
		width: 85%;
		max-width: 300px;
	}

	.sidebar.open {
		transform: translateX(0);
	}

	.sidebar-overlay.active {
		display: block;
	}

	.editor-toolbar {
		padding: 6px 8px;
		gap: 2px;
	}

	.toolbar-divider {
		display: none;
	}

	.note-canvas {
		padding: 16px;
	}

	.modal-box {
		max-width: 100%;
	}

	.color-picker-group {
		margin-top: 4px;
	}
}

@media (max-width: 480px) {
	.auth-container {
		padding: 28px 22px;
	}

	.auth-logo h1 {
		font-size: 2rem;
	}
}