:root {
  --bg: #f5efe4;
  --ink: #1f1a16;
  --muted: #6e6258;
  --panel: rgba(255, 250, 242, 0.78);
  --panel-border: rgba(56, 40, 27, 0.12);
  --line: rgba(56, 40, 27, 0.12);
  --primary: #d95c2b;
  --ok: #1c8f61;
  --danger: #b64232;
  --shadow: 0 24px 70px rgba(71, 48, 29, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-display: "Fraunces", "Times New Roman", "Songti SC", serif;
  --font-body: "Manrope", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(217, 92, 43, 0.18), transparent 24%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.5), transparent 18%),
    linear-gradient(180deg, #f8f2e8 0%, #efe5d6 50%, #e8dccb 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: auto auto -14rem -8rem;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  background: rgba(82, 147, 128, 0.14);
  filter: blur(18px);
  pointer-events: none;
}

.page {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 32px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 247, 238, 0.82), rgba(246, 234, 219, 0.72)),
    linear-gradient(180deg, #f4eadb, #f9f4ec);
  border: 1px solid rgba(60, 44, 31, 0.08);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -4rem -5rem auto;
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(217, 92, 43, 0.18), rgba(217, 92, 43, 0));
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-tag {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(56, 40, 27, 0.1);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
}

h1 {
  margin-top: 16px;
  font-size: clamp(2.3rem, 12vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

h2 {
  margin-top: 8px;
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1;
}

.lead {
  margin-top: 16px;
  max-width: 40rem;
  color: #43362c;
  line-height: 1.75;
}

.hero-metrics {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.metric-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(56, 40, 27, 0.08);
}

.metric-card strong {
  display: block;
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.workspace {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.panel-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status,
.server-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.status::before {
  content: "";
  width: 9px;
  height: 9px;
  margin-right: 10px;
  border-radius: 50%;
  background: #d5972d;
  box-shadow: 0 0 0 5px rgba(213, 151, 45, 0.14);
}

.status.connected::before {
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(28, 143, 97, 0.14);
}

.status.error::before {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(182, 66, 50, 0.14);
}

.server-badge.ready {
  color: var(--ok);
}

.server-badge.error {
  color: var(--danger);
}

.form-grid,
.field,
.chip-block {
  display: grid;
  gap: 10px;
}

label {
  color: #32281f;
  font-size: 0.95rem;
}

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

input,
select,
textarea {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input,
select {
  min-height: 52px;
  padding: 0 15px;
}

textarea {
  min-height: 168px;
  resize: vertical;
  padding: 14px 15px;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(217, 92, 43, 0.52);
  box-shadow: 0 0 0 4px rgba(217, 92, 43, 0.12);
}

.field-meta,
.range-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.helper-text,
.range-meta span,
.revised-prompt {
  color: var(--muted);
  line-height: 1.6;
}

.counter {
  color: #5b4f46;
  font-size: 0.88rem;
}

.chip-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip-button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(56, 40, 27, 0.12);
  background: rgba(255, 255, 255, 0.6);
  color: #3d2f25;
}

.select-grid {
  display: grid;
  gap: 12px;
}

.compact-grid {
  align-items: end;
}

input[type="range"] {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

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

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

.button-primary {
  color: #fff7f2;
  background: linear-gradient(135deg, var(--primary), #ef8446);
  box-shadow: 0 16px 32px rgba(217, 92, 43, 0.24);
}

.button-secondary,
.download-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(56, 40, 27, 0.12);
}

.logout-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 22px;
  text-align: center;
  border-radius: 24px;
  border: 1px dashed rgba(56, 40, 27, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(249, 240, 228, 0.7)),
    linear-gradient(135deg, rgba(217, 92, 43, 0.05), rgba(82, 147, 128, 0.07));
}

.empty-state.hidden,
.hidden {
  display: none;
}

.empty-art {
  width: 112px;
  height: 112px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(217, 92, 43, 0.25), rgba(82, 147, 128, 0.18)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(243, 231, 218, 0.8));
  box-shadow: inset 0 0 0 1px rgba(56, 40, 27, 0.08);
  margin-bottom: 18px;
}

.empty-state p {
  max-width: 18rem;
  color: var(--muted);
  line-height: 1.7;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.meta-pill {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(56, 40, 27, 0.1);
  font-size: 0.9rem;
}

.gallery {
  display: grid;
  gap: 14px;
}

.image-card {
  overflow: hidden;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(56, 40, 27, 0.09);
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e8dccf;
}

.image-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 6px;
}

.download-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
}

.revised-prompt {
  margin: 0;
  padding: 0 14px 16px;
  font-size: 0.9rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  width: min(100% - 24px, 560px);
  margin: 0 auto;
  padding: 24px 0;
}

.login-shell {
  width: 100%;
}

.login-panel {
  padding: 24px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.login-form {
  margin-top: 24px;
}

.auth-status {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(56, 40, 27, 0.1);
  color: var(--muted);
}

.auth-status.success {
  color: var(--ok);
}

.auth-status.error {
  color: var(--danger);
}

@media (min-width: 900px) {
  .page {
    width: min(1180px, calc(100% - 40px));
    padding-top: 28px;
    padding-bottom: 56px;
  }

  .hero {
    padding: 32px;
  }

  .hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
    align-items: start;
  }

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

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