:root {
  --ink: #e9eef7;
  --muted: #9aa8bf;
  --navy: #101827;
  --panel: #162033;
  --cream: #f7f1e6;
  --paper: #fffaf0;
  --line: rgba(255, 255, 255, 0.12);
  --blue: #7fb6dd;
  --blue-deep: #2e3a5c;
  --gold: #f0c987;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--navy);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }

.app { height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: rgba(12, 18, 30, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 16px rgba(127, 182, 221, 0.8);
  align-self: center;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; }
.brand small { color: var(--muted); font-size: 12px; }

.floors { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.06); padding: 4px; border-radius: 999px; }
.floors button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 13px;
}
.floors button.active { background: var(--cream); color: var(--navy); font-weight: 700; }

.status { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.status.ok .pulse { background: #8fd6a3; box-shadow: 0 0 10px #8fd6a3; }
.status.bad .pulse { background: #e08b8b; box-shadow: 0 0 10px #e08b8b; }

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

.stage { position: relative; min-width: 0; overflow: hidden; background: #0b1220; }
.scene {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.05) translate(calc(var(--px, 0) * 12px), calc(var(--py, 0) * 9px));
  transition: transform 0.18s ease-out;
  will-change: transform;
}
.stage:not(.room) .scene { display: none; }

.home-view {
  position: absolute; inset: 0; z-index: 1; overflow: hidden;
  display: none; align-items: center; justify-content: center;
  background: #fdfdfd;
}
.home-view.show { display: flex; }
.home-bg {
  position: absolute; inset: -5%;
  background: #fdfdfd;
  transform: translate(calc(var(--px, 0) * -16px), calc(var(--py, 0) * -12px)) scale(1.06);
  transition: transform 0.2s ease-out;
  will-change: transform;
}
.home-bg::after { content: none; }
.home-frame {
  position: relative; max-width: 100%; max-height: 100%;
  transform: perspective(1500px) rotateX(calc(var(--py, 0) * -2.2deg)) rotateY(calc(var(--px, 0) * 3deg));
  transition: transform 0.18s ease-out;
  will-change: transform;
}
.home-frame.zooming {
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.5s ease;
}
.home-frame > img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
}
.home-hotspots { position: absolute; inset: 0; z-index: 2; }

.character {
  position: absolute; left: var(--char-x, 50%); bottom: var(--char-y, 10%);
  height: var(--char-h, 40%); transform: translateX(-50%);
  z-index: 2; display: none; pointer-events: none;
}
.stage.room .character.show { display: block; }
.character img {
  height: 100%; width: auto; display: block;
  animation: char-idle 4s ease-in-out infinite;
  filter: drop-shadow(0 12px 14px rgba(30, 40, 60, 0.28));
}
.char-shadow {
  position: absolute; left: 50%; bottom: -4px; width: 72%; height: 16px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(30, 40, 60, 0.38), transparent 70%);
  filter: blur(4px); z-index: -1;
}
@keyframes char-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.hotspot {
  position: absolute; transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: rgba(10, 16, 28, 0.55);
  color: #fff; border-radius: 999px; padding: 6px 11px;
  font-size: 12px; backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.hotspot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 10px var(--blue);
}
.hotspot:hover { background: rgba(46, 58, 92, 0.92); border-color: rgba(255, 255, 255, 0.7); }
.shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.12) 0%, rgba(8, 12, 20, 0) 35%, rgba(8, 12, 20, 0.55) 100%);
  pointer-events: none;
}

.stage-info { position: absolute; left: 30px; bottom: 96px; max-width: 520px; z-index: 2; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); }
.stage-info h1 { margin: 0 0 6px; font-size: clamp(26px, 3vw, 38px); letter-spacing: 0.04em; }
.stage-info p { margin: 0; color: rgba(255, 255, 255, 0.78); font-size: 14px; }
.stage:not(.room) .stage-info { text-shadow: none; }
.stage:not(.room) .stage-info h1 { color: #24303f; }
.stage:not(.room) .stage-info p { color: #5f6d80; }
.stage:not(.room) .tags span {
  color: #2e3a5c; background: rgba(255, 255, 255, 0.7);
  border-color: rgba(46, 58, 92, 0.18);
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span {
  font-size: 12px; color: #eaf4ff; background: rgba(30, 58, 84, 0.55);
  border: 1px solid rgba(160, 205, 235, 0.35); padding: 4px 9px; border-radius: 999px;
}

.stage-actions { position: absolute; right: 24px; bottom: 24px; display: flex; gap: 10px; z-index: 3; }
button.primary, button.ghost {
  border-radius: 999px; padding: 11px 18px; font-size: 14px; border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}
button.primary { background: var(--cream); color: var(--navy); font-weight: 700; }
button.primary:hover { transform: translateY(-1px); background: #fff; }
button.ghost { background: rgba(10, 16, 28, 0.55); color: #e8f1fb; border-color: rgba(255, 255, 255, 0.22); backdrop-filter: blur(8px); }
button.ghost:hover { background: rgba(10, 16, 28, 0.75); }
button.small { padding: 7px 12px; font-size: 12px; }
button.icon { border: 0; background: transparent; color: #6b788c; font-size: 24px; line-height: 1; padding: 0 6px; }

.map {
  position: absolute; inset: 22px; z-index: 5;
  display: none; flex-direction: column;
  background: rgba(10, 16, 28, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  padding: 18px;
  backdrop-filter: blur(14px);
}
.map.open { display: flex; }
.map-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.map-head span { font-size: 15px; font-weight: 700; letter-spacing: 0.08em; color: #dce8f7; }
.map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; overflow: auto; padding: 2px; }
.room-card {
  position: relative; min-height: 132px; border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14); background: #111a2a; text-align: left; padding: 0;
}
.room-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s ease; }
.room-card:hover img { transform: scale(1.04); }
.room-card .card-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.02), rgba(0,0,0,0.58)); }
.room-card .card-label { position: absolute; left: 11px; right: 11px; bottom: 9px; color: #fff; font-size: 14px; font-weight: 700; text-shadow: 0 1px 8px rgba(0,0,0,0.6); }
.room-card .card-tags { position: absolute; left: 11px; right: 11px; bottom: 30px; display: flex; gap: 4px; flex-wrap: wrap; }
.room-card .card-tags span { font-size: 10px; color: #d9ecff; background: rgba(0,0,0,0.4); padding: 2px 6px; border-radius: 999px; }

.chat {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--cream); color: #24303f;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
}
.chat-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #e4dccb; background: var(--paper); }
.chat-who { display: flex; align-items: baseline; gap: 10px; }
.chat-who strong { font-size: 15px; }
.chat-who span { font-size: 12px; color: #8a6f52; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.msg { max-width: 84%; padding: 10px 13px; border-radius: 15px; font-size: 14px; line-height: 1.62; white-space: pre-wrap; word-break: break-word; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid #e7ddcc; border-bottom-left-radius: 5px; }
.msg.user { align-self: flex-end; background: var(--blue-deep); color: #fff; border-bottom-right-radius: 5px; }
.msg.system { align-self: center; background: transparent; color: #8b97a7; font-size: 12px; text-align: center; padding: 4px 8px; }
.msg .stamp { display: block; margin-top: 4px; font-size: 10px; opacity: 0.5; }
.msg .voice {
  margin-top: 7px; border: 1px solid #d9cdb9; background: #fff7e8;
  border-radius: 999px; padding: 3px 10px; font-size: 11px; color: #7a5c3a;
}
.typing { align-self: flex-start; color: #8a6f52; font-size: 13px; padding: 4px 8px; }
.composer { flex: none; display: flex; gap: 8px; padding: 12px; border-top: 1px solid #e4dccb; background: var(--paper); }
.composer input {
  flex: 1; min-width: 0; border: 1px solid #e0d5c2; background: #fff;
  border-radius: 12px; padding: 10px 12px; font: inherit; color: #24303f; outline: none;
}
.composer input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(127, 182, 221, 0.18); }
.composer button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--blue-deep); color: #fff; font-weight: 700; }
.composer button:disabled { opacity: 0.5; cursor: default; }

.dock {
  position: absolute; left: 18px; top: 18px; z-index: 7;
  display: flex; flex-wrap: wrap; gap: 6px; max-width: 380px;
}
.dock button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 16, 28, 0.55);
  color: #e8f1fb; border-radius: 999px; padding: 7px 12px;
  font-size: 12px; backdrop-filter: blur(8px);
}
.dock button:hover { background: rgba(10, 16, 28, 0.8); }

.panel {
  position: absolute; inset: 22px; z-index: 8;
  display: none; flex-direction: column;
  background: rgba(247, 241, 230, 0.98); color: #24303f;
  border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35); overflow: hidden;
}
.panel.open { display: flex; }
.panel-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; background: var(--paper); border-bottom: 1px solid #e4dccb;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-body { flex: 1; overflow: auto; padding: 18px 20px; }

.row { display: flex; gap: 8px; align-items: center; }
.input {
  flex: 1; min-width: 0; border: 1px solid #e0d5c2; background: #fff;
  border-radius: 10px; padding: 9px 12px; font: inherit; color: #24303f; outline: none;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(127, 182, 221, 0.18); }
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px;
  background: var(--blue-deep); color: #fff; font-weight: 700;
}
.btn.secondary { background: #efe5d4; color: #5b4a36; }
.btn:disabled { opacity: 0.5; cursor: default; }
.item {
  padding: 12px; border: 1px solid #e7ddcc; background: #fff;
  border-radius: 12px; margin-bottom: 8px;
}
.item.click { cursor: pointer; }
.item.click:hover { border-color: var(--blue); }
.item h3 { margin: 0 0 6px; font-size: 14px; line-height: 1.45; }
.item p { margin: 0; color: #5f6d80; font-size: 12px; line-height: 1.55; }
.item .meta { color: #8a97a8; font-size: 11px; margin-top: 6px; }
.pre {
  white-space: pre-wrap; line-height: 1.7; font-size: 14px;
  background: #fff; border: 1px solid #e7ddcc; border-radius: 12px; padding: 14px;
}
.muted { color: #8a97a8; font-size: 12px; line-height: 1.6; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: #6b788c; margin-bottom: 5px; }
.field input[type="time"], .field select {
  border: 1px solid #e0d5c2; border-radius: 9px; padding: 8px; font: inherit;
}
.field input[type="checkbox"] { width: 16px; height: 16px; vertical-align: middle; margin-right: 6px; }
.note-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.note-row span { flex: 1; font-size: 13px; line-height: 1.5; }


@media (max-width: 920px) {
  .topbar { height: 56px; padding: 0 12px; gap: 10px; }
  .brand small { display: none; }
  .brand-name { font-size: 15px; }
  .status { display: none; }
  .layout { grid-template-columns: 1fr; }
  .stage { height: 100%; }
  .stage-info { left: 18px; right: 18px; bottom: 86px; }
  .stage-actions { right: 14px; bottom: 16px; }
  .map { inset: 10px; padding: 12px; border-radius: 18px; }
  .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .room-card { min-height: 118px; }
  .home-hotspots { display: none; }
  .dock { left: 10px; top: 10px; right: 10px; max-width: none; }
  .dock button { padding: 6px 10px; font-size: 11px; }
  .panel { inset: 8px; border-radius: 16px; }
  .panel-head { padding: 12px 14px; }
  .panel-body { padding: 12px; }
  .chat {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: 74dvh; border-left: 0; border-radius: 20px 20px 0 0;
    transform: translateY(105%); transition: transform 0.22s ease;
    box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.35);
  }
  .chat.open { transform: translateY(0); }
  .chat-head { padding: 12px 14px; }
  .messages { padding: 12px; }
  .composer { padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}
