:root {
    color: #273340;
    font-family: "Segoe UI", Arial, sans-serif;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--viewer-background, #eef1f3); }
button, a, audio { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 3px solid #5a81c9; outline-offset: 3px; }
[hidden] { display: none !important; }
.artifact-embed-main, .viewer-stage { position: relative; width: 100%; height: 100%; overflow: hidden; }
.viewer-stage { isolation: isolate; background: var(--viewer-background, #eef1f3); }
model-viewer { display: block; width: 100%; height: 100%; --poster-color: transparent; background: var(--viewer-background, #eef1f3); }
.icon { display: block; flex: none; }
/* Top bar holds navigation and page tools; the gap between groups stays draggable for the model. */
.viewer-topbar { position: absolute; z-index: 7; top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.viewer-topbar-start, .viewer-tools { display: flex; align-items: center; pointer-events: auto; }
.viewer-topbar-start { gap: 12px; min-width: 0; }
.viewer-tools { gap: 6px; flex: none; }
.viewer-brand { display: block; flex: none; }
.viewer-brand img { display: block; width: 112px; height: 38px; object-fit: contain; }
.language-dropdown { position: relative; }
.language-current { display: flex; align-items: center; gap: 7px; min-height: 42px; padding: 0 10px 0 11px; border: 1px solid #d7dde4; border-radius: 8px; background: #ffffffed; box-shadow: 0 2px 10px #24374d0b; font-size: 12px; font-weight: 650; color: #253f75; list-style: none; cursor: pointer; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: background .15s, border-color .15s; }
.language-current::-webkit-details-marker { display: none; }
.language-current:hover, .language-dropdown[open] .language-current { background: #fff; border-color: #aab8ce; }
.language-current:focus-visible { outline: 3px solid #5a81c9; outline-offset: 3px; }
.language-current .icon { width: 14px; height: 14px; color: #77818e; transition: transform .15s; }
.language-dropdown[open] .language-current .icon { transform: rotate(180deg); }
.language-menu { position: absolute; top: calc(100% + 6px); right: 0; display: grid; gap: 2px; min-width: 164px; padding: 5px; border: 1px solid #d7dde4; border-radius: 10px; background: #fff; box-shadow: 0 10px 30px #24374d1f; animation: language-menu-in .14s ease-out; }
.language-menu a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: 6px; font-size: 13px; color: #4a586a; white-space: nowrap; }
.language-menu a:hover { background: #f4f6f9; }
.language-menu .active { background: #edf1f7; color: #253f75; font-weight: 650; }
.language-menu .icon { width: 16px; height: 16px; margin-left: auto; }
.language-flag { display: block; width: 20px; height: 15px; flex: none; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px #0000000c; }
.viewer-controls { position: absolute; z-index: 3; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 6px; }
.viewer-controls:empty { display: none; }
.viewer-button { display: inline-flex; justify-content: center; align-items: center; flex: none; width: 42px; height: 42px; padding: 10px; border: 1px solid #d7dde4; border-radius: 8px; background: #ffffffed; color: #4a586a; box-shadow: 0 2px 10px #24374d0b; line-height: 1; transition: background .15s, border-color .15s; }
.viewer-button:hover { background: #fff; border-color: #aab8ce; }
.viewer-button[aria-expanded=true] { color: #253f75; background: #edf1f7; border-color: #aab8ce; }
.viewer-button:disabled { opacity: .48; cursor: default; }
.viewer-reset { padding: 9px; animation: viewer-pop-in .18s ease-out; }
.viewer-reset .icon { width: 22px; height: 22px; }
.viewer-button-text { width: auto; padding: 10px 16px; font-size: 13px; }
.viewer-back { width: auto; gap: 6px; padding: 10px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.viewer-ar { position: absolute; z-index: 3; bottom: max(16px, env(safe-area-inset-bottom)); right: max(16px, env(safe-area-inset-right)); gap: 7px; width: auto; padding: 10px 13px; font-size: 12px; font-weight: 650; }
.viewer-status { position: absolute; z-index: 5; left: 50%; bottom: 75px; transform: translateX(-50%); max-width: min(520px, calc(100% - 32px)); margin: 0; padding: 10px 14px; border: 1px solid #d7dde4; border-radius: 8px; background: #fffffff0; color: #586678; text-align: center; font-size: 12px; line-height: 1.5; }
.viewer-status:empty { display: none; }
.viewer-info { position: absolute; z-index: 6; bottom: 72px; left: max(16px, env(safe-area-inset-left)); width: min(390px, calc(100% - 32px)); max-height: calc(100% - 145px); overflow: auto; padding: 20px; border: 1px solid #d7dde4; border-radius: 11px; background: #fffffff5; box-shadow: 0 10px 35px #24374d18; font-size: 14px; line-height: 1.7; }
.viewer-info-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.viewer-info-heading h2 { margin: 0; padding-top: 3px; font-size: 16px; line-height: 1.45; font-weight: 650; overflow-wrap: anywhere; }
.viewer-close { width: 30px; height: 30px; padding: 3px; border: 0; box-shadow: none; font-size: 25px; background: transparent; color: #7b8796; }
.rich-text { overflow-wrap: anywhere; }
.rich-text p { margin: 0 0 14px; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text img { display: block; max-width: 100% !important; height: auto; margin: 12px auto; }
.rich-text video, .rich-text iframe { max-width: 100%; }
.rich-text table { width: 100% !important; max-width: 100%; table-layout: fixed; border-collapse: collapse; }
.rich-text th, .rich-text td { padding: 7px; border: 1px solid #d7dde4; overflow-wrap: anywhere; }
.rich-text a { color: #315590; text-decoration: underline; }
.rich-text h1, .rich-text h2, .rich-text h3 { line-height: 1.4; }
.viewer-audio { position: relative; width: min(300px, calc(100vw - 200px)); }
.viewer-audio audio { display: block; width: 100%; height: 42px; border-radius: 24px; }
.audio-status { position: absolute; bottom: 52px; left: 0; width: min(320px, calc(100vw - 80px)); margin: 0; padding: 9px 12px; border: 1px solid #ead8c6; border-radius: 8px; background: #fff9f1; font-size: 12px; line-height: 1.5; color: #8a5739; }
.model-loading, .viewer-error, .viewer-empty { position: absolute; z-index: 2; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; padding: 30px; font-size: 13px; text-align: center; color: #657186; }
.model-loading { background: var(--viewer-background, #eef1f3); pointer-events: none; }
.viewer-error { background: var(--viewer-background, #eef1f3); }
.loading-spinner { width: 37px; height: 37px; border: 2px solid #cbd5e0; border-top-color: #657b9b; border-radius: 50%; animation: viewer-spin 1s linear infinite; }
.model-loading progress { width: 150px; height: 4px; border: 0; border-radius: 3px; overflow: hidden; accent-color: #657b9b; }
.model-loading progress::-webkit-progress-bar { background: #cbd5e0; }
.model-loading progress::-webkit-progress-value { background: #657b9b; }
.loading-percentage { font-size: 11px; }
.gallery-image-link { display: block; width: 100%; height: 100%; }
.gallery-main { display: block; width: 100%; height: 100%; object-fit: contain; }
.gallery-counter { position: absolute; z-index: 3; top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); padding: 8px 12px; border: 1px solid #d7dde4; border-radius: 7px; background: #ffffffed; font-size: 11px; color: #657186; }
.viewer-stage-branded .gallery-counter, .viewer-stage-with-back .gallery-counter { top: calc(70px + env(safe-area-inset-top)); }
.gallery-thumbnails { position: absolute; z-index: 3; bottom: 72px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; max-width: calc(100% - 32px); padding: 5px; overflow-x: auto; border: 1px solid #d7dde4; border-radius: 8px; background: #ffffffed; }
.gallery-thumbnails button { width: 66px; height: 48px; flex: none; padding: 3px; border: 2px solid transparent; border-radius: 5px; background: #f1f3f6; }
.gallery-thumbnails button.active { border-color: #657b9b; }
.gallery-thumbnails img { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer-reader { width: 100%; height: 100%; overflow: auto; background: #fff; }
.text-artifact { width: min(840px, 100%); padding: 68px 32px 95px; margin: 0 auto; font-size: 16px; line-height: 1.85; }
.viewer-stage:fullscreen { width: 100vw; height: 100vh; }
@keyframes viewer-spin { to { transform: rotate(360deg); } }
@keyframes language-menu-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes viewer-pop-in { from { opacity: 0; transform: scale(.85); } }
@media (max-width: 560px) {
    .viewer-topbar { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); gap: 8px; }
    .viewer-topbar-start { flex-direction: column; align-items: flex-start; gap: 8px; }
    .viewer-tools { gap: 5px; }
    .viewer-brand img { width: 96px; height: 32px; }
    .viewer-controls { bottom: max(12px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); gap: 5px; }
    .viewer-ar { bottom: calc(70px + env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right)); }
    .viewer-audio { width: min(300px, calc(100vw - 78px)); }
    .viewer-info { bottom: calc(70px + env(safe-area-inset-bottom)); max-height: calc(100% - 136px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); left: 12px; width: calc(100% - 24px); padding: 17px; }
    .viewer-status { bottom: calc(70px + env(safe-area-inset-bottom)); font-size: 11px; }
    .text-artifact { padding: calc(70px + env(safe-area-inset-top)) 22px 84px; font-size: 15px; }
    .viewer-stage-branded .text-artifact { padding-top: calc(110px + env(safe-area-inset-top)); }
    .gallery-counter, .viewer-stage-branded .gallery-counter, .viewer-stage-with-back .gallery-counter { top: calc(66px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); left: auto; }
    .gallery-thumbnails { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
    .viewer-back { width: 42px; padding: 10px; }
    .viewer-back > span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .viewer-button, .language-current, .language-current .icon { transition: none; } .language-menu, .viewer-reset { animation: none; } .loading-spinner { animation-duration: 2s; } }
