/* Res Opera Mini Photo Editor — all rules are scoped to .ro-mpe */

.ro-mpe, .ro-mpe *, .ro-mpe *::before, .ro-mpe *::after { box-sizing: border-box; }

.ro-mpe {
	--ro-bg: #eef2f6;
	--ro-panel: #ffffff;
	--ro-panel-2: #f5f8fb;
	--ro-stage: #dfe6ed;
	--ro-text: #14202b;
	--ro-muted: #5b6b7a;
	--ro-line: #d6dee6;
	--ro-field: #ffffff;
	--ro-link: var(--ro-primary);
	--ro-on-primary: #ffffff;
	--ro-shadow: 0 1px 2px rgba(10, 30, 50, .06), 0 8px 24px rgba(10, 30, 50, .08);
	--ro-radius: 12px;

	position: relative;
	width: 100%;
	max-width: 1360px;
	margin: 0 auto 2rem;
	color: var(--ro-text);
	font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
.ro-mpe[data-theme="dark"] {
	--ro-bg: #0e151d;
	--ro-panel: #16202b;
	--ro-panel-2: #1b2733;
	--ro-stage: #0a1017;
	--ro-text: #e7eef5;
	--ro-muted: #93a4b5;
	--ro-line: #263543;
	--ro-field: #0f1821;
	--ro-link: var(--ro-accent);
	--ro-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

.ro-mpe button, .ro-mpe input, .ro-mpe select, .ro-mpe textarea { font: inherit; color: inherit; margin: 0; }
.ro-mpe [hidden] { display: none !important; }
.ro-mpe .ro-ico { width: 20px; height: 20px; flex: none; display: block; }
.ro-mpe :focus-visible { outline: 2px solid var(--ro-accent); outline-offset: 2px; }

/* ---------- Header ---------- */
.ro-mpe .ro-hero {
	display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
	padding: 22px 26px; margin: 0 0 14px; border-radius: var(--ro-radius); color: #fff;
	background: linear-gradient(115deg, var(--ro-primary) 0%, var(--ro-primary) 38%, var(--ro-accent) 130%);
	box-shadow: var(--ro-shadow);
}
.ro-mpe[data-theme="dark"] .ro-hero { background: linear-gradient(115deg, #0a3f70 0%, var(--ro-primary) 55%, var(--ro-accent) 150%); }
.ro-mpe .ro-hero__brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.ro-mpe .ro-hero__logo {
	flex: none; display: grid; place-items: center; width: 64px; height: 64px; padding: 8px;
	background: #fff; border-radius: 14px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.ro-mpe .ro-hero__logo img, .ro-mpe .ro-hero__logo svg { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
.ro-mpe .ro-hero__title { margin: 0; padding: 0; color: #fff; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.ro-mpe .ro-hero__sub { margin: 4px 0 0; color: #fff; font-size: 15px; font-weight: 500; opacity: .96; }
.ro-mpe .ro-hero__desc { margin: 8px 0 0; max-width: 62ch; color: #fff; opacity: .88; font-size: 13.5px; }
.ro-mpe .ro-hero__desc a { color: #fff; text-decoration: underline; }

.ro-mpe .ro-theme-toggle {
	flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
	color: #fff; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%;
	transition: background .15s;
}
.ro-mpe .ro-theme-toggle:hover { background: rgba(255, 255, 255, .28); }
.ro-mpe .ro-theme-toggle--float { margin: 0 0 10px auto; color: var(--ro-text); background: var(--ro-panel); border-color: var(--ro-line); }
.ro-mpe .ro-theme-toggle .ro-ico--moon { display: none; }
.ro-mpe[data-theme="dark"] .ro-theme-toggle .ro-ico--sun { display: none; }
.ro-mpe[data-theme="dark"] .ro-theme-toggle .ro-ico--moon { display: block; }

/* ---------- App frame ---------- */
.ro-mpe .ro-app {
	display: flex; flex-direction: column; position: relative;
	height: clamp(560px, 82vh, 820px);
	background: var(--ro-panel); border: 1px solid var(--ro-line); border-radius: var(--ro-radius);
	box-shadow: var(--ro-shadow); overflow: hidden;
}
.ro-mpe .ro-app:focus { outline: none; }

/* Top bar */
.ro-mpe .ro-topbar {
	display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
	padding: 8px 12px; background: var(--ro-panel-2); border-bottom: 1px solid var(--ro-line);
}
.ro-mpe .ro-group { display: flex; align-items: center; gap: 6px; }

.ro-mpe .ro-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	min-height: 36px; padding: 0 13px; cursor: pointer; font-weight: 600; font-size: 13.5px; line-height: 1;
	color: var(--ro-text); background: var(--ro-panel); border: 1px solid var(--ro-line); border-radius: 8px;
	text-decoration: none; transition: background .12s, border-color .12s, opacity .12s;
}
.ro-mpe .ro-btn:hover:not(:disabled) { border-color: var(--ro-link); }
.ro-mpe .ro-btn:disabled { opacity: .4; cursor: not-allowed; }
.ro-mpe .ro-btn.ro-icon { width: 36px; padding: 0; }
.ro-mpe .ro-btn.ro-primary { color: var(--ro-on-primary); background: var(--ro-primary); border-color: var(--ro-primary); }
.ro-mpe .ro-btn.ro-primary:hover:not(:disabled) { filter: brightness(1.12); border-color: var(--ro-primary); }
.ro-mpe .ro-btn.ro-accent { color: #06292b; background: var(--ro-accent); border-color: var(--ro-accent); }
.ro-mpe .ro-btn.ro-accent:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--ro-accent); }
.ro-mpe .ro-btn.ro-block { width: 100%; }

.ro-mpe .ro-zoomval { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ro-muted); font-size: 13px; }

.ro-mpe .ro-field, .ro-mpe select.ro-field, .ro-mpe textarea.ro-field, .ro-mpe input[type="number"].ro-field {
	width: 100%; min-height: 36px; padding: 6px 10px; color: var(--ro-text); background: var(--ro-field);
	border: 1px solid var(--ro-line); border-radius: 8px; box-shadow: none;
}
.ro-mpe textarea.ro-field { resize: vertical; min-height: 64px; line-height: 1.4; }
.ro-mpe .ro-save select.ro-field { width: auto; min-width: 74px; }
.ro-mpe .ro-q { display: inline-flex; align-items: center; gap: 6px; color: var(--ro-muted); font-size: 12.5px; }
.ro-mpe .ro-q input { width: 80px; }

/* Main grid */
.ro-mpe .ro-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 68px minmax(0, 1fr) 304px; }

/* Tool rail */
.ro-mpe .ro-tools {
	display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 6px; overflow-y: auto;
	background: var(--ro-panel-2); border-right: 1px solid var(--ro-line);
}
.ro-mpe .ro-tool {
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
	min-height: 54px; padding: 6px 2px; cursor: pointer; color: var(--ro-muted); background: transparent;
	border: 1px solid transparent; border-radius: 9px; font-size: 11.5px; font-weight: 600; line-height: 1.1;
}
.ro-mpe .ro-tool:hover { color: var(--ro-text); background: var(--ro-panel); }
.ro-mpe .ro-tool[aria-pressed="true"] { color: var(--ro-on-primary); background: var(--ro-primary); box-shadow: inset 0 -3px 0 var(--ro-accent); }
.ro-mpe[data-theme="dark"] .ro-tool[aria-pressed="true"] { background: #0f4a82; }

/* Stage */
.ro-mpe .ro-stage {
	position: relative; display: flex; min-width: 0; min-height: 0; overflow: auto; padding: 24px;
	background-color: var(--ro-stage);
	background-image: linear-gradient(45deg, rgba(128,148,168,.10) 25%, transparent 25%, transparent 75%, rgba(128,148,168,.10) 75%),
		linear-gradient(45deg, rgba(128,148,168,.10) 25%, transparent 25%, transparent 75%, rgba(128,148,168,.10) 75%);
	background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
.ro-mpe .ro-stage.is-over { outline: 3px dashed var(--ro-accent); outline-offset: -10px; }
.ro-mpe .ro-canvaswrap { position: relative; margin: auto; flex: none; line-height: 0; box-shadow: 0 4px 24px rgba(0, 0, 0, .35); }
.ro-mpe .ro-canvas { display: block; max-width: none; background: #fff; image-rendering: auto; }
.ro-mpe .ro-tool-draw .ro-canvas, .ro-mpe .ro-tool-retouch .ro-canvas { cursor: none; touch-action: none; }
.ro-mpe .ro-tool-text .ro-canvas, .ro-mpe .ro-tool-crop .ro-canvas { touch-action: none; }
.ro-mpe .ro-tool-text .ro-canvas { cursor: text; }
.ro-mpe .ro-cursor {
	position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; border-radius: 50%;
	border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .65); transform: translate(-50%, -50%); display: none;
}

/* Empty state */
.ro-mpe .ro-drop {
	margin: auto; width: min(460px, 100%); padding: 38px 28px; text-align: center; cursor: pointer;
	background: var(--ro-panel); border: 2px dashed var(--ro-line); border-radius: 16px; transition: border-color .15s;
}
.ro-mpe .ro-drop:hover, .ro-mpe .is-over .ro-drop { border-color: var(--ro-accent); }
.ro-mpe .ro-drop__ico { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; color: #fff; border-radius: 18px; background: linear-gradient(135deg, var(--ro-primary), var(--ro-accent)); }
.ro-mpe .ro-drop__ico .ro-ico { width: 32px; height: 32px; }
.ro-mpe .ro-drop h3 { margin: 0 0 6px; padding: 0; font-size: 18px; color: var(--ro-text); }
.ro-mpe .ro-drop p { margin: 0 0 16px; color: var(--ro-muted); }
.ro-mpe .ro-drop small { display: block; margin-top: 14px; color: var(--ro-muted); font-size: 12px; }

/* Panel */
.ro-mpe .ro-panel { min-height: 0; overflow-y: auto; padding: 16px 16px 20px; background: var(--ro-panel); border-left: 1px solid var(--ro-line); }
.ro-mpe .ro-panel h3 { margin: 0 0 12px; padding: 0; font-size: 15px; font-weight: 700; color: var(--ro-text); }
.ro-mpe .ro-panel h4 { margin: 20px 0 10px; padding: 12px 0 0; border-top: 1px solid var(--ro-line); font-size: 13px; font-weight: 700; color: var(--ro-text); }
.ro-mpe .ro-row { margin: 0 0 12px; }
.ro-mpe .ro-row > label, .ro-mpe .ro-lab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; font-size: 13px; font-weight: 600; color: var(--ro-text); }
.ro-mpe .ro-lab output { font-weight: 500; color: var(--ro-muted); font-variant-numeric: tabular-nums; }
.ro-mpe .ro-btns { display: flex; gap: 8px; margin-top: 14px; }
.ro-mpe .ro-btns .ro-btn { flex: 1; }
.ro-mpe .ro-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ro-mpe .ro-grid2 .ro-btn { padding: 0 8px; }
.ro-mpe .ro-note { margin: 12px 0 0; color: var(--ro-muted); font-size: 12.5px; }
.ro-mpe .ro-check { display: inline-flex; align-items: center; gap: 7px; margin-right: 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
.ro-mpe .ro-check input { width: 16px; height: 16px; accent-color: var(--ro-primary); }
.ro-mpe .ro-dims { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.ro-mpe .ro-dims span { color: var(--ro-muted); }

.ro-mpe input[type="range"] { width: 100%; height: 22px; margin: 0; background: transparent; accent-color: var(--ro-accent); cursor: pointer; }
.ro-mpe input[type="color"] { width: 44px; height: 36px; padding: 2px; background: var(--ro-field); border: 1px solid var(--ro-line); border-radius: 8px; cursor: pointer; }
.ro-mpe .ro-colorrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ro-mpe .ro-sw { width: 26px; height: 26px; padding: 0; cursor: pointer; border-radius: 50%; border: 2px solid var(--ro-panel); box-shadow: 0 0 0 1px var(--ro-line); }
.ro-mpe .ro-sw:hover { box-shadow: 0 0 0 2px var(--ro-link); }

/* Status + toast */
.ro-mpe .ro-status {
	display: flex; justify-content: space-between; gap: 12px; padding: 6px 14px; color: var(--ro-muted); font-size: 12.5px;
	background: var(--ro-panel-2); border-top: 1px solid var(--ro-line);
}
.ro-mpe .ro-status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ro-mpe .ro-toast {
	position: absolute; left: 50%; bottom: 44px; z-index: 10; max-width: calc(100% - 32px); padding: 10px 16px;
	color: #fff; background: #1d2b38; border-left: 4px solid var(--ro-accent); border-radius: 8px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .35); transform: translateX(-50%); font-weight: 500;
}
.ro-mpe .ro-toast.is-error { border-left-color: #ef5350; }

.ro-mpe .ro-credit { margin-top: 10px; text-align: center; font-size: 12.5px; color: var(--ro-muted); }
.ro-mpe .ro-credit a { color: var(--ro-link); text-decoration: none; font-weight: 600; }
.ro-mpe .ro-credit a:hover { text-decoration: underline; }
.ro-mpe .ro-noscript { padding: 20px; text-align: center; color: var(--ro-muted); }

/* ---------- Tablet / mobile ---------- */
@media (max-width: 960px) {
	.ro-mpe .ro-main { grid-template-columns: minmax(0, 1fr) 280px; grid-template-rows: minmax(0, 1fr) auto; }
	.ro-mpe .ro-tools { grid-column: 1 / -1; grid-row: 2; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid var(--ro-line); padding: 6px 8px; }
	.ro-mpe .ro-tool { flex: 1 0 64px; min-height: 52px; }
	.ro-mpe .ro-stage { grid-row: 1; grid-column: 1; }
	.ro-mpe .ro-panel { grid-row: 1; grid-column: 2; }
}
@media (max-width: 720px) {
	.ro-mpe .ro-hero { padding: 16px; }
	.ro-mpe .ro-hero__logo { width: 48px; height: 48px; padding: 6px; border-radius: 11px; }
	.ro-mpe .ro-hero__brand { gap: 12px; }
	.ro-mpe .ro-hero__title { font-size: 20px; }
	.ro-mpe .ro-hero__sub { font-size: 13.5px; }
	.ro-mpe .ro-hero__desc { font-size: 12.5px; }

	.ro-mpe .ro-app { height: auto; }
	.ro-mpe .ro-main { display: flex; flex-direction: column; }
	.ro-mpe .ro-stage { order: 1; height: 56vh; min-height: 300px; padding: 14px; flex: none; }
	.ro-mpe .ro-tools { order: 2; flex: none; }
	.ro-mpe .ro-panel { order: 3; flex: none; border-left: 0; border-top: 1px solid var(--ro-line); overflow: visible; }
	.ro-mpe .ro-topbar { padding: 8px; }
	.ro-mpe .ro-topbar .ro-btn span { display: none; }
	.ro-mpe .ro-topbar .ro-btn { padding: 0; width: 38px; min-height: 38px; }
	.ro-mpe .ro-topbar .ro-zoom { order: 3; width: 100%; justify-content: center; }
	.ro-mpe .ro-save { margin-left: auto; }
	.ro-mpe .ro-q { display: none; }
	.ro-mpe .ro-toast { bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
	.ro-mpe * { transition: none !important; }
}
