:root {
  --red: #e60012;
  --red-dark: #b90010;
  --ink: #171b23;
  --muted: #68707d;
  --line: #e8ebef;
  --paper: #ffffff;
  --soft: #f6f7f9;
  --success: #3aa882;
  --gold: #c9ad64;
  --shadow: 0 18px 48px rgba(23, 27, 35, 0.1);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fff 0%, #f7f8fa 38%, #f3f5f7 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(230, 0, 18, 0.22);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(220px, 320px) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 74px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 260px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.brand img {
  width: min(300px, 100%);
  height: 42px;
  object-fit: contain;
  object-position: left center;
}

.brand span {
  display: none;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.search-box span {
  width: 14px;
  height: 14px;
  border: 2px solid var(--red);
  border-radius: 50%;
  position: relative;
}

.search-box span::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -5px;
  width: 7px;
  border-top: 2px solid var(--red);
  transform: rotate(45deg);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.nav-tabs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.nav-tab,
.login-button,
.avatar-button,
.text-button,
.tool-button,
.profile-tab,
.status-button {
  border: 0;
  background: transparent;
}

.nav-tab {
  min-width: max-content;
  height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  color: #5b6471;
  font-weight: 900;
}

.nav-tab:hover,
.nav-tab.active {
  color: var(--red);
  background: #fff4f5;
}

.account-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.session-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #4c5563;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.login-button,
.primary-action {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), #f0443e);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(230, 0, 18, 0.22);
}

.login-button { padding: 0 16px; }

.user-menu {
  position: relative;
}

.avatar-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
}

.avatar-button span,
.profile-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #fff;
  background: var(--red);
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.user-dropdown button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.user-dropdown button:hover {
  background: #f7f8fa;
}

main {
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-layout,
.work-layout,
.result-layout,
.profile-layout,
.feishu-layout,
.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.35fr);
  gap: 20px;
}

.home-hero,
.workflow-panel,
.composition-panel,
.result-main,
.result-side,
.profile-lock,
.profile-sidebar,
.profile-main,
.feishu-main,
.feishu-side,
.admin-lock,
.admin-editor,
.admin-catalog,
.section-block,
.panel-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 32px rgba(23, 27, 35, 0.06);
}

.home-hero {
  padding: 32px;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.section-kicker::before {
  content: "";
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: var(--red);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 14px;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-top: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.75;
}

.home-hero p {
  max-width: 650px;
  margin-top: 18px;
  font-size: 16px;
}

.hero-actions,
.result-actions,
.workflow-actions,
.auth-actions,
.widget-actions,
.layout-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions {
  margin-top: 28px;
}

.primary-action,
.secondary-action,
.ghost-action {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-weight: 900;
  text-decoration: none;
}

.secondary-action,
.secondary-link,
.ghost-action {
  border: 1px solid var(--line);
  background: #fff;
  color: #27313d;
  box-shadow: none;
}

.secondary-link {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 900;
}

.ghost-action {
  color: var(--red);
  background: #fff5f6;
  border-color: rgba(230, 0, 18, 0.18);
}

.primary-action:hover,
.secondary-action:hover,
.ghost-action:hover,
.login-button:hover,
.secondary-link:hover {
  transform: translateY(-1px);
}

.primary-action:active,
.secondary-action:active,
.ghost-action:active,
.login-button:active {
  transform: translateY(0);
}

.wide {
  width: 100%;
}

.text-button {
  color: var(--red);
  font-weight: 900;
}

.home-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 28px 0 0;
}

.home-metrics div,
.compact-stats div,
.stats-grid article,
.widget-metrics article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

dt,
dd {
  margin: 0;
}

.home-metrics dt,
.compact-stats dt,
.stats-grid span,
.widget-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.home-metrics dd,
.compact-stats dd,
.stats-grid strong,
.widget-metrics strong {
  display: block;
  margin-top: 6px;
  color: var(--red);
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
}

.home-stage {
  min-width: 0;
}

.stage-card,
.composition-stage {
  position: relative;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #f7f8fa 72%, #eef2f4 100%);
}

.home-stage .stage-card {
  height: 100%;
}

.stage-bg,
.composition-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.72;
}

.stage-set {
  position: absolute;
  left: calc(var(--set-x, 62) * 1%);
  top: calc(var(--set-y, 58) * 1%);
  width: calc(var(--set-width, 46) * 1%);
  aspect-ratio: var(--set-aspect, 1.027);
  transform: translate(-50%, -50%);
  transform-origin: center center;
  touch-action: none;
  cursor: move;
}

.stage-set.dragging,
.stage-set.resizing {
  cursor: grabbing;
}

.stage-shelf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 24px rgba(0, 0, 0, 0.22));
}

.stage-products {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.stage-product {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: auto;
  height: calc(var(--product-height) * 1%);
  max-width: none;
  max-height: none;
  object-fit: contain;
  transform: translate(-50%, -100%) scale(var(--product-scale));
  transform-origin: center bottom;
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, 0.18));
}

.stage-note,
.composition-badge {
  position: absolute;
  left: 24px;
  top: 24px;
  max-width: min(360px, calc(100% - 48px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(24, 28, 35, 0.76);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
}

.stage-note strong,
.composition-badge strong {
  display: block;
  font-size: 18px;
}

.stage-note span,
.composition-badge span {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.5;
}

.section-block {
  margin-top: 22px;
  padding: 22px;
}

.section-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head.compact {
  align-items: center;
}

.recommend-grid,
.catalog-grid,
.records-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.recommend-card,
.choice-card,
.record-card,
.todo-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recommend-card {
  padding: 0;
  text-align: left;
  overflow: hidden;
}

.recommend-card img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #f7f8fa;
}

.recommend-card span,
.recommend-card strong,
.recommend-card small {
  display: block;
  margin: 12px 14px;
}

.recommend-card span,
.recommend-card small,
.choice-card span,
.choice-card small,
.record-card span,
.record-card small,
.record-card em,
.todo-item span,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  font-style: normal;
}

.recommend-card strong,
.choice-card strong,
.record-card strong,
.todo-item strong {
  color: var(--ink);
  font-size: 16px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding: 18px 4px 0;
  color: var(--muted);
}

.workflow-panel,
.composition-panel,
.result-main,
.result-side,
.profile-lock,
.profile-sidebar,
.profile-main,
.feishu-main,
.feishu-side,
.admin-editor,
.admin-catalog {
  padding: 22px;
  align-self: start;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stepper button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
  color: #5c6470;
  font-weight: 900;
}

.stepper button span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border-radius: 50%;
  color: #fff;
  background: #aeb5bf;
}

.stepper button.active,
.stepper button.done {
  color: var(--red);
  background: #fff4f5;
  border-color: rgba(230, 0, 18, 0.22);
}

.stepper button.active span,
.stepper button.done span {
  background: var(--red);
}

.catalog-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.catalog-tools label,
.settings-form label,
.auth-field label {
  display: grid;
  gap: 7px;
  color: #4f5865;
  font-size: 13px;
  font-weight: 900;
}

.catalog-tools select,
.settings-form input,
.auth-field input,
.share-panel input,
.readonly-input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: 0;
}

.catalog-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card {
  position: relative;
  padding: 12px;
  display: grid;
  gap: 10px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.choice-card.current-target {
  box-shadow: 0 0 0 2px rgba(230, 0, 18, 0.12), 0 14px 28px rgba(23, 27, 35, 0.08);
}

.choice-selected-mark {
  position: absolute;
  right: 18px;
  top: 18px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 6px;
  color: #fff !important;
  background: rgba(230, 0, 18, 0.9);
  box-shadow: 0 6px 14px rgba(230, 0, 18, 0.2);
}

.choice-card:hover,
.choice-card.active {
  transform: translateY(-2px);
  border-color: rgba(230, 0, 18, 0.28);
  box-shadow: 0 14px 28px rgba(23, 27, 35, 0.08);
}

.choice-image {
  width: 100%;
  height: 150px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #f7f8fa;
}

.choice-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 200ms ease;
}

.choice-card:hover .choice-image img {
  transform: scale(1.05);
}

.product-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}

.product-card-meta em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.product-card-meta b {
  color: var(--red);
  font-size: 14px;
}

.admin-layout {
  grid-template-columns: minmax(340px, 0.78fr) minmax(500px, 1.22fr);
  align-items: start;
}

.admin-lock {
  max-width: 560px;
  margin: 72px auto;
  padding: 36px;
  text-align: center;
}

.admin-lock p {
  margin: 10px 0 22px;
}

.admin-form {
  display: grid;
  gap: 16px;
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: #4f5865;
  font-size: 13px;
  font-weight: 900;
}

.admin-form input:not([type="checkbox"]),
.admin-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}

.admin-form textarea {
  min-height: 84px;
  padding: 12px;
  resize: vertical;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-active-field {
  display: flex !important;
  align-items: center;
  align-self: end;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.admin-active-field input {
  accent-color: var(--red);
}

.admin-image-field {
  position: relative;
}

.admin-image-field > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.admin-image-preview {
  display: grid;
  place-items: center;
  width: 100%;
  height: 220px;
  overflow: hidden;
  border: 1px dashed #c9ced6;
  border-radius: 8px;
  color: var(--muted);
  background: #f8f9fb;
  cursor: pointer;
}

.admin-image-preview:hover {
  border-color: rgba(230, 0, 18, 0.42);
  color: var(--red);
}

.admin-image-preview img {
  width: 100%;
  height: 100%;
  padding: 14px;
  object-fit: contain;
}

.admin-product-list {
  display: grid;
}

.admin-product-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 104px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.admin-product-item:first-child {
  padding-top: 0;
}

.admin-product-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.admin-product-item.inactive {
  opacity: 0.62;
}

.admin-product-item > img {
  width: 76px;
  height: 76px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #f8f9fb;
}

.admin-product-info {
  min-width: 0;
}

.admin-product-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-product-title strong {
  overflow-wrap: anywhere;
}

.admin-product-title span {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 6px;
  color: #24745d;
  background: #e9f7f1;
  font-size: 11px;
  font-weight: 900;
}

.admin-product-item.inactive .admin-product-title span {
  color: #626b78;
  background: #eceff2;
}

.admin-product-info p,
.admin-product-info small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.admin-product-actions {
  display: flex;
  gap: 8px;
}

.admin-product-actions button {
  min-height: 36px;
  padding: 0 11px;
}

.workflow-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.composition-stage {
  min-height: 430px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 68%, #edf1f4 100%);
  user-select: none;
}

.composition-stage.white-wall {
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
}

.composition-stage.shelf-product-fit-stage {
  min-height: clamp(680px, 72vh, 820px);
}

.composition-stage.prop-preview-stage {
  background: #fff;
}

.prop-preview-image {
  position: absolute;
  inset: 28px;
  width: calc(100% - 56px);
  height: calc(100% - 56px);
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(15, 23, 42, 0.14));
}

.composition-stage.scene-mode .composition-bg {
  opacity: 1;
}

.composition-stage.scene-mode {
  min-height: 0;
  aspect-ratio: 16 / 9;
}

.composition-set {
  position: absolute;
  left: calc(var(--set-x) * 1%);
  top: calc(var(--set-y) * 1%);
  width: calc(var(--set-width) * 1%);
  aspect-ratio: var(--set-aspect, 1.027);
  transform: translate(-50%, -50%);
  transform-origin: center center;
  touch-action: none;
  cursor: move;
}

.composition-set::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px dashed rgba(230, 0, 18, 0.34);
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.composition-set:hover::after,
.composition-set.dragging::after {
  opacity: 1;
}

.composition-set.dragging,
.composition-set.resizing {
  cursor: grabbing;
}

.composition-stage.products-editable .composition-set {
  cursor: default;
}

.composition-stage.products-editable .composition-set::after {
  display: none;
}

.composition-stage.shelves-editable .composition-set {
  cursor: default;
}

.composition-stage.shelves-editable .composition-set::after {
  display: none;
}

.composition-stage.products-locked .composition-product-item {
  pointer-events: none;
  cursor: inherit;
  outline: 0;
}

.composition-stage:not(.scene-mode) .flat-prop-set {
  cursor: default;
}

.composition-stage:not(.scene-mode) .flat-prop-set::after {
  display: none;
}

.group-selection-frame,
.product-selection-frame {
  position: absolute;
  border-radius: 8px;
  pointer-events: none;
}

.group-selection-frame {
  inset: -8px;
  z-index: 8;
  border: 1px dashed rgba(230, 0, 18, 0.45);
}

.product-selection-frame {
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--frame-width) * 1%);
  height: calc(var(--frame-height) * 1%);
  z-index: 9;
  border: 1.5px solid rgba(230, 0, 18, 0.78);
  transform: translate(-50%, -100%);
  transform-origin: center bottom;
  cursor: move;
  pointer-events: auto;
}

.product-selection-frame.dragging,
.product-selection-frame.resizing {
  border-color: rgba(230, 0, 18, 0.95);
  box-shadow: 0 0 0 4px rgba(230, 0, 18, 0.08);
}

.selection-handle {
  position: absolute;
  width: 13px;
  height: 13px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 4px 10px rgba(230, 0, 18, 0.28);
  pointer-events: auto;
  touch-action: none;
}

.selection-handle.handle-nw {
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.selection-handle.handle-ne {
  right: 0;
  top: 0;
  transform: translate(50%, -50%);
  cursor: nesw-resize;
}

.selection-handle.handle-sw {
  left: 0;
  bottom: 0;
  transform: translate(-50%, 50%);
  cursor: nesw-resize;
}

.selection-handle.handle-se {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
  cursor: nwse-resize;
}

.composition-stage .composition-shelf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  filter: drop-shadow(0 20px 24px rgba(0, 0, 0, 0.2));
  transform: none;
}

.composition-shelf-unit {
  position: absolute;
  left: calc(var(--unit-left) * 1%);
  top: 0;
  width: calc(var(--unit-width) * 1%);
  height: 100%;
  min-width: 0;
}

.composition-stage.shelves-editable .composition-shelf-unit {
  cursor: grab;
  touch-action: none;
  transform: translateX(var(--shelf-drag-x, 0));
  transition: transform 160ms ease, filter 160ms ease;
}

.composition-stage.shelves-editable .composition-shelf-unit:hover::after {
  border-color: rgba(230, 0, 18, 0.42);
}

.composition-stage.shelves-editable .composition-shelf-unit.dragging-shelf {
  z-index: 10;
  cursor: grabbing;
  filter: drop-shadow(0 16px 18px rgba(23, 27, 35, 0.22));
  transition: none;
}

.composition-shelf-unit::after {
  content: "";
  position: absolute;
  inset: -3px;
  z-index: 7;
  border: 2px solid transparent;
  border-radius: 6px;
  pointer-events: none;
}

.composition-stage.products-editable .composition-shelf-unit.active-shelf::after {
  border-color: rgba(230, 0, 18, 0.42);
}

.shelf-unit-label {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 8;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: #fff;
  background: rgba(21, 25, 31, 0.74);
  font-size: 11px;
  font-weight: 900;
  pointer-events: none;
}

.composition-stage .composition-products {
  position: absolute;
  left: calc(var(--product-left, 0) * 1%);
  top: calc(var(--product-top, 0) * 1%);
  width: calc(var(--product-width, 100) * 1%);
  height: calc(var(--product-height, 100) * 1%);
  transform: none;
  z-index: 2;
  overflow: hidden;
}

.composition-product-item {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: auto;
  height: calc(var(--product-height) * 1%);
  max-width: none;
  max-height: none;
  object-fit: contain;
  transform: translate(-50%, -100%) scale(var(--product-scale));
  transform-origin: center bottom;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.18));
  touch-action: none;
  cursor: grab;
  transition: filter 140ms ease, outline-color 140ms ease;
  z-index: 2;
}

.composition-product-item.active,
.composition-product-item.multi-selected {
  outline: 2px solid rgba(230, 0, 18, 0.72);
  outline-offset: 3px;
  z-index: 4;
}

.composition-product-item.multi-selected:not(.active) {
  outline-style: dashed;
  outline-color: rgba(230, 0, 18, 0.62);
}

.composition-product-item.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.26));
  z-index: 5;
}

.layout-hint {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.layout-tools {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.layout-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.layout-status strong {
  color: var(--red);
}

.compact-actions {
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

.compact-actions .secondary-action,
.compact-actions .ghost-action {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.selection-mode-toggle.is-active {
  border-color: rgba(230, 0, 18, 0.42);
  color: var(--red);
  background: #fff2f3;
  box-shadow: inset 0 0 0 1px rgba(230, 0, 18, 0.08);
}

.locked-layout-summary {
  justify-content: space-between;
}

.quantity-control,
.select-control,
.estimate-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: #fff;
}

.select-control select {
  min-width: 126px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.quantity-control input,
.estimate-row input {
  width: 70px;
  border: 0;
  outline: none;
  color: var(--ink);
  font: inherit;
}

.estimate-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.estimate-row span:last-child {
  color: var(--ink);
}

.price-breakdown {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

.range-control {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.range-control input {
  width: 100%;
  accent-color: var(--red);
}

.range-control strong {
  color: var(--red);
  text-align: right;
}

.selection-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.selection-summary article,
.rule-list,
.share-panel,
.panel-card {
  padding: 16px;
}

.selection-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.selection-summary span,
.rule-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.selection-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}

.rule-list {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rule-list ul,
.clean-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #4e5865;
  line-height: 1.8;
  font-size: 13px;
}

.result-layout,
.feishu-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.result-stage-wrap {
  overflow: hidden;
  border-radius: 8px;
}

.result-stage {
  min-height: 0;
  aspect-ratio: 16 / 9;
}

.tool-button {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: #fff;
  color: #5c6572;
  font-weight: 900;
}

.result-actions {
  margin-top: 16px;
}

.amount-calculator {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.calculator-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.calculator-head h3 {
  margin: 7px 0 0;
  font-size: 20px;
}

.calculator-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.calculator-rows {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.calculator-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(92px, 0.7fr) minmax(100px, 0.75fr) minmax(110px, 0.8fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8f9fb;
}

.calculator-field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.calculator-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.calculator-field select,
.calculator-field input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.calculator-unit-price strong,
.calculator-line-amount strong {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 15px;
}

.calculator-line-amount strong {
  color: var(--brand);
}

.calculator-remove {
  min-width: 56px;
  height: 42px;
  border: 1px solid #ffc9c9;
  border-radius: 7px;
  background: #fff7f7;
  color: var(--brand);
  font-weight: 900;
}

.calculator-summary {
  display: flex;
  justify-content: flex-end;
  gap: 28px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.calculator-summary strong {
  margin-left: 8px;
  color: var(--text);
  font-size: 17px;
}

.calculator-summary span:last-child strong {
  color: var(--brand);
}

.calculator-empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  text-align: center;
}

.share-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.share-panel div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.detail-list dd {
  text-align: right;
  font-size: 13px;
  font-weight: 900;
}

.compact-stats {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.profile-lock {
  max-width: 560px;
  margin: 44px auto;
  padding: 34px;
  text-align: center;
}

.profile-lock p {
  margin: 12px 0 22px;
}

.profile-layout {
  grid-template-columns: 260px minmax(0, 1fr);
}

.profile-card {
  display: grid;
  place-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  font-size: 26px;
  font-weight: 900;
}

.profile-card span {
  color: var(--muted);
  font-size: 12px;
}

.profile-tab {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border-radius: 8px;
  color: #4f5865;
  text-align: left;
  font-weight: 900;
}

.profile-tab.active,
.profile-tab:hover {
  color: var(--red);
  background: #fff4f5;
}

.profile-section {
  display: none;
}

.profile-section.active {
  display: block;
}

.records-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.record-thumb {
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: #f7f8fa;
}

.record-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-card strong,
.record-card small,
.record-card em {
  display: block;
  overflow-wrap: anywhere;
}

.record-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-form button {
  grid-column: 1 / -1;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.empty-state {
  grid-column: 1 / -1;
  padding: 36px;
  border: 1px dashed #cfd5dd;
  border-radius: 8px;
  background: #fafbfc;
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state span {
  margin-top: 8px;
  color: var(--muted);
}

.feishu-widget {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fafbfc);
  overflow: hidden;
}

.widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  color: #fff;
  background: var(--red);
}

.widget-head span {
  font-size: 12px;
  font-weight: 900;
}

.todo-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.todo-item strong,
.todo-item span {
  display: block;
}

.status-button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--red);
  background: #fff4f5;
  font-weight: 900;
}

.widget-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 14px 14px;
}

.widget-actions {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.feishu-side {
  display: grid;
  gap: 14px;
}

.auth-modal,
.product-modal {
  width: min(460px, calc(100vw - 36px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.26);
}

.auth-modal::backdrop,
.product-modal::backdrop {
  background: rgba(16, 18, 24, 0.42);
  backdrop-filter: blur(5px);
}

.modal-box {
  position: relative;
  padding: 28px;
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f2f3f5;
  color: #6b7280;
  font-size: 20px;
}

.modal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 900;
}

.modal-brand img {
  width: 220px;
  height: 36px;
  object-fit: contain;
  object-position: left center;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: #f3f4f6;
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 900;
}

.auth-tab.active {
  color: var(--red);
  background: #fff;
  box-shadow: 0 8px 16px rgba(23, 27, 35, 0.08);
}

.auth-field {
  margin-top: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: #4f5865;
  font-size: 13px;
  font-weight: 900;
}

.third-party {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.third-party button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
}

.detail-image {
  display: block;
  max-width: 220px;
  max-height: 260px;
  margin: 0 auto 16px;
  object-fit: contain;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: #20242b;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 1181px) {
  .workflow-panel.product-step {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 122px);
    overflow: hidden;
  }

  .workflow-panel.product-step .section-head,
  .workflow-panel.product-step .stepper,
  .workflow-panel.product-step .catalog-tools,
  .workflow-panel.product-step .workflow-actions {
    flex: 0 0 auto;
  }

  .workflow-panel.product-step .catalog-grid {
    flex: 1 1 auto;
    min-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 8px;
  }

  .composition-panel {
    position: sticky;
    top: 98px;
  }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .search-box {
    grid-column: 2 / 3;
  }

  .nav-tabs {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .home-layout,
  .work-layout,
  .result-layout,
  .profile-layout,
  .feishu-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .result-side,
  .feishu-side {
    grid-template-columns: repeat(2, 1fr);
    display: grid;
  }
}

@media (max-width: 760px) {
  main {
    padding: 12px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 12px;
    gap: 10px;
  }

  .brand {
    min-width: 0;
  }

  .brand img {
    width: 180px;
    height: 30px;
  }

  .session-pill {
    display: none;
  }

  .search-box {
    grid-column: 1 / -1;
    order: 3;
  }

  .nav-tabs {
    order: 4;
    grid-column: 1 / -1;
  }

  .nav-tab {
    padding: 0 10px;
  }

  .home-hero,
  .workflow-panel,
  .composition-panel,
  .result-main,
  .result-side,
  .profile-lock,
  .profile-sidebar,
  .profile-main,
  .feishu-main,
  .feishu-side,
  .admin-lock,
  .admin-editor,
  .admin-catalog,
  .section-block {
    padding: 16px;
  }

  h1 {
    font-size: 34px;
  }

  .home-metrics,
  .recommend-grid,
  .catalog-grid,
  .records-grid,
  .stats-grid,
  .result-side,
  .feishu-side,
  .selection-summary,
  .settings-form,
  .widget-metrics,
  .stepper,
  .catalog-tools,
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-product-item {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .admin-product-item > img {
    width: 64px;
    height: 64px;
  }

  .admin-product-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .stage-card,
  .composition-stage,
  .result-stage {
    min-height: 330px;
  }

  .composition-stage.scene-mode,
  .result-stage {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .stage-set {
    left: calc(var(--set-x, 58) * 1%);
    top: calc(var(--set-y, 58) * 1%);
    width: calc(var(--set-width, 78) * 1%);
  }

  .composition-badge,
  .stage-note {
    left: 14px;
    top: 14px;
    max-width: calc(100% - 28px);
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .share-panel div,
  .todo-item {
    grid-template-columns: 1fr;
    display: grid;
  }

  .calculator-head,
  .calculator-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .calculator-actions {
    justify-content: flex-start;
  }

  .calculator-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calculator-product-field {
    grid-column: 1 / -1;
  }

  .calculator-remove {
    align-self: end;
  }

  .calculator-summary {
    gap: 8px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
