/* =========================================================================
   Outfit Preview — style.css
   ========================================================================= */

:root {
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', 'Leelawadee UI', 'Tahoma', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;

  --bg: #08090d;
  --panel: rgba(16, 18, 26, 0.74);
  --panel-solid: #141620;
  --card-bg: #1a1d29;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef0f6;
  --muted: #9ca3b5;
  --dim: #6b7286;

  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-ring: rgba(167, 139, 250, 0.5);
  --grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 48%, #06b6d4 100%);
  --grad-text: linear-gradient(90deg, #c4b5fd, #67e8f9);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;

  --checker: repeating-conic-gradient(#2b2e39 0% 25%, #1f222b 0% 50%) 50% / 16px 16px;

  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7), 0 2px 10px rgba(0, 0, 0, 0.25);
  --blur: saturate(160%) blur(20px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --pad: 14px;
  --top-h: 58px;
  --left-w: 304px;
  --right-w: 364px;
}

@media (max-width: 1240px) {
  :root { --left-w: 272px; --right-w: 336px; }
}
@media (max-width: 1100px) {
  .app[data-layout="desktop"] .brand { width: auto; padding: 0 10px; }
  .app[data-layout="desktop"] .brand-text { display: none; }
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }

svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.app { position: fixed; inset: 0; }

/* panes are moved into containers by JS; hide until placed */
.app > .pane { display: none; }

/* ---------------------------------------------------------------- glass */
.glass {
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- layout vars */
.app {
  --lw: calc(var(--pad) + var(--left-w));
  --rw: calc(var(--pad) + var(--right-w));
  --center-x: calc((var(--lw) + 100vw - var(--rw)) / 2);
}
.app.left-closed  { --lw: 0px; }
.app.right-closed { --rw: 0px; }

/* ---------------------------------------------------------------- stage */
.stage { position: fixed; inset: 0; transition: background 0.5s ease; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

.stage[data-bg="midnight"] { background: radial-gradient(120% 90% at 50% 32%, #262b3c 0%, #131620 46%, #08090d 100%); }
.stage[data-bg="aurora"]   { background: radial-gradient(60% 50% at 25% 18%, rgba(124, 58, 237, 0.38), transparent 70%), radial-gradient(55% 50% at 80% 78%, rgba(8, 145, 178, 0.34), transparent 70%), #0a0b12; }
.stage[data-bg="studio"]   { background: radial-gradient(100% 80% at 50% 30%, #6d7280 0%, #3b3f49 55%, #23252c 100%); }
.stage[data-bg="light"]    { background: radial-gradient(100% 80% at 50% 30%, #ffffff 0%, #eef0f4 50%, #d3d7df 100%); }
.stage[data-bg="checker"]  { background: repeating-conic-gradient(#d9dce3 0% 25%, #ffffff 0% 50%) 50% / 24px 24px; }

.stage-hint {
  position: fixed;
  left: var(--center-x);
  bottom: calc(var(--pad) + 74px);
  transform: translateX(-50%);
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s ease, left 0.35s var(--ease);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
  z-index: 5;
}
.stage-hint.is-hidden { opacity: 0; }
.app[data-tone="light"] .stage-hint { color: rgba(20, 22, 30, 0.55); text-shadow: none; }
.hint-mobile { display: none; }

.stage-loader {
  position: fixed;
  left: var(--center-x);
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 20px 26px;
  border-radius: 18px;
  background: rgba(10, 12, 18, 0.55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  z-index: 15;
  animation: fadeIn 0.25s ease;
  transition: left 0.35s var(--ease);
}
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #a78bfa;
  border-right-color: #22d3ee;
  animation: spin 0.8s linear infinite;
}

/* ---------------------------------------------------------------- boot */
.boot {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(90% 70% at 50% 40%, #1b1f2c 0%, #08090d 100%);
  transition: opacity 0.6s ease, visibility 0.6s;
}
.boot.is-done { opacity: 0; visibility: hidden; }
.boot-logo {
  width: 72px; height: 72px; border-radius: 22px;
  background: var(--grad);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 20px 60px -15px rgba(124, 92, 255, 0.8);
  animation: float 2.4s ease-in-out infinite;
}
.boot-logo svg { width: 40px; height: 40px; stroke-width: 2; }
.boot-bar { width: 180px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; border-radius: 4px; background: var(--grad); animation: indet 1.2s ease-in-out infinite; }
.boot p { margin: 0; color: var(--muted); font-size: 13px; }
.boot.is-error .boot-bar { display: none; }
.boot.is-error p { color: var(--err); max-width: 420px; text-align: center; padding: 0 20px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed;
  top: var(--pad); left: var(--pad); right: var(--pad);
  height: var(--top-h);
  display: flex; align-items: stretch; justify-content: space-between;
  pointer-events: none;
  z-index: 30;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 12px;
  width: var(--left-w);
  padding: 0 14px 0 10px;
  border-radius: 18px;
}
.logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: var(--grad);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 18px -6px rgba(124, 92, 255, 0.85);
}
.logo svg { width: 22px; height: 22px; stroke-width: 2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; }

.model-switch {
  position: absolute;
  top: 0; height: 100%;
  left: calc(var(--center-x) - var(--pad));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 0 6px;
  border-radius: 18px;
  width: clamp(250px, 30vw, 400px);
  transition: left 0.35s var(--ease);
}
.ms-arrow {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: none; border-radius: 11px; background: transparent;
  color: var(--muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ms-arrow:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.ms-arrow:active { transform: scale(0.94); }
.ms-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.ms-cat {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: #c4b5fd;
}
.ms-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ms-text b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-text small { font: 500 11.5px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-title.is-swap .ms-text { animation: swapIn 0.35s var(--ease); }

.top-actions {
  display: flex; align-items: center; gap: 2px;
  padding: 0 7px;
  border-radius: 18px;
}

/* ---------------------------------------------------------------- buttons */
.icon-btn {
  position: relative;
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: none; border-radius: 12px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-pressed="true"] {
  color: #fff;
  background: rgba(139, 92, 246, 0.25);
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.5);
}
.icon-btn-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn-sm svg { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 500; font-size: 13.5px; line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s, transform 0.1s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--line-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-soft { background: rgba(255, 255, 255, 0.05); }
.btn-primary {
  border: none; color: #fff; font-weight: 600;
  background: var(--grad);
  box-shadow: 0 10px 26px -10px rgba(124, 92, 255, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover { filter: brightness(1.1); background: var(--grad); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }

.link-btn {
  border: none; background: none; padding: 2px 4px;
  color: #a5b4fc; font-size: 12.5px; font-weight: 500;
  cursor: pointer; border-radius: 6px;
}
.link-btn:hover { color: #c7d2fe; text-decoration: underline; text-underline-offset: 3px; }

.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
.btn-row-tight { gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- tooltip */
@media (hover: hover) {
  [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%; bottom: calc(100% + 10px);
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 8px;
    background: #0c0e14;
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow);
    color: #fff; font-size: 12px; font-weight: 500; line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    z-index: 60;
    animation: tipIn 0.16s ease 0.25s both;
  }
  .topbar [data-tip]:hover::after { top: calc(100% + 10px); bottom: auto; }
}

/* ---------------------------------------------------------------- segmented */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg button svg { width: 17px; height: 17px; }
.seg button:hover { color: #fff; }
.seg button.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.seg-full { display: flex; width: 100%; }

/* ---------------------------------------------------------------- panels (desktop) */
.panel {
  position: fixed;
  top: calc(var(--pad) * 2 + var(--top-h));
  bottom: var(--pad);
  display: flex; flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  z-index: 20;
  transition: transform 0.4s var(--ease), opacity 0.3s ease;
}
.panel-left  { left: var(--pad);  width: var(--left-w); }
.panel-right { right: var(--pad); width: var(--right-w); }
.app.left-closed  .panel-left  { transform: translateX(calc(-100% - var(--pad) - 20px)); opacity: 0; pointer-events: none; }
.app.right-closed .panel-right { transform: translateX(calc(100% + var(--pad) + 20px));  opacity: 0; pointer-events: none; }
.panel-body {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 18px 16px 20px;
  overscroll-behavior: contain;
}
.seg-tabs { margin: 12px 12px 0; display: flex; }
.seg-tabs button { height: 36px; }

.panel-body, .sheet-body, .modal-body { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.2); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- pane content */
.pane { display: flex; flex-direction: column; gap: 14px; animation: paneIn 0.3s var(--ease); }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pane-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.1px; }
.pane-head p { margin: 2px 0 0; font-size: 12.5px; }
.pane-head p b { color: var(--text); font-weight: 600; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--dim);
}
.section-title em { font-style: normal; font-weight: 500; }

.search {
  display: flex; align-items: center; gap: 9px;
  height: 42px; padding: 0 12px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  color: var(--dim);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search svg { width: 18px; height: 18px; }
.search:focus-within { border-color: rgba(139, 92, 246, 0.6); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); color: #c4b5fd; }
.search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-size: 13.5px; color: var(--text); }
.search input::placeholder { color: var(--dim); }
.search input::-webkit-search-cancel-button { filter: invert(0.7); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 32px; padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: 0.15s;
}
.chip svg { width: 15px; height: 15px; }
.chip em { font-style: normal; font-size: 11px; opacity: 0.6; }
.chip:hover { color: #fff; border-color: var(--line-2); }
.chip.is-active { background: rgba(139, 92, 246, 0.2); border-color: var(--accent-ring); color: #fff; }

/* model cards */
.model-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.model-card {
  position: relative;
  display: flex; flex-direction: column;
  padding: 6px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s;
  animation: cardIn 0.35s var(--ease) both;
}
.model-card:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--line-2); transform: translateY(-2px); }
.model-card:active { transform: scale(0.98); }
.model-card.is-active {
  border-color: transparent;
  background: linear-gradient(var(--card-bg), var(--card-bg)) padding-box, var(--grad) border-box;
  box-shadow: 0 10px 30px -12px rgba(124, 92, 255, 0.7);
}
.mc-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 11px;
  overflow: hidden;
  display: grid; place-items: center;
  background: radial-gradient(75% 70% at 50% 42%, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.01) 72%), rgba(0, 0, 0, 0.18);
}
.mc-thumb img { width: 100%; height: 100%; object-fit: contain; animation: fadeIn 0.45s ease; }
.mc-thumb .mc-ph { color: rgba(255, 255, 255, 0.16); }
.mc-thumb .mc-ph svg { width: 34px; height: 34px; stroke-width: 1.4; }
.mc-thumb.is-loading::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.07) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.mc-tex {
  position: absolute; top: 7px; right: 7px;
  width: 20px; height: 20px; border-radius: 7px;
  background-size: cover; background-position: center;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.mc-del {
  position: absolute; top: 10px; left: 10px;
  width: 26px; height: 26px; border-radius: 8px;
  display: none; place-items: center;
  border: none; background: rgba(10, 10, 14, 0.75); color: #fff;
  cursor: pointer;
}
.mc-del svg { width: 14px; height: 14px; }
.mc-del:hover { background: var(--err); }
.model-card:hover .mc-del { display: grid; }
@media (hover: none) { .mc-del { display: grid; } }
.mc-meta { padding: 8px 5px 4px; min-width: 0; }
.mc-name {
  font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.mc-sub { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.mc-sub code { font: 500 10.5px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
.mc-badge { display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 10.5px; background: rgba(34, 211, 238, 0.14); color: #67e8f9; }

.add-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 120px;
  border-radius: 15px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--muted);
  cursor: pointer; text-align: center;
  font-size: 12.5px;
  transition: 0.18s;
}
.add-card svg { width: 26px; height: 26px; color: #a78bfa; }
.add-card small { font: 500 10.5px var(--mono); color: var(--dim); }
.add-card:hover { border-color: #a78bfa; background: rgba(139, 92, 246, 0.08); color: #fff; }
.empty-note { margin: 0; text-align: center; color: var(--dim); font-size: 13px; padding: 20px 0; }

/* dropzone */
.dropzone {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border-radius: 17px;
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(6, 182, 212, 0.05));
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.dropzone:hover, .dropzone.is-over {
  border-color: #a78bfa;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(6, 182, 212, 0.1));
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
}
.dz-icon {
  width: 46px; height: 46px; flex: none;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  box-shadow: 0 10px 22px -8px rgba(124, 92, 255, 0.85);
}
.dz-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.dz-icon-lg { width: 72px; height: 72px; border-radius: 22px; }
.dz-icon-lg svg { width: 34px; height: 34px; }
.dz-text { min-width: 0; }
.dz-text b { display: block; font-size: 14px; font-weight: 600; line-height: 1.4; }
.dz-text u { color: #c4b5fd; text-decoration-color: rgba(167, 139, 250, 0.6); text-underline-offset: 3px; }
.dz-text small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }

.helper { margin: -6px 0 0; font-size: 11.5px; color: var(--dim); line-height: 1.5; }

/* live bar */
.live-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 14px;
  border-radius: 14px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.35);
  animation: paneIn 0.3s var(--ease);
}
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #22d3ee; flex: none; box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); animation: pulse 1.6s infinite; }
.live-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.live-text b { font-size: 13px; color: #a5f3fc; }
.live-text small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* current texture */
.current-tex {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.ct-thumb, .ns-thumb {
  width: 54px; height: 54px; flex: none;
  border-radius: 11px;
  background: var(--checker);
  background-size: cover; background-position: center;
  border: 1px solid var(--line-2);
  overflow: hidden;
}
.ct-thumb.is-clay { background: radial-gradient(circle at 35% 30%, #f5f1ea, #b9b2a6 55%, #6f6a62); }
.ct-meta, .ns-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.ct-meta b, .ns-meta b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-meta small, .ns-meta small { font-size: 11.5px; color: var(--muted); }

/* texture grid */
.tex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.tex-card {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--checker);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
  animation: cardIn 0.3s var(--ease) both;
}
.tex-card:hover { transform: translateY(-2px); }
.tex-card.is-active { box-shadow: 0 0 0 2px var(--panel-solid), 0 0 0 4px #a78bfa; }
.tc-img { position: absolute; inset: 0; background-size: cover; background-position: center; }
.tc-img.is-clay { background: radial-gradient(circle at 35% 30%, #f5f1ea, #b9b2a6 55%, #6f6a62); }
.tc-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 6px 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: #fff; font-size: 10.5px; font-weight: 500; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 7px;
  display: none; place-items: center;
  background: rgba(10, 10, 14, 0.72); color: #fff;
}
.tc-del svg { width: 13px; height: 13px; }
.tc-del:hover { background: var(--err); }
.tex-card:hover .tc-del { display: grid; }
@media (hover: none) { .tc-del { display: grid; } }
.tc-badge {
  position: absolute; top: 4px; left: 4px;
  padding: 1px 5px; border-radius: 5px;
  font: 700 9px/1.4 var(--mono); letter-spacing: 0.5px;
  background: #06b6d4; color: #001318;
}
.tex-add {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: 0.15s;
}
.tex-add:hover { border-color: #a78bfa; color: #fff; background: rgba(139, 92, 246, 0.08); }

/* groups */
.group {
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.group summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  border-radius: 15px;
}
.group summary::-webkit-details-marker { display: none; }
.group summary > svg:first-child { width: 18px; height: 18px; color: #a78bfa; }
.group summary .chev { margin-left: auto; width: 18px; height: 18px; color: var(--muted); transition: transform 0.25s var(--ease); }
.group[open] summary .chev { transform: rotate(180deg); }
.group-body { display: flex; flex-direction: column; gap: 12px; padding: 0 14px 16px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; min-height: 26px; }
.field-top b { font-weight: 500; }
output {
  font: 500 11.5px/1 var(--mono);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 5px 7px;
  border-radius: 7px;
  min-width: 42px; text-align: center;
}
.color-wrap { display: inline-flex; align-items: center; gap: 8px; }

.field-switch {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 3px 0;
  cursor: pointer;
}
.field-switch > span { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.field-switch > span b { font-size: 13px; font-weight: 500; }
.field-switch > span small { font-size: 11.5px; color: var(--dim); }
.field-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative; flex: none;
  width: 42px; height: 25px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.13);
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1.3);
}
.field-switch input:checked + .switch { background: var(--grad); }
.field-switch input:checked + .switch::after { transform: translateX(17px); }
.field-switch input:focus-visible + .switch { outline: 2px solid #a78bfa; outline-offset: 2px; }

.chip-toggle { position: relative; cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12.5px; color: var(--muted);
  transition: 0.15s;
}
.chip-toggle span::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2); transition: 0.15s;
}
.chip-toggle input:checked + span { color: #fff; border-color: var(--accent-ring); background: rgba(139, 92, 246, 0.16); }
.chip-toggle input:checked + span::before { background: #22d3ee; box-shadow: 0 0 8px #22d3ee; }
.chip-toggle input:focus-visible + span { outline: 2px solid #a78bfa; outline-offset: 2px; }

/* range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; --p: 50%; }
.range:focus { outline: none; }
.range::-webkit-slider-runnable-track {
  height: 5px; border-radius: 5px;
  background: linear-gradient(90deg, #a78bfa, #22d3ee) 0 / var(--p) 100% no-repeat, rgba(255, 255, 255, 0.12);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; margin-top: -6.5px;
  border-radius: 50%; border: none; background: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.28), 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.15s;
}
.range:active::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 7px rgba(139, 92, 246, 0.3), 0 2px 6px rgba(0, 0, 0, 0.45); }
.range::-moz-range-track { height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); }
.range::-moz-range-progress { height: 5px; border-radius: 5px; background: linear-gradient(90deg, #a78bfa, #22d3ee); }
.range::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.28), 0 2px 6px rgba(0, 0, 0, 0.45); }

/* color */
input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 36px; height: 28px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: none; cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

/* select */
.select-wrap { position: relative; }
.select-wrap select {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 40px;
  padding: 0 38px 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
}
.select-wrap select:focus { outline: none; border-color: rgba(139, 92, 246, 0.6); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.select-wrap select option { background: #161922; color: var(--text); }
.select-wrap svg { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }

/* normal slot */
.normal-slot { display: flex; align-items: center; gap: 12px; }
.ns-thumb { width: 46px; height: 46px; }

/* card block */
.card-block {
  display: flex; flex-direction: column; gap: 12px;
  padding: 15px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.card-block h3 { margin: 0; display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.card-block h3 svg { width: 18px; height: 18px; color: #a78bfa; }
.card-block > p { margin: -6px 0 0; line-height: 1.55; }

/* uv preview */
.uv-view {
  position: relative;
  width: min(100%, calc(48vh * var(--uv-aspect, 1)));
  aspect-ratio: var(--uv-aspect, 1);
  margin: 0 auto;
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--checker);
  cursor: zoom-in;
}
.uv-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.uv-view::after {
  content: 'แตะเพื่อขยาย';
  position: absolute; right: 8px; bottom: 8px;
  padding: 3px 8px; border-radius: 7px;
  font-size: 11px; color: #fff;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.uv-view:hover::after { opacity: 1; }

/* swatches / lights */
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: none; background: none;
  color: var(--muted); font-size: 11px; cursor: pointer;
}
.swatch i {
  width: 44px; height: 44px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: box-shadow 0.18s, transform 0.18s var(--ease);
}
.swatch:hover i { transform: scale(1.06); }
.swatch.is-active { color: #fff; }
.swatch.is-active i { box-shadow: 0 0 0 2px var(--panel-solid), 0 0 0 4px #a78bfa; }

.light-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.light-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-align: left; cursor: pointer;
  transition: 0.18s;
}
.light-card:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.06); }
.light-card.is-active { border-color: var(--accent-ring); background: rgba(139, 92, 246, 0.15); }
.light-card i { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.light-card span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.light-card b { font-size: 13px; font-weight: 600; }
.light-card small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* info list */
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 12.5px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; text-align: right; font-weight: 500; word-break: break-all; }
.info-list dd code { font: 500 12px var(--mono); }
.orient { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.orient .field-top small { font-size: 11.5px; }
.orient .seg button { padding: 0 6px; font-size: 12.5px; }

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  position: fixed;
  left: var(--center-x);
  bottom: calc(var(--pad) + 4px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 3px;
  padding: 5px;
  border-radius: 18px;
  z-index: 25;
  transition: left 0.35s var(--ease);
}
.seg-views { background: transparent; border: none; padding: 0; }
.seg-views button { height: 40px; padding: 0 14px; border-radius: 12px; }
.tb-sep { width: 1px; height: 24px; margin: 0 4px; background: var(--line-2); }
#tbViewCycle em {
  position: absolute; left: 0; right: 0; bottom: 2px;
  font-style: normal; font-size: 9px; font-weight: 600; line-height: 1;
  color: #c4b5fd;
}
#tbViewCycle svg { transform: translateY(-4px); }

/* ---------------------------------------------------------------- sheet (mobile) */
.sheet { display: none; }

/* ---------------------------------------------------------------- overlays */
.drop-overlay {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  background: rgba(8, 9, 13, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.18s ease;
}
.drop-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 44px 56px;
  border-radius: 28px;
  border: 2px dashed rgba(167, 139, 250, 0.75);
  background: rgba(139, 92, 246, 0.1);
  text-align: center;
  animation: popIn 0.3s var(--ease);
}
.drop-card b { font-size: 20px; }
.drop-card small { color: var(--muted); font-size: 13px; }

.modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 8, 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fadeIn 0.2s ease; }
.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86vh, 820px);
  display: flex; flex-direction: column;
  border-radius: 22px;
  background: rgba(18, 20, 29, 0.92);
  overflow: hidden;
  animation: popIn 0.3s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 10px 22px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-tools { display: flex; gap: 2px; }
.modal-body { padding: 4px 22px 22px; overflow: auto; }
.modal-wide .modal-card { width: min(1100px, 100%); height: min(90vh, 1100px); max-height: none; }

.steps { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.steps li > span { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--grad); font-weight: 700; color: #fff; }
.steps li div { display: flex; flex-direction: column; line-height: 1.45; }
.steps li b { font-size: 14px; }
.steps li small { color: var(--muted); font-size: 12.5px; }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; font-size: 12.5px; color: var(--muted); }
.kbd-grid div { display: flex; align-items: center; gap: 5px; }
.kbd-grid span { margin-left: 6px; }
kbd {
  display: inline-block; min-width: 24px; padding: 3px 7px;
  border-radius: 7px;
  font: 600 11px/1.3 var(--font); text-align: center; color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line-2); border-bottom-width: 2px;
}
.note { margin: 18px 0 0; line-height: 1.6; }

.uv-big {
  position: relative; flex: 1; min-height: 0;
  margin: 0 14px 14px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--checker);
  border: 1px solid var(--line);
  touch-action: none;
  cursor: grab;
}
.uv-big:active { cursor: grabbing; }
.uv-big canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; image-rendering: auto; }

/* toasts */
.toasts {
  position: fixed;
  left: var(--center-x, 50%);
  bottom: calc(var(--pad) + 78px);
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 8px;
  z-index: 150;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  max-width: min(440px, 90vw);
  padding: 10px 16px 10px 12px;
  border-radius: 14px;
  background: rgba(18, 20, 29, 0.94);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.4;
  animation: toastIn 0.35s var(--ease);
  pointer-events: auto;
}
.toast i { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 700; color: #07120d; background: var(--ok); }
.toast.is-error i { background: var(--err); color: #1a0606; }
.toast.is-info i { background: #a78bfa; color: #120a24; }
.toast.is-warn i { background: var(--warn); color: #1a1205; }
.toast.is-leaving { animation: toastOut 0.3s ease forwards; }

.flash { position: fixed; inset: 0; z-index: 140; background: #fff; opacity: 0; pointer-events: none; }
.flash.is-on { animation: flash 0.5s ease; }

/* ======================================================================
   MOBILE LAYOUT
   ====================================================================== */
.app[data-layout="mobile"] { --pad: 10px; --top-h: 52px; --center-x: 50vw; }
[data-layout="mobile"] .desktop-only { display: none !important; }
[data-layout="desktop"] .mobile-only { display: none !important; }
[data-layout="mobile"] .hint-desktop { display: none; }
[data-layout="mobile"] .hint-mobile { display: inline; }
[data-layout="mobile"] .panel { display: none; }

[data-layout="mobile"] .topbar {
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  gap: 8px;
}
[data-layout="mobile"] .brand { width: auto; padding: 0 6px; border-radius: 16px; }
[data-layout="mobile"] .brand-text { display: none; }
[data-layout="mobile"] .logo { width: 38px; height: 38px; }
[data-layout="mobile"] .model-switch {
  position: relative; left: auto; transform: none;
  flex: 1; min-width: 0; width: auto;
  padding: 0 3px; border-radius: 16px;
}
[data-layout="mobile"] .ms-cat { width: 32px; height: 32px; border-radius: 10px; }
[data-layout="mobile"] .ms-cat svg { width: 18px; height: 18px; }
[data-layout="mobile"] .ms-title { gap: 8px; padding: 0 2px; }
[data-layout="mobile"] .ms-text b { font-size: 13.5px; }
[data-layout="mobile"] .ms-arrow { width: 34px; height: 40px; }
[data-layout="mobile"] .top-actions { padding: 0 4px; border-radius: 16px; }
[data-layout="mobile"] .top-actions .icon-btn { width: 38px; height: 40px; }

[data-layout="mobile"] .toolbar {
  left: auto;
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  bottom: auto;
  transform: none;
  flex-direction: column;
  gap: 2px; padding: 4px;
  border-radius: 16px;
}
[data-layout="mobile"] .toolbar .icon-btn { width: 42px; height: 42px; }

[data-layout="mobile"] .stage-hint { left: 50%; bottom: calc(var(--sheet-peek, 90px) + 16px); font-size: 12px; }
[data-layout="mobile"] .stage-loader { left: 50%; top: 42%; }
@media (max-width: 900px) {
  .toasts { left: calc(50% - 26px); top: calc(env(safe-area-inset-top, 0px) + 70px); bottom: auto; flex-direction: column; }
  .toast { max-width: calc(100vw - 92px); }
}

[data-layout="mobile"] .sheet {
  display: flex; flex-direction: column;
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--sheet-full, 80vh);
  transform: translate3d(0, calc(var(--sheet-full, 80vh) - var(--sheet-vis, 90px)), 0);
  border-radius: 24px 24px 0 0;
  border-bottom: none;
  background: rgba(15, 17, 25, 0.86);
  z-index: 40;
  transition: transform 0.42s var(--ease);
  will-change: transform;
}
[data-layout="mobile"] .sheet.is-dragging { transition: none; }
.sheet-head { flex: none; touch-action: none; cursor: grab; }
.sheet-grip { display: grid; place-items: center; height: 18px; }
.sheet-grip span { width: 40px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.22); }
.sheet-tabs { display: flex; gap: 4px; padding: 0 10px 10px; }
.sheet-tabs button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 54px;
  border: none; border-radius: 14px;
  background: transparent; color: var(--muted);
  font-size: 11.5px; font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.sheet-tabs button svg { width: 21px; height: 21px; }
.sheet-tabs button.is-active { color: #fff; background: rgba(139, 92, 246, 0.2); }
.sheet-tabs button.is-active svg { color: #c4b5fd; }
.sheet:not(.is-open) .sheet-tabs button.is-active { background: transparent; color: #c4b5fd; }
.sheet-body {
  flex: none;
  height: var(--sheet-body-h, 0px);
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 16px 28px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
[data-layout="mobile"] .sheet::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0;
  height: env(safe-area-inset-bottom, 0px);
}

[data-layout="mobile"] .model-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
[data-layout="mobile"] .mc-name { font-size: 12.5px; }
[data-layout="mobile"] .tex-grid { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
[data-layout="mobile"] .pane-head h2 { font-size: 16px; }
[data-layout="mobile"] .range::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -8.5px; }
[data-layout="mobile"] .range::-moz-range-thumb { width: 22px; height: 22px; }
[data-layout="mobile"] .uv-view { width: min(100%, calc(40vh * var(--uv-aspect, 1))); }
[data-layout="mobile"] .uv-view::after { content: 'แตะเพื่อขยาย'; opacity: 1; }
[data-layout="mobile"] .modal { padding: 10px; align-items: end; }
[data-layout="mobile"] .modal-card { max-height: 88vh; border-radius: 22px; }
[data-layout="mobile"] .modal-wide .modal-card { height: 88vh; }
[data-layout="mobile"] .drop-card { padding: 32px 28px; margin: 20px; }

@media (max-width: 380px) {
  [data-layout="mobile"] .brand { display: none; }
  .swatch i { width: 38px; height: 38px; }
}

/* ======================================================================
   CHECKER
   ====================================================================== */
.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); color: var(--text); z-index: 999; font-size: 15px; }

.check-card {
  --st: #a78bfa;
  scroll-margin: 10px;
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  transition: border-color 0.25s, box-shadow 0.25s;
}
.check-card[data-state="pass"] { --st: var(--ok); }
.check-card[data-state="warn"] { --st: var(--warn); }
.check-card[data-state="fail"] { --st: var(--err); }
.check-card[data-state="pass"], .check-card[data-state="warn"], .check-card[data-state="fail"] {
  border-color: color-mix(in srgb, var(--st) 45%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--st) 12%, transparent), 0 14px 40px -24px color-mix(in srgb, var(--st) 70%, transparent);
  animation: popIn 0.35s var(--ease);
}
.cc-head { display: flex; align-items: center; gap: 12px; }
.cc-badge {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--st) 18%, transparent);
  color: var(--st);
}
.cc-badge svg { width: 24px; height: 24px; }
.cc-ico-state { display: none; width: 28px; height: 28px; border-radius: 50%; place-items: center; background: var(--st); color: #0b0d12; font-size: 15px; font-weight: 800; line-height: 1; }
.check-card[data-state="pass"] .cc-ico-state::before { content: '✓'; }
.check-card[data-state="warn"] .cc-ico-state::before { content: '!'; }
.check-card[data-state="fail"] .cc-ico-state::before { content: '✕'; }
.check-card:is([data-state="pass"], [data-state="warn"], [data-state="fail"]) .cc-ico-state { display: grid; }
.check-card:is([data-state="pass"], [data-state="warn"], [data-state="fail"]) .cc-ico-empty { display: none; }
.cc-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.cc-title b { font-size: 15px; font-weight: 700; }
.check-card:is([data-state="pass"], [data-state="warn"], [data-state="fail"]) .cc-title b { color: var(--st); }
.cc-title small { font-size: 12px; color: var(--muted); }

.cc-label { display: block; margin-bottom: 7px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px; color: var(--dim); }
.cc-rules { padding: 11px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.18); }
.cc-rules .info-list { gap: 5px 12px; font-size: 12px; }

.cc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cc-list:empty { display: none; }
.cc-item { --c: var(--ok); display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px; border-radius: 11px; }
.cc-item.is-warn { --c: var(--warn); background: rgba(251, 191, 36, 0.06); }
.cc-item.is-fail { --c: var(--err); background: rgba(248, 113, 113, 0.08); }
.cc-item.is-info { --c: #a78bfa; }
.cc-item > i {
  width: 20px; height: 20px; flex: none; margin-top: 1px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--c); color: #0b0d12;
  font: 800 11px/1 var(--font); font-style: normal;
}
.cc-item > div { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; align-items: baseline; }
.cc-item b { font-size: 13px; font-weight: 600; }
.cc-item span { font-size: 12.5px; color: var(--c); font-weight: 600; text-align: right; }
.cc-item.is-ok span { color: var(--muted); font-weight: 500; }
.cc-item small { grid-column: 1 / -1; font-size: 12px; color: var(--muted); line-height: 1.5; }
.cc-item .link-btn { align-self: center; white-space: nowrap; font-size: 12px; }

.cc-manual { padding-top: 4px; border-top: 1px dashed var(--line-2); }
.cc-manual .cc-label { margin-top: 10px; }
.cc-tick { display: flex; align-items: flex-start; gap: 10px; padding: 6px 2px; cursor: pointer; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.cc-tick input { position: absolute; opacity: 0; pointer-events: none; }
.cc-tick .box {
  width: 20px; height: 20px; flex: none; margin-top: 0;
  display: grid; place-items: center;
  border-radius: 6px; border: 1.5px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s, border-color 0.15s;
}
.cc-tick .box svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 3.2; opacity: 0; transform: scale(0.6); transition: 0.15s var(--ease); }
.cc-tick input:checked + .box { background: var(--accent); border-color: #a78bfa; }
.cc-tick input:checked + .box svg { opacity: 1; transform: none; }
.cc-tick input:checked ~ span { color: var(--text); }
.cc-tick input:focus-visible + .box { outline: 2px solid #a78bfa; outline-offset: 2px; }
.cc-tick:hover .box { border-color: var(--accent-ring); }

.cc-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.cc-submit { text-decoration: none; color: var(--text); }
.cc-submit.is-ready { background: linear-gradient(135deg, #10b981, #0891b2); border-color: transparent; color: #fff; }
.cc-note { margin: 0; }

.uv-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; }
.uv-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.lg-red { background: #ff2828; }
.lg-pink { background: #ff40d6; }

/* verdict pill on the stage */
.verdict-pill {
  --st: var(--ok);
  position: fixed;
  left: var(--center-x);
  top: calc(var(--pad) + var(--top-h) + 12px);
  transform: translateX(-50%);
  z-index: 6;
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--st) 55%, transparent);
  background: color-mix(in srgb, var(--st) 14%, rgba(14, 16, 23, 0.82));
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  color: var(--text);
  font: 600 13px var(--font);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: left 0.35s var(--ease), background 0.2s;
  animation: popIn 0.35s var(--ease);
}
.verdict-pill[data-state="warn"] { --st: var(--warn); }
.verdict-pill[data-state="fail"] { --st: var(--err); }
.verdict-pill i { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--st); color: #0b0d12; font: 800 12px/1 var(--font); font-style: normal; }
.verdict-pill svg { width: 15px; height: 15px; opacity: 0.6; }
.verdict-pill:hover { background: color-mix(in srgb, var(--st) 24%, rgba(14, 16, 23, 0.86)); }
.verdict-pill[hidden] { display: none; }
[data-layout="mobile"] .verdict-pill { left: 50%; top: auto; bottom: calc(var(--sheet-peek, 90px) + 14px); }
[data-layout="mobile"] .stage-hint { bottom: calc(var(--sheet-peek, 90px) + 62px); }
[data-layout="mobile"] .sheet.is-open ~ .verdict-pill,
.app[data-layout="mobile"]:has(.sheet.is-open) .verdict-pill { opacity: 0; pointer-events: none; }

/* ======================================================================
   ANIMATIONS
   ====================================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes paneIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes swapIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes tipIn { from { opacity: 0; transform: translate(-50%, 3px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.97); } }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.65); } 70% { box-shadow: 0 0 0 9px rgba(34, 211, 238, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); } }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 0.55; } 100% { opacity: 0; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes indet { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
