:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-deep: #e9ebef;
  --surface: rgba(255,255,255,.72);
  --surface-strong: rgba(255,255,255,.94);
  --surface-solid: #ffffff;
  --glass-border: rgba(255,255,255,.72);
  --border: rgba(20,25,34,.09);
  --border-strong: rgba(20,25,34,.15);
  --text: #151820;
  --muted: #6f7580;
  --muted-2: #989da6;
  --accent: #4462ff;
  --accent-soft: rgba(68,98,255,.10);
  --accent-pressed: #304be1;
  --success: #22a06b;
  --danger: #d84b4b;
  --shadow-soft: 0 10px 35px rgba(20,25,34,.09);
  --shadow-float: 0 20px 60px rgba(20,25,34,.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f13;
  --bg-deep: #090b0e;
  --surface: rgba(22,25,31,.72);
  --surface-strong: rgba(22,25,31,.94);
  --surface-solid: #16191f;
  --glass-border: rgba(255,255,255,.09);
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.16);
  --text: #f4f6fa;
  --muted: #a0a7b3;
  --muted-2: #717985;
  --accent: #7d91ff;
  --accent-soft: rgba(125,145,255,.13);
  --accent-pressed: #9aaaFF;
  --success: #53c28b;
  --danger: #ff7373;
  --shadow-soft: 0 12px 38px rgba(0,0,0,.22);
  --shadow-float: 0 22px 70px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(68,98,255,.25); outline-offset: 2px; }

.app-shell { position: relative; width: 100%; height: 100%; background: var(--bg); }
.viewer-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 52% 35%, rgba(255,255,255,.95) 0, rgba(255,255,255,.45) 30%, transparent 61%),
    linear-gradient(155deg, var(--bg) 0%, var(--bg-deep) 100%);
}
:root[data-theme="dark"] .viewer-stage {
  background:
    radial-gradient(circle at 52% 35%, rgba(58,66,80,.34) 0, rgba(28,32,40,.18) 36%, transparent 62%),
    linear-gradient(155deg, #12151b 0%, #080a0d 100%);
}
.stage-glow { position: absolute; z-index: 0; border-radius: 50%; filter: blur(2px); pointer-events: none; opacity: .72; }
.stage-glow-a { width: min(60vw, 720px); aspect-ratio: 1; left: -22%; top: 12%; background: radial-gradient(circle, rgba(68,98,255,.09), transparent 68%); }
.stage-glow-b { width: min(48vw, 580px); aspect-ratio: 1; right: -17%; bottom: -12%; background: radial-gradient(circle, rgba(137,156,255,.10), transparent 68%); }
:root[data-theme="dark"] .stage-glow-a { background: radial-gradient(circle, rgba(91,113,255,.11), transparent 68%); }
:root[data-theme="dark"] .stage-glow-b { background: radial-gradient(circle, rgba(67,82,170,.09), transparent 68%); }
.floor-grid {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -27%;
  width: 130%;
  height: 55%;
  transform: translateX(-50%) perspective(500px) rotateX(63deg);
  transform-origin: center bottom;
  opacity: .24;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to top, rgba(0,0,0,.7), transparent 74%);
  pointer-events: none;
}
model-viewer { position: relative; z-index: 1; width: 100%; height: 100%; background: transparent; --poster-color: transparent; outline: none; }
.mv-progress-slot { display: none; }

.topbar {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(12px + var(--safe-top)) calc(14px + var(--safe-right)) 12px calc(14px + var(--safe-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.brand-pill, .top-actions { pointer-events: auto; }
.brand-pill {
  min-width: 0;
  max-width: min(66vw, 520px);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 13px 7px 8px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
}
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--text), color-mix(in srgb, var(--text) 74%, transparent));
  color: var(--bg);
}
.brand-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.brand-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; line-height: 1.05; }
.brand-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.brand-copy strong { font-size: 13px; letter-spacing: -.015em; white-space: nowrap; }
.brand-copy > span { max-width: min(46vw, 390px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.viewer-badge { padding: 3px 5px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.glass-button {
  width: 43px;
  height: 43px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.glass-button:active { transform: scale(.94); }
.glass-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }

.model-status {
  position: absolute;
  z-index: 19;
  left: calc(14px + var(--safe-left));
  bottom: calc(18px + var(--safe-bottom));
  min-height: 34px;
  max-width: min(52vw, 280px);
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 10.5px;
  font-weight: 650;
  pointer-events: none;
}
.status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 12%, transparent); }
.status-separator { width: 1px; height: 12px; background: var(--border-strong); }
#modelStatusText, #modelSourceLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.control-dock {
  position: absolute;
  z-index: 22;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(67px, 1fr));
  gap: 5px;
  width: min(calc(100vw - 120px), 390px);
  padding: 6px;
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(24px) saturate(1.16);
  -webkit-backdrop-filter: blur(24px) saturate(1.16);
}
.control-button {
  min-width: 0;
  min-height: 58px;
  padding: 7px 5px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}
.control-button:active { transform: scale(.96); }
.control-button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.control-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.control-button span { font-size: 10.5px; font-weight: 720; white-space: nowrap; }

.loading-panel, .error-panel {
  position: absolute;
  z-index: 40;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(88vw, 390px);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(26px) saturate(1.18);
  -webkit-backdrop-filter: blur(26px) saturate(1.18);
}
.loading-panel { padding: 27px 26px 24px; display: grid; grid-template-columns: 58px 1fr; gap: 16px; align-items: center; }
.loading-orbit { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--accent-soft); position: relative; overflow: hidden; }
.loading-orbit::after { content: ""; position: absolute; width: 44px; height: 16px; border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent); border-radius: 50%; transform: rotate(-19deg); animation: orbitSpin 1.8s linear infinite; }
.loading-cube { position: relative; width: 22px; height: 22px; transform: rotate(30deg) skewY(-8deg); }
.loading-cube span { position: absolute; inset: 0; border: 1.5px solid var(--accent); border-radius: 3px; opacity: .95; }
.loading-cube span:nth-child(2) { transform: translate(5px,-5px); opacity: .55; }
.loading-cube span:nth-child(3) { transform: translate(-5px,5px); opacity: .28; }
@keyframes orbitSpin { to { transform: rotate(341deg); } }
.loading-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.loading-kicker, .error-kicker { color: var(--accent); font-size: 9px; font-weight: 850; letter-spacing: .14em; }
.loading-copy strong { font-size: 16px; letter-spacing: -.02em; }
.loading-copy > span:last-child { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.loading-progress-row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 36px; align-items: center; gap: 9px; margin-top: 2px; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: var(--border); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, white)); transition: width .16s ease; }
.progress-value { text-align: right; color: var(--muted); font-size: 10px; font-weight: 760; font-variant-numeric: tabular-nums; }

.error-panel { padding: 27px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 9px; }
.error-icon { width: 48px; height: 48px; margin-bottom: 4px; display: grid; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.error-icon svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.error-kicker { color: var(--danger); }
.error-panel strong { font-size: 18px; letter-spacing: -.02em; }
.error-panel p { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.error-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
.primary-button, .secondary-button {
  min-height: 46px;
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 760;
  font-size: 12.5px;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.primary-button { border: 0; background: var(--text); color: var(--bg); }
.primary-button:active, .secondary-button:active { transform: scale(.98); }
.secondary-button { border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); }
.secondary-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.touch-hint {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
  width: max-content;
  max-width: 91vw;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px;
  background: rgba(18,21,27,.84);
  color: #fff;
  box-shadow: 0 12px 38px rgba(0,0,0,.22);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 10.5px;
  animation: hintIn .25s ease both;
}
.touch-hint span + span::before { content: "·"; margin-right: 7px; color: #8f97a3; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.ready-toast {
  position: absolute;
  z-index: 36;
  left: 50%;
  top: calc(78px + var(--safe-top));
  transform: translateX(-50%);
  min-height: 40px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  animation: toastIn .25s ease both;
}
.ready-toast svg { width: 18px; height: 18px; fill: none; stroke: var(--success); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty-state {
  position: absolute;
  z-index: 35;
  inset: 0;
  padding: calc(88px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  overflow: auto;
  touch-action: pan-y;
  display: grid;
  place-items: center;
}
.empty-card {
  width: min(100%, 540px);
  padding: 30px;
  border: 1px solid var(--glass-border);
  border-radius: 30px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(28px) saturate(1.14);
  -webkit-backdrop-filter: blur(28px) saturate(1.14);
}
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .14em; }
.eyebrow span { width: 22px; height: 1px; background: var(--accent); }
.empty-mark { width: 58px; height: 58px; margin-bottom: 19px; display: grid; place-items: center; border-radius: 18px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-soft); }
.empty-mark svg { width: 29px; height: 29px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-card h1 { margin: 0; font-size: clamp(28px, 6vw, 42px); line-height: 1.02; letter-spacing: -.05em; }
.empty-card h1 span { color: var(--muted-2); font-weight: 620; }
.empty-card > p { max-width: 440px; margin: 14px 0 25px; color: var(--muted); line-height: 1.55; font-size: 13px; }
.url-form label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10.5px; font-weight: 780; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.url-row input { width: 100%; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 14px; outline: 0; color: var(--text); background: var(--surface-solid); }
.url-row input::placeholder { color: var(--muted-2); }
.url-row input:focus { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 0 4px var(--accent-soft); }
.or-separator { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted-2); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.or-separator::before, .or-separator::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.file-button { width: 100%; }
.empty-feature-row { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.empty-feature-row span { padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 9.5px; font-weight: 700; }

.help-sheet, .visual-sheet { position: fixed; z-index: 70; inset: 0; display: grid; align-items: end; }
.sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgba(8,10,14,.46); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet-card {
  position: relative;
  width: min(100%, 590px);
  max-height: min(82vh, 690px);
  margin: 0 auto;
  padding: 10px 20px calc(22px + var(--safe-bottom));
  overflow: auto;
  border: 1px solid var(--glass-border);
  border-bottom: 0;
  border-radius: 30px 30px 0 0;
  background: var(--surface-strong);
  box-shadow: 0 -24px 70px rgba(8,10,14,.22);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  touch-action: pan-y;
  animation: sheetIn .24s ease both;
}
@keyframes sheetIn { from { transform: translateY(20px); opacity: .3; } to { transform: translateY(0); opacity: 1; } }
.sheet-handle { width: 42px; height: 4px; margin: 1px auto 17px; border-radius: 99px; background: var(--border-strong); }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sheet-header > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sheet-kicker { color: var(--accent); font-size: 9px; font-weight: 850; letter-spacing: .14em; }
.sheet-header strong { font-size: 19px; letter-spacing: -.025em; }
.sheet-header > div > span:last-child { max-width: 72vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.sheet-close { width: 40px; height: 40px; flex: 0 0 40px; box-shadow: none; }
.sheet-meta { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-meta > div { min-width: 0; padding: 12px 13px; border: 1px solid var(--border); border-radius: 15px; background: color-mix(in srgb, var(--surface-solid) 55%, transparent); display: flex; flex-direction: column; gap: 4px; }
.sheet-meta span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.sheet-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.gesture-list { margin-top: 17px; display: grid; gap: 8px; }
.gesture-list > div { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 16px; background: color-mix(in srgb, var(--surface-solid) 60%, transparent); }
.gesture-glyph { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: 9px; font-weight: 850; letter-spacing: .05em; }
.gesture-list p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.gesture-list strong { color: var(--text); }
.sheet-footnote { margin: 15px 2px 0; color: var(--muted-2); font-size: 10.5px; line-height: 1.5; }

[hidden] { display: none !important; }

@media (hover: hover) and (pointer: fine) {
  .glass-button:hover { background: var(--surface-strong); border-color: var(--border-strong); transform: translateY(-1px); }
  .control-button:hover { background: var(--accent-soft); color: var(--accent); }
  .primary-button:hover { filter: brightness(1.04); }
  .secondary-button:hover { border-color: var(--border-strong); background: var(--surface-strong); }
}

@media (orientation: landscape) and (max-height: 650px) {
  .topbar { right: auto; width: min(520px, 78vw); }
  .brand-pill { max-width: min(55vw, 420px); }
  .control-dock {
    left: auto;
    right: calc(13px + var(--safe-right));
    bottom: 50%;
    transform: translateY(50%);
    width: 72px;
    grid-template-columns: 1fr;
    padding: 6px;
    border-radius: 22px;
  }
  .control-button { min-height: 57px; }
  .model-status { left: calc(13px + var(--safe-left)); bottom: calc(12px + var(--safe-bottom)); }
  .touch-hint { bottom: calc(12px + var(--safe-bottom)); }
}

@media (max-width: 560px) {
  .brand-pill { max-width: calc(100vw - 174px); padding-right: 10px; }
  .brand-mark { width: 36px; height: 36px; flex-basis: 36px; }
  .brand-copy strong { font-size: 12px; }
  .brand-copy > span { font-size: 10.5px; }
  .top-actions { gap: 5px; }
  .glass-button { width: 40px; height: 40px; border-radius: 14px; }
  .control-dock { width: min(calc(100vw - 20px), 390px); }
  .model-status { display: none; }
  .empty-card { padding: 25px 21px; }
}

@media (max-width: 390px) {
  .topbar { padding-left: calc(9px + var(--safe-left)); padding-right: calc(9px + var(--safe-right)); }
  .brand-pill { max-width: calc(100vw - 145px); border-radius: 16px; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 11px; }
  .brand-line strong { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  .viewer-badge { display: none; }
  .glass-button { width: 38px; height: 38px; }
  .glass-button svg { width: 19px; height: 19px; }
  .control-dock { bottom: calc(8px + var(--safe-bottom)); width: calc(100vw - 16px); }
  .control-button { min-height: 54px; }
  .control-button span { font-size: 9.5px; }
  .loading-panel { width: calc(100vw - 26px); padding: 22px; grid-template-columns: 50px 1fr; }
  .loading-orbit { width: 50px; height: 50px; }
  .empty-card h1 { font-size: 30px; }
  .url-row { grid-template-columns: 1fr; }
  .url-row .primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* v0.3 Visual Pro controls */
.pro-button { position: relative; }
.pro-dot {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.glass-button:disabled,
.tool-button:disabled,
.preset-button:disabled,
.text-button:disabled { opacity: .42; cursor: default; transform: none !important; }

.visual-sheet { position: fixed; z-index: 72; inset: 0; display: grid; align-items: end; }
.visual-card { width: min(100%, 680px); max-height: min(88vh, 820px); overflow: hidden; display: flex; flex-direction: column; }
.visual-card > .sheet-header { flex: 0 0 auto; padding-bottom: 2px; }
.visual-scroll {
  margin: 16px -4px 0;
  padding: 0 4px 5px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.settings-section {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface-solid) 62%, transparent);
}
.settings-section + .settings-section { margin-top: 10px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-title-row > div { display: flex; flex-direction: column; gap: 3px; }
.section-title-row span { color: var(--accent); font-size: 8.5px; font-weight: 850; letter-spacing: .14em; }
.section-title-row strong { font-size: 14px; letter-spacing: -.015em; }
.text-button { border: 0; padding: 7px 4px; background: transparent; color: var(--accent); font: inherit; font-size: 10.5px; font-weight: 800; cursor: pointer; }

.toggle-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.toggle-card {
  min-width: 0;
  min-height: 70px;
  padding: 11px 11px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-solid);
  cursor: pointer;
}
.toggle-card > span { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.toggle-card strong { font-size: 11.5px; }
.toggle-card small { color: var(--muted); font-size: 9px; line-height: 1.25; }
.toggle-card input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-card i {
  width: 34px;
  height: 20px;
  padding: 2px;
  display: block;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background .18s ease;
}
.toggle-card i::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-solid);
  box-shadow: 0 1px 5px rgba(0,0,0,.18);
  transition: transform .18s ease;
}
.toggle-card input:checked + i { background: var(--accent); }
.toggle-card input:checked + i::after { transform: translateX(14px); }
.toggle-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-card:has(input:disabled) { opacity: .45; cursor: default; }

.range-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 13px; margin-top: 13px; }
.range-control { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.range-control > span { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.range-control b { color: var(--text); font-weight: 720; }
.range-control output { font-variant-numeric: tabular-nums; }
.range-control input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.range-control.is-disabled { opacity: .42; }
.range-control input:disabled { cursor: default; }

.preset-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.preset-row::-webkit-scrollbar { display: none; }
.preset-button {
  min-width: 72px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-solid);
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 760;
  cursor: pointer;
  white-space: nowrap;
}
.preset-button.active { border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); background: var(--accent-soft); color: var(--accent); }
.settings-section > .range-control { margin-top: 13px; }

.view-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
.view-grid button {
  min-height: 48px;
  padding: 8px 7px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-solid);
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 730;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.view-grid button span { color: var(--text); font-size: 16px; line-height: 1; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-button {
  min-width: 0;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.tool-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.tool-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool-button > span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tool-button strong { font-size: 11.5px; }
.tool-button small { color: var(--muted); font-size: 9px; }
.ar-tool .tool-icon { background: color-mix(in srgb, var(--success) 13%, transparent); color: var(--success); }
.pro-note { margin: 11px 2px 0; color: var(--muted-2); font-size: 9.5px; line-height: 1.4; }

@media (hover: hover) and (pointer: fine) {
  .toggle-card:hover, .preset-button:hover, .view-grid button:hover, .tool-button:hover { border-color: var(--border-strong); background: var(--surface-strong); }
  .preset-button.active:hover { background: var(--accent-soft); }
  .text-button:hover { text-decoration: underline; }
}

@media (max-width: 560px) {
  .brand-pill { max-width: calc(100vw - 219px); }
  .visual-card { max-height: 91vh; }
  .settings-section { padding: 14px; border-radius: 18px; }
  .toggle-grid { grid-template-columns: 1fr; }
  .toggle-card { min-height: 58px; }
  .range-stack { grid-template-columns: 1fr; }
  .view-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tool-grid { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .brand-pill { max-width: calc(100vw - 204px); padding-left: 8px; }
  .brand-mark { display: none; }
  .brand-copy > span { max-width: 80px; }
  .top-actions { gap: 4px; }
  .glass-button { width: 37px; height: 37px; }
  .pro-dot { right: 6px; top: 6px; }
  .visual-card { padding-left: 15px; padding-right: 15px; }
}


/* v0.4 non-blocking Visual Pro + local model actions */
.global-file-input { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: -10000px; top: -10000px; }

/* Visual Pro stays visible without covering the model. The wrapper lets pointer events pass through. */
.visual-sheet {
  pointer-events: none;
  display: block;
  padding: calc(78px + var(--safe-top)) calc(14px + var(--safe-right)) calc(16px + var(--safe-bottom)) 14px;
}
.visual-sheet .sheet-backdrop { display: none; }
.visual-sheet .visual-card {
  pointer-events: auto;
  width: min(390px, calc(100vw - 28px));
  height: calc(100% - 0px);
  max-height: none;
  margin: 0 0 0 auto;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 22px 70px rgba(8,10,14,.22);
}
.visual-sheet .visual-scroll { min-height: 0; }
.file-tools-section .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 720px) {
  .visual-sheet {
    display: flex;
    align-items: flex-end;
    padding: 0 8px calc(8px + var(--safe-bottom));
  }
  .visual-sheet .visual-card {
    width: 100%;
    height: auto;
    max-height: min(54svh, 560px);
    margin: 0;
    border-radius: 24px;
  }
  .visual-sheet .sheet-handle { margin-top: 3px; }
}

@media (max-width: 430px) {
  .file-tools-section .tool-grid { grid-template-columns: 1fr; }
}
