:root {
  color-scheme: light;
  --ink: #192322;
  --muted: #667371;
  --line: #cad6d2;
  --panel: #f4f7f4;
  --panel-strong: #ffffff;
  --accent: #2e8f83;
  --accent-soft: #d8f3ee;
  --warning: #b88724;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  background: #e8efec;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.mobile-only-icon {
  display: none;
}

.model-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  min-height: 100vh;
  padding: 14px;
}

body[data-embedded="true"] .model-stage {
  display: block;
  height: 100vh;
  min-height: 100vh;
  padding: 0;
}

body[data-embedded="true"] .viewer-shell {
  height: 100vh;
  min-height: 100vh;
  border: 0;
  box-shadow: none;
}

body[data-embedded="true"] .word-card {
  display: none;
}

body[data-embedded="true"] .canvas-wrap {
  height: auto;
  min-height: 0;
}

body[data-embedded="true"] .viewer-topbar,
body[data-embedded="true"] .viewer-footer {
  gap: 10px;
  padding: 9px 12px;
}

body[data-embedded="true"][data-editor="false"] #scene-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

body[data-editor="true"] .scene-breadcrumb > a,
body[data-editor="true"] .scene-breadcrumb > span {
  display: none;
}

body[data-embedded="true"] .viewer-topbar h1 {
  font-size: 20px;
}

body[data-embedded="true"] .viewer-footer {
  flex-wrap: wrap;
}

/* Editor mode moves 隐藏标注 / 重置视角 into the admin panel's toolbar above
   the iframe, next to the tab that owns them, so the viewer's own topbar would
   only be a second, emptier bar stacked on top of the canvas. Removing it from
   the grid drops the shell to two rows: canvas, then footer. */
body[data-editor="true"] .viewer-topbar {
  display: none;
}

body[data-editor="true"] .viewer-shell {
  grid-template-rows: minmax(0, 1fr) auto;
}

/* The editor's mode reminder used to be a generated ::before on the footer,
   which is a second flex item and therefore pushed the hint onto its own line.
   It is a real span inside the note now, so the reminder and the hint read as
   one sentence and the footer keeps its single-line height. */
#scene-mode {
  color: var(--accent);
  font-weight: 760;
}

#scene-mode:empty {
  display: none;
}

.viewer-shell,
.word-card {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: 0 10px 30px rgb(25 35 34 / 0.08);
}

.viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 28px);
}

.viewer-topbar,
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.viewer-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Keeps the hint text and the copyright link on one line, so the footer's
   space-between still pushes the attribution to the right edge. */
.viewer-footer-note {
  display: inline;
}

.scene-license {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.scene-license:hover {
  color: var(--ink);
  text-decoration: underline;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 760;
}

.scene-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scene-breadcrumb a {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
  text-decoration: none;
}

.scene-breadcrumb a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.scene-breadcrumb > span {
  color: var(--line);
  font-size: 14px;
  line-height: 1.25;
}

#word-example {
  white-space: pre-line;
}

.viewer-actions button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.viewer-actions button {
  padding: 9px 12px;
  font-weight: 700;
}

.canvas-wrap {
  position: relative;
  height: calc(100vh - 145px);
  min-height: 620px;
  overflow: hidden;
  background: #dfe9e4;
}

#application-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#application-canvas[data-drag-mode] {
  cursor: grabbing;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #dfe9e4;
  color: var(--muted);
  font-size: 14px;
}

.loading.hidden {
  display: none;
}

.labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  overflow: visible;
  isolation: isolate;
  opacity: 1;
  transition: opacity 180ms ease, filter 180ms ease;
}

.hotspot[data-occluded="true"] {
  filter: saturate(0.55);
  opacity: 0.3;
}

.hotspot[data-occluded="true"] .hotspot-pin {
  border-color: rgb(255 255 255 / 0.72);
  background: rgb(0 0 0 / 0.6);
  box-shadow:
    0 0 0 2px rgb(255 255 255 / 0.06),
    0 2px 8px rgb(0 0 0 / 0.18);
}

.hotspot[data-occluded="true"]::after {
  animation: none;
  opacity: 0;
}

.hotspot::after {
  content: "";
  position: absolute;
  inset: -4px;
  z-index: -1;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.28);
  opacity: 0.65;
  animation: hotspot-pulse 2.8s ease-out infinite;
}

.hotspot-pin {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1.5px solid rgb(255 255 255 / 0.88);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.46);
  box-shadow:
    0 0 0 3px rgb(255 255 255 / 0.08),
    0 4px 12px rgb(0 0 0 / 0.28),
    inset 0 1px 0 rgb(255 255 255 / 0.18);
  backdrop-filter: blur(5px);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.hotspot:hover .hotspot-pin,
.hotspot:focus-visible .hotspot-pin,
.hotspot[data-expanded="true"] .hotspot-pin {
  border-color: #fff;
  background: rgb(0 0 0 / 0.7);
  transform: scale(1.06);
}

.hotspot:focus-visible {
  outline: none;
}

/* The bubble's offset is written by updateLabels() as inline left/top in pixels
   relative to the hotspot button's own box, so the edge-avoidance maths lives in
   one place and holds at every anchor position. Only the direction the bubble
   grows from is still a state class. */
.hotspot-bubble {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  min-width: 142px;
  max-width: 220px;
  gap: 3px;
  padding: 9px 12px;
  transform: scale(0.96);
  transform-origin: left center;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 7px;
  background: rgb(0 0 0 / 0.84);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.3);
  color: #fff;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  text-align: left;
  white-space: nowrap;
  backdrop-filter: blur(7px);
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
}

.hotspot[data-expanded="true"] {
  z-index: 10;
}

.hotspot[data-expanded="true"] .hotspot-bubble {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Set from the bubble's final clamped position, so it grows out of whichever
   edge faces the pin — including when the pin's preferred side had no room. */
.hotspot[data-bubble-side="left"] .hotspot-bubble {
  transform-origin: right center;
}

.hotspot-bubble-english {
  overflow: hidden;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.hotspot-bubble-chinese {
  overflow: hidden;
  color: rgb(255 255 255 / 0.68);
  font-size: 11px;
  font-weight: 560;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.hotspot-bubble-chinese:empty {
  display: none;
}

@keyframes hotspot-pulse {
  0%,
  72%,
  100% {
    transform: scale(0.92);
    opacity: 0;
  }

  12% {
    transform: scale(1);
    opacity: 0.55;
  }

  42% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hotspot::after {
    animation: none;
  }

  .hotspot-pin,
  .hotspot-bubble,
  .hotspot {
    transition: none;
  }
}

.word-card {
  align-self: stretch;
  padding: 18px;
}

.word-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#word-english {
  font-size: 42px;
  line-height: 1;
  font-weight: 780;
}

.phonetic {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  font-size: 17px;
}

.translation {
  margin-top: 20px;
  font-size: 26px;
  font-weight: 760;
}

.definition {
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.word-meta {
  display: grid;
  gap: 12px;
  margin: 24px 0 0;
}

.word-meta div {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}

.word-meta dt {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 760;
  color: var(--ink);
}

.word-meta dd {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

@media (max-width: 900px) {
  .model-stage {
    grid-template-columns: 1fr;
  }

  .viewer-shell {
    min-height: 560px;
  }

  .canvas-wrap {
    min-height: 500px;
  }
}

@media (max-width: 767px) {
  body[data-embedded="true"],
  body[data-embedded="true"] .model-stage,
  body[data-embedded="true"] .viewer-shell {
    height: 100dvh;
    min-height: 0;
  }

  body[data-embedded="true"] .viewer-topbar {
    min-height: 45px;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 6px 8px;
  }

  body[data-embedded="true"] .viewer-footer {
    min-height: 34px;
    flex-wrap: nowrap;
    padding: 5px 8px;
    font-size: 10px;
    line-height: 1.35;
  }

  body[data-embedded="true"] .canvas-wrap {
    min-height: 0;
  }

  .scene-breadcrumb > span,
  .scene-breadcrumb > h1,
  .desktop-only-label,
  .viewer-action-label,
  .scene-license,
  #scene-attribution {
    display: none;
  }

  .mobile-only-icon {
    display: block;
    width: 20px;
    height: 20px;
  }

  .scene-breadcrumb a,
  .viewer-actions button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    padding: 0;
  }

  .viewer-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
  }

  #toggle-labels[data-labels-visible="true"] .labels-hidden-icon,
  #toggle-labels[data-labels-visible="false"] .labels-visible-icon {
    display: none;
  }

  .viewer-footer-note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
