:root {
  --bg: #0a0a0f;
  --bg-2: #12121a;
  --panel: #14141c;
  --panel-2: #1c1c26;
  --border: #2a2a38;
  --border-light: #3a3a48;
  --fg: #e8e8ed;
  --muted: #6a6a78;
  --dim: #4a4a58;
  --accent: #ff6b35;
  --accent-glow: rgba(255, 107, 53, 0.4);
  --lime: #c4f042;
  --lime-dim: #8ab020;
  --danger: #ff3860;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Space Grotesk", sans-serif;
  background: var(--bg);
  color: var(--fg);
  user-select: none;
  -webkit-user-select: none;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 60px 1fr 36px;
  grid-template-areas:
    "header header"
    "toolbar main"
    "toolbar status";
  height: 100vh;
}

/* ============ HEADER ============ */
header {
  grid-area: header;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 2;
}

header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  line-height: 1.1;
}
.brand-name .accent {
  color: var(--accent);
}

.brand-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.metrics {
  display: flex;
  gap: 28px;
  align-items: center;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.metric-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 2px;
}

.metric-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--lime);
  margin-top: 2px;
}
.metric-value.orange {
  color: var(--accent);
}

/* ============ TOOLBAR ============ */
.toolbar {
  grid-area: toolbar;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.toolbar::-webkit-scrollbar {
  width: 4px;
}
.toolbar::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}
.toolbar::-webkit-scrollbar-track {
  background: transparent;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
}

.tool-btn {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 13px 13px;
  margin-bottom: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-align: left;
}

.tool-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.25s ease;
}

.tool-btn:hover {
  background: #20202c;
  border-color: var(--border-light);
  transform: translateX(2px);
}

.tool-btn:hover::before {
  transform: scaleY(1);
  transform-origin: top;
}

.tool-btn:active {
  transform: translateX(2px) scale(0.98);
}

.tool-btn.flash {
  background: rgba(255, 107, 53, 0.18);
  border-color: var(--accent);
  animation: flashPulse 0.4s ease-out;
}

@keyframes flashPulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent-glow);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(255, 107, 53, 0);
  }
}

.tool-btn .icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.tool-btn .icon svg {
  width: 20px;
  height: 20px;
}
.tool-btn .text {
  flex: 1;
  min-width: 0;
}
.tool-btn .text .name {
  font-weight: 600;
  letter-spacing: 0.5px;
}
.tool-btn .text .desc {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.action-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 107, 53, 0.05);
}

.action-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(255, 56, 96, 0.05);
}

.action-btn .kbd {
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid var(--border);
}

/* ============ INFO PANEL ============ */
.info-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  border-radius: 2px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.info-row:last-child {
  margin-bottom: 0;
}
.info-row .value {
  color: var(--lime);
  font-weight: 700;
}
.info-row .value.orange {
  color: var(--accent);
}
.info-row .value.dim {
  color: var(--dim);
  font-weight: 400;
}

.hints {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  padding: 12px 14px;
  font-size: 11px;
  line-height: 1.85;
  color: var(--muted);
  border-radius: 2px;
}

.hints .key {
  font-family: "JetBrains Mono", monospace;
  color: var(--lime);
  font-size: 10px;
  background: rgba(196, 240, 66, 0.08);
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid rgba(196, 240, 66, 0.2);
  margin-right: 4px;
}

/* ============ 启动设置弹窗 ============ */
.setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.setup-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 40px 36px 32px;
  width: 420px;
  box-shadow: 0 0 80px rgba(255, 107, 53, 0.1), 0 16px 64px rgba(0, 0, 0, 0.6);
}

.setup-header {
  text-align: center;
  margin-bottom: 32px;
}

.setup-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--fg);
  margin-bottom: 6px;
}

.setup-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
}

.setup-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.preset-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 18px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  text-align: center;
}

.preset-btn:hover {
  border-color: var(--border-light);
  background: #20202c;
}

.preset-btn.active {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.08);
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.12);
}

.preset-size {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.preset-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 2px;
}

.setup-custom {
  margin-bottom: 24px;
}

.setup-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.setup-custom-row label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}

.setup-custom-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color 0.2s;
  width: 80px;
}

.setup-custom-row input:focus {
  border-color: var(--accent);
}

.setup-enter {
  width: 100%;
  background: var(--accent);
  border: none;
  color: #0a0a0f;
  padding: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  transition: all 0.2s;
}

.setup-enter:hover {
  background: #ff8855;
  box-shadow: 0 0 24px rgba(255, 107, 53, 0.3);
}

/* ============ 场景存档 ============ */
.scene-save-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.scene-name-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
  border-radius: 2px;
}

.scene-name-input::placeholder {
  color: var(--dim);
}

.scene-name-input:focus {
  border-color: var(--accent);
}

#import-btn {
  width: 100%;
  margin-bottom: 0;
}

/* ============ MAIN ============ */
.main {
  grid-area: main;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.canvas-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 1px solid var(--accent);
  opacity: 0.4;
}
.corner.tl {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
}
.corner.tr {
  top: 10px;
  right: 10px;
  border-left: none;
  border-bottom: none;
}
.corner.bl {
  bottom: 10px;
  left: 10px;
  border-right: none;
  border-top: none;
}
.corner.br {
  bottom: 10px;
  right: 10px;
  border-left: none;
  border-top: none;
}

.spawn-zone {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--lime);
  letter-spacing: 2.5px;
  background: rgba(196, 240, 66, 0.05);
  border: 1px solid rgba(196, 240, 66, 0.25);
  padding: 4px 12px;
  pointer-events: none;
  border-radius: 2px;
}

.spawn-zone::before,
.spawn-zone::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 240, 66, 0.3));
}
.spawn-zone::before {
  right: 100%;
  margin-right: 8px;
}
.spawn-zone::after {
  left: 100%;
  margin-left: 8px;
  transform: scaleX(-1);
}

/* Toast */
.toast {
  position: absolute;
  top: 24px;
  right: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  transform: translateX(calc(100% + 40px));
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  min-width: 200px;
  border-radius: 2px;
}

.toast.show {
  transform: translateX(0);
}

.toast .toast-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 4px;
  font-weight: 700;
}

/* ============ STATUS BAR ============ */
.status {
  grid-area: status;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-item .dot.warn {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.status-item .value {
  color: var(--fg);
}
.status-spacer {
  flex: 1;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 220px 1fr;
  }
  .tool-btn .text .desc {
    display: none;
  }
  .metrics {
    gap: 16px;
  }
  .metric-value {
    font-size: 14px;
  }
}
