:root {
  --ink: #684015;
  --muted: #b2763a;
  --line: #e5b360;
  --line-dark: #7c5424;
  --paper: #fff9df;
  --stage: #f7f1e8;
  --accent: #ffc932;
  --accent-dark: #8a5b12;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #fffdf4;
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topBar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 160px 1fr 420px;
  align-items: center;
  min-height: 116px;
  padding: 16px 40px 14px;
  border-bottom: 4px solid var(--line-dark);
  background:
    radial-gradient(circle at 8px 8px, rgba(255, 255, 255, 0.35) 1px, transparent 2px) 0 0 / 30px 30px,
    linear-gradient(100deg, #ffd849, #fff2a6 56%, #ffe072);
}

.sun {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffcc3d 48%, #f1843f 52%, #f1843f 64%, transparent 65%);
  box-shadow: 0 0 0 8px rgba(255, 204, 61, 0.25);
}

.titleBlock {
  text-align: center;
}

.titleBlock h1 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.35);
}

.titleBlock p {
  display: inline-block;
  margin: 0;
  padding: 10px 28px;
  border: 3px solid var(--line-dark);
  border-radius: 999px;
  background: #fff6cf;
  font-size: 19px;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(104, 64, 21, 0.25);
}

.topActions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.topActions button,
.styleGrid button,
.previewToolbar button,
.thumbStrip button,
.historyGrid button {
  border: 2px solid #d7ad54;
  border-radius: 14px;
  background: #fff4bd;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(104, 64, 21, 0.18);
}

.topActions button {
  min-width: 104px;
  height: 42px;
  font-weight: 800;
}

.builder {
  display: grid;
  grid-template-columns: minmax(420px, 50%) minmax(420px, 1fr);
  min-height: calc(100vh - 116px);
}

.leftPane {
  display: grid;
  align-content: start;
  gap: 40px;
  max-height: calc(100vh - 116px);
  overflow: auto;
  padding: 40px;
  border-right: 1px solid #d8d0c4;
}

.rightPane {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-width: 0;
  max-height: calc(100vh - 116px);
  overflow: auto;
  background: var(--stage);
}

.cardSection {
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 8px 0 rgba(104, 64, 21, 0.18), 0 20px 30px rgba(104, 64, 21, 0.08);
}

.sectionTitle {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.sectionTitle h2,
.emptyState h2,
.historyPanel h2 {
  margin: 0;
  font-size: 31px;
  letter-spacing: 0;
}

.iconDot,
.gear {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font-size: 28px;
}

.styleGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(92px, 1fr));
  gap: 14px;
}

.styleGrid button {
  min-height: 44px;
  padding: 8px 10px;
  background: #fffef8;
  font-size: 16px;
  font-weight: 800;
}

.styleGrid button.selected {
  border-color: var(--accent-dark);
  background: var(--accent);
}

.twoCols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

label {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

label span {
  font-size: 18px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #ead8ab;
  border-radius: 16px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
  box-shadow: 0 5px 0 rgba(104, 64, 21, 0.14);
}

input,
select {
  height: 52px;
  padding: 0 18px;
  font-size: 18px;
}

textarea {
  min-height: 150px;
  padding: 16px 18px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-dark);
}

.switchRow {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 4px 0 22px;
}

.switchLabel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  margin: 0;
}

.switchLabel input {
  width: 24px;
  height: 24px;
  box-shadow: none;
}

.generateBtn {
  width: 100%;
  height: 58px;
  border: 3px solid var(--line-dark);
  border-radius: 18px;
  background: var(--accent);
  color: var(--ink);
  font-size: 21px;
  font-weight: 900;
  box-shadow: 0 6px 0 rgba(104, 64, 21, 0.28);
}

.generateBtn:disabled,
.previewToolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.errorBox {
  min-height: 22px;
  margin-top: 14px;
  color: var(--danger);
  font-weight: 800;
}

.previewToolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid #ded4c7;
  background: rgba(255, 253, 244, 0.75);
}

.previewToolbar div {
  display: grid;
  gap: 4px;
}

.previewToolbar span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.previewToolbar strong {
  font-size: 18px;
}

.previewToolbar button {
  min-width: 92px;
  height: 42px;
  font-weight: 900;
}

.previewStage {
  display: grid;
  place-items: center;
  min-height: 560px;
  padding: 34px;
}

.previewStage img {
  max-width: 100%;
  max-height: calc(100vh - 270px);
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(104, 64, 21, 0.22);
}

.emptyState {
  display: grid;
  place-items: center;
  gap: 22px;
  text-align: center;
}

.spark {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 34px;
  background: #ffd324;
  color: #fff5c2;
  font-size: 72px;
  box-shadow: 0 10px 0 rgba(204, 139, 15, 0.28);
}

.emptyState p {
  margin: 0;
  color: #d29858;
  font-size: 18px;
}

.thumbStrip {
  display: flex;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid #ded4c7;
  overflow: auto;
}

.thumbStrip:empty {
  display: none;
}

.thumbStrip button {
  flex: 0 0 92px;
  height: 92px;
  padding: 4px;
  overflow: hidden;
}

.thumbStrip button.selectedThumb {
  border-color: var(--accent-dark);
  background: var(--accent);
}

.thumbStrip img,
.historyGrid img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 10px;
}

.historyPanel {
  padding: 22px 28px 30px;
  border-top: 1px solid #ded4c7;
  background: rgba(255, 253, 244, 0.58);
}

.historyPanel h2 {
  margin-bottom: 14px;
  font-size: 22px;
}

.historyGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
}

.historyGrid button {
  aspect-ratio: 1;
  padding: 4px;
  overflow: hidden;
}

@media (max-width: 1180px) {
  .topBar {
    grid-template-columns: 60px 1fr;
  }

  .topActions {
    grid-column: 1 / -1;
    justify-content: center;
    margin-top: 14px;
  }

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

  .leftPane,
  .rightPane {
    max-height: none;
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .topBar {
    padding: 14px;
  }

  .titleBlock h1 {
    font-size: 30px;
  }

  .titleBlock p {
    font-size: 14px;
    padding: 8px 14px;
  }

  .topActions {
    flex-wrap: wrap;
  }

  .leftPane {
    padding: 18px;
    gap: 22px;
  }

  .cardSection {
    padding: 20px;
    border-radius: 20px;
  }

  .styleGrid {
    grid-template-columns: repeat(2, 1fr);
  }

  .twoCols {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .previewStage {
    min-height: 420px;
    padding: 18px;
  }
}


/* ═══════════════════════════════════════════════
   Auth Modal
   ═══════════════════════════════════════════════ */

.authOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  place-items: center;
}

.authOverlay.show {
  display: grid;
}

.authModal {
  width: 440px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 28px;
  background: #fffcf0;
  box-shadow: 0 20px 60px rgba(80, 50, 10, 0.25);
}

.authHeader {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 36px 32px 20px;
  text-align: center;
}

.authSun {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffcc3d 48%, #f1843f 52%, #f1843f 64%, transparent 65%);
  box-shadow: 0 0 0 6px rgba(255, 204, 61, 0.2);
  margin-bottom: 4px;
}

.authHeader h2 {
  margin: 0;
  font-size: 22px;
  color: #4a3012;
  letter-spacing: 0;
}

.authHeader p {
  margin: 4px 0 0;
  font-size: 14px;
  color: #a87b40;
}

.authBody {
  padding: 0 32px 28px;
}

.authTabs {
  display: flex;
  margin-bottom: 24px;
  border-radius: 999px;
  background: #f5ebd4;
  padding: 4px;
}

.authTab {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #8a6b3a;
  font-size: 16px;
  font-weight: 800;
  transition: all 0.2s;
}

.authTab.active {
  background: #fffcf0;
  color: #4a3012;
  box-shadow: 0 2px 8px rgba(80, 50, 10, 0.12);
}

.authForm {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.authForm.active {
  display: flex;
}

.authForm label {
  display: grid;
  gap: 8px;
  margin: 0;
}

.authForm label > span {
  font-size: 15px;
  font-weight: 800;
  color: #4a3012;
}

.inputWrap {
  position: relative;
  display: flex;
  align-items: center;
}

.inputIcon {
  position: absolute;
  left: 14px;
  color: #c9a86a;
  flex-shrink: 0;
  pointer-events: none;
}

.inputWrap input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 42px;
  border: 1px solid #e5d4b0;
  border-radius: 14px;
  background: #fefcf7;
  color: #4a3012;
  font-size: 16px;
  outline: none;
  box-shadow: 0 3px 0 rgba(104, 64, 21, 0.10);
  transition: border-color 0.2s;
}

.inputWrap input:focus {
  border-color: #c9a86a;
}

.agreeRow {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px !important;
}

.agreeRow input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #c9a86a;
}

.agreeRow span {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #8a6b3a !important;
  line-height: 1.5;
}

.authError {
  min-height: 0;
  font-size: 14px;
  font-weight: 700;
  color: #d4482a;
  text-align: center;
  transition: min-height 0.2s;
}

.authError:not(:empty) {
  min-height: 24px;
}

.authSubmit {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd549 0%, #f5b820 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 0 #c48d18;
  transition: all 0.15s;
}

.authSubmit:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c48d18;
}

.authSubmit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.authFooter {
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 0 32px 28px;
  text-align: center;
}

.authFooter > span {
  font-size: 13px;
  color: #b69860;
}

.authDivider {
  width: 60%;
  height: 1px;
  background: #e5d4b0;
}

.authFingerprint {
  color: #d4b888;
}
