/* ชั้น "ขัดเงา" (2026-10-16): มิติ + ความลื่นไหล — โหลดหลัง style.css จึงทับค่าพื้นฐาน
   หลัก: แสงขอบบางๆ ด้านบน (inset highlight) + เงาซ้อนชั้น + การเคลื่อนไหวแบบ ease-out นุ่มๆ */

:root {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --hl: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-1: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 10px 28px rgba(0, 0, 0, 0.42);
  --glow: 0 0 0 1px rgba(245, 217, 10, 0.45), 0 0 22px rgba(245, 217, 10, 0.22);
  --card-grad: linear-gradient(180deg, #1e1e21 0%, #18181a 100%);
  --panel-grad: linear-gradient(180deg, #161618 0%, #121213 100%);
}

/* ---------- พื้นหลังทั้งหน้า: ดำอุ่นไล่เบาๆ จากด้านบน (ไม่มีหมอกสี — สีเหลืองเก็บไว้ให้ปุ่มหลัก) ---------- */
body { background: linear-gradient(180deg, #16120e 0, var(--bg) 520px) var(--bg); }
.top { background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent); }


/* ---------- แถบเลื่อน: บาง สีเข้ม กลืนธีม ---------- */
* { scrollbar-width: thin; scrollbar-color: #2c2c31 transparent; }
*:hover { scrollbar-color: #3a3a41 transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c2c31; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #45454d; border: 2px solid transparent; background-clip: padding-box; }

/* ---------- แผง ---------- */
.side { background: var(--panel-grad); box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02); }
.side.right { box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.02); }
.page-card { background: var(--panel-grad); box-shadow: var(--shadow-2); }
.label { letter-spacing: 0.08em; }

/* ---------- ปุ่ม/การ์ด: มีมิติ + ยกตัวเมื่อชี้ + ยุบเมื่อกด ---------- */
.mode, .eng, .chip-btn, .secondary, .secondary-btn, .zoom button, .zoom select, .icon-btn, .dropzone, .co-sw {
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease),
              background-color 0.18s var(--ease), color 0.18s var(--ease), opacity 0.18s;
}
.mode, .eng, .chip-btn, .secondary, .secondary-btn, .zoom button, .zoom select, .icon-btn {
  background: var(--card-grad);
  box-shadow: var(--shadow-1);
}
.mode:hover, .eng:hover:not(:disabled), .chip-btn:hover, .secondary:hover, .secondary-btn:hover:not(:disabled),
.zoom button:hover, .icon-btn:hover:not(:disabled), .co-sw:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  border-color: #3a3a40;
}
.mode:active, .eng:active, .chip-btn:active, .secondary:active, .secondary-btn:active, .zoom button:active,
.icon-btn:active, .co-sw:active, .primary:active { transform: translateY(0) scale(0.97); }
.mode.on { border-color: rgba(245, 217, 10, 0.6); box-shadow: var(--glow); background: linear-gradient(180deg, #23231d, #1b1b17); }
.eng.on { border-color: rgba(245, 217, 10, 0.55); box-shadow: var(--glow); }
.eng.on .radio { border-color: var(--accent); background: radial-gradient(var(--accent) 40%, transparent 45%); }

.primary {
  background: linear-gradient(180deg, #ffffff 0%, #e4e4e8 100%);
  box-shadow: inset 0 1px 0 #fff, 0 6px 18px rgba(255, 255, 255, 0.08), 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s var(--ease), box-shadow 0.25s var(--ease), filter 0.2s;
}
.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 #fff, 0 10px 28px rgba(245, 217, 10, 0.18), 0 0 0 1px rgba(245, 217, 10, 0.5);
}
.small-btn.accent { box-shadow: 0 4px 14px rgba(245, 217, 10, 0.25); }

.dropzone { background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent); }
.dropzone:hover, .dropzone.dragover { box-shadow: 0 0 0 4px rgba(245, 217, 10, 0.08); }
.dropzone .drop-icon { transition: transform 0.35s var(--spring); }
.dropzone:hover .drop-icon { transform: translateY(3px); }

/* ---------- ตัวชี้เลื่อนนุ่มๆ ใต้ตัวเลือกที่เลือก (ui.js วางตำแหน่งให้) ---------- */
.seg { position: relative; background: #141416; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5); }
.seg.has-pill button.on { background: transparent; }
.seg button { position: relative; z-index: 1; transition: color 0.2s var(--ease); }
.slider-pill {
  position: absolute; top: 4px; bottom: 4px; left: 0; border-radius: 9px; pointer-events: none;
  background: linear-gradient(180deg, #2c2c31, #232327);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.32s var(--ease), width 0.32s var(--ease), opacity 0.2s;
}
.tabs { position: relative; }
.tabs .tab { border-bottom-color: transparent !important; transition: color 0.2s var(--ease); }
.tab-pill {
  position: absolute; bottom: -1px; left: 0; height: 2px; border-radius: 2px; pointer-events: none;
  background: var(--accent);
  transition: transform 0.35s var(--ease), width 0.35s var(--ease), opacity 0.2s;
}

/* ---------- สวิตช์ / แถบเลื่อนค่า ---------- */
.switch { transition: background 0.25s var(--ease), box-shadow 0.25s; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5); }
.switch::after { transition: transform 0.3s var(--spring), background 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.switch:checked { background: var(--accent); }
.switch:checked::after { background: #111; }
input[type="range"] { accent-color: var(--accent); }

/* ---------- พื้นที่ภาพ ---------- */
.stage { box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.02); }
.layer-wrap img, #svg-host svg, #co-canvas { animation: fade-in 0.35s var(--ease); }
.handle span { box-shadow: 0 0 0 4px rgba(245, 217, 10, 0.18), 0 4px 14px rgba(0, 0, 0, 0.45); transition: transform 0.2s var(--spring); }
.handle:hover span { transform: translate(-50%, -50%) scale(1.12); }
.tag { backdrop-filter: blur(8px); background: rgba(14, 14, 15, 0.7); border: 1px solid rgba(255, 255, 255, 0.06); }

/* แถบเครื่องมือลอย: กระจกฝ้า */
.toolbar {
  background: rgba(22, 22, 25, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: var(--shadow-2);
}
.tool { transition: background-color 0.18s var(--ease), color 0.18s, transform 0.2s var(--spring), box-shadow 0.2s; }
.tool:hover:not(.soon) { background: rgba(255, 255, 255, 0.07); transform: scale(1.06); }
.tool.on { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.35); }
.tool:active { transform: scale(0.94); }

.tool-hint, .loading { backdrop-filter: blur(12px); background: rgba(16, 16, 18, 0.78); border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.tool-hint { animation: drop-in 0.3s var(--ease); }
.pen-bar { backdrop-filter: blur(14px); background: rgba(20, 20, 22, 0.85); animation: pop-in 0.22s var(--ease); }

/* ---------- แผงขวา ---------- */
.layer { transition: background-color 0.18s var(--ease), box-shadow 0.2s var(--ease), transform 0.18s var(--ease); }
.layer.editable:hover { transform: translateX(2px); }
.sw { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.35); }
.sel-bar, .prep-info, .notice, .co-info { animation: pop-in 0.28s var(--ease); }
.sel-bar { border: 1px solid rgba(245, 217, 10, 0.25); box-shadow: 0 6px 20px rgba(245, 217, 10, 0.08); }
.progress-bar span { background: linear-gradient(90deg, #f5d90a, #ffe970, #f5d90a); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ---------- ป๊อปอัป ---------- */
.cpick { animation: pop-in 0.22s var(--ease); background: rgba(28, 28, 31, 0.92); backdrop-filter: blur(16px); }
.credit { box-shadow: var(--shadow-1), 0 0 0 1px rgba(245, 217, 10, 0.15); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes drop-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

/* เปลี่ยนแท็บ: เนื้อหาค่อยๆ ขึ้น */
main:not([hidden]) { animation: fade-in 0.28s var(--ease); }

/* ผู้ใช้ตั้ง "ลดการเคลื่อนไหว" ไว้ใน Windows → ปิดแอนิเมชัน */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- แท็บสร้างลาย (G2b) ---------- */
.gen-work { grid-template-columns: 330px minmax(0, 1fr); }
.gen-work textarea { width: 100%; resize: vertical; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25);
  color: var(--text); font: inherit; outline: none; -webkit-user-select: text; user-select: text; }
.gen-work textarea:focus { border-color: rgba(245, 217, 10, 0.45); box-shadow: 0 0 0 3px rgba(245, 217, 10, 0.08); }
.gen-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gen-examples .chip { padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); font-size: 12.5px; }
.gen-examples .chip:hover { border-color: rgba(245, 217, 10, 0.45); }
.gen-ends { display: flex; justify-content: space-between; color: var(--text-3); font-size: 11.5px; margin-top: 4px; }
.gen-style-hint { min-height: 2.6em; }
.gen-go { width: 100%; justify-content: center; margin-top: 14px; }
.gen-go:disabled { opacity: 0.5; transform: none; }
.gen-progress { margin-top: 12px; }
.gen-progress .bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.gen-progress .bar span { display: block; height: 100%; width: 3%; border-radius: 99px; background: linear-gradient(90deg, #ffe46b, #f5a524);
  box-shadow: 0 0 12px rgba(245, 190, 60, 0.5); transition: width 0.6s var(--ease); }
.gen-progress small { display: block; margin-top: 6px; color: var(--text-2); }
.gen-center { overflow-y: auto; padding: 18px; }
.gen-empty, .gen-unavailable { margin: 12vh auto 0; max-width: 420px; text-align: center; color: var(--text-2); }
.gen-empty span, .gen-unavailable span { font-size: 40px; display: block; margin-bottom: 8px; }
.gen-empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.gen-results { display: flex; flex-direction: column; gap: 18px; }
.gen-task { padding: 14px; border-radius: 18px; background: var(--panel-grad, var(--panel)); border: 1px solid var(--line); animation: pop-in 0.3s var(--ease); }
.gen-task-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.gen-task-head b { font-size: 14px; }
.gen-task-head small { color: var(--text-3); }
.gen-task-head .chip-btn { margin-left: auto; }
.gen-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gen-cell { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #fff; display: grid; place-items: center; }
.gen-cell.pending { background: repeating-linear-gradient(135deg, #1d1813 0 14px, #221c16 14px 28px); animation: gen-shimmer 1.2s linear infinite; background-size: 40px 40px; }
@keyframes gen-shimmer { to { background-position: 40px 0; } }
.gen-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gen-acts { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 6px; justify-content: center; opacity: 0;
  transform: translateY(6px); transition: opacity 0.2s var(--ease), transform 0.2s var(--ease); }
.gen-cell:hover .gen-acts, .gen-cell:focus-within .gen-acts { opacity: 1; transform: none; }
.gen-acts .chip-btn { background: rgba(20, 16, 12, 0.85); text-decoration: none; color: var(--text); }
.gen-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(245, 217, 10, 0.2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gen-fail { font-size: 30px; color: #ff9b9b; }
@media (hover: none) { .gen-acts { opacity: 1; transform: none; } }
@media (max-width: 760px) { .gen-work { grid-template-columns: 1fr; } }

/* ---------- Vector Cleaner (Phase L) ---------- */
.clean-work .stage { position: relative; }
.cl-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--text-2); padding: 20px; }
.cl-empty span { font-size: 40px; }
.cl-empty b { display: block; color: var(--text); font-size: 16px; margin: 6px 0 4px; }
.cl-empty p { max-width: 420px; margin: 0 auto; }
.cl-compare { --split: 50%; position: absolute; inset: 16px; cursor: ew-resize; user-select: none; -webkit-user-select: none; touch-action: none; }
.cl-compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.cl-compare[data-view="split"] #cl-before { clip-path: inset(0 calc(100% - var(--split)) 0 0); }
.cl-compare[data-view="split"] #cl-after { clip-path: inset(0 0 0 var(--split)); }
.cl-compare[data-view="result"] #cl-before, .cl-compare[data-view="source"] #cl-after { display: none; }
.cl-compare:not([data-view="split"]) { cursor: default; }
.cl-compare:not([data-view="split"]) .lb-handle, .cl-compare:not([data-view="split"]) .tag2 { display: none; }
.cl-compare .lb-handle { pointer-events: none; }
.cl-busy { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.cl-busy .gen-spinner { width: 16px; height: 16px; border-width: 2px; }
.cl-stats { display: flex; flex-direction: column; gap: 8px; }
.cl-stat { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.cl-stat .lbl { color: var(--text-3); font-size: 12px; grid-column: 1 / -1; }
.cl-stat b { font-size: 14px; }
.cl-stat small { align-self: center; font-weight: 800; color: var(--text-3); }
.cl-stat small.down { color: #6ee7a8; }
.cl-same { padding: 10px 12px; border-radius: 12px; text-align: center; font-weight: 800; background: rgba(245, 217, 10, 0.08); color: var(--accent); }
.cl-same.good { background: rgba(110, 231, 168, 0.1); color: #6ee7a8; }
.cl-same.warn { background: rgba(255, 107, 107, 0.1); color: #ff9b9b; }
.dl-row a.disabled { opacity: 0.4; pointer-events: none; }
.to-clean { margin-top: 10px; }
.cl-group { margin: 6px 0 12px; }

/* ---------- Layer Tools (L2) ---------- */
.obj-card { width: min(900px, 100%); }
.obj-card h3 { margin: 0 0 4px; font-size: 18px; }
.obj-busy { display: flex; align-items: center; gap: 12px; padding: 40px 0; justify-content: center; color: var(--text-2); }
.obj-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; }
.obj-body img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 14px; background: #fff; }
.obj-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; margin-bottom: 14px; }
.obj-row { display: grid; grid-template-columns: 14px 1fr auto; grid-template-rows: auto auto; gap: 0 10px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.obj-dot { width: 14px; height: 14px; border-radius: 4px; grid-row: span 2; }
.obj-row code { color: var(--text-3); font-size: 11.5px; }
.obj-row small { color: var(--text-3); grid-column: 2 / -1; font-size: 12px; }
@media (max-width: 720px) { .obj-body { grid-template-columns: 1fr; } }
.obj-head { display: flex; align-items: center; gap: 10px; }
.obj-row { grid-template-columns: 14px minmax(0, 1fr) auto; }
.obj-name { min-width: 0; padding: 5px 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text);
  font-weight: 700; font: inherit; outline: none; }
.obj-name:hover { border-color: var(--line); }
.obj-name:focus { border-color: rgba(245, 217, 10, 0.5); background: rgba(0, 0, 0, 0.25); }
.obj-tools { display: flex; gap: 2px; }
.obj-btn { width: 26px; height: 26px; border-radius: 7px; border: 1px solid transparent; background: none; color: var(--text-2); font-size: 13px; padding: 0; }
.obj-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); }
.obj-btn.on { color: var(--accent); background: rgba(245, 217, 10, 0.1); border-color: rgba(245, 217, 10, 0.3); }
.obj-btn:disabled { opacity: 0.25; }
.obj-row.is-hidden .obj-name, .obj-row.is-hidden .obj-dot { opacity: 0.45; }
.obj-row.is-locked { background: rgba(245, 217, 10, 0.03); }

/* ---------- หน้า Layer Tools ---------- */
.lt-canvas { position: absolute; inset: 0; overflow: hidden; }   /* ซูม/เลื่อน: กรอบภาพวางด้วย left/top */
/* กรอบขนาดเท่าสัดส่วนภาพ (JS คำนวณให้พอดีจอ) — ภาพ/เลเยอร์/กรอบตัวเลข/ชั้นระบาย ซ้อนตรงกันพอดี */
.lt-frame { position: absolute; }
.lt-stack, .lt-orig, .lt-map, .lt-draw { position: absolute; inset: 0; width: 100%; height: 100%; }
.lt-stack img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.lt-map { object-fit: contain; border-radius: 12px; background: #fff; }
.lt-orig { object-fit: contain; }
.lt-list { max-height: 52vh; }
.obj-thumb { width: 34px; height: 34px; object-fit: contain; border-radius: 7px; grid-row: span 2;
  border: 2px solid var(--line); background: repeating-conic-gradient(#3a3530 0 25%, #2a2622 0 50%) 0 0 / 10px 10px; }
/* แผงแคบ: ชื่อเต็มแถวบน · % + ปุ่มอยู่แถวล่าง */
.lt-list .obj-row { grid-template-columns: 34px minmax(0, 1fr) auto; row-gap: 2px; }
.lt-list .obj-name { grid-column: 2 / -1; }
.lt-list .obj-row small { grid-column: 2; grid-row: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-list .obj-tools { grid-column: 3; grid-row: 2; }
.lt-select { width: 100%; margin: 6px 0 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25); color: var(--text); }
.lt-progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: 10px; }
.lt-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.lt-size { display: flex; margin-bottom: 10px; }
.lt-size button { flex: 1; }
.lt-zip { display: block; text-align: center; margin-bottom: 8px; }
.export.disabled .lt-zip, .export.disabled .lt-size { opacity: 0.4; pointer-events: none; }
.hint.ok { color: #8fd18f; }

/* ---------- Layer Tools · AI โปร ---------- */
.lt-mode { display: flex; margin-top: 6px; }
.lt-mode button { flex: 1; }
.lt-ai-items { display: flex; flex-direction: column; gap: 5px; margin: 6px 0; max-height: 46vh; overflow-y: auto; }
.lt-ai-item { display: grid; grid-template-columns: 16px 18px 56px minmax(0, 1fr); align-items: center; gap: 6px;
  padding: 5px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.lt-ai-item:hover { border-color: rgba(245, 217, 10, 0.5); }
.lt-ai-item.on { background: rgba(245, 217, 10, 0.08); border-color: rgba(245, 217, 10, 0.4); }
.lt-ai-num { font-size: 12px; color: var(--accent); text-align: center; }
.lt-ai-thumb { width: 56px; height: 56px; object-fit: contain; border-radius: 7px; background: #fff; display: grid; place-items: center; color: #777; }
.lt-ai-item .obj-name { font-size: 12px; }
.lt-ai-bulk { display: flex; gap: 6px; margin: 4px 0; }
.lt-boxes { position: absolute; inset: 0; pointer-events: none; }
.lt-box { position: absolute; border: 2px dashed rgba(255, 255, 255, 0.35); border-radius: 6px; }
.lt-box span { position: absolute; left: -2px; top: -2px; min-width: 20px; padding: 1px 5px; font-size: 12px; font-weight: 700;
  border-radius: 6px 0 6px 0; background: rgba(40, 36, 30, 0.85); color: #fff; text-align: center; }
.lt-box.on { border: 2px solid var(--accent); }
.lt-box.on span { background: var(--accent); color: #1b1712; }
.lt-box.hover { border: 3px solid #4fd1ff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45); z-index: 2; }
.lt-box.hover span { background: #4fd1ff; color: #08202a; }
.lt-ai-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-bottom: 10px; }
.lt-ai-add .obj-name { border-color: var(--line); }
.hint.warn { color: #e8b04a; }

/* ---------- พื้นกรอบดูภาพ "มืดลายจุด" + แสงจางๆ ขยับช้าๆ (แค่ในจอ ไม่ติดไปในไฟล์) ---------- */
.stage.bg-night { background-color: #0b0d12; isolation: isolate;
  background-image: radial-gradient(rgba(255, 255, 255, 0.075) 1px, transparent 1.4px); background-size: 22px 22px; }
.stage.bg-night::before { content: ""; position: absolute; inset: -30%; z-index: -1; pointer-events: none;
  background: radial-gradient(38% 32% at 30% 35%, rgba(245, 190, 90, 0.10), transparent 70%),
              radial-gradient(34% 30% at 72% 68%, rgba(90, 130, 255, 0.09), transparent 70%);
  animation: stage-glow 22s ease-in-out infinite alternate; }
@keyframes stage-glow {
  0% { transform: translate(-6%, -4%) scale(1); }
  50% { transform: translate(5%, 3%) scale(1.08); }
  100% { transform: translate(-2%, 6%) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) { .stage.bg-night::before { animation: none; } }
.co-sw.night { background: #0b0d12 radial-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1.4px) 0 0 / 7px 7px; }
.stage-bg-seg { width: auto; flex: none; margin-left: 4px; }
.stage-bg-seg button { min-width: 34px; padding: 0 8px; }
.lt-quick { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.lt-quick summary { cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.lt-quick[open] summary { margin-bottom: 6px; }
.lt-list .obj-btn { width: 22px; }
.lt-list .obj-tools { gap: 1px; }

/* ---------- ระบายเลือกพื้นที่เอง ---------- */
.lt-draw { pointer-events: none; opacity: 0.5; z-index: 3; }
.lt-lasso { opacity: 1; z-index: 4; }
.lt-frame.drawing .lt-draw { pointer-events: auto; cursor: crosshair; }
.lt-frame.drawing .lt-lasso { pointer-events: none; }
.lt-size-ctl { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.lt-size-ctl input { width: 110px; }
.lt-area-name { width: 220px; border-color: var(--line); }
.lt-ai-item.done .lt-ai-num::after { content: " ✓"; color: #8fd18f; }
.lt-ai-item.done { opacity: 0.6; }
.lt-refine { font-size: 12.5px; white-space: nowrap; }
/* ชิ้นที่ระบายเอง: รูปทรงที่ระบาย (ไม่มีกรอบสี่เหลี่ยม — กรอบใช้แค่วางเลขกำกับ) */
.lt-shape { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.22; pointer-events: none; }
.lt-shape.on { opacity: 0.45; }
.lt-shape.hover { opacity: 0.8; z-index: 2; outline: none; }   /* สีประจำชิ้นคงเดิม แค่เข้มขึ้น */
.lt-box.shape, .lt-box.shape.on, .lt-box.shape.hover { border-color: transparent; box-shadow: none; }

/* ---------- Layer Tools: แถบเครื่องมือแนวตั้ง + วงขนาดแปรง ---------- */
.lt-rail { z-index: 6; }
.lt-tool-name { font-size: 13px; color: var(--accent); min-width: 48px; }
.lt-size-ctl output { min-width: 44px; font-variant-numeric: tabular-nums; color: var(--text); }
.lt-frame.drawing.no-ring .lt-draw { cursor: crosshair; }
.lt-frame.drawing:not(.no-ring) .lt-draw { cursor: none; }

/* ---------- ชุดเครื่องมือกลาง (tooltools.js) — แนวทางจาก MangaToolPlus ---------- */
/* ไอคอน Bootstrap Icons ในปุ่มเครื่องมือ (ขนาดเท่าไอคอนเส้นเดิม) */
.tool .bi { font-size: 18px; line-height: 1; }
.tool .bi-svg { width: 19px; height: 19px; }
/* ขีดด้านบนแถบ = ที่จับลาก (เพิ่มพื้นที่กดให้ใหญ่กว่าเส้นที่เห็น) */
.toolbar .grip { width: 22px; height: 14px; margin: -4px auto 0; background: none; cursor: grab; position: relative; }
.toolbar .grip::before { content: ""; position: absolute; left: 2px; right: 2px; top: 6px; height: 3px; border-radius: 3px; background: var(--line); }
.toolbar .grip:hover::before { background: var(--text-3); }
.toolbar.dragging, .toolbar.dragging .grip { cursor: grabbing; transition: none; }

/* แถบตั้งค่าเครื่องมือ: กระจกลอยล่างกลางภาพ (ไม่ดันเนื้อหา) */
.tool-options { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 8;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  width: max-content; max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 18px;
  background: rgba(22, 19, 16, 0.82); border: 1px solid rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(242, 235, 225, 0.06); }
.tool-options .chip-btn { width: auto; }
.tool-options .primary { width: auto; flex: none; padding: 7px 14px; }

/* วงแปรง: ขาว+เงาดำ เห็นได้ทั้งบนภาพสว่างและมืด · ป้าย px โผล่ตอนปรับขนาด */
.brush-ring { position: absolute; z-index: 9; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.brush-ring::after { content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 2px; margin: -1px 0 0 -1px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
.brush-ring span { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap;
  font: 600 11px Inter, sans-serif; color: #fff; background: rgba(16, 14, 12, 0.92); border: 1px solid rgba(245, 217, 10, 0.75);
  border-radius: 6px; padding: 2px 7px; opacity: 0; transition: opacity 0.18s; font-variant-numeric: tabular-nums; }
.brush-ring.show-label span { opacity: 1; }
.brush-ring[data-variant="eraser"], .brush-ring[data-variant="erase"] { border-style: dashed; }
.brush-ring[data-variant="erase"] { border-color: #ff8a8a; }
.brush-ring[data-variant="restore"] { border-color: #8fe3a0; }

.co-rail, .co-rail .tool, .tool-options { cursor: default; }
.co-rail .tool, .tool-options button { cursor: pointer; }

/* แท็บลบพื้นหลัง: Lasso (เส้นประวิ่ง) / Magic Wand */
.co-lasso { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; overflow: visible; }
.co-lasso polyline { fill: none; stroke-width: 1.5; }
.co-lasso .a { stroke: #000; }
.co-lasso .b { stroke: #fff; stroke-dasharray: 6 5; }
.co-stage.painting.crosshair { cursor: crosshair; }
.co-action { width: auto; flex: none; }
.co-action button { padding: 5px 14px; }

/* ---------- คำอธิบายตอนชี้เมาส์ (tooltip.js) — กระจกเข้ากับเว็บ แทนกล่องเหลืองของระบบ ---------- */
#app-tooltip { position: fixed; z-index: 10500; max-width: 280px; padding: 6px 10px; border-radius: 10px; pointer-events: none;
  font: 500 12.5px/1.45 "IBM Plex Sans Thai", Inter, sans-serif; color: var(--text);
  background: rgba(22, 19, 16, 0.9); border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(242, 235, 225, 0.06);
  opacity: 0; transform: translateY(3px); transition: opacity 0.12s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.12s cubic-bezier(0.22, 0.61, 0.36, 1); }
#app-tooltip.show { opacity: 1; transform: none; }
#app-tooltip::after { content: ""; position: absolute; left: var(--arrow-x, 50%); width: 8px; height: 8px; margin-left: -4px;
  background: inherit; border: inherit; border-width: 0 1px 1px 0; transform: rotate(45deg); }
#app-tooltip[data-side="top"]::after { top: calc(100% - 4px); }
#app-tooltip[data-side="bottom"]::after { bottom: calc(100% - 4px); transform: rotate(225deg); }

/* ซูม/เลื่อนภาพ (Layer Tools) — Space ค้าง หรือเครื่องมือ V = มือ */
#lt-result { cursor: default; }
.lt-frame:not(.drawing) { cursor: grab; }
body.space-pan #lt-result, body.space-pan #lt-result .lt-draw, body.space-pan .co-stage { cursor: grab !important; }
#lt-result.panning, #lt-result.panning .lt-draw { cursor: grabbing !important; }
.stage-bg-seg .bi { font-size: 13px; }
.lt-hires { font-size: 12.5px; margin: -4px 0 8px; }

/* ย้ายชิ้น (Layer Tools · AI โปร): ชิ้นที่เลือกมีขอบเรืองตามรูปทรง */
.lt-frame.moving { cursor: move; }
.lt-stack img.sel { filter: drop-shadow(0 0 1.5px #4fa3ff) drop-shadow(0 0 1.5px #4fa3ff) drop-shadow(0 0 6px rgba(79, 163, 255, 0.6)); }

/* ---------- ช่องเลือกแบบกระจก (select.js) แทน dropdown สีเทาของระบบ ---------- */
.nsel-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important;
  pointer-events: none !important; overflow: hidden; clip-path: inset(50%); }
.nsel { position: relative; display: block; width: 100%; margin: 6px 0 10px; }
.nsel > button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--text);
  transition: border-color 0.18s cubic-bezier(0.22, 0.61, 0.36, 1), background-color 0.18s cubic-bezier(0.22, 0.61, 0.36, 1); }
.nsel > button:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.04); }
.nsel.open > button, .nsel > button:focus-visible { border-color: rgba(245, 217, 10, 0.55); outline: none; box-shadow: 0 0 0 3px rgba(245, 217, 10, 0.15); }
.nsel > button:disabled { opacity: 0.55; cursor: not-allowed; }
.nsel-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nsel-label { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsel-desc { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsel-caret { font-size: 12px; color: var(--text-2); transition: transform 0.18s cubic-bezier(0.22, 0.61, 0.36, 1); }
.nsel.open .nsel-caret { transform: rotate(180deg); }
.nsel-menu { position: fixed; z-index: 10500; overflow-y: auto; padding: 6px; border-radius: 14px;
  background: rgba(22, 19, 16, 0.92); border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(242, 235, 225, 0.06);
  animation: nsel-in 0.14s cubic-bezier(0.22, 0.61, 0.36, 1); }
@keyframes nsel-in { from { opacity: 0; transform: translateY(-4px); } }
.nsel-item { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 8px 34px 8px 10px; border-radius: 10px; cursor: pointer; }
.nsel-item.active { background: rgba(255, 255, 255, 0.06); }
.nsel-item.selected { background: rgba(245, 217, 10, 0.1); }
.nsel-text { display: flex; align-items: center; gap: 8px; }
.nsel-text b { font-weight: 600; font-size: 13.5px; color: var(--text); }
.nsel-text em { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  color: var(--accent); background: rgba(245, 217, 10, 0.12); border: 1px solid rgba(245, 217, 10, 0.3); }
.nsel-item small { font-size: 11.5px; color: var(--text-3); }
.nsel-tick { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--accent); opacity: 0; }
.nsel-item.selected .nsel-tick { opacity: 1; }
/* ในแถบซูมของแท็บแปลงภาพ: ช่องเล็กบรรทัดเดียว */
.zoom .nsel { width: auto; margin: 0; }
.zoom .nsel > button { height: 30px; padding: 0 10px; border-radius: 8px; background: var(--card); }
.zoom .nsel-label { font-weight: 500; font-size: 12.5px; }

/* ---------- แชร์ลงหน้าผลงาน + ป้าย "ใหม่" + หลังบ้าน ---------- */
.share-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.share-box .adm-check { font-size: 12.5px; line-height: 1.45; }
.share-title { width: 100%; margin-bottom: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25); color: var(--text); }
.g-card.is-new::after { content: "NEW"; position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  font: 700 10px Inter, sans-serif; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 999px;
  color: #1b1712; background: var(--accent); z-index: 3; }
.adm-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.adm-gcard { display: flex; flex-direction: column; gap: 8px; }
.adm-gpics { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.adm-gpics img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
.adm-ginfo { display: flex; flex-direction: column; gap: 2px; }
.adm-ginfo small { color: var(--text-3); }

/* ---------- กล่องข้อความกระจก (dialog.js) แทนป๊อปอัปของเบราว์เซอร์ ---------- */
.dlg-back { position: fixed; inset: 0; z-index: 11000; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 5, 4, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: dlg-fade 0.18s ease both; }
.dlg-back.out { animation: dlg-fade 0.16s ease reverse both; }
@keyframes dlg-fade { from { opacity: 0; } }
.dlg { width: min(440px, 100%); padding: 22px 22px 18px; border-radius: 20px; color: var(--text);
  background: linear-gradient(180deg, rgba(34, 29, 24, 0.94), rgba(20, 17, 14, 0.94)); border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(242, 235, 225, 0.07);
  animation: dlg-pop 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.dlg-back.out .dlg { animation: dlg-pop 0.16s ease reverse both; }
@keyframes dlg-pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.dlg.nudge { animation: dlg-nudge 0.26s ease; }
@keyframes dlg-nudge { 30% { transform: scale(1.02); } }
.dlg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.dlg-ico { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px;
  color: var(--accent); background: rgba(245, 217, 10, 0.1); box-shadow: inset 0 0 0 1px rgba(245, 217, 10, 0.25); }
.dlg.tone-ai .dlg-ico { color: #c9b6ff; background: rgba(150, 120, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(170, 140, 255, 0.3), 0 0 18px rgba(150, 120, 255, 0.25); }
.dlg.tone-danger .dlg-ico { color: #ff9b9b; background: rgba(255, 90, 90, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 110, 110, 0.3); }
.dlg-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.35; }
.dlg-msg { margin: 0 0 14px; color: var(--text-2); font-size: 14px; line-height: 1.6; white-space: pre-line; }
.dlg-details { margin: 0 0 16px; padding: 4px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06); }
.dlg-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 13.5px; }
.dlg-row + .dlg-row { border-top: 1px dashed rgba(255, 255, 255, 0.08); }
.dlg-row dt { color: var(--text-3); }
.dlg-row dd { margin: 0; font-weight: 600; text-align: right; }
.dlg-row.strong dt { color: var(--text-2); }
.dlg-row.strong dd { color: var(--accent); font-size: 16px; font-weight: 800; }
.dlg-input { width: 100%; margin: 0 0 16px; padding: 11px 13px; border-radius: 12px; font: inherit; color: var(--text);
  background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.12); outline: none; }
.dlg-input:focus { border-color: rgba(245, 217, 10, 0.55); box-shadow: 0 0 0 3px rgba(245, 217, 10, 0.12); }
.dlg-acts { display: flex; justify-content: flex-end; gap: 10px; }
.dlg-btn { min-width: 96px; padding: 10px 18px; border-radius: 999px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; }
.dlg-btn:active { transform: scale(0.97); }
.dlg-btn.is-cancel { color: var(--text-2); background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); }
.dlg-btn.is-cancel:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.dlg-btn.is-ok { color: #111; background: var(--accent); box-shadow: 0 6px 18px rgba(245, 217, 10, 0.25); }
.dlg-btn.is-ok:hover { box-shadow: 0 6px 24px rgba(245, 217, 10, 0.4); }
.dlg-btn.is-danger { color: #fff; background: #d64545; box-shadow: 0 6px 18px rgba(214, 69, 69, 0.3); }
.dlg-btn:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 2px; }
@media (max-width: 480px) { .dlg-acts { flex-direction: column-reverse; } .dlg-btn { width: 100%; } }

/* ---------- การ์ดรอระหว่างทำงาน (Layer Tools) ลอยบนกรอบภาพ ---------- */
.busy-card { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9;
  display: flex; align-items: center; gap: 14px; width: min(440px, calc(100% - 32px)); padding: 12px 16px 12px 12px; border-radius: 18px;
  background: rgba(22, 19, 16, 0.86); border: 1px solid rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(242, 235, 225, 0.06);
  animation: busy-in 0.25s cubic-bezier(0.22, 0.61, 0.36, 1) both; cursor: default; }
@keyframes busy-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.busy-ring { position: relative; flex: none; width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); font-size: 16px; }
.busy-ring::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(245, 217, 10, 0) 0deg, rgba(245, 217, 10, 0.9) 280deg, #fff6c2 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  animation: spin 1s linear infinite; }
.busy-ring i { animation: busy-glow 1.6s ease-in-out infinite; }
@keyframes busy-glow { 50% { opacity: 0.45; transform: scale(0.88); } }
.busy-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.busy-top { display: flex; align-items: baseline; gap: 10px; }
.busy-top b { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busy-top time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-3); }
.busy-body small { font-size: 12px; color: var(--text-2); }
.busy-bar { position: relative; height: 5px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, 0.07); }
.busy-bar span { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #b99e00, var(--accent)); transition: width 0.5s cubic-bezier(0.22, 0.61, 0.36, 1); }
.busy-bar::after { content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 246, 194, 0.45), transparent); animation: busy-sweep 1.4s ease-in-out infinite; }
.busy-bar.indeterminate span { width: 0 !important; }
@keyframes busy-sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ตัวหมุนรอทั้งเว็บ: วงแหวนไล่สีมีแสง แทนวงขอบธรรมดา */
.gen-spinner, .spinner { border: 0 !important; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(245, 217, 10, 0) 0deg, rgba(245, 217, 10, 0.9) 280deg, #fff6c2 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  animation: spin 0.9s linear infinite; }
.spinner, .cl-busy .gen-spinner { -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px)); }
@media (prefers-reduced-motion: reduce) { .busy-bar::after, .busy-ring i { animation: none; } }

/* Layer Tools: ขยายให้คม ×1/×2/×4 */
.lt-enlarge { margin: 2px 0 12px; }
.lt-enlarge .label { display: flex; align-items: center; gap: 6px; }
.lt-enlarge .label em { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  color: #8fe3a8; background: rgba(80, 200, 120, 0.1); border: 1px solid rgba(80, 200, 120, 0.3); }
.lt-scale { display: flex; margin-bottom: 6px; }
.lt-scale button { flex: 1; font-variant-numeric: tabular-nums; font-weight: 700; }
.lt-enlarge .note { display: block; font-size: 11.5px; line-height: 1.5; color: var(--text-3); }
.export.disabled .lt-enlarge { opacity: 0.4; pointer-events: none; }
.lt-out-size { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Layer Tools: จัดใหม่ตามผลตรวจ (คำใบ้บรรทัดเดียว + ⓘ · แผงขวาให้เลเยอร์เป็นหลัก · ZIP ปุ่มหลัก) ---------- */
.lt-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.info-tip { display: inline-grid; place-items: center; width: 24px; height: 24px; margin: -4px 0; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--text-3); font-size: 13px; cursor: pointer; flex: none; transition: color 0.15s ease, background 0.15s ease; }
.info-tip:hover, .info-tip:focus-visible { color: var(--accent); background: rgba(245, 217, 10, 0.08); }
.info-tip:focus-visible { outline: 2px solid rgba(245, 217, 10, 0.5); outline-offset: 1px; }
.label.lt-line { text-transform: none; }

@media (min-width: 1101px) {
  .lt-work .side.right { overflow: hidden; }
  .lt-work .side.right .lt-layers-sec { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
  .lt-work .side.right .lt-list { flex: 1; min-height: 0; max-height: none; margin-bottom: 0; }
}
.lt-export { margin-top: auto; padding-bottom: 2px; }
.lt-dl-opts { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.lt-dl-opts > summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 600; color: var(--text-2); border-radius: 12px; }
.lt-dl-opts > summary::-webkit-details-marker { display: none; }
.lt-dl-opts > summary:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.lt-dl-caret { margin-left: auto; font-size: 11px; transition: transform 0.2s cubic-bezier(0.22, 0.61, 0.36, 1); }
.lt-dl-opts[open] .lt-dl-caret { transform: rotate(180deg); }
.lt-dl-opts[open] > summary { border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.lt-dl-opts .lt-size { margin: 10px 12px; }
.lt-dl-opts .lt-enlarge { margin: 0 12px 12px; }
.lt-dl-opts .lt-enlarge .label { margin-bottom: 8px; }
.lt-zip.primary { background: var(--accent); color: #111; font-weight: 700; box-shadow: 0 6px 18px rgba(245, 217, 10, 0.18); }
.lt-zip.primary:hover { background: #ffe433; box-shadow: 0 8px 22px rgba(245, 217, 10, 0.28); }
.lt-send-all { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; font-weight: 600; }
.export.disabled .lt-dl-opts { opacity: 0.4; pointer-events: none; }

/* แถวเลเยอร์: ปุ่มตาแสดงตลอด · ที่เหลือโผล่เมื่อชี้/เลือกแถว (จอสัมผัสแสดงตลอด) · พื้นที่กด 28 px */
.lt-list .obj-btn { width: 28px; height: 28px; font-size: 14px; }
.lt-list .obj-tools { gap: 0; }
@media (hover: hover) {
  /* ซ่อนแบบไม่กินที่ (ตัวเลข % เห็นเต็ม) · ชี้/โฟกัสแถว = โผล่ */
  .lt-list .obj-tools .obj-btn:not(:first-child) { display: none; }
  .lt-list .obj-row:hover .obj-btn:not(:first-child), .lt-list .obj-row:focus-within .obj-btn:not(:first-child) { display: inline-grid; place-items: center; animation: lt-tools-in 0.15s ease; }
}
@keyframes lt-tools-in { from { opacity: 0; } }

/* แถบระบาย: เพิ่มเป็นชิ้น / ลบออกจากชิ้น */
.lt-purpose { display: inline-flex; width: auto; flex: none; }
.lt-purpose button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lt-purpose button[data-lt-purpose="cut"].on { color: #ff8a95; background: rgba(255, 77, 94, 0.12); }
.lt-cut { display: inline-flex; align-items: center; gap: 8px; }
.lt-cut-label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.lt-cut .nsel { min-width: 150px; }
.lt-cut-go.primary { background: #e5484d; color: #fff; }
.lt-cut-go.primary:hover:not(:disabled) { background: #f25c61; }
.lt-purpose button[data-lt-purpose="fill"].on { color: #8ff0b0; background: rgba(61, 220, 132, 0.12); }
.lt-fill-go.primary { background: #2fb36d; color: #fff; }
.lt-fill-go.primary:hover:not(:disabled) { background: #39c77c; }

/* ---------- เปิด-ปิดฟีเจอร์ ---------- */
.feat-hidden { display: none !important; }
.feat-maint { opacity: 0.55; }
.feat-maint, .feat-owner-hidden { position: relative; }
.feat-maint[data-feat-badge]::after, .feat-owner-hidden[data-feat-badge]::after {
  content: attr(data-feat-badge); margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  white-space: nowrap; align-self: center; color: #f5be3c; background: rgba(245, 190, 60, 0.12); border: 1px solid rgba(245, 190, 60, 0.3); }
.feat-owner-hidden[data-feat-badge]::after { color: var(--text-2); background: rgba(255, 255, 255, 0.06); border-color: var(--line); }
.feat-owner-hidden { opacity: 0.7; }
.maint-card { max-width: 520px; margin: 10vh auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.maint-ico { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 28px; color: #f5be3c;
  background: rgba(245, 190, 60, 0.1); box-shadow: inset 0 0 0 1px rgba(245, 190, 60, 0.28); }
.maint-card h2 { margin: 6px 0 0; }
.maint-card p { margin: 0 0 8px; }
.feat-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 12px; font-size: 12.5px; color: var(--text-2); }
.feat-legend .dot, .feat-row .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: 1px; }
.dot.on { background: #3ddc84; } .dot.maint { background: #f5be3c; } .dot.hidden { background: #6d655c; }
.feat-tools { margin-bottom: 8px; }
.feat-group { margin: 16px 0 6px; }
.feat-row { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: 8px 14px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; background: rgba(255, 255, 255, 0.02); }
.feat-row b { font-weight: 600; }
.feat-seg { width: auto; }
.feat-seg button { padding: 6px 12px; white-space: nowrap; }
.feat-row.is-on .feat-seg button.on { color: #8ff0b0; }
.feat-row.is-maint .feat-seg button.on { color: #f5be3c; }
.feat-row.is-hidden { opacity: 0.85; }
.feat-msg { grid-column: 1 / -1; display: none; gap: 8px; }
.feat-row.is-maint .feat-msg, .feat-row.is-hidden .feat-msg { display: grid; grid-template-columns: 1fr 1fr; }
.feat-msg input { padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--text); font: inherit; font-size: 13px; }
@media (max-width: 640px) { .feat-row { grid-template-columns: 1fr; } .feat-row.is-maint .feat-msg, .feat-row.is-hidden .feat-msg { grid-template-columns: 1fr; } }
