.qtp-app {
	--qtp-accent: #c1502e;
	--qtp-accent-dark: #a8402a;
	--qtp-active: #2e6da4;
	--qtp-sidebar-bg: #eef1f4;
	--qtp-border: #dde2e7;
	--qtp-text: #2b2b2b;
	--qtp-height: 85vh;

	display: flex;
	height: var(--qtp-height);
	min-height: 420px;
	border: 1px solid var(--qtp-border);
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--qtp-text);
	box-sizing: border-box;
}
.qtp-app * { box-sizing: border-box; }

/* Sidebar */
.qtp-sidebar { width: 104px; flex-shrink: 0; background: var(--qtp-sidebar-bg); border-right: 1px solid var(--qtp-border); overflow-y: auto; }
.qtp-sidebar-list { display: flex; flex-direction: column; }
.qtp-page-item {
	display: flex; align-items: center; gap: 8px; width: 100%;
	border: none; background: transparent; cursor: pointer;
	padding: 9px 12px; font-size: 13px; color: #44505c; text-align: left;
	border-bottom: 1px solid rgba(0, 0, 0, 0.045);
}
.qtp-page-item:hover { background: rgba(0, 0, 0, 0.05); }
.qtp-page-circle {
	width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
	background: #fff; border: 1px solid var(--qtp-border);
	display: flex; align-items: center; justify-content: center;
	font-size: 11px; font-weight: 700; color: #5a6a78;
}
.qtp-page-item.is-active { background: var(--qtp-active); color: #fff; }
.qtp-page-item.is-active .qtp-page-circle { background: #fff; border-color: #fff; color: var(--qtp-active); }

/* Main */
.qtp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }

.qtp-toolbar {
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
	padding: 9px 14px; border-bottom: 1px solid var(--qtp-border); background: #fafafa;
}
.qtp-tool-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.qtp-tool-group-actions { margin-left: auto; }
.qtp-mobile-tools-toggle { display: none; }

.qtp-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	border: 1px solid var(--qtp-border); background: #fff;
	border-radius: 7px; padding: 6px 10px; font-size: 14px; line-height: 1;
	cursor: pointer; color: #3c4753; min-width: 34px; min-height: 34px;
}
.qtp-btn:hover { background: #f3f4f6; }
.qtp-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.qtp-btn.is-active { background: var(--qtp-active); border-color: var(--qtp-active); color: #fff; }
.qtp-btn-primary { background: var(--qtp-accent); border-color: var(--qtp-accent); color: #fff; font-weight: 600; }
.qtp-btn-primary:hover { background: var(--qtp-accent-dark); }

.qtp-swatches { display: flex; align-items: center; gap: 5px; }
.qtp-swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.15); cursor: pointer; padding: 0; }
.qtp-color-picker { width: 30px; height: 28px; border: 1px solid var(--qtp-border); border-radius: 6px; padding: 0 2px; background: #fff; cursor: pointer; }
.qtp-brush-size { width: 100px; }

.qtp-page-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #5a6a78; }
.qtp-page-input { width: 56px; text-align: center; border: 1px solid var(--qtp-border); border-radius: 6px; padding: 5px 4px; font-size: 13px; }

/* Stage */
.qtp-canvas-stage {
	flex: 1; overflow: auto; position: relative;
	display: flex; justify-content: center; align-items: flex-start;
	padding: 18px; background: #f7f6f2;
	background-image: linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px);
	background-size: 100% 28px;
}
.qtp-canvas-wrap { position: relative; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); background: #fff; }
.qtp-canvas-page { display: block; }
.qtp-canvas-ink { position: absolute; top: 0; left: 0; touch-action: none; cursor: crosshair; }
.qtp-text-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.qtp-text-note {
	position: absolute; pointer-events: auto;
	min-width: 24px; padding: 2px 4px;
	font-family: inherit; outline: 1px dashed rgba(0,0,0,0.15);
	background: rgba(255,255,200,0.4); border-radius: 3px;
	white-space: pre-wrap; max-width: 60%;
}
.qtp-text-note:focus { outline: 2px solid var(--qtp-active); background: rgba(255,255,200,0.7); }

.qtp-stage-overlay {
	position: absolute; inset: 0;
	background: rgba(255, 255, 255, 0.7);
	display: flex; align-items: center; justify-content: center;
	font-size: 14px; color: #5a6a78;
}
.qtp-stage-overlay[hidden] { display: none; }

.qtp-status { min-height: 20px; margin: 0; padding: 4px 14px 8px; font-size: 13px; color: var(--qtp-accent-dark); text-align: center; }

.qtp-empty-state, .qtp-loading-state {
	width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: 12px; padding: 40px 20px; text-align: center; color: #5a6a78; font-size: 15px;
}
.qtp-empty-wrap { display: block; height: auto; min-height: 0; }

.qtp-spinner { width: 28px; height: 28px; border: 3px solid var(--qtp-border); border-top-color: var(--qtp-accent); border-radius: 50%; animation: qtp-spin 0.8s linear infinite; }
@keyframes qtp-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { .qtp-spinner { animation: none; } }

.qtp-app button:focus-visible, .qtp-app input:focus-visible { outline: 2px solid var(--qtp-active); outline-offset: 2px; }

/* Responsive */
@media (max-width: 900px) {
	.qtp-app { flex-direction: column; height: auto; min-height: 80vh; }
	.qtp-sidebar { width: 100%; height: 64px; border-right: none; border-bottom: 1px solid var(--qtp-border); }
	.qtp-sidebar-list { flex-direction: row; }
	.qtp-page-item { flex-direction: column; gap: 3px; padding: 8px 10px; border-bottom: none; border-right: 1px solid rgba(0, 0, 0, 0.045); }
	.qtp-page-label { font-size: 10px; }

	.qtp-mobile-tools-toggle { display: inline-flex; }
	.qtp-toolbar { padding: 8px; gap: 6px; }
	.qtp-tool-group-nav { order: 1; }
	.qtp-tool-group-actions { order: 2; margin-left: auto; }
	.qtp-tool-group-draw {
		order: 3; width: 100%;
		display: none;
		padding-top: 8px; border-top: 1px dashed var(--qtp-border);
	}
	.qtp-toolbar.is-open .qtp-tool-group-draw { display: flex; }
	.qtp-brush-size { width: 80px; }
}

@media (max-width: 480px) {
	.qtp-btn { padding: 8px 10px; }
	.qtp-canvas-stage { padding: 8px; }
	.qtp-page-input { width: 48px; }
	.qtp-tool-group-actions .qtp-download span { display: none; }
}

/* ---- v3 additions ---- */

/* Tool section labels */
.qtp-tool-sep-label {
	font-size: 10px; font-weight: 600; text-transform: uppercase;
	color: #9aa5b1; letter-spacing: 0.06em; padding: 0 2px;
	user-select: none;
}

/* Text controls */
.qtp-text-controls {
	display: inline-flex; align-items: center; gap: 6px;
}
.qtp-font-select {
	border: 1px solid var(--qtp-border); border-radius: 6px;
	padding: 5px 6px; font-size: 13px; background: #fff;
	color: var(--qtp-text); cursor: pointer; max-width: 140px;
}
.qtp-font-size-input {
	width: 52px; border: 1px solid var(--qtp-border); border-radius: 6px;
	padding: 5px 4px; font-size: 13px; text-align: center;
}

/* Draggable text notes */
.qtp-text-note {
	position: absolute; pointer-events: auto;
	background: rgba(255,255,210,0.88);
	border: 1.5px dashed #b8a000;
	border-radius: 6px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.13);
	min-width: 60px; max-width: 260px;
	cursor: grab;
	user-select: none;
	transition: box-shadow 0.1s;
}
.qtp-text-note:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.18); border-color: #8a6f00; }

/* Top control bar — hidden until the note is hovered */
.qtp-note-bar {
	display: flex; align-items: center; justify-content: flex-end; gap: 2px;
	padding: 2px 3px 1px;
	background: rgba(240,220,80,0.55);
	border-bottom: 1px solid rgba(180,150,0,0.25);
	border-radius: 4px 4px 0 0;
	cursor: grab;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s;
}
.qtp-text-note:hover .qtp-note-bar {
	opacity: 1;
	pointer-events: auto;
}
.qtp-note-size, .qtp-note-del {
	display: inline-flex; align-items: center; justify-content: center;
	width: 18px; height: 18px; border-radius: 4px; border: none;
	cursor: pointer; font-size: 13px; font-weight: 700; line-height: 1;
	padding: 0;
}
.qtp-note-size { background: rgba(255,255,255,0.6); color: #555; }
.qtp-note-size:hover { background: #fff; color: #222; }
.qtp-note-del { background: #e55; color: #fff; margin-left: 2px; font-size: 11px; }
.qtp-note-del:hover { background: #c00; }

/* Editable text inside the note */
.qtp-note-text {
	padding: 4px 7px 5px;
	outline: none; min-height: 1.4em;
	white-space: pre-wrap; word-break: break-word;
	cursor: text; user-select: text;
	line-height: 1.4;
}
.qtp-note-text:focus { background: rgba(255,255,240,0.6); }

/* Eraser tool buttons — show the SVG icon cleanly */
.qtp-tool-btn[data-tool="eraser"] svg,
.qtp-tool-btn[data-tool="eraser_soft"] svg {
	display: block; pointer-events: none;
}

/* Style group */
.qtp-tool-group-style {
	display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}

@media (max-width: 900px) {
	.qtp-tool-sep-label { display: none; }
	.qtp-font-select { max-width: 110px; }
}
@media (max-width: 480px) {
	.qtp-font-select { max-width: 90px; font-size: 12px; }
	.qtp-font-size-input { width: 42px; }
}
