/* VIARCAD di động (QD-290): nền đen như vùng vẽ desktop, thanh công cụ trên, bảng trượt dưới; nút ≥ 40 px cho ngón tay. */
:root { --red: #c8102e; --bar: #15171a; --panel: #1d2024; --line: #33373d; --text: #e8e8e8; --muted: #9aa0a6; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); font-family: "Segoe UI", Roboto, Arial, sans-serif; overscroll-behavior: none; }
#app { height: 100%; }
.shell { display: flex; flex-direction: column; height: 100dvh; }
.bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; padding-top: max(4px, env(safe-area-inset-top)); background: var(--bar); border-bottom: 1px solid var(--line); min-height: 48px; }
.logo { font-weight: 300; color: var(--red); font-size: 18px; letter-spacing: .5px; white-space: nowrap; }
.logo b { color: #fff; font-weight: 700; }
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; padding: 0 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 40px; height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
       background: #24272c; color: var(--text); font-size: 14px; cursor: pointer; position: relative; user-select: none; }
.btn:disabled { opacity: .4; }
.btn.on { background: #1e5aa8; border-color: #3d7fd6; }
.btn .ic { font-size: 17px; line-height: 1; }
.btn.big { height: 48px; padding: 0 18px; font-size: 16px; background: var(--red); border-color: var(--red); margin: 6px; }
.btn.big.ghost { background: transparent; border-color: var(--line); }
.btn.small { height: 34px; font-size: 13px; }
.hidden-input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
@media (max-width: 560px) { .btn .tx { display: none; } .fname { font-size: 12px; } }
.stage { position: relative; flex: 1; overflow: hidden; }
canvas.cad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.welcome { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.welcome h1 { font-weight: 300; font-size: 24px; margin: 0 0 8px; }
.welcome p { max-width: 520px; color: #c9c9c9; line-height: 1.5; }
.small { font-size: 12.5px; color: var(--muted); }
.pad { padding: 0 12px; }
.err { color: #ff6b6b; }
.busy { position: absolute; inset: 0; background: rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; font-size: 14px; }
.spinner { width: 42px; height: 42px; border: 4px solid #444; border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; left: 8px; right: 8px; top: 8px; background: rgba(29,32,36,.95); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: pre-line; }
.toast.err { border-color: #a33; color: #ffb3b3; }
.sheet, .panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); border-radius: 12px 12px 0 0;
                 display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 20px rgba(0,0,0,.5); }
.sheet { max-height: 48%; }
.panel { top: 0; border-radius: 0; }
@media (min-width: 900px) { .sheet, .panel { left: auto; width: 420px; top: 0; border-radius: 0; max-height: none; border-left: 1px solid var(--line); } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sheet-head b { flex: 1; font-size: 15px; }
.x { width: 36px; height: 36px; border: none; background: transparent; color: var(--text); font-size: 18px; }
.sheet-body { overflow: auto; padding: 4px 12px 12px; -webkit-overflow-scrolling: touch; }
.grp { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
table.props, table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.props td { padding: 5px 4px; border-bottom: 1px solid #2a2d32; vertical-align: top; }
table.props td:first-child { color: var(--muted); width: 44%; }
table.stats th, table.stats td { padding: 5px 4px; border-bottom: 1px solid #2a2d32; text-align: left; font-size: 13px; }
table.stats th { color: var(--muted); font-weight: 500; }
table.stats td.n { text-align: right; white-space: nowrap; }
table.stats tfoot td { font-weight: 600; }
table.stats th.n { text-align: right; }
table.stats .code { color: var(--muted); font-size: 11px; word-break: break-all; }
.panel-tools { display: flex; gap: 6px; padding: 8px 12px; }
.filter { flex: 1; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #111; color: var(--text); padding: 0 10px; font-size: 15px; }
.layer { display: flex; align-items: center; gap: 10px; min-height: 40px; border-bottom: 1px solid #2a2d32; font-size: 14px; }
.layer input { width: 22px; height: 22px; }
.sw { width: 16px; height: 16px; border-radius: 3px; border: 1px solid #555; flex: none; }
.ln { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cnt { color: var(--muted); font-size: 12px; }
.row { display: flex; justify-content: space-between; width: 100%; min-height: 42px; background: transparent; color: var(--text); border: none; border-bottom: 1px solid #2a2d32; font-size: 15px; text-align: left; }
.boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.boot-logo { font-size: 30px; color: var(--red); font-weight: 300; margin-bottom: 10px; } .boot-logo b { color: #fff; font-weight: 700; }
.loading-progress { position: relative; display: block; width: 6rem; height: 6rem; }
.loading-progress circle { fill: none; stroke: #333; stroke-width: .5rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--red); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray .05s ease-in-out; }
.loading-progress-text { text-align: center; font-weight: bold; margin-top: 8px; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Đang tải"); }
#blazor-error-ui { background: #5a1a1a; color: #fff; bottom: 0; display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui a { color: #fff; margin-left: 12px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
/* QD-293 – thanh công cụ theo mẫu CAD trên điện thoại: nút biểu tượng trên, thanh nhóm cuộn ngang dưới, bảng công cụ bật lên, thanh lời nhắc, bảng màu ACI. */
.ib { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border: none; border-radius: 8px; background: transparent;
      color: var(--text); cursor: pointer; position: relative; padding: 0; }
.ib:active, .ib:hover { background: #2a2e34; }
.ib:disabled { opacity: .35; }
.ib.float { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; background: rgba(29,32,36,.9); border: 1px solid var(--line); z-index: 5; }
.icon { display: block; }
@media (max-width: 420px) { .bar .logo { display: none; } .ib { width: 36px; } }
.shell.clean .bar, .shell.clean .tools { display: none; }
.tools { background: var(--bar); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 68px; padding: 6px 6px 5px; border: none; background: transparent;
       color: var(--muted); font-size: 11.5px; cursor: pointer; border-top: 2px solid transparent; }
.tab.on { color: #fff; border-top-color: var(--red); background: #1d2024; }
.tab:disabled { opacity: .4; }
.tool-pop { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); border-radius: 12px 12px 0 0;
            box-shadow: 0 -6px 20px rgba(0,0,0,.5); max-height: 60%; overflow: auto; z-index: 4; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; padding: 10px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border: 1px solid transparent; border-radius: 10px; background: transparent;
        color: var(--text); font-size: 12px; text-align: center; cursor: pointer; min-height: 70px; }
.tool:active, .tool:hover { background: #2a2e34; border-color: var(--line); }
.tool.on { background: #1e5aa8; }
.tool:disabled { opacity: .4; }
.chip { position: absolute; left: 8px; bottom: 34px; display: flex; align-items: center; gap: 4px; background: rgba(30,90,168,.92); border-radius: 18px; padding: 0 2px 0 12px;
        font-size: 13px; height: 36px; z-index: 3; }
.chip .x { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; }
.prompt { padding: 6px 8px 8px; }
.ptext { font-size: 13.5px; padding: 2px 2px 6px; color: #f3f3f3; }
.ptext b { color: #ffd54a; font-weight: 600; }
.prow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pin { min-width: 120px; }
.pin.coord { max-width: 190px; }
.btn.primary { background: var(--red); border-color: var(--red); }
.btn.ghost { background: transparent; }
.layer .cur { width: 34px; height: 34px; border: none; background: transparent; color: #555; font-size: 18px; }
.layer .cur.on { color: #4caf50; }
.row.choice { justify-content: flex-start; gap: 10px; align-items: center; }
.row.choice .ln { display: flex; flex-direction: column; }
.row .code { color: var(--muted); font-size: 11px; }
.color-sheet { max-height: 75%; }
.aci { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin: 8px 0; }
.aci.std { grid-template-columns: repeat(9, 1fr); }
.swb { aspect-ratio: 1; min-height: 22px; border: 1px solid #444; border-radius: 4px; padding: 0; cursor: pointer; }
.swb.on { outline: 2px solid #fff; outline-offset: 1px; }
.color-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.color-row .num { flex: 0 0 84px; }
.color-row .btn.primary { margin-left: auto; }
.sw.big { width: 30px; height: 30px; }
.btn.on { background: #1e5aa8; border-color: #3d7fd6; }
.color-sheet .color-row:last-child { position: sticky; bottom: -12px; background: var(--panel); padding: 8px 0 12px; margin: 0; }

/* ---- Màn hình chào (QD-294, js/splash.js): ảnh desktop 1215 × 757 giữa màn hình nền tối, dải đáy in sẵn phủ tối và vẽ lại bằng chữ / thanh thật như QD-265 ---- */
#splash { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
          background: radial-gradient(ellipse at 50% 45%, #1a0507 0%, #050608 62%, #000 100%); transition: opacity .28s ease; cursor: pointer; }
#splash.out { opacity: 0; pointer-events: none; }
.sp-card { position: relative; container-type: inline-size; width: min(calc(100vw - 24px), 640px, calc((100dvh - 64px) * 1.605));
           aspect-ratio: 1215 / 757; border-radius: 10px; overflow: hidden; border: 1px solid rgba(58,58,58,.56);
           box-shadow: 0 4px 22px rgba(0,0,0,.55), 0 0 40px rgba(200,16,46,.12); animation: sp-in .22s ease-out both; }
@keyframes sp-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.sp-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
/* dải đáy in sẵn (điểm ảnh 652–745 / 757): tối dần từ trên xuống, mờ hai đầu để giữ ánh đỏ mép trái */
.sp-band { position: absolute; left: 0; right: 0; top: 86.13%; height: 12.29%;
           background: linear-gradient(to bottom, rgba(4,7,11,0) 0%, #04070b 20%, #04070b 88%, rgba(4,7,11,0) 100%);
           -webkit-mask-image: linear-gradient(to right, transparent 0, #000 3.5%, #000 96.5%, transparent 100%);
           mask-image: linear-gradient(to right, transparent 0, #000 3.5%, #000 96.5%, transparent 100%); }
/* ngôi sao góc dưới phải (tâm 1136, 667; bán kính 30) vắt qua mép dải – phủ quầng tối tròn */
.sp-star { position: absolute; left: 91.03%; top: 84.15%; width: 4.94%; height: 7.93%; border-radius: 50%;
           background: radial-gradient(circle, #04070b 55%, rgba(4,7,11,0) 100%); }
.sp-bottom { position: absolute; left: 5%; right: 5%; bottom: 2.6%; font-size: clamp(9px, 1.9cqw, 12.5px); line-height: 1.25; }
.sp-line { display: flex; gap: 1em; align-items: baseline; }
.sp-status { flex: 1; min-width: 0; color: #e2e2e2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-ver { color: #9a9a9a; white-space: nowrap; }
.sp-meter { position: relative; height: max(12px, 3cqw); }
.sp-track, .sp-bar { position: absolute; left: 0; bottom: 3px; height: 3px; border-radius: 1.5px; }
.sp-track { right: 0; background: rgba(58,62,68,.5); }
.sp-bar { width: 0; background: linear-gradient(to right, #5a0606 0%, #a80909 60%, #ff3b30 100%); box-shadow: 0 0 8px rgba(255,59,48,.85);
          transition: width .26s ease-out; }
.sp-head { position: absolute; left: 0; bottom: 0; width: 0; height: 100%; visibility: hidden; transition: left .26s ease-out; }
.sp-head i { position: absolute; left: -3.5px; bottom: 1px; width: 7px; height: 7px; border-radius: 50%; background: #ffe6e2;
             box-shadow: 0 0 10px 2px rgba(255,59,48,.95); }
.sp-pct { position: absolute; left: -1em; bottom: 9px; font-size: .78em; color: #c8c8c8; white-space: nowrap; }
.sp-copy { position: fixed; left: max(10px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom)); font-size: 11px; color: rgba(255,255,255,.45); pointer-events: none; }

/* bản quyền góc dưới trái vùng vẽ (QD-294) – nhỏ, mờ, không chặn chạm */
.copyright { position: absolute; left: 6px; bottom: 3px; font-size: 10px; line-height: 1; color: rgba(255,255,255,.38); pointer-events: none; user-select: none; z-index: 1; }
.stage.light .copyright { color: rgba(0,0,0,.4); }

/* ---- Bảng kích hoạt (QD-297) ---- */
.activate { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; padding: 16px;
            padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); overflow: auto; }
.act-box { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 16px 10px;
           box-shadow: 0 8px 30px rgba(0,0,0,.6); max-height: 100%; overflow: auto; }
.act-box h2 { margin: 0 0 8px; font-size: 19px; font-weight: 500; }
.act-box h2::before { content: ""; display: inline-block; width: 4px; height: 18px; background: var(--red); border-radius: 2px; margin-right: 8px; vertical-align: -2px; }
.act-box p { font-size: 14px; line-height: 1.5; color: #d0d0d0; margin: 0 0 10px; }
.act-l { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.act-in { display: block; width: 100%; margin-top: 4px; border-radius: 8px; border: 1px solid var(--line); background: #111; color: var(--text); padding: 9px 10px; font-size: 16px; }
.act-code { font-family: Consolas, "Roboto Mono", monospace; font-size: 14px; resize: vertical; letter-spacing: .5px; }
.act-mail { width: 100%; margin: 8px 0 0 !important; }
.act-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.act-row .btn.big { margin: 8px 0; }
.lic-ok { color: #8fd48f !important; }
.welcome .lic-ok a { color: #9cc9ff; }
.lic-trial { color: #f0c674 !important; }
.welcome .lic-trial a { color: #9cc9ff; }
/* QD-300: iPhone / iPad – Safari không bỏ phóng trang bằng user-scalable=no: chặn chạm đúp phóng; gợi ý Thêm vào Màn hình chính */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
.ios-hint { color: #f0c674 !important; }
