:root {
  --bg: #08090d;
  --bg-soft: #101116;
  --panel: rgba(18, 18, 24, 0.88);
  --panel-strong: rgba(12, 13, 18, 0.98);
  --line: rgba(242, 208, 150, 0.16);
  --line-strong: rgba(242, 208, 150, 0.34);
  --text: rgba(255, 247, 239, 0.96);
  --muted: rgba(255, 240, 226, 0.68);
  --gold: #f2d096;
  --gold-dark: #9d7b43;
  --danger: #ffb3a9;
  --success: #c8f2d2;
  --shadow: 0 26px 72px rgba(0, 0, 0, 0.42);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --container: min(1160px, calc(100vw - 40px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(242, 208, 150, 0.16), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(248, 236, 232, 0.08), transparent 26%),
    linear-gradient(180deg, #0a0b10 0%, #08090d 62%, #0e0f14 100%);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: radial-gradient(rgba(242, 208, 150, 0.28) 0.65px, transparent 0.75px);
  background-size: 16px 16px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78), transparent 84%);
}

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

button {
  cursor: pointer;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.generator-card,
.result-card,
.hero-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    var(--panel);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(420px, 100%);
  padding: 30px;
}

.auth-logo {
  width: 150px;
  height: 46px;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.75rem;
}

h1,
h2 {
  margin: 10px 0 0;
  font-family: "Iowan Old Style", "Didot", "Bodoni 72", "Songti SC", serif;
  font-weight: 500;
  line-height: 1.04;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.7rem);
}

h2 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
}

.auth-form,
.generator-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 9px;
}

.field span {
  color: rgba(255, 247, 239, 0.9);
  font-weight: 600;
}

.field small {
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.045);
  outline: none;
  transition: border-color 180ms ease, background 180ms ease;
}

input,
select {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 170px;
  padding: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.065);
}

input[type="file"] {
  display: grid;
  align-items: center;
  padding: 11px;
}

button,
.download-link {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.auth-form button,
.primary-action {
  color: #17140f;
  border: 0;
  background: linear-gradient(135deg, rgba(242, 208, 150, 0.98), rgba(255, 241, 221, 0.9));
  box-shadow: 0 16px 42px rgba(242, 208, 150, 0.16);
  font-weight: 700;
}

.primary-action[disabled] {
  cursor: not-allowed;
  opacity: 0.62;
}

.error,
.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.app-shell {
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(20px, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid rgba(242, 208, 150, 0.1);
  background: linear-gradient(180deg, rgba(7, 8, 12, 0.94), rgba(7, 8, 12, 0.68));
  backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 126px;
  height: 38px;
  object-fit: cover;
  border-radius: 14px;
}

.brand span,
.topbar-meta span {
  color: var(--muted);
}

.topbar-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.topbar-meta form {
  margin: 0;
}

.topbar-meta button {
  min-height: 38px;
  padding: 0 14px;
}

.workspace {
  width: var(--container);
  margin: 0 auto;
  padding: 34px 0 72px;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: 22px;
}

.hero-panel {
  grid-column: 1 / -1;
  padding: clamp(24px, 5vw, 46px);
}

.hero-panel p:last-child {
  max-width: 760px;
  margin: 16px 0 0;
  color: var(--muted);
}

.generator-card,
.result-card {
  padding: clamp(20px, 4vw, 30px);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.preview-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preview-grid:empty {
  display: none;
}

.preview-item {
  overflow: hidden;
  min-height: 140px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.preview-item img,
.result-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-badge {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.86rem;
}

.message {
  margin-bottom: 16px;
  white-space: pre-wrap;
}

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

.result-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  text-decoration: none;
}

@media (max-width: 860px) {
  :root {
    --container: min(100vw - 28px, 1160px);
  }

  .topbar {
    padding: 10px 14px;
  }

  .brand img {
    width: 112px;
    height: 34px;
  }

  .brand span {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding-top: 22px;
  }

  .control-grid,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .result-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
