:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --toolbar: #fafafa;
  --canvas-bg: #f5f5f5;
  --border: #e8e8e8;
  --text: #0d0d0d;
  --muted: #7a7a7a;
  --accent: #e42313;
  --accent-strong: #c91c0e;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(13, 13, 13, 0.12);
  --font-body: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Space Grotesk", "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font-family: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

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

.hidden {
  display: none !important;
}

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

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.left-group,
.center-group,
.right-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.filename {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
}

.divider.vertical {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.divider.horizontal {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 0;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--bg);
}

.icon-btn:hover {
  color: var(--text);
  border-color: #d6d6d6;
}

.icon-btn.small {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.btn-outline,
.btn-solid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
}

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-solid {
  background: var(--text);
  color: #fff;
}

.main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.toolbar {
  width: 56px;
  background: var(--toolbar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  overflow-y: auto;
}

.tool-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: #f0f0f0;
  color: var(--text);
}

.tool-btn.active {
  background: var(--accent);
  color: #fff;
}

.tool-divider {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.canvas-area {
  flex: 1;
  position: relative;
  background: var(--canvas-bg);
  overflow: hidden;
}

.canvas-frame {
  width: 100%;
  height: 100%;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--canvas-bg);
  cursor: crosshair;
  touch-action: none;
}

.sidebar {
  width: 280px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fafafa;
  color: var(--text);
}

.layer-item.inactive {
  color: var(--muted);
}

.layer-item.active {
  border: 1px solid var(--accent);
}

.layer-eye {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  border-radius: 50%;
  position: relative;
}

.layer-eye.visible::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--accent);
  border-radius: 50%;
}

.prop-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prop-label {
  width: 60px;
  color: var(--muted);
  font-size: 12px;
}

.prop-value {
  font-size: 12px;
}

.prop-input {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  flex: 1;
}

.prop-input.narrow {
  width: 60px;
  flex: none;
  text-align: center;
}

.color-input {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 0;
  background: #fff;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.statusbar {
  height: 32px;
  background: var(--toolbar);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  color: var(--muted);
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.coord-info {
  color: var(--muted);
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  background: none;
  font-size: 12px;
}

.toggle-btn .icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.toggle-btn.active {
  color: var(--accent);
}

.help-text {
  color: var(--muted);
}

.context-menu,
.menu {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.context-menu button,
.menu button {
  padding: 8px 12px;
  border-radius: 6px;
  text-align: left;
  font-size: 12px;
  color: var(--text);
}

.context-menu button:hover,
.menu button:hover {
  background: #f2f2f2;
}

.toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 30;
}

@media (max-width: 1100px) {
  .sidebar {
    width: 240px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .toolbar {
    width: 52px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    height: auto;
    padding: 8px 16px;
  }
  .statusbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 16px;
    gap: 8px;
  }
}
