:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", system-ui, sans-serif;
  --page: #eef1f3;
  --text: #132431;
  --quiet: #526472;
  --line: #cfd9e1;
  --panel: #fcfdfe;
  --stage: #142534;
  --accent: #145c70;
  --soft-accent: #e5f1f5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 300px; margin: 0; background: var(--page); color: var(--text); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, canvas:focus-visible { outline: 3px solid #25a6bd; outline-offset: 3px; }

.workspace {
  width: min(1040px, 100%);
  margin-inline: auto;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.page-header, .viewer-heading, .viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .78rem;
}
.page-header { margin-bottom: 1rem; }
.heading { min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: .4rem; margin: 0 0 .17rem; color: var(--accent); font-size: .875rem; font-weight: 700; }
.eyebrow span { width: .58rem; height: .58rem; background: #1884a1; }
h1, h2 { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.45rem, 4.3vw, 2.35rem); letter-spacing: .035em; line-height: 1.2; }
.copy-button {
  flex-shrink: 0;
  min-height: 44px;
  padding: .48rem .74rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: #f8fbfd;
  color: var(--accent);
  font-size: .87rem;
  font-weight: 750;
  white-space: nowrap;
}

.viewer { overflow: hidden; border: 1px solid var(--line); border-radius: .8rem; background: var(--panel); }
.viewer-heading { flex-wrap: wrap; padding: .68rem .85rem; }
.viewer-heading h2 { font-size: clamp(1.03rem, 3.5vw, 1.34rem); line-height: 1.45; }
.viewer-heading p { margin: 0; color: var(--quiet); font-size: .83rem; white-space: nowrap; }
.viewer-heading p span { color: var(--text); font-variant-numeric: tabular-nums; }

.stage {
  position: relative;
  height: clamp(19.5rem, 52vh, 35rem);
  height: clamp(19.5rem, 52svh, 35rem);
  overflow: hidden;
  background: radial-gradient(ellipse at 52% 49%, #263e51 0%, #1a2e3e 43%, var(--stage) 82%);
}
.viewport, .stage-status, .plan-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewport { touch-action: none; }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewport canvas:focus-visible { outline-offset: -5px; }
.motion-toggle {
  position: absolute;
  z-index: 1;
  top: .65rem;
  right: .65rem;
  min-height: 44px;
  padding: .35rem .62rem;
  border: 1px solid #94a8b5;
  border-radius: .35rem;
  background: rgba(18, 36, 49, .88);
  color: #f4f9fc;
  font-size: .78rem;
  font-weight: 650;
}
.stage-status {
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: .85rem;
  color: #f7fbff;
  background: rgba(20, 37, 52, .62);
  font-size: .95rem;
  pointer-events: none;
}
.loader { width: 1.68rem; height: 1.68rem; border: 2px solid rgba(166, 219, 237, .22); border-top-color: #8fdeef; border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loader { animation: none; border-color: #8fdeef; } }

.plan-fallback {
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: .45rem;
  margin: 0;
  padding: .8rem;
  background: var(--stage);
  color: #f4f9fc;
  text-align: center;
}
.plan-fallback img { display: block; width: 100%; max-width: 560px; min-height: 0; flex: 1 1 auto; object-fit: contain; }
.plan-fallback figcaption { flex: 0 0 auto; font-size: .875rem; }
.retry-button { flex: 0 0 auto; min-height: 44px; padding: .4rem .85rem; border: 1px solid #7ea5b7; border-radius: .35rem; color: white; background: #234759; }

.viewer-footer { min-height: 3.65rem; padding: .36rem .68rem; }
.gesture-help { display: flex; flex-wrap: wrap; align-items: center; gap: .18rem .5rem; margin: 0; color: var(--quiet); font-size: .83rem; }
.gesture-help span { white-space: nowrap; }
.tool-row { display: flex; align-items: center; gap: .2rem; flex-shrink: 0; }
.tool-row button { min-width: 44px; min-height: 44px; padding: .35rem .47rem; border: 1px solid transparent; border-radius: .38rem; color: var(--accent); background: transparent; font-size: .84rem; font-weight: 750; white-space: nowrap; }
.tool-row button[aria-pressed="true"] { border-color: #b2d0dc; background: var(--soft-accent); }

.cabin-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .48rem; margin-top: .72rem; }
.cabin-option { min-height: 48px; padding: .5rem .3rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--panel); color: var(--text); font-size: .9rem; font-weight: 700; }
.cabin-option[aria-pressed="true"] { border-color: #176981; background: #176981; color: #fff; }
.copy-status { position: fixed; z-index: 4; bottom: max(1rem, env(safe-area-inset-bottom)); left: 50%; max-width: calc(100vw - 2rem); margin: 0; transform: translateX(-50%); text-align: center; }
.copy-status:not(:empty) { padding: .55rem .8rem; border-radius: .42rem; background: #133645; color: white; box-shadow: 0 4px 20px rgba(10, 32, 43, .19); }

@media (hover: hover) {
  .copy-button:hover, .tool-row button:not(:disabled):hover, .cabin-option[aria-pressed="false"]:hover { background: var(--soft-accent); }
}
@media (max-width: 620px) {
  .cabin-picker { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cabin-option { grid-column: span 2; }
  .cabin-option:nth-child(n + 4) { grid-column: span 3; }
}
@media (max-width: 380px) {
  .workspace { padding-inline: max(.65rem, env(safe-area-inset-left)) max(.65rem, env(safe-area-inset-right)); }
  .viewer-heading { row-gap: .1rem; }
  .gesture-help { font-size: .76rem; }
  .tool-row button { font-size: .8rem; }
}

