:root {
  color-scheme: light;
  --ink: #173e32;
  --ink-strong: #102f26;
  --muted: #657369;
  --paper: #f5f6ef;
  --surface: #fffef9;
  --line: rgba(32, 63, 47, 0.13);
  --accent-soft: #e7eee4;
  --shadow: 0 4px 24px rgba(26, 47, 35, 0.07), 0 1px 3px rgba(26, 47, 35, 0.04);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--paper); font-size: 14px; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { border: 0; background: transparent; }
button:disabled { cursor: default; opacity: 0.43; }
[hidden] { display: none !important; }
svg { display: block; flex: 0 0 auto; }
button svg, .panel-heading svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
button:focus-visible, canvas:focus-visible { outline: 3px solid #437d60; outline-offset: 3px; }
button:focus:not(:focus-visible) { outline: none; }

#viewer-shell { position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; isolation: isolate; }
#scene { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene:focus-visible { outline-offset: -4px; }
.surface { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);  }
.topbar { position: absolute; z-index: 30; top: max(24px, env(safe-area-inset-top)); right: max(24px, env(safe-area-inset-right)); left: max(24px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 20px; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 11px; padding: 8px 12px 8px 0; color: var(--ink-strong); text-shadow: 0 1px 10px rgba(255, 255, 251, 0.8); }
.brand-name { font-size: 16px; font-weight: 500; letter-spacing: 0.12em; white-space: nowrap; }
.brand-name strong { font-weight: 760; }
.brand-mark { filter: drop-shadow(0 1px 8px rgba(255, 255, 251, 0.7)); }
.topbar-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 10px; }
.topbar-actions .icon-button { border-radius: 50%; }

.view-dock { position: absolute; z-index: 30; top: 108px; left: max(24px, env(safe-area-inset-left)); width: 240px; border-radius: 16px; }
.panel-toggle { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 15px; }
.panel-heading { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 650; letter-spacing: 0.015em; white-space: nowrap; }
.panel-heading svg { width: 18px; height: 18px; }
.panel-chevron { width: 16px; height: 16px; transform: rotate(180deg); }
#views-panel { display: flex; flex-direction: column; gap: 4px; padding: 0 8px 8px; }
.view-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 12px; border-radius: 10px; text-align: left; }
.view-number { color: var(--muted); font-size: 11px; font-weight: 550; font-variant-numeric: tabular-nums; }
.view-copy { display: flex; flex: 1; flex-direction: column; gap: 5px; min-width: 0; }
.view-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.view-description { color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.view-arrow { width: 16px; height: 16px; opacity: 0; }
.view-button[aria-pressed="true"], .view-button.active { background: var(--ink); color: #fffef5; }
.view-button[aria-pressed="true"] .view-number, .view-button.active .view-number { color: #bdd3bc; }
.view-button[aria-pressed="true"] .view-description, .view-button.active .view-description { color: #cbdcc9; }
.view-button[aria-pressed="true"] .view-arrow, .view-button.active .view-arrow { opacity: 1; }
body.panel-collapsed #views-panel { display: none; }
body.panel-collapsed .panel-chevron { transform: none; }
body.panel-collapsed .view-dock { width: 216px; }

.view-caption { position: absolute; z-index: 10; bottom: 61px; left: max(24px, env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; text-shadow: 0 1px 10px #f7f8ef, 0 0 24px #f7f8ef; }
.caption-eyebrow { color: var(--muted); font-size: 9px; line-height: 1.4; font-weight: 650; letter-spacing: 0.16em; }
#view-title { color: var(--ink-strong); font-size: 22px; line-height: 1.15; font-weight: 650; letter-spacing: -0.035em; }
#view-subtitle { max-width: 270px; color: #4e6153; font-size: 11px; line-height: 1.4; }
.scene-toolbar { position: absolute; z-index: 30; bottom: max(51px, calc(env(safe-area-inset-bottom) + 35px)); left: 50%; display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 15px; transform: translateX(-50%); }
.mode-controls { display: flex; align-items: center; gap: 3px; }
.tool-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 10px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.tool-button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink-strong); }
.toolbar-divider { width: 1px; height: 22px; margin: 0 2px; background: var(--line); }
.zoom-controls { position: absolute; z-index: 30; right: max(24px, env(safe-area-inset-right)); bottom: 61px; display: flex; flex-direction: column; gap: 1px; padding: 4px; border-radius: 14px; }
.zoom-controls .icon-button + .icon-button { border-top: 1px solid var(--line); border-top-left-radius: 0; border-top-right-radius: 0; }
.viewer-footer { position: absolute; z-index: 10; right: max(24px, env(safe-area-inset-right)); bottom: max(17px, calc(env(safe-area-inset-bottom) + 10px)); left: max(24px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #536657; font-size: 10px; letter-spacing: 0.01em; pointer-events: none; text-shadow: 0 1px 7px var(--paper), 0 0 16px var(--paper); }
.model-version { font-size: 9px; letter-spacing: 0.06em; }

/* main.js controls readiness, panel state and native disabled attributes. */
body:not([data-ready="true"]) [data-scene-control] { pointer-events: none; }
.loading-overlay { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 100px 24px 160px; background: radial-gradient(ellipse at 55% 38%, #fcfcf6 0, #f2f4ec 65%, #e9eee4 100%); }
.loading-card { display: flex; flex-direction: column; align-items: center; width: min(340px, 100%); text-align: center; }
.loading-mark { margin-bottom: 25px; color: var(--ink); }
#loading-title { margin: 0 0 10px; font-size: 22px; font-weight: 550; letter-spacing: -0.03em; line-height: 1.25; }
#loading-detail { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; }
#loading-progress { display: block; width: 180px; height: 3px; overflow: hidden; margin-top: 26px; border: 0; border-radius: 3px; appearance: none; -webkit-appearance: none; background: #d9e2d6; color: var(--ink); }
#loading-progress::-webkit-progress-bar { border-radius: 3px; background: #d9e2d6; }
#loading-progress::-webkit-progress-value { border-radius: 3px; background: var(--ink); }
#loading-progress::-moz-progress-bar { border-radius: 3px; background: var(--ink); }
body[data-ready="true"] #loading { display: none; }
.primary-button { min-height: 44px; margin-top: 24px; padding: 0 20px; border-radius: 10px; background: var(--ink); color: #fffef5; font-size: 13px; font-weight: 550; }
.toast { position: absolute; z-index: 40; left: 50%; bottom: 126px; width: max-content; max-width: min(460px, calc(100% - 32px)); padding: 12px 18px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 12px; background: rgba(20, 48, 37, 0.96); color: #fffef5; font-size: 12px; line-height: 1.5; text-align: center; box-shadow: var(--shadow); transform: translateX(-50%); }
.toast[hidden].visible, .toast[hidden].show { display: block !important; }

#help-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); margin: auto; padding: 28px; overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: #fffef9; color: var(--ink); box-shadow: 0 24px 100px rgba(13, 35, 26, 0.2); overscroll-behavior: contain; }
#help-dialog::backdrop { background: rgba(20, 37, 29, 0.3); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dialog-heading h2 { margin: 7px 0 0; font-size: 23px; line-height: 1.2; font-weight: 600; letter-spacing: -0.035em; }
.dialog-heading .icon-button { margin: -10px -10px 0 0; }
.help-intro { margin: 17px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.help-section { padding: 17px 0; border-top: 1px solid var(--line); }
.help-section h3 { margin: 0 0 8px; font-size: 12px; font-weight: 650; }
.help-section p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.help-section strong { color: var(--ink); font-weight: 600; }
.keyboard-shortcuts { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 0; }
.keyboard-shortcuts > div { display: grid; grid-template-columns: 95px 1fr; gap: 12px; align-items: center; }
.keyboard-shortcuts dt { color: var(--muted); white-space: nowrap; }
.keyboard-shortcuts dd { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 25px; min-height: 24px; padding: 2px 6px; border: 1px solid #d7dfd3; border-radius: 5px; background: #f3f5ed; color: var(--ink); font-size: 11px; line-height: 1.2; font-family: inherit; box-shadow: 0 1px 0 #d7dfd3; }
.help-footnote { margin: 8px 0 0; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.6; }
.noscript-message { position: absolute; z-index: 100; top: 45%; right: 24px; left: 24px; padding: 24px; border-radius: 16px; background: #fffef9; color: var(--ink); text-align: center; }

@media (hover: hover) and (pointer: fine) {
  button { transition: background-color 130ms ease, color 130ms ease, transform 100ms ease; }
  .icon-button:not(:disabled):hover, .tool-button:not(:disabled):hover, .panel-toggle:hover { background-color: #e8eee3; }
  .view-button:not(:disabled):not([aria-pressed="true"]):hover { background: #edf1e8; }
  .view-button:not(:disabled)[aria-pressed="true"]:hover, .primary-button:hover { background: #254e3e; }
  button:not(:disabled):active { transform: scale(0.97); }
  button:focus-visible { transition: none; }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .scene-toolbar { left: 59%; }
  .auto-button { padding: 0; width: 44px; }
  .auto-button span { display: none; }
  #view-title { font-size: 20px; }
  #view-subtitle { max-width: 225px; }
}

@media (max-width: 760px) {
  .topbar { top: max(14px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); left: max(16px, env(safe-area-inset-left)); gap: 8px; }
  .brand { gap: 8px; padding: 5px 0; }
  .brand-mark { width: 25px; height: 30px; }
  .brand-name { font-size: 13px; letter-spacing: 0.09em; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .icon-button { width: 44px; height: 44px; }
  .view-caption { top: max(83px, calc(env(safe-area-inset-top) + 65px)); right: 16px; bottom: auto; left: max(16px, env(safe-area-inset-left)); gap: 5px; }
  .view-caption .caption-eyebrow { display: none; }
  #view-title { font-size: 21px; }
  #view-subtitle { max-width: 300px; font-size: 10px; }
  .view-dock { top: auto; bottom: max(151px, calc(env(safe-area-inset-bottom) + 135px)); left: max(16px, env(safe-area-inset-left)); width: min(264px, calc(100% - 100px)); border-radius: 14px; }
  body.panel-collapsed .view-dock { width: 205px; }
  .panel-toggle { min-height: 48px; padding: 11px 13px; }
  .panel-heading { font-size: 11px; gap: 8px; }
  #views-panel { max-height: calc(100dvh - 340px); overflow-y: auto; overscroll-behavior: contain; }
  .view-button { min-height: 60px; gap: 10px; padding: 10px; }
  .view-name { font-size: 12px; }
  .view-description { font-size: 10px; }
  .scene-toolbar { left: 50%; bottom: max(55px, calc(env(safe-area-inset-bottom) + 39px)); gap: 3px; max-width: calc(100% - 32px); padding: 5px; border-radius: 14px; }
  .mode-controls { gap: 2px; }
  .tool-button { gap: 6px; padding: 0 10px; font-size: 11px; }
  .tool-button svg { width: 18px; height: 18px; }
  .auto-button { width: 44px; padding: 0; }
  .auto-button span { display: none; }
  .toolbar-divider { margin: 0; }
  .zoom-controls { right: max(16px, env(safe-area-inset-right)); bottom: max(151px, calc(env(safe-area-inset-bottom) + 135px)); padding: 3px; border-radius: 13px; }
  .viewer-footer { right: max(16px, env(safe-area-inset-right)); left: max(16px, env(safe-area-inset-left)); bottom: max(16px, calc(env(safe-area-inset-bottom) + 9px)); font-size: 9px; }
  .model-version { font-size: 8px; }
  .loading-overlay { padding: 150px 24px 240px; }
  #loading-title { font-size: 21px; }
  #loading-detail { font-size: 11px; }
  .loading-mark { margin-bottom: 20px; }
  .toast { bottom: max(117px, calc(env(safe-area-inset-bottom) + 101px)); font-size: 11px; }
  #help-dialog { padding: 24px; border-radius: 18px; }
}

@media (max-width: 359px) {
  .brand-name { font-size: 11px; letter-spacing: 0.06em; }
  .brand-mark { width: 22px; }
  .tool-button { gap: 5px; padding: 0 7px; }
  .view-dock { width: calc(100% - 90px); }
  body.panel-collapsed .view-dock { width: 190px; }
  .panel-heading { font-size: 10px; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .topbar { top: 12px; }
  .view-dock { top: 76px; bottom: auto; width: 230px; }
  #views-panel { max-height: calc(100dvh - 180px); overflow-y: auto; }
  .view-button { min-height: 52px; }
  .view-caption { top: 78px; right: 76px; left: auto; bottom: auto; max-width: 280px; align-items: flex-end; text-align: right; }
  .view-caption .caption-eyebrow { display: none; }
  .scene-toolbar { left: 58%; bottom: 41px; }
  .zoom-controls { bottom: 42px; }
  .loading-overlay { padding: 80px 24px 110px; }
  .loading-mark { width: 28px; height: 32px; margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  button:not(:disabled):active { transform: none; }
}
