@font-face { font-family: "BVP"; src: url("vendor/fonts/BeVietnamPro-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "BVP"; src: url("vendor/fonts/BeVietnamPro-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
	/* Bản 3.x: nền không gian tối, kính mờ, màu nhấn theo công cụ (biến --ac, --ac2, --ac-on, --ac-rgb đặt ở cuối app.css theo data-mode). */
	--bg0: #05080f; --pnl: #0d1524; --pnl-h: #121c30;
	--glass: rgba(10, 16, 28, .74); --glass-2: rgba(16, 24, 40, .88);
	--line: rgba(150, 180, 230, .14); --line-2: rgba(150, 180, 230, .26);
	--tx: #eaf1fb; --mu: #9aa9c0; --mu2: #6b7b93;
	--ac: #4da3ff; --ac2: #8b7bff; --ac-on: #061426; --ac-rgb: 77, 163, 255;
	--ac-ink: color-mix(in srgb, var(--ac) 62%, #fff); --ac-soft: rgba(var(--ac-rgb), .13); --ac-line: rgba(var(--ac-rgb), .5);
	--bad: #ef6a70; --ok: #4fd1a0; --warn: #ffb84d;
	--r: 12px; --r-sm: 9px; --mbar: 58px;
	--ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: var(--tx); font: 14px/1.45 "BVP", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(var(--ac-rgb), .35); }
#app { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; isolation: isolate;
	background:
		radial-gradient(1000px 520px at 50% -10%, rgba(var(--ac-rgb), .17), transparent 70%),
		radial-gradient(760px 460px at 100% 105%, rgba(var(--ac-rgb), .08), transparent 70%),
		radial-gradient(1.1px 1.1px at 14% 26%, rgba(255, 255, 255, .6), transparent) 0 0 / 290px 230px,
		radial-gradient(1px 1px at 63% 71%, rgba(255, 255, 255, .45), transparent) 0 0 / 370px 310px,
		radial-gradient(1.4px 1.4px at 86% 18%, rgba(255, 255, 255, .5), transparent) 0 0 / 510px 420px,
		var(--bg0); }

/* ---- thanh trên (kính mờ) ---- */
.menubar { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); min-height: var(--mbar); background: var(--glass); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%); z-index: 7; flex: none; }
.menubar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(var(--ac-rgb), .55) 30%, rgba(var(--ac-rgb), .55) 70%, transparent); opacity: .55; }
.mb-l, .mb-r, .mb-c { display: flex; align-items: center; min-width: 0; }
.mb-l { gap: 2px; }
.mb-r { gap: 8px; justify-content: flex-end; }
.mb-c { gap: 10px; justify-content: center; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 14px 0 0; margin-right: 6px; border-right: 1px solid var(--line); height: 34px; }
.brand .mark { display: flex; filter: drop-shadow(0 4px 12px rgba(var(--ac-rgb), .45)); }
.brand svg { display: block; }
.wm { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.wm b { font-size: 10.5px; letter-spacing: .22em; color: var(--mu); font-weight: 700; }
.wm em { font-style: normal; font-size: 14px; font-weight: 700; color: var(--tx); white-space: nowrap; margin-top: 2px; }
.mbi { height: 34px; padding: 0 13px; border: 0; background: none; color: var(--mu); border-radius: var(--r-sm); cursor: pointer; font-size: 14px; white-space: nowrap; transition: background .15s, color .15s; }
.mbi:hover, .mbi[aria-expanded="true"] { background: rgba(255, 255, 255, .07); color: var(--tx); }
.fname { position: relative; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 15px; border-radius: 999px; background: rgba(255, 255, 255, .045); border: 1px solid var(--line); color: var(--tx); font-size: 13px; }
.fname:empty { display: none; }
.fname.dirty::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 10px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px var(--warn); vertical-align: 1px; }
.autosave { color: var(--mu2); font-size: 12px; white-space: nowrap; }

/* ---- nút ---- */
.btn, .tool { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid transparent; background: transparent; color: var(--tx); border-radius: 10px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease), box-shadow .2s; }
.btn { border-color: var(--line); background: rgba(255, 255, 255, .05); }
.btn:hover:not(:disabled), .tool:hover { background: rgba(255, 255, 255, .1); border-color: var(--line-2); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--ac), var(--ac2)); border-color: transparent; color: var(--ac-on); font-weight: 700; box-shadow: 0 8px 22px -8px rgba(var(--ac-rgb), .7), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08) saturate(1.05); box-shadow: 0 12px 28px -8px rgba(var(--ac-rgb), .85), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn.danger { color: #ffb4b6; border-color: rgba(239, 106, 112, .4); background: transparent; }
.btn.danger:hover:not(:disabled) { background: rgba(239, 106, 112, .14); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 52px; padding: 0 28px; font-size: 15.5px; border-radius: 14px; }
.tool { color: var(--mu); }
.tool:hover { color: var(--tx); }
#bRead[aria-pressed="true"] { border-color: var(--ac-line); color: var(--ac-ink); background: var(--ac-soft); }
#app.empty #bRead, #app.empty #bSave, #app.empty #bMore { opacity: .4; pointer-events: none; }
#app.empty .menubar .btn.primary { background: rgba(255, 255, 255, .08); color: var(--mu); box-shadow: none; }
.split { position: relative; display: inline-flex; }
.split #bSave { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 15px; }
.split .save-more { padding: 0 9px; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(0, 0, 0, .22); }

.ic { width: 18px; height: 18px; display: inline-block; background: currentColor; flex: none;
	-webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ic-open { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7v12a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-7l-2-3H5a2 2 0 0 0-2 2z'/%3E%3C/svg%3E"); }
.ic-plus { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.ic-save { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12m0 0 4-4m-4 4-4-4M5 21h14'/%3E%3C/svg%3E"); }
.ic-print { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M6 9V3h12v6M6 18H4a1 1 0 0 1-1-1v-6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1h-2'/%3E%3Crect x='6' y='14' width='12' height='7'/%3E%3C/svg%3E"); }
.ic-close { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E"); }
.ic-caret { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); }
.ic-key { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='6' width='19' height='12' rx='2'/%3E%3Cpath d='M6 10h.01M10 10h.01M14 10h.01M18 10h.01M7 14h10'/%3E%3C/svg%3E"); }
.ic-up { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 15 6-6 6 6'/%3E%3C/svg%3E"); }
.ic-down { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.ic-copy { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='8' y='8' width='12' height='12' rx='2'/%3E%3Cpath d='M4 16V6a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E"); }
.ic-eye { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.ic-eye-off { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.4 0 10 7 10 7a17 17 0 0 1-3.2 4M6.6 6.6C3.9 8.3 2 12 2 12s3.6 7 10 7a9.6 9.6 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2'/%3E%3C/svg%3E"); }
.ic-trash { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13'/%3E%3C/svg%3E"); }
.ic-grip { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01' stroke-width='3'/%3E%3C/svg%3E"); }
.ic-play-from { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 4.5v15'/%3E%3Cpath d='M9 4.5v15l11-7.5z' fill='black'/%3E%3C/svg%3E"); }
.ic-play { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 4.5v15l12-7.5z' fill='black'/%3E%3C/svg%3E"); }
.ic-presenter { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='4' width='12' height='9' rx='1.5'/%3E%3Cpath d='M17.5 6h4M17.5 10h4M2.5 17h19M8 13v4'/%3E%3C/svg%3E"); }
.ic-full { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H5a2 2 0 0 0-2 2v3'/%3E%3Cpath d='M21 8V5a2 2 0 0 0-2-2h-3'/%3E%3Cpath d='M3 16v3a2 2 0 0 0 2 2h3'/%3E%3Cpath d='M16 21h3a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E"); }
.ic-exitfull { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3v3a2 2 0 0 1-2 2H3'/%3E%3Cpath d='M21 8h-3a2 2 0 0 1-2-2V3'/%3E%3Cpath d='M3 16h3a2 2 0 0 1 2 2v3'/%3E%3Cpath d='M16 21v-3a2 2 0 0 1 2-2h3'/%3E%3C/svg%3E"); }


/* ---- vùng làm việc: khung LibreOffice như một cửa sổ nổi ---- */
.stage { flex: 1; min-height: 0; position: relative; z-index: 0; isolation: isolate; color: var(--tx); }

/* ---- màn hình đầu ---- */
.drop { position: absolute; inset: var(--mbar) 0 0 0; display: flex; align-items: center; justify-content: center; overflow: auto; overscroll-behavior: contain; padding: 24px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); z-index: 3; }
#app:not(.empty) .drop { display: none; }
.drop-in { max-width: 640px; width: 100%; margin: auto; padding: 8px 24px 28px; text-align: center; animation: rise .7s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.hero-art { position: relative; display: inline-block; width: 168px; height: 168px; margin-bottom: 10px; perspective: 700px; }
.hero-art svg { position: absolute; left: 50%; top: 50%; width: 118px; height: 118px; margin: -59px 0 0 -59px; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .5)); animation: float 6s ease-in-out infinite; }
.hero-art::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 1px solid rgba(var(--ac-rgb), .4); background: radial-gradient(circle at 50% 0, #fff 0 2.5px, rgba(var(--ac-rgb), .9) 3px, transparent 7px); box-shadow: 0 0 40px -6px rgba(var(--ac-rgb), .35), inset 0 0 40px -14px rgba(var(--ac-rgb), .3); animation: orbit 16s linear infinite; }
.hero-art::after { content: ""; position: absolute; inset: 22px -34px; border-radius: 50%; border: 1px solid var(--line); transform: rotate(-14deg); }
@keyframes orbit { from { transform: rotateX(72deg) rotateZ(0); } to { transform: rotateX(72deg) rotateZ(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(-3px); } 50% { transform: translateY(4px); } }
.drop-in h1 { margin: 6px 0 26px; font-size: 42px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; background: linear-gradient(180deg, #fff 30%, color-mix(in srgb, var(--ac) 45%, #b7c4da)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.btnrow { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 4px 0 2px; }
.drop::after { content: ""; position: absolute; inset: 18px; border: 2px dashed var(--ac); border-radius: 28px; background: var(--ac-soft); opacity: 0; pointer-events: none; transition: opacity .18s; }
#app.dragging .drop::after { opacity: 1; }
.restore { margin: 30px auto 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; background: var(--ac-soft); border: 1px solid var(--ac-line); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(8px); }
.restore p { margin: 0; flex-basis: 100%; color: var(--ac-ink); font-size: 13.5px; }

/* ---- menu thả xuống, hộp thoại, thông báo (kính mờ) ---- */
.dd, .modal, .toast, .help, .ime, #app.reading .rbar { background: var(--glass-2); backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%); border: 1px solid var(--line-2); }
.dd { position: fixed; z-index: 80; color: var(--tx); border-radius: 14px; box-shadow: 0 22px 56px rgba(0, 0, 0, .6); padding: 6px; min-width: 260px; max-height: calc(100vh - 60px); overflow: auto; animation: ddin .14s var(--ease); overscroll-behavior: contain; }
.dd button { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: none; border: 0; border-radius: 9px; padding: 9px 12px; color: inherit; cursor: pointer; white-space: nowrap; }
.dd button:hover:not(:disabled), .dd button:focus-visible { background: rgba(var(--ac-rgb), .16); outline: none; }
.dd button:disabled { opacity: .38; cursor: default; }
.dd .kb { margin-left: auto; padding-left: 24px; color: var(--mu2); font-size: 12px; }
.dd .mdiv { height: 1px; background: var(--line); margin: 6px 4px; }
@keyframes ddin { from { opacity: 0; transform: translateY(-5px) scale(.985); } to { opacity: 1; transform: none; } }
.mov { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 5, 10, .66); backdrop-filter: blur(4px); }
.modal { color: var(--tx); border-radius: 20px; max-width: 460px; width: 100%; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); overflow: hidden; animation: ddin .18s var(--ease); }
.modal h2 { margin: 0; padding: 18px 22px 4px; font-size: 17px; letter-spacing: -.01em; }
.modal .mb { padding: 8px 22px 18px; line-height: 1.55; color: var(--mu); }
.modal .mf { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .025); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; align-items: flex-start; gap: 11px; color: var(--tx); padding: 13px 20px 13px 16px; border-radius: 14px; box-shadow: 0 18px 48px rgba(0, 0, 0, .6); z-index: 95; max-width: min(560px, 92vw); font-size: 13.5px; animation: ddin .22s var(--ease); }
.toast::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 1px; background: var(--ok); -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); }
.toast.bad::before { background: var(--bad); --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4 2.5 20h19z'/%3E%3Cpath d='M12 10v5M12 18v.01'/%3E%3C/svg%3E"); }

/* ---- màn chờ tải ---- */
.busy { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; color: var(--mu); font-weight: 400; font-size: 14px; background: radial-gradient(700px 420px at 50% 42%, rgba(var(--ac-rgb), .16), transparent 70%), #04070d; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.busy::before { content: ""; width: 58px; height: 58px; border-radius: 50%; order: 0; background: conic-gradient(from 0deg, transparent 0 40%, var(--ac) 85%, var(--ac2)); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px)); animation: spin 1.05s linear infinite; filter: drop-shadow(0 0 14px rgba(var(--ac-rgb), .55)); }
#busyText { order: 2; letter-spacing: .02em; }
.busy-sub { order: 1; }
.busy .bar { order: 3; }
@keyframes spin { to { transform: rotate(360deg); } }
kbd { font: inherit; font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .05); color: var(--mu); white-space: nowrap; }

/* ---- hướng dẫn nhanh ---- */
.help { width: min(660px, 94vw); max-height: 86vh; padding: 0; border-radius: 20px; color: var(--tx); box-shadow: 0 34px 90px rgba(0, 0, 0, .65); }
.help::backdrop { background: rgba(3, 5, 10, .66); backdrop-filter: blur(4px); }
.help-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 22px; border-bottom: 1px solid var(--line); font-size: 15px; }
.help-b2 { padding: 6px 22px 20px; overflow: auto; max-height: calc(86vh - 60px); }
.help h2 { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ac-ink); margin: 18px 0 6px; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13.5px; }
.help dt { color: var(--mu); }
.help dd { margin: 0; }
.help p { color: var(--mu); font-size: 12.5px; margin: 8px 0 0; }

/* ---- toàn màn hình ---- */
.rbar { display: none; }
#app.reading .rbar { display: flex; align-items: center; gap: 2px; position: fixed; right: 18px; top: 16px; z-index: 60; padding: 5px; border-radius: 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, .55); transition: opacity .25s, transform .25s; }
#app.reading .rbar.idle { opacity: 0; pointer-events: none; transform: translateY(-8px); }
.rb { width: 38px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--tx); cursor: pointer; }
.rb:hover { background: rgba(255, 255, 255, .12); }
.rb .ic { width: 17px; height: 17px; }
#app.reading .menubar { display: none !important; }

/* ---- màn hình hẹp ---- */
@media (max-width: 1100px) { .btn .lbl-d, #bIme span, #bRead span { display: none; } #bIme, #bRead { padding: 0 11px; } .autosave { display: none; } }
@media (max-width: 860px) { .wm, .fname { display: none; } .menubar { grid-template-columns: auto 1fr auto; } }
@media (max-width: 640px) {
	.menubar { gap: 4px; padding-left: 8px; padding-right: 8px; }
	.mbi { padding: 0 9px; }
	.brand { padding-right: 8px; margin-right: 2px; }
	.btn span { display: none; }
	.btn.lg span { display: inline; }
	.btn.lg { padding: 0 22px; }
	.drop-in h1 { font-size: 32px; }
	.hero-art { width: 132px; height: 132px; } .hero-art svg { width: 92px; height: 92px; margin: -46px 0 0 -46px; }
}
@media (max-width: 420px) { .brand { display: none; } .drop-in h1 { font-size: 27px; margin-bottom: 18px; } .help dl { grid-template-columns: 1fr; gap: 2px 0; } .help dd { margin-bottom: 6px; } }
@media (max-height: 560px) { :root { --mbar: 48px; } .hero-art { display: none; } .drop-in h1 { font-size: 26px; margin-bottom: 14px; } }
@media (pointer: coarse) { .dd button { height: 46px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- in ---- */
#printArea { display: none; }
@media print {
	html, body, #app { height: auto; background: #fff; overflow: visible; }
	.menubar, .tabrow, .toast, .busy, .drop, .rbar, .help, .dd, .mov { display: none !important; }
	.host.off { display: none !important; }
	body.print-area #app, body.print-area .toast { display: none !important; }
	body.print-area #printArea { display: block; color: #000; background: #fff; font: 10pt/1.3 "BVP", system-ui, sans-serif; }
	.pr-sheet h1 { font-size: 12pt; margin: 0 0 6pt; }
	.pr-sheet table { border-collapse: collapse; }
	.pr-sheet td { border: .5pt solid #999; padding: 2pt 4pt; vertical-align: top; white-space: pre-wrap; }
}

/* ===== Trình chỉnh sửa ảnh: phủ giao diện VNISES lên miniPaint (selector có tiền tố #app / body[data-mode] để thắng CSS của lõi) ===== */

html:root { font-size: 10px; }
html body[data-mode] { padding: 0; font: 1.4rem/1.45 "BVP", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--tx); background: var(--bg0); }

/* Bảng màu của lõi -> bảng màu không gian của VNISES (đặt trên body để dùng được --ac) */
body[data-mode="img"] {
	--background: var(--bg0);
	--text-color: var(--tx); --text-color-muted: var(--mu); --text-color-red: #ff9ea2; --text-color-green: #7fe6c0; --text-color-blue: #a9b8ff;
	--link-color: var(--ac-ink);
	--section-background-color: transparent;
	--area-background-color: rgba(255, 255, 255, .05);
	--block-background-color: rgba(12, 19, 34, .78);
	--header-background-color: rgba(255, 255, 255, .045);
	--button-background-color: rgba(255, 255, 255, .06);
	--button-background-color-hover: rgba(var(--ac-rgb), .26);
	--button-background-color-active: rgba(var(--ac-rgb), .16);
	--button-shadow-color: rgba(0, 0, 0, .25);
	--button-text-color-active: var(--ac-ink);
	--button-border-radius: 9px;
	--button-toggle-background-color: rgba(255, 255, 255, .08);
	--button-toggle-background-color-hover: rgba(255, 255, 255, .12);
	--input-background-color: rgba(3, 7, 14, .72);
	--input-background-color-hover: rgba(255, 255, 255, .08);
	--input-text-color: var(--tx);
	--input-border-color: var(--line-2);
	--input-border-color-active: var(--ac);
	--input-border-radius: 8px;
	--input-group-border-color: var(--line);
	--background-color-active: rgba(var(--ac-rgb), .2);
	--background-color-hover: rgba(255, 255, 255, .09);
	--text-color-active: var(--ac-ink);
	--border-color: var(--line);
	--scrollbar-track-color: transparent;
	--scrollbar-thumb-color: rgba(150, 180, 230, .28);
	--menu-icons-filter: invert(1);
	--menu-icons-filter-active: invert(1);
	--mobile-menu-toggle-filter: invert(1);
	--menu-dropdown-background-color: var(--glass-2);
	--menu-dropdown-border-color: var(--line-2);
	--menu-dropdown-text-color: var(--tx);
	--menu-dropdown-text-muted-color: var(--mu2);
	--menu-dropdown-hover-background-color: rgba(var(--ac-rgb), .18);
	--menu-dropdown-hover-text-color: var(--tx);
	--menu-dropdown-divider-color: var(--line);
}

/* ---- thanh trên: bỏ làm mờ nền để menu của lõi (position: fixed) định vị đúng ---- */
#app .menubar { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(7, 11, 20, .96); }
#app .mb-l { gap: 0; }
#app .main_menu { position: static; display: block; z-index: 100; }
#app .main_menu > ul.menu_bar { height: 34px; padding: 0; background: none; gap: 1px; }
#app .main_menu > ul.menu_bar > li { overflow: visible; }
#app .main_menu > ul.menu_bar > li > a { white-space: nowrap; height: 34px; padding: 0 12px; font-size: 14px; color: var(--mu); border-radius: var(--r-sm); transition: background .15s, color .15s; }
#app .main_menu > ul.menu_bar > li > a:hover, #app .main_menu > ul.menu_bar > li > a[aria-expanded="true"] { background: rgba(255, 255, 255, .08); color: var(--tx); box-shadow: none; }
#app .main_menu > ul.menu_bar > li > a:focus-visible { outline: 2px solid var(--ac); outline-offset: -2px; box-shadow: none; }
#app .main_menu > ul.menu_dropdown { background: var(--glass-2); backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 22px 56px rgba(0, 0, 0, .6); padding: 6px; min-width: 240px; animation: ddin .14s var(--ease); }
#app .main_menu > ul.menu_dropdown > li > a { white-space: nowrap; height: 34px; line-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; color: var(--tx); }
#app .main_menu > ul.menu_dropdown > li > a:hover, #app .main_menu > ul.menu_dropdown > li > a[aria-expanded="true"], #app .main_menu > ul.menu_dropdown > li > a:focus { background: rgba(var(--ac-rgb), .18); color: var(--tx); box-shadow: none; outline: none; }
#app .main_menu > ul.menu_dropdown > li > hr { border: 0; height: 1px; background: var(--line); margin: 6px 4px; }
#app .main_menu > ul.menu_dropdown > li > a > .shortcut { color: var(--mu2); font-size: 12px; padding-left: 22px; }
#app .main_menu > ul.menu_dropdown > li > a[aria-haspopup="true"]::after { content: ""; width: 7px; height: 7px; right: 14px; border-top: 1.6px solid var(--mu); border-right: 1.6px solid var(--mu); transform: rotate(45deg); }

/* ---- vùng làm việc ---- */
#app .stage { overflow: hidden; }
#app .wrapper { position: absolute; inset: 0; top: 0; bottom: 0; padding: 12px; gap: 0; grid-template-columns: auto 1fr auto; column-gap: 12px; row-gap: 10px; background: transparent; }
#app .submenu { margin: 0; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); min-height: 48px; padding: 0 6px; overflow: hidden; }
#app .attributes { background: none; width: 100%; margin: 0 !important; padding: 7px 8px; min-height: 46px; border: 0; align-items: center; scrollbar-width: thin; }
#app .attributes .item { margin-right: 18px; }
#app .attributes .item > label { margin: 0 8px 0 0; color: var(--mu); font-size: 13px; }
#app .attributes input[type="number"] { width: 68px; }
#app .attributes input[type="color"] { border: 1px solid var(--line-2); border-radius: 8px; background: none; height: 30px; width: 42px; padding: 2px; }

#app .sidebar_left { margin: 0; padding: 6px; width: 54px; gap: 4px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); align-content: flex-start; max-height: 100%; scrollbar-width: none; }
#app .sidebar_left .item { height: 40px; width: 40px; margin: 0; border-radius: 11px; background: transparent; transition: background .15s, box-shadow .2s, transform .12s var(--ease); }
#app .sidebar_left .item::after { background-size: 21px 21px; opacity: .78; transition: opacity .15s; }
#app .sidebar_left .item:hover { background: rgba(255, 255, 255, .09); }
#app .sidebar_left .item:hover::after { opacity: 1; }
#app .sidebar_left .item.active { background: linear-gradient(135deg, rgba(var(--ac-rgb), .34), rgba(var(--ac-rgb), .12)); box-shadow: inset 0 0 0 1px var(--ac-line), 0 6px 18px -8px rgba(var(--ac-rgb), .8); }
#app .sidebar_left .item.active::after { opacity: 1; filter: invert(1) drop-shadow(0 0 6px rgba(var(--ac-rgb), .9)); }
#app .sidebar_left .text::after { background-size: 18px auto; }
#app .sidebar_left .gradient::after { filter: none; background-size: 20px 13px; }

#app .middle_area { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: radial-gradient(900px 500px at 50% 0, rgba(var(--ac-rgb), .07), transparent 70%), #080d17; }
#app .main_wrapper { background: transparent; }

#app .sidebar_right { margin: 0; width: 244px; gap: 10px; padding-right: 2px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(150, 180, 230, .28) transparent; }
#app .sidebar_right .block { margin: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--glass); box-shadow: none; overflow: hidden; flex: none; }
#app .sidebar_right .block.layers { flex: 1 0 auto; }
#app .block h2 { padding: 9px 14px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mu); background: rgba(255, 255, 255, .03); border-radius: 0; border-bottom: 1px solid var(--line); }
#app .block h2.toggle:before { border-color: transparent transparent var(--mu) transparent; top: 15px; right: 14px; }
#app .block h2.toggled:before { border-color: var(--mu) transparent transparent transparent; }
#app .block .content { padding: 10px 12px; }

/* ---- thành phần chung ---- */
#app input[type="text"], #app input[type="number"], #app select, #app textarea { font: inherit; font-size: 13px; padding: 5px 9px; background: var(--input-background-color); border: 1px solid var(--line-2); border-radius: 8px; color: var(--tx); transition: border-color .15s, box-shadow .15s; }
#app input[type="text"]:focus, #app input[type="number"]:focus, #app select:focus, #app textarea:focus { outline: none; border-color: var(--ac); box-shadow: 0 0 0 3px rgba(var(--ac-rgb), .2); }
#app select option { background: #0d1524; color: var(--tx); }
#app .wrapper button, #app .sidebar_right button { font: inherit; font-size: 13px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); border-radius: 9px; color: var(--tx); box-shadow: none; transition: background .15s, border-color .15s; }
#app .wrapper button:hover, #app .sidebar_right button:hover { background: rgba(var(--ac-rgb), .24); border-color: var(--ac-line); }
#app .wrapper button[aria-pressed="true"] { background: rgba(var(--ac-rgb), .2); border-color: var(--ac-line); color: var(--ac-ink); box-shadow: none; }
#app input[type="range"] { accent-color: var(--ac); }
#app .layers_list .item.active .layer_name { background: rgba(var(--ac-rgb), .2); border-color: var(--ac-line); color: var(--tx); }
#app .layers_list .layer_name { background: rgba(255, 255, 255, .045); border-color: var(--line); border-radius: 8px; height: 26px; padding: 3px 8px; }
#app .layer_add { border-radius: 8px; background: rgba(var(--ac-rgb), .2); border-color: var(--ac-line); color: var(--ac-ink); padding: 3px 12px; }
#app .layers_arrow { border-color: var(--line-2); border-radius: 8px; color: var(--tx); padding: 3px 9px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track-piece { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(150, 180, 230, .28); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(150, 180, 230, .45); background-clip: padding-box; border: 2px solid transparent; }

/* ---- hộp thoại của lõi ---- */
#popups:not(:empty) { position: fixed; inset: 0; z-index: 90; background: rgba(3, 5, 10, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
html body #popups .popup { background: var(--glass-2); backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%); border: 1px solid var(--line-2); border-radius: 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); color: var(--tx); font-size: 14px; padding: 5.2rem 0 6.4rem; max-width: 520px; animation: ddin .18s var(--ease); }
html body #popups .popup.wide { max-width: 860px; }
html body #popups .popup h2 { height: 5.2rem; line-height: 5.2rem; padding: 0 2.2rem; font-size: 1.7rem; letter-spacing: -.01em; background: transparent; border-bottom: 1px solid var(--line); cursor: default; }
html body #popups .popup .dialog_content { padding: 1.4rem 2.2rem; max-height: calc(80vh - 12rem); }
html body #popups .popup .buttons { height: 6.4rem; padding: 1.2rem 2.2rem; display: flex; align-items: center; justify-content: flex-end; gap: 8px; background: rgba(255, 255, 255, .025); border-top: 1px solid var(--line); line-height: 1; }
html body #popups .popup .buttons .button { margin: 0; min-width: 0; height: 36px; padding: 0 18px; border-radius: 10px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); color: var(--tx); font: inherit; font-size: 13.5px; cursor: pointer; }
html body #popups .popup .buttons .button:hover { background: rgba(255, 255, 255, .12); }
html body #popups .popup .buttons .button.focus, html body #popups .popup .buttons .button:first-child { background: linear-gradient(135deg, var(--ac), var(--ac2)); border-color: transparent; color: var(--ac-on); font-weight: 700; box-shadow: 0 8px 22px -8px rgba(var(--ac-rgb), .7), inset 0 1px 0 rgba(255, 255, 255, .35); order: 2; }
html body #popups .popup .buttons .button:first-child:hover { filter: brightness(1.08); }
html body #popups .popup .close { top: 1rem; right: 1.2rem; width: 32px; height: 32px; margin: 0; border-radius: 9px; font-size: 20px; line-height: 1; color: var(--mu); background: none; border: 0; }
html body #popups .popup .close:hover { background: rgba(255, 255, 255, .1); color: var(--tx); }
html body #popups .popup th { color: var(--mu); font-weight: 400; font-size: 13px; width: 130px; padding: 9px 10px 0 0; }
html body #popups .popup td, html body #popups .popup th { height: 34px; }
html body #popups .popup input[type="text"], html body #popups .popup input[type="number"], html body #popups .popup select, html body #popups .popup textarea { height: 34px; }
html body #popups .popup textarea { height: auto; }
html body #popups .popup label span, html body #popups .popup .checkbox label { color: var(--mu); }
html body #popups .popup .field_comment { opacity: .7; color: var(--mu); }
html body #popups .popup .range_value { color: var(--mu); }
/* nút chọn: viên tròn và ô tích theo màu nhấn */
#app input[type="radio"], #app input[type="checkbox"], html body #popups input[type="radio"], html body #popups input[type="checkbox"] { zoom: 1; transform: none; margin: 0 8px 0 0; width: 18px; height: 18px; appearance: none; -webkit-appearance: none; vertical-align: middle; background: rgba(3, 7, 14, .72); border: 1.5px solid var(--line-2); display: inline-grid; place-content: center; cursor: pointer; flex: none; transition: border-color .15s, background .15s; }
#app input[type="radio"], html body #popups input[type="radio"] { border-radius: 50%; }
#app input[type="checkbox"], html body #popups input[type="checkbox"] { border-radius: 6px; }
#app input[type="radio"]::before, html body #popups input[type="radio"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ac-on); transform: scale(0); transition: transform .12s; }
#app input[type="checkbox"]::before, html body #popups input[type="checkbox"]::before { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--ac-on); border-bottom: 2px solid var(--ac-on); transform: rotate(-45deg) scale(0) translate(1px, -1px); transition: transform .12s; }
#app input[type="radio"]:checked, #app input[type="checkbox"]:checked, html body #popups input[type="radio"]:checked, html body #popups input[type="checkbox"]:checked { background: linear-gradient(135deg, var(--ac), var(--ac2)); border-color: transparent; }
#app input[type="radio"]:checked::before, html body #popups input[type="radio"]:checked::before { transform: scale(1); }
#app input[type="checkbox"]:checked::before, html body #popups input[type="checkbox"]:checked::before { transform: rotate(-45deg) scale(1) translate(1px, -1px); }
html body #popups input:focus-visible, #app input[type="radio"]:focus-visible, #app input[type="checkbox"]:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }
html body #popups .popup label { margin-top: 0; vertical-align: middle; }
html body #popups .popup .group { border: 1px solid var(--line); border-radius: 10px; background: rgba(3, 7, 14, .5); padding: 8px 12px; line-height: 2.1; max-height: 250px; overflow: auto; }
html body #popups .popup .group label { margin-right: 0; }

/* ---- thông báo của lõi (bộ thông báo nhỏ của VNISES thay alertifyjs) ---- */
.vn-notify { position: fixed; right: 16px; bottom: 16px; z-index: 100000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.vn-msg { pointer-events: auto; cursor: pointer; padding: 12px 16px; font-size: 14px; line-height: 1.45; border-radius: 12px; background: var(--glass-2); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line-2); color: var(--tx); box-shadow: 0 16px 40px rgba(0, 0, 0, .55); animation: vn-in .2s ease-out; transition: opacity .2s, transform .2s; }
.vn-msg.vn-out { opacity: 0; transform: translateY(6px); }
.vn-msg.vn-error { border-color: rgba(239, 106, 112, .55); background: rgba(70, 22, 28, .92); color: #ffd2d4; }
.vn-msg.vn-warning { border-color: rgba(240, 190, 90, .55); }
.vn-msg.vn-success { border-color: rgba(79, 209, 160, .5); }
@keyframes vn-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .vn-msg { animation: none; transition: none; } }

/* ---- màn hình đầu & trạng thái ---- */
#app.empty .stage { visibility: hidden; }
#app.empty #bRead, #app.empty #bSave, #app.empty #bMore { opacity: .4; pointer-events: none; }
#app.empty .menubar .btn.primary { background: rgba(255, 255, 255, .08); color: var(--mu); box-shadow: none; }
#app.empty #main_menu { opacity: .45; pointer-events: none; }
#app.reading .stage { }
.busy { z-index: 120; }

/* thanh trên: cột giữa không đè lên menu */
#app .menubar { grid-template-columns: auto minmax(0, 1fr) auto; }
#app .mb-l { min-width: 0; }
#app .mb-c { min-width: 0; padding: 0 12px; }
#app .sidebar_left { padding: 5px; gap: 2px; width: 50px; }
#app .sidebar_left .item { height: 36px; width: 36px; }

/* ---- màn hình hẹp: thanh menu cuộn ngang, hai nút bảng công cụ / bảng bên phải nổi ở góc dưới ---- */
@media (max-width: 1000px) {
	#app .menubar { grid-template-columns: minmax(0, 1fr) auto; }
	#app .mb-c { display: none; }
	#app .mb-l { min-width: 0; }
	#app .main_menu { min-width: 0; overflow-x: auto; scrollbar-width: none; }
	#app .main_menu::-webkit-scrollbar { display: none; }
	#app .main_menu > ul.menu_bar { width: max-content; }
}
@media (max-width: 700px) {
	html body { padding-top: 0; }
	#app .main_menu > ul.menu_bar { height: 34px; padding: 0; }
	#app ~ .mobile_menu { display: block; position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 0; z-index: 150; }
	#app ~ .mobile_menu .left_mobile_menu, #app ~ .mobile_menu .right_mobile_menu {
		position: fixed; top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); width: 46px; height: 46px; border-radius: 50%;
		background: var(--glass-2); border: 1px solid var(--line-2); box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .7);
		backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
	}
	#app ~ .mobile_menu .left_mobile_menu { left: 14px; }
	#app ~ .mobile_menu .right_mobile_menu { right: 14px; }
	#app ~ .mobile_menu .left_mobile_menu:after, #app ~ .mobile_menu .right_mobile_menu:after { background-size: auto 20px; }
	#app.empty ~ .mobile_menu { display: none; }
	#app .sidebar_left { padding-bottom: 76px; }
	#app .sidebar_right { right: 0 !important; transform: translateX(112%); visibility: hidden; }
	#app .sidebar_right.active { transform: none; visibility: visible; }
}

body[data-mode="img"] { --ac: #ff6fae; --ac2: #9b7bff; --ac-on: #2b0818; --ac-rgb: 255, 111, 174; }
