:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f2ee;
  color: #1e1d1b;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
body.gallery-page {
  min-height: 100vh;
  overflow-y: auto;
}
.app {
  width: min(1644px, calc(100% - 32px));
  margin: 126px auto 32px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 390px));
  gap: 28px;
  align-items: start;
}
.workspace-tabs {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 50;
  width: min(520px, calc(100% - 32px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 10px 14px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(16px);
  border: 1px solid #e7e2da;
  border-radius: 999px;
  box-shadow: 0 18px 55px rgba(50,38,20,.12);
}
.workspace-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 999px;
  color: #1f2d4a;
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.03em;
  transition: .18s ease;
}
.workspace-tab:hover {
  color: #0b57ff;
  background: #f5f8ff;
}
.workspace-tab.active {
  color: #0b57ff;
  background: #f1f4f8;
}
.panel, .preview-wrap {
  background: rgba(255,255,255,.92);
  border: 1px solid #e7e2da;
  border-radius: 24px;
  box-shadow: 0 18px 55px rgba(50,38,20,.08);
}
.panel {
  height: 838px;
  padding: 26px;
  position: sticky;
  top: 24px;
  overflow-y: auto;
}
.eyebrow { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .16em; color: #ff3d72; }
h1 { margin: 0; font-size: 32px; letter-spacing: -.04em; }
.intro { color: #77716a; margin: 8px 0 20px; font-size: 13px; line-height: 1.5; }
label { display: block; margin: 14px 0; font-size: 13px; font-weight: 700; }
.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(92px, .75fr) minmax(110px, .8fr);
  gap: 12px;
}
.inline-fields label { margin-top: 14px; margin-bottom: 14px; }
.inline-fields label {
  text-align: center;
}
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid #ddd6cd;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font: inherit;
  font-weight: 500;
  resize: vertical;
  outline: none;
  background: #fff;
}
select { appearance: auto; }
input:focus, textarea:focus, select:focus { border-color: #ff3d72; box-shadow: 0 0 0 3px rgba(255,61,114,.1); }
.upload input { display: none; }
.upload b {
  display: grid;
  min-height: 70px;
  margin-top: 8px;
  place-items: center;
  border: 1px dashed #cfc6bb;
  border-radius: 14px;
  color: #77716a;
  background: #faf9f7;
  cursor: pointer;
}
.upload b:hover { border-color: #ff3d72; color: #ff3d72; }
.actions { display: grid; gap: 13px; margin-top: 18px; }
button { border: 0; border-radius: 13px; padding: 12px; font: inherit; font-weight: 800; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .7; transform: none; }
.link-button {
  display: block;
  text-align: center;
  text-decoration: none;
  border-radius: 13px;
  padding: 12px;
  font: inherit;
  font-weight: 800;
}
.primary { color: white; background: linear-gradient(135deg,#ff274e,#ff3c86); box-shadow: 0 7px 18px rgba(255,39,78,.18); }
.primary:hover { transform: translateY(-1px); }
.secondary { background: #f0ede8; color: #615b54; }
.tip { margin: 18px 0 0; color: #999188; font-size: 12px; line-height: 1.55; }
.preview-wrap { padding: 18px; }
.preview-head { display: flex; justify-content: space-between; padding: 2px 4px 14px; font-size: 13px; font-weight: 700; color: #79736c; }
.preview-head > span { display: flex; align-items: center; gap: 8px; }
.preview-title { min-width: 0; flex-wrap: wrap; }
.preview-actions { flex-shrink: 0; justify-content: flex-end; }
.preview-head i {
  color: #9a9289;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}
.copy-image {
  padding: 5px 9px;
  border-radius: 8px;
  color: #ff3267;
  background: #fff0f4;
  font-size: 12px;
  font-weight: 700;
}
.copy-image:hover { background: #ffe3eb; }
.template-upload {
  display: inline-flex;
  margin: 0;
  cursor: pointer;
}
.template-upload input {
  display: none;
}
.template-upload b {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 8px;
  color: #0b57ff;
  background: #f1f5ff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.template-upload:hover b {
  background: #e5edff;
}
canvas { display: block; width: 100%; height: auto; border-radius: 16px; background: #eee; }
.gallery-app {
  width: min(1280px, calc(100% - 32px));
  margin: 126px auto 32px;
}
body.gallery-page .gallery-app {
  min-height: calc(100vh - 158px);
}
.gallery-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 158px);
  overflow: visible;
  padding: 24px;
  background: rgba(255,255,255,.92);
  border: 1px solid #e7e2da;
  border-radius: 24px;
  box-shadow: 0 18px 55px rgba(50,38,20,.08);
}
.gallery-top {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}
.gallery-top h1 { margin-bottom: 6px; }
.gallery-tools {
  display: grid;
  grid-template-columns: 1fr 150px 150px;
  gap: 12px;
  align-items: end;
}
.gallery-tools-search-only {
  grid-template-columns: minmax(260px, 720px);
}
.gallery-tools label { margin: 0; }
.gallery-count {
  margin-top: 14px;
  color: #77716a;
  font-size: 13px;
  font-weight: 700;
}
.gallery-scroll {
  flex: 1 1 auto;
  overflow: visible;
  margin-top: 20px;
  padding: 0 0 6px 0;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
  overflow: visible;
  margin-top: 0;
}
.gallery-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e7e2da;
  border-radius: 20px;
  box-shadow: 0 12px 35px rgba(50,38,20,.06);
}
.gallery-card-head {
  padding: 16px 16px 10px;
}
.gallery-card-title-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}
.gallery-card-title-row > div {
  min-width: 0;
  flex: 1 1 auto;
}
.gallery-code {
  color: #1d1d1f;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}
.gallery-card h2 {
  margin: 4px 0 6px;
  font-size: 17px;
  line-height: 1.35;
}
.gallery-copy-group {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 34px;
  padding: 8px 10px;
  margin-top: 0;
  border-radius: 999px;
  color: #ff3267;
  background: #fff0f4;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.gallery-copy-group:hover {
  background: #ffe2eb;
}
.gallery-meta {
  color: #817970;
  font-size: 12px;
  line-height: 1.5;
}
.gallery-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow: visible;
  padding: 0 16px 12px;
}
.gallery-image {
  display: grid;
  grid-template-rows: 18px auto 38px;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #f0e8e0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(50,38,20,.04);
}
.gallery-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1.22;
  object-fit: cover;
  object-position: top;
  border-radius: 12px;
  background: #eee;
  border: 1px solid #eee8e0;
}
.gallery-image .wide {
  aspect-ratio: 1 / 1.22;
}
.gallery-image span {
  color: #77716a;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  min-height: 18px;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.gallery-image .mini-actions {
  grid-template-columns: 1fr;
  align-self: stretch;
}
.gallery-image .mini-actions button,
.gallery-image .mini-actions a {
  display: grid;
  min-height: 38px;
  place-items: center;
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 12px;
}
.gallery-card-actions {
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
  margin-top: 0;
  padding: 14px 16px 16px;
  border-top: 1px solid #f1ece6;
  background: linear-gradient(180deg, rgba(255,255,255,.96), #fff7fa);
}
.gallery-card-actions button,
.gallery-card-actions a {
  min-height: 40px;
  padding: 10px 8px;
  border-radius: 12px;
  color: #ff3267;
  background: #fff0f4;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}
.gallery-card-actions a {
  display: grid;
  place-items: center;
}
.gallery-card-actions button:hover,
.gallery-card-actions a:hover {
  background: #ffe2eb;
}
.mini-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.mini-actions button,
.mini-actions a {
  padding: 7px 5px;
  border-radius: 8px;
  color: #ff3267;
  background: #fff0f4;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.empty-state {
  margin-top: 20px;
  padding: 34px;
  color: #817970;
  text-align: center;
  background: #fff;
  border: 1px dashed #d7cec4;
  border-radius: 20px;
}
@media (max-width: 1680px) {
  .app { grid-template-columns: repeat(3, minmax(0, 390px)); }
}
@media (max-width: 1260px) {
  .app { grid-template-columns: repeat(2, minmax(0, 390px)); }
}
  @media (max-width: 850px) {
  .app { grid-template-columns: 1fr; margin: 104px auto 16px; }
  .gallery-app { margin: 104px auto 16px; }
  body.gallery-page .gallery-app { min-height: calc(100vh - 120px); min-height: calc(100dvh - 120px); }
  .workspace-tabs { top: 12px; min-height: auto; padding: 8px; gap: 8px; }
  .workspace-tab { min-height: 48px; padding: 0 12px; font-size: 16px; }
  .panel { height: auto; position: static; overflow-y: visible; }
  .inline-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
  }
  .inline-fields label {
    display: grid;
    grid-template-rows: auto 54px;
    min-width: 0;
    margin-top: 14px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.2;
  }
  .inline-fields input,
  .inline-fields select {
    height: 54px;
    min-height: 54px;
    margin-top: 8px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 54px;
    text-align: center;
  }
  .inline-fields select {
    text-align-last: center;
  }
  #code {
    text-align: center;
  }
  .gallery-images {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 0 12px 10px;
    overflow: visible;
  }
  .gallery-image {
    grid-template-rows: 16px auto 38px;
    gap: 7px;
    padding: 7px;
    border-radius: 13px;
  }
  .gallery-image img {
    border-radius: 10px;
  }
  .gallery-image span {
    font-size: 10px;
    min-height: 16px;
  }
  .gallery-image .mini-actions button,
  .gallery-image .mini-actions a {
    padding: 8px 4px;
    font-size: 11px;
  }
  .gallery-card-actions {
    padding: 12px 16px 14px;
  }
  .gallery-card-title-row {
    gap: 8px;
  }
  .gallery-copy-group {
    flex-basis: auto;
    min-width: 70px;
    min-height: 32px;
    padding: 7px 9px;
    font-size: 11px;
  }
  .gallery-card-actions button,
  .gallery-card-actions a {
    min-height: 44px;
    font-size: 14px;
  }
  .gallery-tools { grid-template-columns: 1fr; }
  .gallery-top { display: block; }
}
