:root {
  color-scheme: light;
  --bg: #e9edf0;
  --panel: #f8faf9;
  --ink: #1c2526;
  --muted: #657273;
  --line: #c9d2d1;
  --accent: #1e7f73;
  --accent-dark: #155d54;
  --warn: #b33a2f;
  --tile: rgba(42, 79, 76, 0.28);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.active {
  background: #243b3a;
  border-color: #243b3a;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: white;
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.login-panel label,
.field-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.error-text,
.save-status {
  min-height: 20px;
  margin: 0;
  color: var(--warn);
  font-size: 13px;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
}

.brand-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.brand-row h1 {
  margin: 0;
  font-size: 20px;
}

.brand-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot.online {
  color: #146642;
  border-color: #8bbfa5;
  background: #e5f4ec;
}

.panel {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.compact {
  display: grid;
  gap: 10px;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 72px 72px 92px;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.toggle-row input {
  width: auto;
}

.button-row,
.tool-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-list {
  margin: 0;
  padding-left: 18px;
  color: #3f4d4e;
  font-size: 13px;
  line-height: 1.55;
}

.search-input {
  margin-bottom: 10px;
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.category-tab {
  min-width: 0;
  padding: 7px 4px;
  border-color: var(--line);
  background: white;
  color: var(--ink);
  font-size: 12px;
}

.category-tab:hover,
.category-tab.active {
  border-color: var(--accent);
  background: #e3f2ed;
  color: var(--accent-dark);
}

.asset-groups {
  display: grid;
  gap: 12px;
}

.asset-group h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.asset-card {
  min-height: 136px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px;
  cursor: pointer;
  display: grid;
  grid-template-rows: 84px auto auto;
  gap: 5px;
  text-align: left;
}

.asset-card.selected {
  border-color: var(--accent);
  outline: 2px solid rgba(30, 127, 115, 0.25);
}

.asset-card img {
  width: 100%;
  height: 84px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #edf1f0;
  border-radius: 4px;
  border: 1px solid #d9e0df;
}

.asset-name {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.25;
  word-break: break-word;
}

.asset-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #f5f7f6;
  padding: 10px 14px;
}

.selected-info {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.canvas-wrap {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #d6dcdf;
  position: relative;
  touch-action: none;
  user-select: none;
}

.canvas-wrap::after {
  content: "左键摆放/选择，拖动移动，滚轮缩放，空格拖动画布";
  position: absolute;
  right: 12px;
  bottom: 12px;
  max-width: min(420px, calc(100% - 24px));
  padding: 6px 9px;
  border: 1px solid rgba(28, 37, 38, 0.12);
  border-radius: 6px;
  background: rgba(248, 250, 249, 0.86);
  color: #475657;
  font-size: 12px;
  pointer-events: none;
}

#mapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #cfd8d7;
  image-rendering: pixelated;
  touch-action: none;
}

@media (max-width: 900px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .selected-info {
    text-align: left;
  }
}
