/* Mini App — визуально как Agents Chat (Manrope / Instrument Serif / terracotta) */
:root,
html[data-theme="light"] {
  --bg-main: #f5f3ee;
  --bg-sidebar: #ebe8e1;
  --bg-composer: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --text: #1c1b18;
  --text-muted: #6d6960;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --accent: #c45c2a;
  --accent-dot: #e07840;
  --danger: #b42318;
  --ok: #3d8b6e;
  --btn: #1c1b18;
  --btn-text: #f5f3ee;
  --user-bubble: #1c1b18;
  --user-bubble-text: #f5f3ee;
  --assistant-bubble: #ffffff;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg-main: #2a2926;
  --bg-sidebar: #201f1c;
  --bg-composer: #32312d;
  --bg-elevated: #2f2e2a;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --text: #f2efe8;
  --text-muted: #a39e94;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(0, 0, 0, 0.35);
  --accent: #e07840;
  --accent-dot: #e89157;
  --danger: #f97066;
  --ok: #5bb894;
  --btn: #f2efe8;
  --btn-text: #2a2926;
  --user-bubble: #e07840;
  --user-bubble-text: #1c1b18;
  --assistant-bubble: #32312d;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg-main: #2a2926;
    --bg-sidebar: #201f1c;
    --bg-composer: #32312d;
    --bg-elevated: #2f2e2a;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --text: #f2efe8;
    --text-muted: #a39e94;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(0, 0, 0, 0.35);
    --accent: #e07840;
    --accent-dot: #e89157;
    --danger: #f97066;
    --ok: #5bb894;
    --btn: #f2efe8;
    --btn-text: #2a2926;
    --user-bubble: #e07840;
    --user-bubble-text: #1c1b18;
    --assistant-bubble: #32312d;
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: light) {
  html[data-theme="system"] {
    --bg-main: #f5f3ee;
    --bg-sidebar: #ebe8e1;
    --bg-composer: #ffffff;
    --bg-elevated: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.05);
    --text: #1c1b18;
    --text-muted: #6d6960;
    --border: rgba(0, 0, 0, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
    --accent: #c45c2a;
    --accent-dot: #e07840;
    --danger: #b42318;
    --ok: #3d8b6e;
    --btn: #1c1b18;
    --btn-text: #f5f3ee;
    --user-bubble: #1c1b18;
    --user-bubble-text: #f5f3ee;
    --assistant-bubble: #ffffff;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 55%),
    var(--bg-main);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.boot, .screen, .app {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 18px 28px;
}

.boot {
  text-align: center;
  padding-top: 28vh;
  animation: rise 0.45s var(--ease) both;
}
.boot-brand, .title, .screen-head h1 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
}
.boot-brand { font-size: 2rem; margin: 0 0 10px; }
.boot-status, .lead, .hint, .disclaimer, .eyebrow { color: var(--text-muted); }

.eyebrow {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--accent);
}
.screen-head h1, .title { font-size: 1.85rem; margin: 0 0 10px; }
.lead { margin: 0 0 20px; line-height: 1.5; font-size: 0.98rem; }

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 10px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  box-shadow: var(--shadow);
}
.check input { margin-top: 3px; accent-color: var(--accent); }
.hint a { color: var(--accent); font-weight: 600; }
.error { color: var(--danger); margin: 8px 0; font-size: 0.9rem; }
.ok { color: var(--ok); margin: 8px 0; font-size: 0.9rem; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--btn);
  color: var(--btn-text);
  width: 100%;
  margin-top: 10px;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn.ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.btn.compact {
  width: auto;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
}
.btn:disabled { opacity: 0.55; cursor: wait; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  animation: rise 0.4s var(--ease) both;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 6px;
  background: color-mix(in srgb, var(--bg-main) 88%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active {
  background: var(--btn);
  color: var(--btn-text);
}

.panel { display: none; min-height: 48vh; }
.panel.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.35s var(--ease) both;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 42vh;
  max-height: calc(100dvh - 280px);
  overflow-y: auto;
  padding: 8px 2px 12px;
}

.bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.98rem;
  animation: bubble-in 0.28s var(--ease) both;
}
.bubble.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 8px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 8px;
  box-shadow: var(--shadow);
}
.bubble.system {
  align-self: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 4px 8px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px 12px;
  background: var(--bg-composer);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.composer textarea {
  width: 100%;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border: 0;
  border-radius: 12px;
  padding: 10px 8px;
  font: inherit;
  background: transparent;
  color: var(--text);
  outline: none;
}
.composer textarea::placeholder { color: var(--text-muted); }
.composer .btn.primary {
  margin: 0;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 14%, var(--bg-composer));
  color: var(--text);
  display: grid;
  place-items: center;
}
.composer .btn.primary:hover {
  background: color-mix(in srgb, var(--text) 20%, var(--bg-composer));
  filter: none;
}
.disclaimer { font-size: 0.72rem; margin: 4px 2px 0; line-height: 1.4; color: var(--text-muted); }

.profile {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile > div {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.profile dt {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}
.profile dd { margin: 0; font-size: 0.98rem; word-break: break-word; }

.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.card .group {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0 0 6px;
}
.card h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
}
.card .price {
  color: var(--text);
  font-weight: 700;
  margin: 0 0 8px;
}
.card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; line-height: 1.45; }
.card a { color: var(--accent); font-weight: 600; text-decoration: none; }
.card .row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.card .row .btn {
  width: auto;
  margin: 0;
  font-size: 0.82rem;
  padding: 8px 14px;
  background: var(--btn);
  color: var(--btn-text);
}

.lead-form { display: flex; flex-direction: column; gap: 12px; }
.lead-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.lead-form input,
.lead-form textarea,
.lead-form select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elevated);
  outline: none;
}
.lead-form input:focus,
.lead-form textarea:focus,
.lead-form select:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

[hidden] { display: none !important; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
