/* web/src/viewer/viewer.css */
:root {
  --ink: #f2f2f7;
  --glass: #ffffffc7;
  --glass-strong: #ffffffe6;
  --line: #3c3c431f;
  --line-strong: #3c3c4338;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #8e8e93;
  --accent: #007aff;
  --accent-soft: #007aff1f;
  --accent-ink: #fff;
  --danger: #ff3b30;
  --ok: #34c759;
  --radius: 16px;
  --shadow: 0 8px 28px #0000002e, 0 1px 2px #0000000f;
  --blur: saturate(180%) blur(20px);
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Roboto, system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html, body {
  color: var(--text);
  font: 14px / 1.4 var(--ui);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #000;
  height: 100%;
  margin: 0;
}

#tw-stage {
  position: fixed;
  inset: 0;
}

#tw-stage canvas {
  display: block;
  outline: none;
  touch-action: none;
  width: 100%;
  height: 100%;
}

#tw-hud {
  position: fixed;
  pointer-events: none;
  z-index: 10;
  inset: 0;
}

#tw-hud > * {
  pointer-events: auto;
}

#tw-hud .tw-hint, #tw-hud .tw-coach, #tw-hud .tw-stick, #tw-hud .tw-status {
  pointer-events: none;
}

.tw-mono {
  font-variant-numeric: tabular-nums;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

.tw-loader {
  position: fixed;
  display: grid;
  background: var(--ink);
  z-index: 30;
  place-items:  center;
  transition: opacity .9s, visibility .9s;
  inset: 0;
}

#tw-hud:not(.is-loading) .tw-loader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tw-loader__inner {
  position: relative;
  z-index: 1;
  text-align: center;
  width: min(420px, 100vw - 48px);
}

.tw-loader__name {
  font: 600 clamp(30px, 5.5vw, 44px) / 1.1 var(--display);
  letter-spacing: -.015em;
  text-wrap: balance;
  margin: 10px 0 26px;
}

.tw-progress {
  overflow: hidden;
  background: #e5e5ea;
  border-radius: 2px;
  height: 4px;
}

.tw-progress__fill {
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  height: 100%;
  transition: width .25s;
}

.tw-loader.is-indeterminate .tw-progress__fill {
  animation: tw-slide 1.4s ease-in-out infinite;
  width: 30% !important;
}

@keyframes tw-slide {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(340%);
  }
}

.tw-loader__meta {
  display: flex;
  color: var(--muted);
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  font-size: 13px;
}

.tw-loader__note {
  color: var(--faint);
  min-height: 1.4em;
  margin: 22px 0 0;
  font-size: 13px;
}

.tw-loader.is-error .tw-progress__fill {
  background: var(--danger);
  animation: none;
  width: 100% !important;
}

.tw-loader.is-error #tw-percent {
  color: var(--danger);
}

.tw-loader__note a {
  color: var(--accent);
  text-decoration: none;
}

.tw-loader__note a:hover {
  text-decoration: underline;
}

.tw-eyebrow {
  display: inline-flex;
  font: 500 15px / 1 var(--ui);
  color: var(--muted);
  align-items:  center;
  gap: 8px;
}

.tw-dot {
  display: none;
}

.tw-top {
  position: fixed;
  top: calc(14px + var(--safe-t));
  left: calc(14px + var(--safe-l));
  right: calc(14px + var(--safe-r));
  display: flex;
  pointer-events: none;
  justify-content: space-between;
  align-items:  flex-start;
  gap: 12px;
  transition: opacity .6s, transform .6s;
}

.tw-top > * {
  pointer-events: auto;
}

#tw-hud.is-loading .tw-top, #tw-hud.is-loading .tw-status {
  opacity: 0;
  transform: translateY(-6px);
}

#tw-hud.is-idle .tw-top {
  opacity: .4;
}

#tw-hud.is-idle .tw-top:hover {
  opacity: 1;
}

.tw-ident {
  display: flex;
  background: var(--glass);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  align-items:  center;
  gap: 8px;
  min-width: 0;
  max-width: min(520px, 60vw);
  padding: 6px 16px 7px 6px;
}

.tw-back {
  display: grid;
  color: var(--accent);
  border-radius: 10px;
  flex: none;
  place-items:  center;
  width: 34px;
  height: 34px;
  transition: background .2s;
}

.tw-back:hover {
  background: #7676801f;
}

.tw-back svg, .tw-icon-btn svg, .tw-vr svg, .tw-play svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 18px;
  height: 18px;
}

.tw-back svg {
  stroke-width: 2.4;
  width: 20px;
  height: 20px;
}

.tw-ident__text {
  min-width: 0;
}

.tw-ident__row {
  display: flex;
  align-items:  center;
  gap: 6px;
}

.tw-brand {
  font: 500 12px / 1 var(--ui);
  color: var(--faint);
}

.tw-tag {
  font: 600 11px / 1 var(--ui);
  color: var(--muted);
  background: #7676801f;
  border-radius: 6px;
  padding: 4px 7px;
}

.tw-name {
  font: 600 17px / 1.15 var(--display);
  letter-spacing: -.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 3px 0 0;
}

.tw-actions {
  display: flex;
  flex: none;
  align-items:  center;
  gap: 8px;
}

.tw-pill-group {
  display: flex;
  background: var(--glass);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  gap: 2px;
  padding: 4px;
}

.tw-icon-btn {
  display: grid;
  color: #3a3a3c;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 11px;
  place-items:  center;
  width: 38px;
  height: 38px;
  transition: background .2s, color .2s;
}

.tw-icon-btn:hover {
  color: var(--text);
  background: #7676801f;
}

.tw-icon-btn.is-active, #tw-btn-reality.is-active {
  color: #fff;
  background: var(--accent);
}

#tw-btn-reality.is-busy {
  opacity: .6;
  cursor: progress;
}

.tw-icon-btn--small {
  width: 30px;
  height: 30px;
}

.tw-icon-btn .i-off, .tw-icon-btn.is-muted .i-on {
  display: none;
}

.tw-icon-btn.is-muted .i-off {
  display: block;
}

.tw-icon-btn:focus-visible {
  outline: 3px solid #007aff73;
  outline-offset: 2px;
}

.tw-vr:focus-visible {
  outline: 3px solid #007aff73;
  outline-offset: 2px;
}

.tw-play:focus-visible {
  outline: 3px solid #007aff73;
  outline-offset: 2px;
}

.tw-back:focus-visible {
  outline: 3px solid #007aff73;
  outline-offset: 2px;
}

.tw-vr {
  display: inline-flex;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 15px / 1 var(--ui);
  box-shadow: var(--shadow);
  border: 0;
  border-radius: 999px;
  align-items:  center;
  gap: 8px;
  height: 46px;
  padding: 0 18px 0 15px;
  transition: background .2s, transform .15s;
}

.tw-vr svg {
  stroke-width: 1.9;
  width: 20px;
  height: 20px;
}

.tw-vr:hover {
  background: #0a84ff;
}

.tw-vr:active {
  transform: scale(.98);
}

.tw-vr:disabled {
  opacity: .5;
  cursor: progress;
}

.tw-hint {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  display: flex;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  color: var(--text);
  animation: tw-rise .6s ease both;
  border-radius: 999px;
  align-items:  center;
  gap: 10px;
  padding: 7px 15px 7px 7px;
  font-size: 14px;
  transform: translateX(-50%);
}

.tw-hint__key {
  font: 600 12px / 1 var(--ui);
  color: var(--text);
  background: #76768024;
  border-radius: 999px;
  padding: 6px 10px;
}

@keyframes tw-rise {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

#tw-hud.has-transport .tw-hint {
  bottom: calc(118px + var(--safe-b));
}

.tw-status {
  position: fixed;
  left: calc(14px + var(--safe-l));
  bottom: calc(14px + var(--safe-b));
  display: flex;
  gap: 8px;
  transition: opacity .6s, transform .6s;
}

.tw-chip {
  display: inline-flex;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  font: 500 12px / 1 var(--ui);
  color: var(--text);
  border-radius: 999px;
  align-items:  center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  box-shadow: 0 2px 10px #00000024;
}

.tw-chip__dot {
  display: none;
}

.tw-chip.is-fly {
  color: #fff;
  background: var(--accent);
}

#tw-perf {
  font-variant-numeric: tabular-nums;
}

.tw-transport {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  display: flex;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  animation: tw-rise .6s ease both;
  border-radius: 999px;
  align-items:  center;
  gap: 12px;
  width: min(560px, 100vw - 28px);
  padding: 6px 16px 6px 6px;
  transform: translateX(-50%);
}

.tw-play {
  display: grid;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 50%;
  flex: none;
  place-items:  center;
  width: 40px;
  height: 40px;
  transition: transform .15s, background .2s;
}

.tw-play svg {
  fill: currentColor;
  stroke: none;
  width: 17px;
  height: 17px;
}

.tw-play .i-pause, .tw-play.is-playing .i-play {
  display: none;
}

.tw-play.is-playing .i-pause {
  display: block;
}

.tw-play:hover {
  transform: scale(1.05);
}

.tw-play.is-waiting {
  background: var(--faint);
}

.tw-time {
  color: var(--text);
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  font-size: 12px;
}

.tw-time--dim {
  color: var(--faint);
}

.tw-scrub {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  --p: 0%;
  background: none;
  flex: 1;
  min-width: 60px;
  height: 24px;
  margin: 0;
}

.tw-scrub::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--accent) var(--p), #d1d1d6 var(--p));
  border-radius: 2px;
  height: 4px;
}

.tw-scrub::-moz-range-track {
  background: #d1d1d6;
  border-radius: 2px;
  height: 4px;
}

.tw-scrub::-moz-range-progress {
  background: var(--accent);
  border-radius: 2px;
  height: 4px;
}

.tw-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  background: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  box-shadow: 0 1px 4px #0000004d, 0 0 0 .5px #0000000f;
}

.tw-scrub::-moz-range-thumb {
  background: #fff;
  border: 0;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  box-shadow: 0 1px 4px #0000004d;
}

.tw-help {
  position: fixed;
  right: calc(14px + var(--safe-r));
  top: calc(78px + var(--safe-t));
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: tw-pop .3s cubic-bezier(.25, .1, .25, 1) both;
  max-height: calc(100vh - 78px - var(--safe-t)  - 124px);
  overflow: auto;
  border-radius: 20px;
  width: min(340px, 100vw - 28px);
  padding: 16px 16px 14px 18px;
  box-shadow: 0 20px 50px #00000038;
}

@keyframes tw-pop {
  from {
    opacity: 0;
    transform: translateY(-6px)scale(.98);
  }
}

.tw-help__head {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  margin-bottom: 12px;
}

.tw-help h3 {
  font: 600 19px / 1.2 var(--display);
  letter-spacing: -.015em;
  margin: 0;
}

.tw-keys {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items:  center;
  gap: 9px 14px;
  margin: 0;
}

.tw-keys dt {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.tw-keys dd {
  color: var(--muted);
  margin: 0;
}

kbd {
  display: inline-grid;
  font: 500 12px / 1 var(--ui);
  color: var(--text);
  background: #fff;
  border: 1px solid #d2d2d7;
  border-bottom-width: 2px;
  border-radius: 6px;
  place-items:  center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
}

dd kbd {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 11px;
}

.tw-help__vr {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.tw-help__vr .tw-eyebrow {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.tw-help__vr p {
  color: var(--muted);
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.tw-help__vr b {
  color: var(--text);
  font-weight: 600;
}

body.is-touch .tw-keys[data-for="desktop"], body:not(.is-touch) .tw-keys[data-for="touch"] {
  display: none;
}

.tw-toasts {
  position: fixed;
  top: calc(78px + var(--safe-t));
  display: flex;
  z-index: 40;
  pointer-events: none;
  flex-direction: column;
  align-items:  center;
  gap: 8px;
  width: min(420px, 100vw - 28px);
  left: 50%;
  transform: translateX(-50%);
}

.tw-toast {
  pointer-events: auto;
  display: flex;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: tw-toast-in .35s cubic-bezier(.25, .1, .25, 1) both;
  background: #f6f6f8db;
  border-radius: 20px;
  align-items:  flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px 13px 16px;
  box-shadow: 0 12px 36px #0003;
}

.tw-toast.is-leaving {
  animation: tw-toast-out .3s ease both;
}

@keyframes tw-toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes tw-toast-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.tw-toast__bar {
  display: none;
}

.tw-toast__title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.tw-toast.is-error .tw-toast__title {
  color: #d70015;
}

.tw-toast__body {
  color: var(--text);
  word-break: break-word;
  margin-top: 2px;
  font-size: 14px;
}

.tw-toast__close {
  color: var(--faint);
  cursor: pointer;
  background: none;
  border: 0;
  flex: none;
  margin-left: auto;
  padding: 2px;
  font-size: 18px;
  line-height: 1;
}

.tw-toast__close:hover {
  color: var(--text);
}

.tw-coach {
  position: fixed;
  display: grid;
  grid-template-columns: 1fr 1fr;
  animation: tw-fade-in .6s ease both;
  inset: 0;
}

@keyframes tw-fade-in {
  from {
    opacity: 0;
  }
}

.tw-coach__half {
  display: flex;
  padding-bottom: calc(120px + var(--safe-b));
  color: var(--text);
  font: 500 14px / 1 var(--ui);
  flex-direction: column;
  justify-content: flex-end;
  align-items:  center;
  gap: 12px;
}

.tw-coach__half span {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: 999px;
  padding: 8px 13px;
  box-shadow: 0 2px 10px #00000024;
}

.tw-coach__half + .tw-coach__half {
  border-left: 1px solid #ffffff2e;
}

.tw-coach__ring {
  position: relative;
  animation: tw-nudge 2.2s ease-in-out infinite;
  background: #ffffff2e;
  border: 1.5px solid #fffc;
  border-radius: 50%;
  width: 74px;
  height: 74px;
  box-shadow: 0 2px 18px #0003;
}

.tw-coach__ring:after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
  inset: 22px;
}

.tw-coach__ring--look {
  animation-name: tw-nudge-x;
}

@keyframes tw-nudge {
  50% {
    transform: translateY(-10px);
  }
}

@keyframes tw-nudge-x {
  50% {
    transform: translateX(10px);
  }
}

.tw-stick {
  position: fixed;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: #ffffff29;
  border: 1.5px solid #ffffff80;
  border-radius: 50%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
}

.tw-stick__knob {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  top: 50%;
  left: 50%;
  box-shadow: 0 4px 16px #0000004d;
}

@media (max-width: 640px) {
  .tw-top {
    top: calc(10px + var(--safe-t));
    left: calc(10px + var(--safe-l));
    right: calc(10px + var(--safe-r));
  }

  .tw-ident {
    max-width: calc(100vw - 150px);
    padding: 5px 12px 6px 5px;
  }

  .tw-back {
    width: 30px;
    height: 30px;
  }

  .tw-name {
    font-size: 16px;
  }

  .tw-brand {
    display: none;
  }

  .tw-icon-btn {
    width: 34px;
    height: 34px;
  }

  #tw-btn-full, #tw-btn-note {
    display: none;
  }

  .tw-vr {
    height: 42px;
    padding: 0 12px;
  }

  .tw-vr span {
    display: none;
  }

  .tw-help {
    top: auto;
    bottom: calc(76px + var(--safe-b));
    width: auto;
    left: 10px;
    right: 10px;
  }

  .tw-status {
    bottom: calc(70px + var(--safe-b));
  }

  .tw-transport {
    bottom: calc(10px + var(--safe-b));
  }
}

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