/* Flex column layout: header keeps its natural height, main flexes.
   `.window notes-window` out-specifies the display:block that BaseWindow
   injects for all window tags. */
.window notes-window,
notes-window {
	display: flex;
	flex-direction: column;
}

notes-window .notes-header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
	border-bottom: 1px solid var(--color-border);
}

notes-window .notes-header .header-button {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4px;
}

notes-window .notes-header .header-button svg {
	width: 18px;
	height: 18px;
}

notes-window .notes-download-container {
	position: relative;
}

notes-window .notes-download-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	background: var(--color-background);
	border: 1px solid var(--color-border);
	box-shadow: var(--shadow-popup);
	z-index: var(--z-menu);
	min-width: 180px;
	border-radius: 4px;
	overflow: hidden;
}

notes-window .notes-download-menu.visible {
	display: block;
}

notes-window .notes-download-item {
	padding: 8px 12px;
	cursor: pointer;
	font-size: 12px;
	white-space: nowrap;
}

notes-window .notes-download-item:hover {
	background: var(--color-background-hover);
}

notes-window .notes-print-container {
	position: relative;
}

notes-window .notes-print-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	background: var(--color-background);
	border: 1px solid var(--color-border);
	box-shadow: var(--shadow-popup);
	z-index: var(--z-menu);
	min-width: 180px;
	border-radius: 4px;
	overflow: hidden;
}

notes-window .notes-print-menu.visible {
	display: block;
}

notes-window .notes-print-item {
	padding: 8px 12px;
	cursor: pointer;
	font-size: 12px;
	white-space: nowrap;
}

notes-window .notes-print-item:hover {
	background: var(--color-background-hover);
}

notes-window .notes-print-option {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
	font-size: 12px;
	cursor: pointer;
	border-top: 1px solid var(--color-border);
}

notes-window .notes-print-option:hover {
	background: var(--color-background-hover);
}

notes-window .notes-search-container {
	flex: 1;
	min-width: 100px;
	position: relative;
}

notes-window .notes-search {
	width: 100%;
	box-sizing: border-box;
}

notes-window .notes-search-suggestions {
	display: none;
	position: absolute;
	inset: 100% 0 auto;
	background: var(--color-background);
	border: 1px solid var(--color-border);
	border-top: none;
	box-shadow: var(--shadow-popup);
	max-height: 200px;
	overflow-y: auto;
	z-index: var(--z-menu);
}

notes-window .notes-search-suggestions.visible {
	display: block;
}

notes-window .notes-suggestion-item {
	padding: 8px 10px;
	cursor: pointer;
	font-size: 12px;
	border-bottom: 1px solid var(--color-border);
}

notes-window .notes-suggestion-item:last-child {
	border-bottom: none;
}

notes-window .notes-suggestion-item:hover {
	background: var(--color-background-hover);
}

notes-window .notes-suggestion-item.selected {
	background: var(--color-primary);
	color: var(--color-background);
}

notes-window .notes-suggestion-title {
	font-weight: 600;
	margin-bottom: 2px;
}

notes-window .notes-suggestion-preview {
	font-size: 11px;
	opacity: 0.8;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

notes-window .notes-main {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	overflow: hidden;
	position: relative;
}

notes-window .notes-sidebar {
	width: 250px;
	min-width: 200px;
	max-width: 45%;
	display: flex;
	flex-direction: column;
	border-right: 1px solid var(--color-border);
	background: var(--color-background-alt);
	transition: width 0.2s ease, min-width 0.2s ease, opacity 0.2s ease;
}

notes-window .notes-sidebar.hidden {
	width: 0;
	min-width: 0;
	overflow: hidden;
	opacity: 0;
	border-right: none;
}

notes-window .notes-sidebar-header {
	display: flex;
	gap: 6px;
	padding: 8px;
	border-bottom: 1px solid var(--color-border);
}

notes-window .notes-sidebar-header select {
	flex: 1;
	min-width: 0;
	border: solid 1px var(--color-border);
	padding: 6px 22px 6px 8px;
	background: var(--color-background) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 8px center;
	color: var(--color-text);
	font-size: 12px;
	appearance: none;
	height: 30px;
	border-radius: 4px;
}

notes-window .notes-list {
	flex: 1;
	overflow-y: auto;
	padding: 4px;
}

notes-window .notes-list-item {
	position: relative;
	padding: 10px;
	cursor: pointer;
	border-radius: 4px;
	margin-bottom: 4px;
	background: var(--color-background);
	border: 1px solid transparent;
}

notes-window .notes-list-item:hover {
	background: var(--color-background-hover);
}

notes-window .notes-list-item.selected {
	background: var(--color-highlight);
	border-color: var(--color-primary);
}

notes-window .notes-list-item-title {
	font-weight: 600;
	font-size: var(--font-size-sm, 13px);
	margin-bottom: 4px;
	padding-right: 24px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

notes-window .notes-pin-btn {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	border-radius: 4px;
	padding: 0;
	color: var(--color-text-muted);
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s ease;
}

notes-window .notes-pin-btn svg {
	width: 13px;
	height: 13px;
}

notes-window .notes-list-item:hover .notes-pin-btn,
notes-window .notes-list-item.pinned .notes-pin-btn {
	opacity: 1;
}

notes-window .notes-pin-btn:hover {
	background: var(--color-background-active);
}

notes-window .notes-list-item.pinned .notes-pin-btn {
	color: var(--color-primary);
}

notes-window .notes-list-item-meta {
	font-size: 11px;
	color: var(--color-text-muted);
	display: flex;
	gap: 8px;
	align-items: center;
}

notes-window .notes-list-item-preview {
	font-size: 12px;
	color: var(--color-text-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-top: 4px;
}

notes-window .notes-list-item-badge {
	background: var(--color-primary);
	color: var(--color-background);
	padding: 2px 6px;
	border-radius: 10px;
	font-size: 10px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 120px;
}

notes-window .notes-editor-container {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

notes-window .notes-editor-container.hidden {
	display: none;
}

notes-window .notes-editor-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px;
	border-bottom: 1px solid var(--color-border);
}

notes-window .notes-title-input {
	flex: 1;
	min-width: 0;
	font-size: 16px;
	font-weight: 600;
	border: none;
	background: transparent;
	padding: 4px;
}

notes-window .notes-title-input:focus-visible {
	outline: none;
	background: var(--color-background);
}

notes-window .notes-reference-badge {
	background: var(--color-primary);
	color: var(--color-background);
	padding: 4px 10px;
	border-radius: 12px;
	font-size: 12px;
	display: none;
}

notes-window .notes-reference-badge.visible {
	display: inline-block;
}

notes-window .notes-unlink-btn {
	display: none;
	background: none;
	border: none;
	font-size: 16px;
	cursor: pointer;
	color: var(--color-text-muted);
	padding: 0 4px;
}

notes-window .notes-unlink-btn.visible {
	display: inline-block;
}

notes-window .notes-unlink-btn:hover {
	color: var(--color-error);
}

notes-window .notes-pin-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	background: none;
	border: none;
	border-radius: 4px;
	padding: 0;
	color: var(--color-text-muted);
	cursor: pointer;
}

notes-window .notes-pin-toggle svg {
	width: 14px;
	height: 14px;
}

notes-window .notes-pin-toggle:hover {
	background: var(--color-background-hover);
}

notes-window .notes-pin-toggle.active {
	color: var(--color-primary);
}

notes-window .notes-delete-btn {
	font-size: 12px;
	background: transparent;
	color: var(--color-error);
	border: 1px solid var(--color-error);
	padding: 4px 8px;
	border-radius: 4px;
	cursor: pointer;
}

notes-window .notes-delete-btn:hover {
	background: var(--color-error);
	color: var(--color-background);
}

notes-window .notes-richtext-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 8px;
	border-bottom: 1px solid var(--color-border);
	background: var(--color-background-alt);
}

notes-window .notes-richtext-toolbar button {
	width: 28px;
	height: 28px;
	border: 1px solid var(--color-border);
	background: var(--color-background-alt);
	color: var(--color-text);
	cursor: pointer;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
}

notes-window .notes-richtext-toolbar button:hover {
	background: var(--color-background-active);
}

notes-window .toolbar-separator {
	width: 1px;
	background: var(--color-border);
	margin: 0 4px;
}

notes-window .notes-editor {
	flex: 1;
	padding: 16px;
	overflow-y: auto;
	outline: none;
	line-height: 1.6;
}

notes-window .notes-editor:empty:before {
	content: attr(data-placeholder);
	color: var(--color-text-muted);
}

notes-window .notes-editor h2 {
	margin: 0.5em 0;
}

notes-window .notes-editor ul,
notes-window .notes-editor ol {
	margin: 0.5em 0;
	padding-left: 1.5em;
}

notes-window .notes-detected-refs {
	display: none;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-top: 1px solid var(--color-border);
	background: var(--color-background-alt);
}

notes-window .notes-detected-refs.visible {
	display: flex;
}

notes-window .notes-detected-refs-label {
	font-size: 11px;
	color: var(--color-text-muted);
}

notes-window .notes-ref-chip {
	background: transparent;
	border: 1px solid var(--color-primary);
	color: var(--color-primary);
	border-radius: 999px;
	padding: 2px 10px;
	font-size: 11px;
	cursor: pointer;
	white-space: nowrap;
}

notes-window .notes-ref-chip:hover {
	background: var(--color-highlight);
}

notes-window .notes-editor-footer {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 8px;
	border-top: 1px solid var(--color-border);
	font-size: 11px;
	color: var(--color-text-muted);
}

notes-window .notes-empty-state {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 16px;
	color: var(--color-text-muted);
}

notes-window .notes-empty-state.hidden {
	display: none;
}

notes-window .notes-storage-warning {
	margin-top: 16px;
	padding: 8px 12px;
	background: var(--color-highlight);
	border: 1px solid var(--color-highlight);
	border-radius: 4px;
	font-size: 12px;
	color: var(--color-text);
	max-width: 300px;
}

notes-window .notes-empty-list {
	padding: 20px;
	text-align: center;
	font-size: 12px;
	color: var(--color-text-muted);
}

/* Narrow windows (< 480px, toggled by size()): the sidebar overlays the
   editor instead of squeezing it. */
notes-window.notes-narrow .notes-sidebar {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 75%;
	min-width: 0;
	max-width: 300px;
	z-index: var(--z-panel-above);
	box-shadow: var(--shadow-lg);
}

notes-window.notes-narrow .notes-sidebar.hidden {
	width: 0;
	box-shadow: none;
}

/* Delete-confirm dialog (rendered inside a global InfoWindow popover,
   outside the notes-window subtree). */
.info-window .notes-confirm {
	padding: 8px 4px 4px;
	min-width: 220px;
}

.info-window .notes-confirm-message {
	margin: 0 0 12px;
}

.info-window .notes-confirm-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

.info-window .notes-confirm-btn {
	padding: 6px 14px;
	border-radius: 4px;
	font-size: 13px;
	cursor: pointer;
	border: 1px solid var(--color-border);
	background: var(--color-background);
	color: var(--color-text);
}

.info-window .notes-confirm-btn:hover {
	background: var(--color-background-hover);
}

.info-window .notes-confirm-ok {
	border-color: var(--color-error);
	color: var(--color-error);
}

.info-window .notes-confirm-ok:hover {
	background: var(--color-error);
	color: var(--color-background);
}
