@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --primary: #0f6e56;
  --primary-dark: #0b5a45;
  --accent-soft: #e1f5ee;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #5f5e5a;
  --border: #e5e3db;
  --warm: #d9a441;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

a { color: var(--primary); }
.muted { color: var(--text-secondary); font-size: 14px; }

/* ---------------- Buttons ---------------- */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 110, 86, 0.15);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15, 110, 86, 0.22); }
.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ---------------- Auth (Login/Register) ---------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.auth-motif {
  position: absolute;
  color: var(--primary);
  opacity: 0.08;
  pointer-events: none;
}
.auth-motif--tl { top: -60px; left: -60px; }
.auth-motif--br { bottom: -60px; right: -60px; }

.auth-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(15, 40, 32, 0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 20px;
  margin-bottom: 4px;
}
.brand svg { color: var(--primary); }

.tabs { display: flex; gap: 6px; margin: 24px 0 20px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab {
  flex: 1; padding: 9px; border: none; background: transparent; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-secondary);
  font-family: 'Inter', sans-serif; transition: all 0.15s ease;
}
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
input, textarea, select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.error { color: #b3261e; font-size: 13px; min-height: 18px; margin-top: 4px; }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-size: 16px; }

/* ---------------- Page layout ---------------- */
.page { max-width: 960px; margin: 0 auto; padding: 40px 24px 64px; }
.page-header { margin-bottom: 28px; }
.page-header p { margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: 0 8px 24px rgba(15, 40, 32, 0.06); }

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--primary);
  margin-left: 8px;
}
.status-badge.draft { background: #f2f1ec; color: var(--text-secondary); }

.addon-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.addon-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.addon-row .btn-primary, .addon-row .btn-secondary { padding: 6px 14px; font-size: 12px; }

/* ---------------- Form page ---------------- */
.form-card { max-width: 640px; margin: 0 auto; }

/* ---------------- Editor layout ---------------- */
.editor-layout { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 61px); }
.editor-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.editor-preview { background: #efece3; position: relative; }
.editor-preview iframe { width: 100%; height: 100%; border: none; background: #fff; }

.chat-log { flex: 1; overflow-y: auto; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.chat-msg {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  align-self: flex-end;
  max-width: 90%;
  line-height: 1.5;
}
.chat-msg.system {
  background: var(--bg);
  color: var(--text-secondary);
  align-self: flex-start;
  border: 1px solid var(--border);
}

.editor-section {
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}
.editor-section h3 { font-size: 15px; }

/* ---------------- Misc ---------------- */
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-secondary); }

@media (max-width: 800px) {
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .editor-preview { height: 60vh; }
}
