:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: rgba(18, 20, 27, 0.92);
  --panel-strong: #151822;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f6f7fb;
  --muted: #aeb6c8;
  --red: #f22a47;
  --yellow: #f4df35;
  --green: #75d044;
  --cyan: #61c9d5;
  --orange: #f29a56;
  --pink: #de88bd;
  --violet: #8790d0;
  --focus: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  width: 100vw;
  height: 100vh;
  background:
    linear-gradient(180deg, rgba(242, 42, 71, 0.08), transparent 34%),
    #08090d;
}

.viewer-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.view-badges {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.view-badges span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.72);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  backdrop-filter: blur(12px);
}

.control-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.28);
}

.panel-header {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.metric-label {
  margin: 0;
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.control-group {
  display: grid;
  gap: 10px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-button,
.seg-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.control-button:hover,
.seg-button:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.09);
}

.control-button:focus-visible,
.seg-button:focus-visible,
.toggle-line input:focus-visible,
#fovControl:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.control-button.is-active,
.seg-button.is-active {
  border-color: rgba(242, 42, 71, 0.78);
  background: rgba(242, 42, 71, 0.22);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

output {
  color: var(--muted);
  font-size: 12px;
}

#fovControl {
  width: 100%;
  accent-color: var(--red);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.toggle-line input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--red);
}

.info-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.info-strip div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.info-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.source-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.source-map {
  display: grid;
  gap: 8px;
  margin: 0;
}

.source-map img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.source-map figcaption {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(58vh, 68vh) auto;
    min-height: 100vh;
    height: auto;
  }

  .control-shell {
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .control-shell {
    padding: 16px;
  }

  .view-badges {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .view-badges span {
    max-width: 100%;
  }

  .button-grid,
  .info-strip {
    grid-template-columns: 1fr;
  }
}
