:root {
  --cream: #f7efe2;
  --ink: #211d18;
  --muted: #746a5d;
  --line: rgba(33, 29, 24, 0.13);
  --gold: #b88b4a;
  --rose: #d9a6a4;
  --sage: #9da889;
  --card: rgba(255, 252, 245, 0.84);
  --heading: "Cormorant Garamond", Georgia, serif;
  --body: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(circle at 8% 8%, rgba(184, 139, 74, 0.22), transparent 24rem),
    radial-gradient(circle at 90% 14%, rgba(217, 166, 164, 0.24), transparent 22rem),
    linear-gradient(135deg, #fffaf1 0%, #f2e4d0 100%);
}

a { color: inherit; }

.landing,
.form-page,
.status-page,
.admin-page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 46px;
}

.topbar.compact { margin-bottom: 24px; }

.brand {
  color: var(--ink);
  font-family: var(--heading);
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-link,
.secondary-button,
.small-button {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.42);
}

.landing-hero {
  min-height: 62vh;
  display: grid;
  align-content: center;
  max-width: 850px;
  position: relative;
}

.landing-hero::after {
  content: "";
  position: absolute;
  right: -260px;
  top: 20px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(184, 139, 74, 0.34);
  border-radius: 46% 54% 42% 58%;
  transform: rotate(-16deg);
  pointer-events: none;
}

.hero-kicker {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: var(--heading);
  font-weight: 500;
}

h1 {
  margin: 10px 0 18px;
  font-size: clamp(4rem, 12vw, 8.8rem);
  line-height: 0.88;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0 0 20px;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.landing-hero p,
.form-intro p,
.admin-header p {
  max-width: 720px;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.primary-button,
.builder-form button,
.actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  background: var(--ink);
  color: var(--cream);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button.disabled,
.builder-form button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  pointer-events: none;
}

.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.feature-strip article,
.form-card,
.status-card,
.table-card,
.notice {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: 0 24px 80px rgba(65, 48, 29, 0.11);
  backdrop-filter: blur(18px);
}

.feature-strip article {
  padding: 28px;
}

.feature-strip span {
  color: var(--gold);
  font-weight: 900;
}

.feature-strip strong {
  display: block;
  margin-top: 18px;
  font-size: 1.1rem;
}

.form-intro,
.admin-header {
  margin-bottom: 26px;
}

.builder-form {
  display: grid;
  gap: 18px;
}

.form-card,
.status-card,
.table-card {
  padding: clamp(22px, 4vw, 42px);
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  font: inherit;
}

textarea {
  resize: vertical;
}

small,
.hint,
.field-error {
  color: var(--muted);
  font-size: 0.85rem;
}

.field-error,
.notice.error {
  color: #9e2f2f;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  border: 0;
  padding: 0;
  margin: 0;
}

.theme-picker legend {
  margin-bottom: 10px;
  color: var(--muted);
}

.theme-option {
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px;
  background: #fffaf2;
  cursor: pointer;
}

.theme-option input {
  width: auto;
}

.theme-option span {
  display: block;
  margin-top: 20px;
  color: var(--ink);
  font-weight: 800;
}

.theme-option.romantic { background: linear-gradient(135deg, #fff7fb, #f3d5dc); }
.theme-option.modern { background: linear-gradient(135deg, #fff, #d7b456); }
.theme-option.rustic { background: linear-gradient(135deg, #f0debd, #b98250); }

.slug-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.domain-preview {
  min-height: 51px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.46);
}

.submit-button {
  justify-self: start;
}

.notice {
  padding: 16px 20px;
  margin: 16px 0;
}

.deploy-log {
  max-height: 360px;
  overflow: auto;
  padding: 18px;
  border-radius: 16px;
  background: #211d18;
  color: #fff7ec;
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(184, 139, 74, 0.16);
  color: var(--ink);
  font-weight: 800;
}

.muted-link {
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions form {
  display: inline;
}

.actions button,
.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.chat-page {
  width: min(920px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.chat-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

.chat-page .topbar {
  margin-bottom: 12px;
}

.chat-page .brand {
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.chat-nav-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.chat-nav-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #2f8f5b;
}

.chat-context,
.chat-card {
  background: rgba(255, 252, 244, 0.9);
  border: 1px solid rgba(48, 42, 32, 0.12);
  border-radius: 32px;
  box-shadow: 0 28px 90px rgba(54, 42, 28, 0.14);
  backdrop-filter: blur(22px);
}

.chat-context {
  min-height: 720px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(26px, 4.5vw, 48px);
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(160deg, rgba(38, 55, 47, 0.96), rgba(104, 83, 53, 0.88)),
    radial-gradient(circle at 20% 20%, rgba(238, 205, 143, 0.32), transparent 18rem);
  color: #fff7e8;
}

.chat-context::after {
  content: "";
  position: absolute;
  right: -110px;
  bottom: -120px;
  width: 300px;
  height: 300px;
  border: 1px solid rgba(184, 139, 74, 0.34);
  border-radius: 42% 58% 55% 45%;
  transform: rotate(21deg);
}

.chat-context .hero-kicker,
.chat-context p {
  color: rgba(255, 247, 232, 0.76);
}

.chat-context h1 {
  max-width: 620px;
  margin-top: 16px;
  color: #fff7e8;
  font-size: clamp(3.2rem, 7.4vw, 6.2rem);
}

.chat-steps {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.chat-steps span {
  width: fit-content;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 247, 232, 0.84);
  font-weight: 800;
}

.chat-card {
  height: calc(100vh - 88px);
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(247, 239, 226, 0.96)),
    #fffaf1;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(48, 42, 32, 0.1);
  background: rgba(255, 255, 255, 0.48);
}

.ai-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #26372f;
  color: #fff7e8;
  font-family: var(--heading);
  font-size: 1.4rem;
}

.chat-header strong,
.chat-header span {
  display: block;
}

.chat-header strong {
  color: var(--ink);
}

.chat-header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 22px 18px;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 10% 0%, rgba(184, 139, 74, 0.12), transparent 18rem),
    linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0));
}

.chat-message {
  max-width: min(82%, 620px);
  display: grid;
  gap: 6px;
  animation: chatIn 220ms ease both;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
  justify-items: end;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.chat-message.user .message-header {
  color: rgba(38, 55, 47, 0.7);
}

.message-header time {
  font-weight: 600;
  opacity: 0.72;
}

.message-body {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(48, 42, 32, 0.1);
  border-radius: 22px;
  padding: 13px 15px;
  background: #ffffff;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
  box-shadow: 0 12px 34px rgba(48, 42, 32, 0.08);
}

.chat-message.bot .message-body {
  border-top-left-radius: 8px;
}

.chat-message.user .message-body {
  border-top-right-radius: 8px;
  background: #26372f;
  color: #fff7e8;
}

.message-status {
  min-height: 1em;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.message-status[data-state="sent"] {
  color: #2f6f4b;
}

.message-status[data-state="failed"] {
  color: #a43f35;
}

.chat-message a {
  color: inherit;
  font-weight: 900;
}

.final-link {
  display: inline-flex;
  width: fit-content;
  margin-top: 12px;
  border-radius: 999px;
  padding: 10px 14px;
  background: #26372f;
  color: #fff7e8 !important;
  text-decoration: none;
}

.final-url {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  word-break: break-all;
}

.chat-composer {
  display: grid;
  gap: 8px;
  border-top: 1px solid rgba(48, 42, 32, 0.1);
  border-radius: 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.chat-input-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
}

.chat-input-row button,
.chat-choice-row button {
  border: 0;
  border-radius: 18px;
  padding: 0 18px;
  background: #26372f;
  color: #fff7e8;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.chat-input-row button {
  min-height: 54px;
  min-width: 86px;
}

.chat-input-row button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.chat-input-row textarea {
  min-height: 54px;
  max-height: 160px;
  border-radius: 18px;
  background: #fffdf8;
  line-height: 1.45;
}

.attach-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(38, 55, 47, 0.16);
  border-radius: 18px;
  padding: 0 14px;
  background: #fffdf8;
  color: #26372f;
  font-weight: 900;
  cursor: pointer;
}

.attach-button input {
  display: none;
}

.selected-file {
  width: fit-content;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(38, 55, 47, 0.08);
  color: #26372f;
  font-size: 0.84rem;
  font-weight: 800;
}

.chat-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-choice-row button {
  min-height: 38px;
  background: rgba(33, 29, 24, 0.08);
  color: var(--ink);
  border: 1px solid var(--line);
}

.chat-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed rgba(38, 55, 47, 0.22);
  border-radius: 18px;
  padding: 10px 12px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
}

.chat-file[hidden],
.chat-choice-row[hidden] {
  display: none;
}

.chat-typing {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #8c7f72;
  animation: typingDot 900ms ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 120ms;
}

.chat-typing span:nth-child(3) {
  animation-delay: 240ms;
}

.chat-typing strong {
  margin-left: 5px;
  font-size: 0.82rem;
}

@keyframes chatIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingDot {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (max-width: 820px) {
  .landing,
  .form-page,
  .status-page,
  .admin-page,
  .chat-page {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .landing-hero::after {
    display: none;
  }

  .feature-strip,
  .form-grid,
  .theme-picker,
  .slug-row,
  .chat-shell {
    grid-template-columns: 1fr;
  }

  .chat-context,
  .chat-card {
    min-height: auto;
  }

  .chat-card {
    height: calc(100vh - 76px);
    min-height: 0;
  }

  .chat-message {
    max-width: 92%;
  }

  .chat-input-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chat-input-row button {
    grid-column: 1 / -1;
    width: 100%;
  }

  h1 {
    font-size: clamp(3.4rem, 19vw, 5.4rem);
  }

  .table-card {
    overflow-x: auto;
  }
}
