:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #17202a;
  --muted: #607083;
  --line: #d9e0e8;
  --accent: #126d7a;
  --accent-strong: #0b5661;
  --accent-soft: #e4f3f5;
  --danger: #b83b3b;
  --shadow: 0 18px 45px rgba(24, 34, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 20px;
  max-width: 1480px;
  margin: 0 auto;
}

.control-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 20px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.brand-block {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 8px 20px rgba(23, 32, 42, 0.15);
}

.brand-block h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.brand-block p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 1.5px dashed #94a6b8;
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  text-align: center;
  padding: 18px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 30px;
  line-height: 1;
}

.upload-title {
  margin-top: 10px;
  font-weight: 700;
}

.upload-hint {
  color: var(--muted);
  font-size: 13px;
}

.photo-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
}

.photo-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.photo-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.photo-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.photo-meta {
  color: var(--muted);
  font-size: 12px;
}

.remove-photo {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.field-grid,
.custom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.size-row {
  display: grid;
  grid-template-columns: 1fr 1fr 42px;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
}

.field input[readonly] {
  background: #f3f6f8;
  color: #516273;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
}

.segmented input:checked + span {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 1px 8px rgba(20, 33, 45, 0.12);
  font-weight: 700;
}

.toggle-row {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

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

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:disabled {
  background: #9fb3b7;
  cursor: not-allowed;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--accent-strong);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--accent-soft);
  border-color: #9ccdd4;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: calc(100vh - 48px);
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.preview-toolbar h2 {
  margin: 0;
  font-size: 20px;
}

.preview-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.size-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.canvas-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 24px;
  overflow: auto;
  background:
    linear-gradient(45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(-45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1f4 75%),
    linear-gradient(-45deg, transparent 75%, #eef1f4 75%);
  background-size: 26px 26px;
  background-position: 0 0, 0 13px, 13px -13px, -13px 0;
}

canvas {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  background: #fff;
  box-shadow: 0 12px 36px rgba(23, 32, 42, 0.22);
}

.empty-state {
  position: absolute;
  display: grid;
  gap: 8px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.has-layout .empty-state {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
  }

  .preview-panel {
    min-height: 620px;
  }
}

@media (max-width: 560px) {
  .field-grid,
  .custom-grid,
  .size-row,
  .actions {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

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