:root,
[data-theme="sage"] {
  --bg: #ebe6de;
  --bg-2: #e3ddd4;
  --panel: rgba(255, 251, 246, 0.62);
  --panel-strong: rgba(255, 252, 248, 0.82);
  --ink: #3f3b36;
  --muted: #7a736a;
  --line: rgba(110, 100, 88, 0.16);
  --glass-line: rgba(255, 255, 255, 0.58);
  --accent: #7d927c;
  --accent-ink: #f7f4ee;
  --accent-2: #b0897a;
  --orb-a: #c5d0c0;
  --orb-b: #d8c6be;
  --orb-c: #c5ced6;
  --chip: rgba(255, 250, 245, 0.55);
  --shadow: 0 10px 36px rgba(78, 68, 58, 0.08);
  --tabbar-h: calc(62px + env(safe-area-inset-bottom));
}

[data-theme="sand"] {
  --bg: #efe6dc;
  --bg-2: #e7d8cc;
  --panel: rgba(255, 248, 242, 0.64);
  --panel-strong: rgba(255, 250, 245, 0.84);
  --ink: #433831;
  --muted: #82766c;
  --accent: #a88878;
  --accent-2: #8a7a68;
  --orb-a: #e2cbb8;
  --orb-b: #d4b8ae;
  --orb-c: #cfc6b8;
}

[data-theme="mist"] {
  --bg: #e4e7ea;
  --bg-2: #d8dde2;
  --panel: rgba(248, 250, 252, 0.62);
  --panel-strong: rgba(252, 253, 255, 0.84);
  --ink: #3a3f44;
  --muted: #6f777e;
  --accent: #7d8b96;
  --accent-2: #9a8b82;
  --orb-a: #c5d0d8;
  --orb-b: #d4c8c4;
  --orb-c: #c9d4cc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  position: relative;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.ambiance {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 8% -10%, var(--orb-a) 0%, transparent 55%),
    radial-gradient(900px 620px at 92% 8%, var(--orb-b) 0%, transparent 50%),
    radial-gradient(800px 540px at 70% 100%, var(--orb-c) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
}

.orb-a {
  width: 280px;
  height: 280px;
  left: -60px;
  top: 18%;
  background: var(--orb-a);
}

.orb-b {
  width: 340px;
  height: 340px;
  right: -80px;
  top: 36%;
  background: var(--orb-b);
}

.orb-c {
  width: 240px;
  height: 240px;
  left: 38%;
  bottom: -70px;
  background: var(--orb-c);
}

.glass {
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow);
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidenav {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 22px 16px 20px;
  display: flex;
  flex-direction: column;
  border-radius: 0 24px 24px 0;
  border-left: 0;
}

.brand {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub,
.lan,
.sidenav em {
  color: var(--muted);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 22px 0 auto;
}

.nav-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid transparent;
}

.nav-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.nav-copy strong {
  font-size: 14px;
  font-weight: 650;
}

.nav-copy em,
.nav-count {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.nav-count {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-weight: 700;
}

.nav-links a.active {
  background: color-mix(in srgb, var(--accent) 18%, white);
  border-color: color-mix(in srgb, var(--accent) 28%, white);
  color: var(--ink);
}

.nav-links a.active .nav-count {
  background: var(--accent);
  color: var(--accent-ink);
}

.theme-switch {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
}

.theme-switch button {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(80, 70, 60, 0.12);
}

.theme-switch button[data-theme="sage"] { background: #7d927c; }
.theme-switch button[data-theme="sand"] { background: #a88878; }
.theme-switch button[data-theme="mist"] { background: #7d8b96; }

.theme-switch button.on {
  box-shadow: 0 0 0 2px var(--ink);
}

.top-theme {
  display: none;
  align-items: center;
}

.lan {
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.main {
  min-width: 0;
  padding: 20px 22px 32px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 22px;
}

.title-block h1,
.card h2,
.inspector p {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(22px, 2.4vw, 30px);
  letter-spacing: 0.01em;
}

.muted,
.hint,
.status,
.label {
  color: var(--muted);
  line-height: 1.55;
}

.label {
  font-size: 12px;
  margin-bottom: 4px;
}

.title-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--glass-line);
}

.meta-pill b {
  font-size: 18px;
  font-weight: 700;
}

.meta-pill span {
  font-size: 12px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.primary,
.ghost,
.accent {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

button,
.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.ghost {
  background: color-mix(in srgb, white 55%, transparent);
  color: var(--ink);
  border: 1px solid var(--glass-line);
}

.accent {
  background: var(--accent-2);
  color: #fff;
}

button:disabled {
  opacity: 0.45;
}

.card {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-grid,
.card-grid {
  display: grid;
  gap: 12px;
}

.stat-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}

.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

#view-models,
#view-spaces {
  display: grid;
  gap: 28px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.home-job-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}

.card-foot .ghost {
  padding: 7px 12px;
  font-size: 13px;
}

.asset {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asset h3 {
  margin: 0;
  font-size: 16px;
}

.asset > .muted {
  font-size: 12px;
  word-break: break-all;
}

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.asset-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
}

.tag.on {
  background: color-mix(in srgb, var(--accent) 22%, white);
  color: color-mix(in srgb, var(--accent) 70%, #1a1a1a);
}

.uploader {
  position: relative;
  display: block;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 16px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: color-mix(in srgb, white 48%, transparent);
  overflow: hidden;
}

.file-real {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 32px;
}

.crop-wrap {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 180px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-2) 80%, white);
}

.crop-wrap canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(56vh, 520px);
  object-fit: contain;
  border-radius: 14px;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-form input,
.stack-form input,
.stack-form select,
.size-row input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.stack-form {
  display: grid;
  gap: 8px;
}

.size-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.splat-sizes {
  margin-top: 12px;
}

.dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(62, 56, 50, 0.28);
  backdrop-filter: blur(10px);
  padding: 16px;
}

.dialog-card {
  width: min(460px, 100%);
}

.stage-view {
  margin: 0 -22px -32px;
}

.stage-layout {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  height: calc(100dvh - 118px);
  min-height: 520px;
}

.stage-canvas {
  height: 100%;
  min-height: 56vh;
  background: color-mix(in srgb, var(--bg-2) 70%, white);
  touch-action: none;
  cursor: grab;
}

.stage-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.inspector {
  padding: 16px;
  background: var(--panel-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--glass-line);
  overflow: auto;
}

.inspector label,
.inspector button {
  display: block;
  width: 100%;
  margin: 8px 0;
}

.inspector input[type="range"],
.inspector select {
  width: 100%;
  margin: 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chip {
  border: 0;
  background: var(--chip);
  color: var(--ink);
  padding: 7px 10px;
  width: auto;
}

.chip.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.chip b {
  margin-left: 6px;
  font-weight: 700;
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode {
  flex: 1;
  background: var(--chip);
  color: var(--ink);
}

.mode.on {
  background: var(--accent);
  color: var(--accent-ink);
}

.mesh-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.mesh-previews img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--chip);
}

.tabbar {
  display: none;
}

.sr-viewer {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 216px 1fr;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .title-meta {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding-bottom: var(--tabbar-h);
  }

  .sidenav {
    display: none;
  }

  .main {
    padding: 12px 12px 18px;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 14px;
    border-radius: 18px;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .top-theme {
    display: flex;
  }

  .stat-grid,
  .stage-layout,
  .size-row {
    grid-template-columns: 1fr;
  }

  .stage-view {
    margin: 0 -12px;
  }

  .stage-layout {
    min-height: 0;
    height: auto;
  }

  .stage-canvas {
    height: 46vh;
    min-height: 260px;
  }

  .inspector {
    border-left: 0;
    border-top: 1px solid var(--glass-line);
  }

  .tabbar {
    display: flex;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
    padding: 6px;
    border-radius: 18px;
    gap: 4px;
  }

  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    font-size: 11px;
    padding: 8px 2px;
    border-radius: 12px;
    color: var(--ink);
  }

  .tabbar a b {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
  }

  .tabbar a.active {
    background: color-mix(in srgb, var(--accent) 20%, white);
  }

  .tabbar a.active b {
    color: var(--ink);
  }

  .mobile-theme {
    display: flex;
  }
}

@media (max-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .crop-wrap canvas {
    max-height: min(48vh, 420px);
  }

  .asset-actions button {
    flex: 1 1 calc(50% - 6px);
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .glass,
  .card,
  .inspector,
  .dialog {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--panel-strong);
  }
}

/* ---- 房东采集台内嵌视图（#/landlord） ---------------------------------- */
.landlord-view { height: 100%; }
.landlord-shell { display: flex; flex-direction: column; gap: 12px; min-height: calc(100vh - 200px); }
.landlord-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-radius: 16px; }
.landlord-bar p { margin: 0; }
.landlord-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.landlord-frame { flex: 1 1 auto; width: 100%; min-height: 72vh; border: 0; border-radius: 16px; background: #fff; box-shadow: 0 10px 30px rgba(20, 16, 10, 0.08); }
@media (max-width: 720px) {
  .landlord-shell { min-height: calc(100vh - 240px); }
  .landlord-frame { min-height: 62vh; }
}
