:root {
  --bg: #f6f5f3;
  --ink: #1c1c1e;
  --muted: #6b6b70;
  --accent: #6c5ce7;
  --card: #ffffff;
  --border: #e7e5e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.wrap { max-width: 780px; margin: 0 auto; padding: 48px 20px 80px; }

.brand { font-weight: 700; letter-spacing: 0.02em; color: var(--accent); margin-bottom: 18px; }

.hero h1 { font-size: 32px; margin: 0 0 10px; }
.hero .sub { color: var(--muted); font-size: 15px; line-height: 1.5; max-width: 560px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  margin-top: 24px;
}

.generator label { display: block; font-weight: 600; margin-bottom: 10px; font-size: 14px; }

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

.ref-image-field { margin-top: 16px; }
.ref-image-field > label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.ref-drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
}
.ref-drop-zone:hover, .ref-drop-zone:focus { border-color: var(--accent); outline: none; }
.ref-drop-zone #refDropText { font-size: 13px; color: var(--muted); }
.ref-preview { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin: 0 auto; }

.prefs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
}
.pref-field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.pref-field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.pref-field select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
}
.color-row { display: flex; align-items: center; gap: 8px; height: 34px; }
.color-row input[type="color"] {
  width: 40px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
}
.color-row input[type="color"]:disabled { opacity: 0.4; cursor: default; }

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
button:hover:not(:disabled) { filter: brightness(1.05); }

.status { color: var(--muted); font-size: 13px; }

.secondary-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.secondary-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.questions-block { margin-top: 4px; }

.question-item { margin-bottom: 16px; }
.question-item .q-text { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.question-options { display: flex; flex-wrap: wrap; gap: 8px; }
.question-option {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.question-option:hover { border-color: #111111; }
.question-option.selected {
  background: #111111;
  border-color: #111111;
  color: white;
}

.section-title { font-weight: 700; margin-bottom: 14px; }

.spaces-list { display: grid; gap: 10px; }

.space-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
}
.space-item:hover { border-color: #111111; }
.space-item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.space-item .del {
  background: transparent;
  color: #b23b3b;
  padding: 6px 10px;
  font-size: 12px;
}

.empty { color: var(--muted); font-size: 14px; }

.refine-image-preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.refine-image-preview { max-height: 60px; border-radius: 6px; }

/* --- space page --- */
body.space-page { margin: 0; height: 100vh; display: flex; flex-direction: column; }

.space-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.space-title { font-weight: 700; flex: 1; }
.space-actions button { padding: 8px 14px; font-size: 13px; }
#shareBtn { background: #111111; }
#shareBtn:hover:not(:disabled) { background: #000000; filter: none; }

.space-frame { flex: 1; width: 100%; border: none; background: white; }

.chat-toggle-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: #111111;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  z-index: 50;
  padding: 0;
}
.chat-toggle-btn:hover { filter: brightness(1.05); }

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}
.chat-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.chat-bubble-assistant.pending { color: var(--muted); font-style: italic; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.chat-input-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
}
.chat-input-row button {
  padding: 9px 14px;
  font-size: 15px;
}
.chat-status { padding: 0 12px 10px; font-size: 12px; }

/* ===========================================================
   CORE — редизайн главной страницы (по макету из Figma)
   Новые классы, ничего из существующих правил выше не тронуто —
   старая разметка/логика (space-page, вопросы, список пространств)
   продолжает работать как раньше.
=========================================================== */

.core-body {
  margin: 0;
  background: #f2f1ef;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  color: var(--ink);
}

.core-wrap { max-width: 900px; margin: 0 auto; padding: 40px 20px 80px; }

.core-brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
  color: #111;
}

.core-card {
  background: #ffffff;
  border-radius: 22px;
  padding: 48px 40px 36px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* --- анимированная орб-сфера --- */
.core-orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 28px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 35% 30%, #5a5a5a, #161616 72%);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.16);
}
.core-orb-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.55;
}
.core-orb-blob-1 {
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55), transparent 65%);
  top: -10%;
  left: -10%;
  animation: coreOrbFloat1 5.5s ease-in-out infinite;
}
.core-orb-blob-2 {
  width: 55%;
  height: 55%;
  background: radial-gradient(circle, rgba(200, 200, 210, 0.5), transparent 70%);
  bottom: -10%;
  right: -5%;
  animation: coreOrbFloat2 7s ease-in-out infinite;
}
@keyframes coreOrbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18%, 22%) scale(1.25); }
}
@keyframes coreOrbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-15%, -18%) scale(1.2); }
}

.core-heading {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
  margin: 0 0 28px;
  text-transform: uppercase;
  color: #111;
}

.core-input-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f5f4f2;
  border-radius: 20px;
  padding: 14px 16px;
  text-align: left;
}

.core-attach-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff;
  color: #555;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  margin-top: 2px;
}
.core-attach-btn:hover { border-color: #111; color: #111; }

.core-input-row textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  padding: 2px 0;
  color: #111;
  font-family: inherit;
}
.core-input-row textarea::placeholder { color: #9a9994; }
.core-input-row textarea:focus { outline: none; }

.core-send-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-top: 2px;
}
.core-send-btn:hover:not(:disabled) { background: #000; filter: none; }

.core-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; }

.core-ref-thumb {
  display: block;
  max-height: 70px;
  border-radius: 10px;
  margin: 12px auto 0;
}
.core-ref-remove {
  display: block;
  margin: 8px auto 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 12px;
  padding: 6px 12px;
}
.core-ref-remove:hover { border-color: #111; color: #111; }

.core-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 22px;
}
.core-control { display: flex; align-items: center; gap: 8px; }
.core-control-label { font-size: 13px; color: #6b6b6b; }

.core-select {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
  padding: 2px 4px;
}
.core-select:focus { outline: none; }

.core-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
}
.core-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.core-swatch::-webkit-color-swatch { border: none; border-radius: 50%; }
.core-swatch::-moz-color-swatch { border: none; border-radius: 50%; }

.core-status { display: block; margin-top: 14px; }

.core-questions { text-align: left; margin-top: 24px; }
.core-questions button#finalGenerateBtn { background: #111111; }
.core-questions button#finalGenerateBtn:hover:not(:disabled) { background: #000000; filter: none; }

.core-spaces-card { text-align: left; }

/* --- account bar (index + login page) --- */
.core-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.account-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.account-email { color: var(--muted); }
.account-logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}
.account-logout:hover { border-color: #111; color: #111; }
.account-signin {
  background: #111;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.account-signin:hover { background: #000; }

.verify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff8e6;
  border: 1px solid #f0dfa8;
  color: #6b5a1f;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}
.verify-banner .secondary-btn { flex-shrink: 0; font-size: 12px; padding: 6px 12px; }

/* --- login/signup page --- */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 60px 20px 80px; }
.auth-card {
  background: #ffffff;
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.auth-tabs { display: flex; gap: 6px; margin-bottom: 22px; background: #f5f4f2; border-radius: 12px; padding: 4px; }
.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 9px 0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
}
.auth-tab.active { background: #ffffff; color: #111; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

#authForm { display: flex; flex-direction: column; gap: 6px; }
#authForm label { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 10px; }
#authForm input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
#authForm input:focus { outline: none; border-color: #111; }

.auth-error {
  margin-top: 12px;
  background: #fdecec;
  color: #b23b3b;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.auth-submit {
  margin-top: 18px;
  width: 100%;
  background: #111;
  color: #fff;
  padding: 12px 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}
.auth-submit:hover:not(:disabled) { background: #000; filter: none; }

.auth-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.auth-consent input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.auth-consent a { color: #111; }

/* --- legal pages (privacy / terms) --- */
.legal-wrap { max-width: 720px; margin: 0 auto; padding: 40px 24px 100px; line-height: 1.6; }
.legal-wrap h1 { font-size: 28px; margin-bottom: 6px; }
.legal-wrap h2 { font-size: 18px; margin-top: 34px; margin-bottom: 10px; }
.legal-wrap p, .legal-wrap li { color: #333; font-size: 14.5px; }
.legal-wrap ul { padding-left: 20px; }
.legal-updated { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.legal-notice {
  background: #fff8e6;
  border: 1px solid #f0dfa8;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: #6b5a1f;
  margin-bottom: 28px;
}
.legal-wrap .back { display: inline-block; margin-bottom: 20px; }
