:root {
  --ag-bg: #f5f6fa;
  --ag-panel-bg: #ffffff;
  --ag-border: #e5e7eb;
  --ag-text: #1f2937;
  --ag-muted: #6b7280;
  --ag-primary: #b3322a;
  --ag-primary-hover: #99231d;
  --ag-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Source Han Sans CN", "Hiragino Sans GB",
    "Helvetica Neue", Arial, sans-serif;
  color: var(--ag-text);
  background: var(--ag-bg);
}

.ag-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
}

.ag-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--ag-border);
  gap: 12px;
}

.ag-topbar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.ag-topbar__hint {
  margin-left: 12px;
  font-size: 12px;
  color: var(--ag-muted);
}

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

.ag-chip {
  font-size: 12px;
  padding: 4px 10px;
  background: #f0f1f5;
  border-radius: 999px;
  color: var(--ag-muted);
}

.ag-btn {
  border: 1px solid var(--ag-border);
  background: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ag-text);
  transition: all 0.15s;
}

.ag-btn:hover {
  border-color: var(--ag-primary);
  color: var(--ag-primary);
}

.ag-btn--primary {
  background: var(--ag-primary);
  border-color: var(--ag-primary);
  color: #fff;
}

.ag-btn--primary:hover {
  background: var(--ag-primary-hover);
  border-color: var(--ag-primary-hover);
  color: #fff;
}

.ag-main {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  overflow: hidden;
}

.ag-panel {
  border-right: 1px solid var(--ag-border);
  background: #fff;
  overflow-y: auto;
  padding: 16px;
}

.ag-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--ag-border);
}

.ag-section:last-child {
  border-bottom: none;
}

.ag-section__title {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--ag-text);
}

.ag-template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.ag-template-card {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
  transition: border-color 0.15s, transform 0.15s;
  padding: 0;
}

.ag-template-card:hover {
  transform: translateY(-1px);
}

.ag-template-card[data-active="1"] {
  border-color: var(--ag-primary);
}

.ag-template-card__preview {
  width: 100%;
  aspect-ratio: 1.4 / 1;
  display: block;
}

.ag-template-card__name {
  display: block;
  padding: 6px 8px;
  font-size: 12px;
  text-align: center;
  background: #fff;
  color: var(--ag-text);
}

.ag-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  gap: 4px;
}

.ag-field--inline {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.ag-field__label {
  font-size: 12px;
  color: var(--ag-muted);
}

.ag-field input[type="text"],
.ag-field input[type="number"],
.ag-field textarea,
.ag-field select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--ag-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ag-text);
  background: #fff;
}

.ag-field input:focus,
.ag-field textarea:focus,
.ag-field select:focus {
  outline: none;
  border-color: var(--ag-primary);
}

.ag-field input[type="color"] {
  height: 32px;
  width: 100%;
  padding: 2px;
  border: 1px solid var(--ag-border);
  border-radius: 6px;
  background: #fff;
}

.ag-field input[type="range"] {
  width: 100%;
}

.ag-form-grid {
  display: grid;
  gap: 10px;
}

.ag-form-grid--2 {
  grid-template-columns: 1fr 1fr;
}

.ag-form-grid--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.ag-stage {
  background: #f0f1f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  overflow: auto;
}

.ag-stage__inner {
  width: 100%;
  max-width: 1100px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ag-stage__tip {
  font-size: 12px;
  color: var(--ag-muted);
  margin-top: 12px;
}

.ag-canvas {
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 1123 / 794;
  background: #fff;
  box-shadow: var(--ag-shadow);
  position: relative;
  overflow: hidden;
}

.ag-canvas svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* drawer */
.ag-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  z-index: 50;
}

.ag-mask[data-open="1"] {
  display: block;
}

.ag-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: #fff;
  box-shadow: -4px 0 18px rgba(15, 23, 42, 0.12);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s;
}

.ag-drawer[data-open="1"] {
  transform: translateX(0);
}

.ag-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ag-border);
}

.ag-drawer__header h3 {
  margin: 0;
  font-size: 15px;
}

.ag-drawer__close {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--ag-muted);
}

.ag-drawer__body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

.ag-history-item {
  border: 1px solid var(--ag-border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ag-history-item__title {
  font-size: 13px;
  font-weight: 500;
}

.ag-history-item__meta {
  font-size: 11px;
  color: var(--ag-muted);
}

.ag-history-item__actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.ag-empty {
  text-align: center;
  color: var(--ag-muted);
  font-size: 13px;
  padding: 24px 0;
}

@media (max-width: 960px) {
  .ag-main {
    grid-template-columns: 1fr;
  }
  .ag-panel {
    border-right: none;
    border-bottom: 1px solid var(--ag-border);
    max-height: 50vh;
  }
}
