:root {
  --background: #f7f6f2;
  --foreground: #1a1a1a;
  --card: #ffffff;
  --secondary: #f0ede8;
  --muted: #eae7e1;
  --muted-foreground: #7a7570;
  --accent: #c9a882;
  --destructive: #d4183d;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 20px 54px rgba(31, 28, 24, 0.10);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(201, 168, 130, 0.16), transparent 38%),
    linear-gradient(315deg, rgba(234, 231, 225, 0.82), transparent 42%),
    var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--foreground);
  font-family: "Plus Jakarta Sans", "Avenir Next", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 70px 16px 22px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 980px);
  min-height: 56px;
  padding: 10px 16px;
  transform: translateX(-50%);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 246, 242, 0.9);
  backdrop-filter: blur(18px);
}

.brand-lockup,
.topbar-meta,
.profile-pill,
.quota-pill {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: #fff;
  background: var(--foreground);
  font-size: 13px;
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.topbar-meta {
  justify-content: flex-end;
  gap: 9px;
  min-width: 0;
}

.profile-pill,
.quota-pill {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
}

.profile-pill {
  gap: 7px;
  padding: 5px 10px 5px 6px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.profile-pill strong {
  max-width: 92px;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quota-pill {
  padding: 7px 12px;
  color: var(--accent);
  background: rgba(201, 168, 130, 0.12);
  border-color: rgba(201, 168, 130, 0.28);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.workspace {
  display: block;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-height: 68vh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  aspect-ratio: 9 / 16;
  background: var(--card);
  box-shadow: var(--shadow);
}

.preview-stage img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--card);
}

.upload-empty {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 420px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: var(--muted-foreground);
  text-align: center;
  cursor: pointer;
}

.upload-empty::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 2px dashed rgba(0, 0, 0, 0.12);
  border-radius: 13px;
  pointer-events: none;
  transition: border-color 160ms ease;
}

.upload-empty:hover::before {
  border-color: rgba(0, 0, 0, 0.22);
}

.plus {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  transition: transform 180ms ease;
}

.upload-empty:hover .plus {
  transform: scale(1.04);
}

.upload-empty strong {
  position: relative;
  color: var(--foreground);
  font-size: 16px;
  font-weight: 800;
}

.upload-empty small {
  position: relative;
  color: var(--muted-foreground);
  font-size: 13px;
}

.delete-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: transparent;
  font-size: 0;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.delete-button::before,
.delete-button::after,
.slot button::before,
.slot button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48%;
  height: 2px;
  border-radius: 999px;
  background: #fff;
  transform-origin: center;
}

.delete-button::before,
.slot button::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.delete-button::after,
.slot button::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.delete-button:hover,
.slot button:hover {
  transform: scale(1.04);
}

.delete-button:disabled,
.slot button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.loading-mask {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(247, 246, 242, 0.88);
  backdrop-filter: blur(14px);
}

.loading-mask strong {
  margin-top: 4px;
  font-size: 15px;
}

.loading-mask span {
  color: var(--muted-foreground);
  font-size: 13px;
}

.spinner {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--foreground);
}

.spinner::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.type-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.type-tab {
  display: flex;
  min-width: 0;
  min-height: 56px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  color: var(--muted-foreground);
  background: transparent;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.type-tab b {
  color: inherit;
  font-size: 16px;
  line-height: 1;
}

.type-tab span {
  max-width: 100%;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-tab.active {
  color: #fff;
  background: var(--foreground);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.type-tab:hover:not(.active) {
  background: var(--secondary);
  color: var(--foreground);
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  padding: 13px 18px;
  color: #fff;
  background: var(--foreground);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.primary-button::before {
  content: "✦";
  font-size: 15px;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.20);
}

.primary-button:disabled {
  opacity: 0.58;
  cursor: wait;
  box-shadow: none;
}

.slot-strip {
  display: block;
  min-width: 0;
}

.slot-title {
  margin: 0 0 8px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.slot-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 74px;
  gap: 10px;
  overflow-x: auto;
  padding: 0 0 2px;
  scrollbar-width: none;
}

.slot-list::-webkit-scrollbar {
  display: none;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--muted);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.slot:hover {
  transform: translateY(-1px);
}

.slot.active {
  border-color: var(--foreground);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot button {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: transparent;
  font-size: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.slot-add {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1.5px dashed rgba(0, 0, 0, 0.12);
  border-radius: 13px;
  color: var(--muted-foreground);
  font-size: 26px;
}

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

.secondary-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 10px 14px;
  color: var(--foreground);
  background: rgba(255, 255, 255, 0.8);
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease;
}

.secondary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 0, 0, 0.18);
}

.toast {
  position: fixed;
  left: 50%;
  top: 68px;
  z-index: 80;
  width: max-content;
  max-width: min(92vw, 420px);
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 16px;
  color: var(--foreground);
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(14px);
}

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

  .topbar {
    padding-inline: 12px;
  }

  .profile-pill strong {
    display: none;
  }

  .quota-pill {
    padding-inline: 10px;
  }

  .preview-stage {
    max-height: 66vh;
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding-top: 78px;
  }

  .main-column {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }

  .slot-strip {
    position: sticky;
    top: 76px;
    grid-column: 1;
    grid-row: 1;
  }

  .slot-list {
    grid-auto-flow: row;
    grid-auto-rows: 80px;
    grid-auto-columns: auto;
    overflow: visible;
  }

  .slot {
    width: 80px;
    height: 80px;
  }

  .main-column {
    min-width: 0;
  }

  .preview-stage {
    grid-column: 2;
    grid-row: 1;
    max-height: 72vh;
  }

  .type-tabs,
  .primary-button,
  .result-actions {
    grid-column: 2;
  }
}
