/* ==========================================================================
   應縣木塔營造圖考 · 宣紙亮白（預設）/ 玄墨深色 雙主題建築圖學樣式
   ========================================================================== */

:root {
  --bg-app: #f4f1ea;
  --bg-stage: #f8f6f0;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 253, 249, 0.91);
  --bg-muted: #ede8dd;
  --bg-hover: #e4ddd0;

  --line-soft: rgba(42, 34, 25, 0.11);
  --line-strong: rgba(42, 34, 25, 0.24);

  --ink-1: #1f1b16;
  --ink-2: #574e43;
  --ink-3: #83786a;

  --vermilion: #ae3526;
  --vermilion-tint: rgba(174, 53, 38, 0.11);
  --timber: #88542e;
  --ochre: #c88224;
  --ochre-tint: rgba(200, 130, 36, 0.15);
  --slate: #3b5968;
  --slate-tint: rgba(59, 89, 104, 0.13);

  --shadow-sm: 0 6px 22px rgba(32, 26, 18, 0.08);
  --shadow-lg: 0 14px 38px rgba(32, 26, 18, 0.15);

  --serif: "Noto Serif TC", "Songti TC", "STSong", Georgia, serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg-app: #131210;
  --bg-stage: #181613;
  --bg-card: #1d1b17;
  --bg-glass: rgba(28, 25, 21, 0.91);
  --bg-muted: #26231d;
  --bg-hover: #322e26;

  --line-soft: rgba(242, 233, 218, 0.11);
  --line-strong: rgba(242, 233, 218, 0.24);

  --ink-1: #f2ede4;
  --ink-2: #bdb3a4;
  --ink-3: #877d6f;

  --vermilion: #da5a48;
  --vermilion-tint: rgba(218, 90, 72, 0.17);
  --timber: #c48756;
  --ochre: #e59f3c;
  --ochre-tint: rgba(229, 159, 60, 0.17);
  --slate: #6f9cb0;
  --slate-tint: rgba(111, 156, 176, 0.16);

  --shadow-sm: 0 6px 24px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.54);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--ink-1);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.app-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Header */
.header-bar {
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line-soft);
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.back-pill {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--bg-muted);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.back-pill:hover {
  border-color: var(--line-strong);
  color: var(--ink-1);
}

.seal-mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--vermilion);
  color: #fff9f2;
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.12;
  display: grid;
  place-items: center;
  text-align: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1.5px rgba(255, 245, 232, 0.35);
}

.title-block { min-width: 0; }

.title-block h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-block p {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.tool-btn {
  height: 33px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--ink-1);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
}

.tool-btn.active {
  background: var(--vermilion-tint);
  border-color: rgba(174, 53, 38, 0.36);
  color: var(--vermilion);
}

.tool-btn-primary {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #fff;
}

.tool-btn-primary:hover {
  background: var(--vermilion);
  filter: brightness(1.08);
}

/* Main 3-Column Grid */
.studio-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr) 344px;
}

/* Left Pane */
.pane-left {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--line-soft);
  z-index: 10;
}

.pane-head {
  padding: 12px 15px 9px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-only-btn,
.mobile-sheet-bar {
  display: none;
}

.transport-ActionsRow {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.kicker {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--vermilion);
}

.pane-head h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 15.5px;
}

.step-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-1);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}

.step-row:hover { background: var(--bg-muted); }

.step-row.done .step-idx {
  background: var(--timber);
  border-color: var(--timber);
  color: #fff;
}

.step-row.current {
  background: var(--vermilion-tint);
  border-color: rgba(174, 53, 38, 0.36);
}

.step-row.current .step-idx {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #fff;
}

.step-idx {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--ink-2);
  margin-top: 1px;
}

.step-txt { min-width: 0; flex: 1; }

.step-name {
  font-size: 12.2px;
  font-weight: 600;
  line-height: 1.28;
}

.step-sub {
  font-size: 10.2px;
  color: var(--ink-3);
  margin-top: 2px;
}

.step-sub .an-flag { color: var(--ochre); font-weight: 600; }

/* Mini Section Stack */
.section-nav-box {
  flex-shrink: 0;
  padding: 9px 12px 11px;
  background: var(--bg-muted);
  border-top: 1px solid var(--line-soft);
}

.section-nav-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.section-nav-head small { font-weight: 400; color: var(--ink-3); font-size: 10px; }

.level-bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lvl-btn {
  height: 16.5px;
  margin: 0 auto;
  padding: 0 7px;
  border-radius: 3px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 9.8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.14s ease;
}

.lvl-btn.an {
  background: var(--ochre-tint);
  border-color: rgba(200, 130, 36, 0.38);
  color: var(--ochre);
  font-weight: 600;
}

.lvl-btn.unbuilt { opacity: 0.4; }

.lvl-btn:hover {
  opacity: 1;
  border-color: var(--vermilion);
  color: var(--vermilion);
}

/* Center Stage */
.stage-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg-stage);
  overflow: hidden;
  user-select: none;
}

.webgl-mount {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.webgl-mount:active { cursor: grabbing; }

/* Loader */
.loader-mask {
  position: absolute;
  inset: 0;
  background: var(--bg-stage);
  display: grid;
  place-items: center;
  z-index: 45;
  transition: opacity 0.35s ease;
}

.loader-mask.hide { opacity: 0; pointer-events: none; }

.loader-box {
  padding: 24px 30px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loader-ring {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--line-soft);
  border-top-color: var(--vermilion);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-title { font-family: var(--serif); font-size: 14.5px; font-weight: 700; }
.loader-msg { font-size: 11.5px; color: var(--ink-3); }

/* 3D Floor Signboards & SVG Leader Lines */
.leader-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.leader-poly {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}

.leader-poly.an { stroke: rgba(200, 130, 36, 0.72); }

.leader-dot {
  fill: var(--vermilion);
  stroke: var(--bg-card);
  stroke-width: 1.5;
}

.leader-dot.an { fill: var(--ochre); }

.floor-badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 7;
}

.f-badge {
  position: absolute;
  transform: translate(0, -50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px 0 5px;
  border-radius: 4px;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--vermilion);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  font-size: 10.8px;
  color: var(--ink-1);
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.f-badge:hover {
  transform: translate(3px, -50%);
  border-color: var(--vermilion);
  z-index: 18;
}

.f-badge.an { border-left-color: var(--ochre); }
.f-badge.sp { border-left-color: var(--slate); }

.fb-kind {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--vermilion-tint);
  color: var(--vermilion);
}

.f-badge.an .fb-kind { background: var(--ochre-tint); color: var(--ochre); }
.f-badge.sp .fb-kind { background: var(--slate-tint); color: var(--slate); }

.fb-title { font-family: var(--serif); font-weight: 700; font-size: 11.2px; }
.fb-elev { font-size: 9.8px; color: var(--ink-3); }
.fb-note { font-family: var(--serif); font-size: 9.8px; color: var(--timber); padding-left: 4px; border-left: 1px solid var(--line-soft); }

/* 3D Structural Callout Pins */
.callout-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 8;
}

.c-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 6px;
  border-radius: 99px;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  font-size: 11.2px;
  font-weight: 600;
  color: var(--ink-1);
  white-space: nowrap;
  cursor: pointer;
}

.c-pin:hover { border-color: var(--vermilion); z-index: 20; }

.c-pin-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--vermilion);
  box-shadow: 0 0 0 3px var(--vermilion-tint);
}

.c-pin.an .c-pin-dot {
  background: var(--ochre);
  box-shadow: 0 0 0 3px var(--ochre-tint);
}

.c-pin-pop {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  width: 215px;
  white-space: normal;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  font-size: 11.2px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.c-pin:hover .c-pin-pop { opacity: 1; }

/* Component Raycast Probe Card */
.probe-card {
  position: absolute;
  left: 14px;
  top: 58px;
  max-width: 280px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--vermilion);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  z-index: 16;
}

.probe-card.hidden { display: none; }
.probe-tag { font-size: 10px; font-weight: 700; color: var(--vermilion); }
.probe-name { font-family: var(--serif); font-size: 13.5px; font-weight: 700; margin-top: 1px; }
.probe-desc { font-size: 11.2px; color: var(--ink-2); line-height: 1.45; margin-top: 3px; }

/* View Modes Bar */
.view-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  z-index: 14;
}

.view-chip {
  height: 29px;
  padding: 0 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11.8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}

.view-chip:hover { background: var(--bg-muted); color: var(--ink-1); }

.view-chip.active {
  background: var(--vermilion);
  color: #fff;
  font-weight: 600;
}

.view-chip-stairs {
  color: var(--vermilion);
  font-weight: 700;
}

.view-chip-statues {
  color: var(--ochre);
  font-weight: 700;
}

.statue-hall-bar {
  position: absolute;
  top: 52px;
  left: 12px;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 5px;
  padding: 5px;
  border-radius: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  z-index: 16;
  max-width: calc(100% - 165px);
}
.statue-hall-bar::-webkit-scrollbar { display: none; }
.statue-hall-bar.hidden { display: none; }

.hall-pill {
  flex-shrink: 0;
  height: 27px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--ink-1);
  font-family: inherit;
  font-size: 11.4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.hall-pill:hover,
.hall-pill.active {
  background: var(--ochre);
  border-color: var(--ochre);
  color: #fff;
}

.photo-links-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.photo-ref-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-muted);
  border: 1px solid var(--line-soft);
  color: var(--ink-1);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.14s ease;
}

.photo-ref-link:hover {
  border-color: var(--vermilion);
  color: var(--vermilion);
  background: var(--vermilion-tint);
}

.mini-follow-btn {
  height: 25px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  color: var(--ink-1);
  font-family: inherit;
  font-size: 11.2px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.mini-follow-btn.hidden { display: none; }

.mini-follow-btn.active {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #fff;
}

.mode-slider-box {
  position: absolute;
  top: 54px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  font-size: 11.8px;
  z-index: 15;
}

.mode-slider-box.hidden { display: none; }
.mode-slider-box input { width: 140px; accent-color: var(--vermilion); cursor: pointer; }

/* Elevation Gauge */
.elevation-gauge {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 132px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  z-index: 14;
}

.gauge-caption { font-size: 10px; color: var(--ink-3); }
.gauge-num { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--vermilion); margin-top: 1px; }
.gauge-num small { font-size: 11.5px; color: var(--ink-2); margin-left: 2px; }
.gauge-track { height: 5px; border-radius: 99px; background: var(--bg-muted); margin-top: 5px; overflow: hidden; }
.gauge-fill { height: 100%; width: 2%; background: linear-gradient(90deg, var(--timber), var(--vermilion)); transition: width 0.4s ease; }
.gauge-sub { font-size: 9.8px; color: var(--ink-3); text-align: right; margin-top: 4px; }

/* Hint & Zoom Dock */
.stage-hint {
  position: absolute;
  left: 14px;
  bottom: 82px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--bg-glass);
  border: 1px solid var(--line-soft);
  font-size: 10.8px;
  color: var(--ink-3);
  pointer-events: none;
  z-index: 11;
}

.zoom-dock {
  position: absolute;
  right: 14px;
  bottom: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 9px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  z-index: 15;
}

.dg-zoom-dock { right: 14px; bottom: 108px; }

.zoom-ctl {
  width: 38px;
  height: 35px;
  border: none;
  background: transparent;
  color: var(--ink-1);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.14s ease, color 0.14s ease;
}

.zoom-ctl:hover { background: var(--vermilion-tint); color: var(--vermilion); }
.zoom-ctl:active { background: var(--vermilion); color: #fff; }
.zoom-ctl-sm { font-size: 14.5px; color: var(--ink-2); }
.zoom-sep { width: 22px; height: 1px; background: var(--line-soft); }

/* Transport Bar */
.transport-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 60px;
  padding: 0 13px;
  border-radius: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 15;
}

.transport-btns { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

.t-btn {
  height: 35px;
  min-width: 33px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--ink-1);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.14s ease;
}

.t-btn:hover { background: var(--bg-hover); border-color: var(--line-strong); }

.t-btn-play {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #fff;
  padding: 0 13px;
}

.t-btn-play:hover { background: var(--vermilion); filter: brightness(1.08); }
.t-btn-play.playing { background: var(--timber); border-color: var(--timber); }

.timeline-box { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.timeline-head {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 2px;
}

.timeline-head strong { color: var(--vermilion); }
.timeline-head span { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 8px; }

#tl-range { width: 100%; margin: 0; accent-color: var(--vermilion); cursor: pointer; }

.tl-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 3px;
  font-size: 8.8px;
  color: var(--ink-3);
}

.speed-pill { min-width: 62px; font-size: 11.5px; }

/* Right Dossier Pane */
.pane-right {
  min-height: 0;
  overflow-y: auto;
  padding: 15px 17px 24px;
  background: var(--bg-card);
  border-left: 1px solid var(--line-soft);
  z-index: 10;
}

.dossier-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step-code { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--vermilion); }

.phase-badge {
  font-size: 10.8px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-muted);
  border: 1px solid var(--line-soft);
  color: var(--ink-2);
}

.phase-badge.an { background: var(--ochre-tint); color: var(--ochre); border-color: rgba(200, 130, 36, 0.35); }

.dossier-title {
  margin: 7px 0 2px;
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.3;
}

.dossier-en { margin: 0 0 13px; font-size: 11.2px; color: var(--ink-3); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 15px;
}

.stat-box {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-muted);
  border: 1px solid var(--line-soft);
}

.stat-k { display: block; font-size: 10.2px; color: var(--ink-3); }
.stat-box strong { display: block; margin-top: 2px; font-family: var(--serif); font-size: 14.5px; }

.dossier-block { margin-bottom: 15px; }

.dossier-block h3 {
  margin: 0 0 7px;
  font-size: 12.2px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dossier-block h3::before {
  content: "";
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--vermilion);
}

.dossier-prose {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.72;
  color: var(--ink-2);
}

.parts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.part-chip {
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--bg-muted);
  border: 1px solid var(--line-soft);
  font-size: 11.3px;
  color: var(--ink-1);
}

.wisdom-box {
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--vermilion-tint);
  border: 1px solid rgba(174, 53, 38, 0.25);
  margin-bottom: 16px;
}

.wisdom-head { font-size: 11.8px; font-weight: 700; color: var(--vermilion); margin-bottom: 4px; }
.wisdom-box p { margin: 0; font-size: 12px; line-height: 1.6; color: var(--ink-1); }

.cat-filters {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11.3px;
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
}

.cat-btn:hover, .cat-btn.active {
  border-color: var(--vermilion);
  background: var(--vermilion-tint);
  color: var(--ink-1);
}

.cat-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Dougong Lab Modal */
.dg-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 13, 10, 0.56);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 60;
}

.dg-backdrop.hidden { display: none; }

.dg-dialog {
  width: min(1080px, 95vw);
  height: min(720px, 90vh);
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dg-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dg-header h2 { margin: 2px 0 0; font-family: var(--serif); font-size: 17.5px; }

.dg-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 340px;
}

.dg-viewport {
  position: relative;
  background: var(--bg-stage);
  border-right: 1px solid var(--line-soft);
  overflow: hidden;
}

.dg-mount { width: 100%; height: 100%; cursor: grab; }
.dg-mount:active { cursor: grabbing; }

.dg-tip {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--bg-glass);
  border: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--ink-3);
  pointer-events: none;
}

.dg-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dg-slider-row { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; }
.dg-slider-row input { flex: 1; accent-color: var(--vermilion); cursor: pointer; }

.dg-presets { display: flex; flex-wrap: wrap; gap: 6px; }

.preset-btn {
  height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11.2px;
  cursor: pointer;
}

.preset-btn:hover, .preset-btn.active {
  border-color: var(--vermilion);
  background: var(--vermilion-tint);
  color: var(--vermilion);
}

.dg-side {
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.dg-lead { margin: 0; font-size: 12.2px; line-height: 1.62; color: var(--ink-2); }

.dg-focus-card {
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--vermilion-tint);
  border: 1px solid rgba(174, 53, 38, 0.28);
}

.dg-part-layer { font-size: 10px; font-weight: 700; color: var(--vermilion); }
.dg-focus-card h3 { margin: 3px 0 4px; font-family: var(--serif); font-size: 15.5px; }
.dg-focus-card p { margin: 0; font-size: 12px; line-height: 1.58; color: var(--ink-1); }

.dg-list-head { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }

.dg-part-list { display: flex; flex-direction: column; gap: 4px; }

.dg-item-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 9px;
  border-radius: 5px;
  border: 1px solid var(--line-soft);
  background: var(--bg-muted);
  color: var(--ink-1);
  font-family: inherit;
  font-size: 11.8px;
  cursor: pointer;
  text-align: left;
}

.dg-item-btn:hover, .dg-item-btn.active {
  border-color: var(--vermilion);
  background: var(--vermilion-tint);
  color: var(--vermilion);
}

.dg-item-btn small { font-size: 10px; color: var(--ink-3); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

@media (max-width: 1180px) {
  .studio-grid { grid-template-columns: 236px minmax(0, 1fr) 294px; }
  .title-block p { display: none; }
}

@media (max-width: 900px) {
  .hide-sm { display: none !important; }

  .header-bar {
    height: 48px;
    padding: 0 10px;
    gap: 6px;
  }

  .seal-mark {
    width: 28px;
    height: 28px;
    font-size: 9.5px;
  }

  .title-block h1 {
    font-size: 15px;
  }

  .back-pill {
    height: 28px;
    padding: 0 8px;
    font-size: 11.5px;
  }

  .header-tools {
    gap: 5px;
  }

  .tool-btn {
    height: 29px;
    padding: 0 8px;
    font-size: 11.2px;
  }

  /* Full-screen spacious 3D stage on mobile; left/right panes become slide-up bottom sheets! */
  .studio-grid {
    display: block;
    position: relative;
    width: 100%;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
  }

  .stage-wrap {
    width: 100%;
    height: 100%;
  }

  /* Single-row horizontally scrollable view modes strip — never wraps or covers tower */
  .view-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px;
    gap: 3px;
  }
  .view-bar::-webkit-scrollbar { display: none; }

  .view-chip {
    flex-shrink: 0;
    height: 27px;
    padding: 0 9px;
    font-size: 11.3px;
  }

  /* Compact single-line height badge tucked cleanly below view-bar */
  .elevation-gauge {
    top: 46px;
    right: 8px;
    width: auto;
    padding: 4px 9px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }
  .gauge-caption, .gauge-track, .gauge-sub { display: none; }
  .gauge-num { font-size: 13.5px; margin: 0; }
  .gauge-num::before {
    content: "標高 ";
    font-family: var(--sans);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-3);
  }

  /* Contextual slider neatly aligned next to compact height pill */
  .mode-slider-box,
  .statue-hall-bar {
    top: 46px;
    left: 8px;
    max-width: calc(100vw - 122px);
    padding: 4px 7px;
    gap: 4px;
    font-size: 11px;
  }
  .mode-slider-box input { width: 88px; }

  .probe-card {
    top: 86px;
    left: 8px;
    right: 56px;
    max-width: none;
    padding: 7px 10px;
  }
  .probe-name { font-size: 12.5px; }
  .probe-desc { font-size: 10.8px; }

  /* Slimmer floor badges when user toggles them ON on mobile */
  .fb-elev, .fb-note { display: none; }
  .f-badge { height: 20px; padding: 0 6px 0 4px; font-size: 10px; }

  .stage-hint { display: none; }

  /* Zoom dock positioned cleanly above the 2-row mobile transport bar */
  .zoom-dock {
    right: 10px;
    bottom: 102px;
  }
  .zoom-ctl { width: 34px; height: 32px; font-size: 16px; }

  /* Spacious 2-row thumb-friendly mobile transport bar */
  .transport-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: auto;
    padding: 8px 10px;
    border-radius: 12px;
    flex-wrap: wrap;
    gap: 7px;
  }

  .timeline-box {
    order: -1;
    flex: 0 0 100%;
    width: 100%;
  }
  .tl-ticks { display: none; }
  .timeline-head { font-size: 11.2px; margin-bottom: 4px; }

  .transport-btns {
    flex: 1;
    justify-content: flex-start;
    gap: 4px;
  }

  .t-btn {
    height: 32px;
    min-width: 30px;
    padding: 0 7px;
    font-size: 11.5px;
  }
  .t-btn-play { padding: 0 10px; }
  .speed-pill { min-width: 38px; }

  .mobile-only-btn {
    display: inline-flex;
  }

  /* Slide-up Bottom Sheets for 18 Steps & Architectural Dossier */
  .pane-left,
  .pane-right {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 68vh;
    height: 68dvh;
    max-height: 68dvh;
    border: none;
    border-top: 1px solid var(--line-strong);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.24);
    transform: translateY(104%);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 50;
  }

  .pane-left.sheet-open,
  .pane-right.sheet-open {
    transform: translateY(0);
  }

  .mobile-sheet-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--line-soft);
  }

  .sheet-bar-title {
    font-family: var(--serif);
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-1);
  }

  .sheet-close-btn {
    height: 28px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--line-soft);
    background: var(--bg-muted);
    color: var(--ink-1);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
  }

  /* Dougong modal mobile adaptation */
  .dg-backdrop { padding: 8px; }
  .dg-dialog { width: 100%; height: 92dvh; border-radius: 12px; }
  .dg-header { padding: 10px 12px; }
  .dg-header h2 { font-size: 14.5px; }
  .dg-grid { grid-template-columns: 1fr; grid-template-rows: 54% 46%; }
  .dg-viewport { border-right: none; border-bottom: 1px solid var(--line-soft); }
  .dg-tip { display: none; }
}

@media (max-width: 520px) {
  .hide-xs { display: none !important; }
  #btn-first, #btn-last { display: none; }
}
