:root {
    --bg: #eef2f7; --panel: #ffffff; --line: #dbe3ec; --text: #172033;
    --muted: #667085; --primary: #2563eb; --primary-dark: #1d4ed8;
    --accent: #f59e0b; --success: #159565; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; padding: 12px 14px 14px; overflow: hidden; color: var(--text); background: var(--bg); font: 14px/1.45 "Segoe UI", Inter, Arial, sans-serif; }
button, input, select { font: inherit; }
button { transition: .18s ease; }
.back-link { display: inline-flex; color: #475467; text-decoration: none; font-weight: 700; }
.back-link:hover { color: var(--primary); }
.app-header { max-width: none; height: 62px; margin: 0 0 10px; padding: 0 3px; display: flex; align-items: center; justify-content: space-between; }
.app-header h1 { margin: 1px 0 0; font-size: clamp(21px, 2.3vw, 30px); line-height: 1.08; letter-spacing: -.6px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }
.version-badge { padding: 7px 11px; color: #1d4ed8; background: #dbeafe; border: 1px solid #bfdbfe; border-radius: 999px; font-weight: 800; }
.app-container { display: grid; grid-template-columns: minmax(340px, 24vw) minmax(0, 1fr); gap: 12px; width: 100%; height: calc(100vh - 98px); margin: 0; align-items: stretch; }
.sidebar { display: grid; align-content: start; gap: 9px; height: 100%; overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.sidebar-heading, .preview-header { display: flex; justify-content: space-between; align-items: center; }
.sidebar-heading { position: sticky; top: 0; z-index: 5; background: #111827; color: white; padding: 12px 14px; border-radius: 11px; box-shadow: 0 8px 24px rgba(15,23,42,.15); }
.sidebar-heading h2, .preview-header h2 { margin: 2px 0 0; font-size: 19px; }
.sidebar-heading .eyebrow { color: #93c5fd; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 5px rgba(52,211,153,.15); }
.control-card { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 12px; box-shadow: 0 3px 12px rgba(15,23,42,.045); }
.auto-card { border-color: #bfd2fb; background: linear-gradient(145deg,#fff 35%,#f3f7ff); box-shadow: 0 7px 20px rgba(37,99,235,.09); }
.export-card { display: grid; gap: 10px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-title b { display: block; font-size: 15px; }
.card-title small { display: block; color: var(--muted); margin-top: 1px; }
.step { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; color: white; background: #344054; border-radius: 8px; font-weight: 800; }
.step.accent { background: var(--primary); }
label { display: block; color: #344054; font-size: 12px; font-weight: 700; }
input[type="number"], input[type="file"], select, input[type="color"] { width: 100%; min-height: 39px; margin-top: 5px; padding: 8px 10px; color: var(--text); background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; outline: none; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input[type="color"] { padding: 4px; cursor: pointer; }
input[type="range"] { width: 100%; margin-top: 10px; accent-color: var(--primary); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center; }
.compact-top { margin-top: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 11px 0; cursor: pointer; font-size: 13px; }
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.input-note { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.input-note small { color: var(--muted); white-space: nowrap; font-weight: 500; }
.upload-box { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 92px; color: #344054; background: #f8fafc; border: 1.5px dashed #94a3b8; border-radius: 10px; cursor: pointer; }
.upload-box:hover { color: var(--primary); border-color: var(--primary); background: #eff6ff; }
.upload-box small { color: var(--muted); font-weight: 500; }
.upload-icon { color: var(--primary); font-size: 23px; line-height: 1; }
.sr-only { position: absolute; width: 1px!important; height: 1px!important; overflow: hidden; clip: rect(0,0,0,0); }
.object-list { display: grid; gap: 7px; max-height: 190px; overflow: auto; margin-top: 10px; }
.object-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 7px; border: 1px solid #e2e8f0; border-radius: 9px; cursor: pointer; text-align: left; }
.object-row:hover { border-color: #93c5fd; }
.object-row.active { border-color: var(--primary); background: #eff6ff; }
.object-row img { width: 42px; height: 42px; object-fit: contain; background: repeating-conic-gradient(#eee 0 25%,#fff 0 50%) 50%/10px 10px; border-radius: 5px; }
.object-row strong { overflow: hidden; display: block; text-overflow: ellipsis; white-space: nowrap; }
.object-row small { display: block; color: var(--muted); margin-top: 2px; }
.btn-delete { border: 0; background: #fff1f2; color: #be123c; border-radius: 7px; padding: 7px 8px; cursor: pointer; }
.btn-delete:hover { background: #ffe4e6; }
.btn-secondary, .btn-auto, .btn-submit, .btn-crop-action { width: 100%; border: 0; border-radius: 9px; cursor: pointer; font-weight: 800; }
.btn-secondary { padding: 9px; color: var(--primary); background: #eff6ff; border: 1px solid #bfdbfe; }
.btn-secondary:hover { background: #dbeafe; }
.btn-auto { margin-top: 12px; padding: 12px; color: white; background: linear-gradient(135deg,var(--primary),#4f46e5); box-shadow: 0 7px 16px rgba(37,99,235,.22); }
.btn-auto:hover { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(37,99,235,.28); }
.btn-auto:disabled { cursor: wait; opacity: .78; transform: none; }
.btn-submit { padding: 13px; color: white; background: var(--success); box-shadow: 0 6px 14px rgba(21,149,101,.2); }
.btn-submit:hover { background: #087f5b; }
.btn-crop-action { margin-top: 7px; padding: 8px; color: white; background: #dd6b20; }
.crop-box-container { display: none; padding: 10px; margin-top: 9px; color: #9a3412; background: #fff7ed; border: 1px dashed #f97316; border-radius: 9px; }
#cropNotice { display: none; margin-top: 7px; color: var(--success); font-size: 12px; font-weight: 700; }
.mode-help { margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.align-help { margin: 11px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
details summary { cursor: pointer; font-weight: 800; list-style: none; }
details summary::after { content: "⌄"; float: right; color: var(--muted); }
details[open] summary::after { content: "⌃"; }
.details-body { padding-top: 13px; }
.align-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; margin-top: 11px; }
.btn-align { min-height: 34px; color: #475467; background: #f8fafc; border: 1px solid #d7dee8; border-radius: 7px; cursor: pointer; font-weight: 800; }
.btn-align:hover, .btn-align.active { color: white; background: var(--primary); border-color: var(--primary); }
.main-content { display: flex; flex-direction: column; min-width: 0; height: 100%; min-height: 0; padding: 14px; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 26px rgba(15,23,42,.07); text-align: center; }
.preview-header { gap: 16px; text-align: left; padding-bottom: 14px; border-bottom: 1px solid #e5e7eb; }
.preview-header p { margin: 4px 0 0; color: var(--muted); }
.preview-header strong { color: #ef4444; font-size: 18px; }
#rotateNotice { color: var(--primary); font-weight: 700; margin-left: 7px; }
.zoom-tools { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; }
.zoom-tools button { min-width: 38px; height: 36px; padding: 0 10px; color: #344054; background: #f8fafc; border: 1px solid #d5dce5; border-radius: 8px; cursor: pointer; font-weight: 800; white-space: nowrap; }
.zoom-tools button:hover { color: var(--primary); border-color: #93c5fd; background: #eff6ff; }
#zoomValue { min-width: 62px; }
.canvas-tip { margin: 11px 0 0; padding: 7px 10px; color: #475467; background: #f8fafc; border-radius: 7px; font-size: 12px; text-align: left; }
.canvas-holder { flex: 1 1 auto; width: 100%; min-height: 0; margin-top: 10px; padding: 24px; overflow: auto; overscroll-behavior: contain; background-color: #252a32; background-image: linear-gradient(45deg,#303640 25%,transparent 25%),linear-gradient(-45deg,#303640 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#303640 75%),linear-gradient(-45deg,transparent 75%,#303640 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0; border: 1px solid #111827; border-radius: 10px; }
.canvas-holder .canvas-container { margin: 0 auto; box-shadow: 0 12px 35px rgba(0,0,0,.38); }
.load-error { max-width: 520px; margin: 50px auto; padding: 22px; color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; }
@media (max-width: 1100px) {
    .app-container { grid-template-columns: 330px minmax(0,1fr); }
    .preview-header h2 { font-size: 16px; }
}
@media (max-width: 820px) {
    body { height: auto; min-height: 100%; overflow: auto; }
    .app-header { align-items: center; }
    .header-actions .back-link { display: none; }
    .app-container { grid-template-columns: 1fr; height: auto; }
    .sidebar { height: auto; max-height: none; overflow: visible; }
    .main-content { height: 72vh; min-height: 520px; }
    .preview-header { align-items: flex-start; flex-direction: column; }
}

/* Giao diện đồng bộ phong cách innamdu.com: tối, đỏ, tương phản cao */
:root { --bg:#070707; --panel:#141414; --line:#303030; --text:#f7f7f7; --muted:#a3a3a3; --primary:#ed1c24; --primary-dark:#bd1118; --accent:#ff3b30; --success:#16a56c; }
body { color:var(--text); background:radial-gradient(circle at 75% 0,#211012 0,#0b0b0b 32%,#060606 72%); }
.back-link { color:#d1d1d1; }
.back-link:hover,.eyebrow { color:#ff3038; }
.app-header { border-bottom:1px solid #292929; }
.version-badge { color:#fff; background:#ed1c24; border-color:#ff4b52; box-shadow:0 0 18px rgba(237,28,36,.24); }
.sidebar-heading { background:linear-gradient(135deg,#1c1c1c,#101010); border:1px solid #3b3b3b; border-left:3px solid var(--primary); }
.sidebar-heading .eyebrow { color:#ff4a51; }
.status-dot { background:#ff3038; box-shadow:0 0 0 5px rgba(237,28,36,.16); }
.control-card { color:#f5f5f5; background:#141414; border-color:#303030; box-shadow:0 5px 18px rgba(0,0,0,.24); }
.auto-card { background:linear-gradient(145deg,#191919 30%,#241012); border-color:#7b2226; box-shadow:0 8px 22px rgba(237,28,36,.09); }
.card-title small,.object-row small,.input-note small,.mode-help { color:#a8a8a8; }
.step { background:#333; }
.step.accent { background:var(--primary); }
label { color:#e8e8e8; }
input[type="number"],input[type="file"],select,input[type="color"] { color:#f4f4f4; background:#202020; border-color:#3d3d3d; color-scheme:dark; }
input:focus,select:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(237,28,36,.15); }
input[type="range"],.check-row input { accent-color:var(--primary); }
.upload-box { color:#eee; background:#1b1b1b; border-color:#575757; }
.upload-box:hover { color:#fff; background:#251416; border-color:var(--primary); }
.upload-box small { color:#9f9f9f; }
.upload-icon { color:#ff3038; }
.object-row { border-color:#343434; background:#191919; }
.object-row:hover { border-color:#a92a30; }
.object-row.active { border-color:var(--primary); background:#2a1214; }
.btn-delete { color:#ff7b81; background:#351416; }
.btn-delete:hover { background:#50191d; }
.btn-secondary { color:#fff; background:#292929; border-color:#454545; }
.btn-secondary:hover { background:#3a1719; border-color:var(--primary); }
.btn-auto { background:linear-gradient(135deg,#ef1f2b,#a90e16); box-shadow:0 7px 18px rgba(237,28,36,.27); }
.btn-auto:hover { box-shadow:0 10px 24px rgba(237,28,36,.35); }
.btn-submit { background:linear-gradient(135deg,#ef1f2b,#bc1119); box-shadow:0 7px 18px rgba(237,28,36,.23); }
.btn-submit:hover { background:#ff2d36; }
details summary::after { color:#aaa; }
.btn-align { color:#ddd; background:#202020; border-color:#3d3d3d; }
.btn-align:hover,.btn-align.active { color:#fff; background:var(--primary); border-color:#ff4a51; }
.main-content { color:#f7f7f7; background:#111; border-color:#303030; box-shadow:0 10px 32px rgba(0,0,0,.4); }
.preview-header { border-bottom-color:#303030; }
.preview-header p { color:#aaa; }
.preview-header strong { color:#ff3038; }
#rotateNotice { color:#ff6268; }
.preview-actions { display:flex; flex-direction:column; align-items:flex-end; gap:7px; }
.page-tools,.zoom-tools { display:flex; align-items:center; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.page-tools button,.zoom-tools button { min-height:34px; padding:0 10px; color:#e7e7e7; background:#202020; border:1px solid #3c3c3c; border-radius:8px; cursor:pointer; font-weight:800; white-space:nowrap; }
.page-tools button:hover,.zoom-tools button:hover { color:#fff; background:#351416; border-color:var(--primary); }
#duplicateSelectionBtn,#addPageBtn { color:#fff; background:#c9161f; border-color:#ef3941; }
#groupSelectionBtn,#ungroupSelectionBtn,#selectAllBtn,#rotateSelectionBtn { color:#f5f5f5; background:#292929; border-color:#555; }
#groupSelectionBtn:hover,#ungroupSelectionBtn:hover,#selectAllBtn:hover,#rotateSelectionBtn:hover { background:#45171a; border-color:#ed1c24; }
#deleteSelectionBtn { color:#ff9da1; background:#281416; border-color:#713036; }
#deleteSelectionBtn:hover { color:#fff; background:#8f1118; }
#undoBtn { color:#ffd2d4; background:#332022; border-color:#704046; }
.page-tools button:disabled { opacity:.4; cursor:not-allowed; }
.field-hint { display:block; margin-top:4px; color:#999; font-weight:500; }
#removePageBtn { color:#ff8e93; }
.canvas-tip { color:#bbb; background:#1b1b1b; border:1px solid #2d2d2d; }
.canvas-holder { background-color:#090909; background-image:linear-gradient(45deg,#151515 25%,transparent 25%),linear-gradient(-45deg,#151515 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#151515 75%),linear-gradient(-45deg,transparent 75%,#151515 75%); border-color:#3b3b3b; }
.sidebar::-webkit-scrollbar,.canvas-holder::-webkit-scrollbar { width:9px;height:9px; }
.sidebar::-webkit-scrollbar-thumb,.canvas-holder::-webkit-scrollbar-thumb { background:#494949;border-radius:8px; }
@media (max-width:1150px){.preview-header{align-items:flex-start;}.preview-actions{max-width:48%;}.page-tools button{font-size:11px;padding:0 7px;}}
@media (max-width:820px){.preview-actions{width:100%;max-width:none;align-items:flex-start}.page-tools,.zoom-tools{justify-content:flex-start}}
