:root {
  --bg: #f7efe8;
  --surface: #fffdf9;
  --surface-2: #fff6ef;
  --surface-3: #f7e9df;
  --line: #ead7ca;
  --line-strong: #d9bba7;
  --text: #2e302d;
  --muted: #756e65;
  --accent: #c66c52;
  --accent-strong: #b55b43;
  --accent-soft: #f4d9cc;
  --shadow: 0 24px 60px rgba(117, 84, 60, 0.10);
  --shadow-soft: 0 12px 28px rgba(117, 84, 60, 0.07);
  --radius: 30px;
  --radius-sm: 18px;
  --radius-xs: 14px;
  --max: 1480px;
  --bg-top: #fff9f4;
  --bg-bottom: #f7ede5;
  --bg-orb-1: rgba(255, 248, 240, 0.98);
  --bg-orb-2: rgba(244, 221, 208, 0.70);
  --hero-start: rgba(255, 248, 241, 0.96);
  --hero-end: rgba(255, 241, 232, 0.92);
  --hero-badge-start: rgba(255, 245, 237, 0.98);
  --hero-badge-end: rgba(249, 233, 221, 0.96);
  --panel-start: #fffdfb;
  --panel-end: #fff4eb;
  --panel-soft-end: #fff7f0;
  --helper-end: #fff6ef;
  --ghost-bg: rgba(255, 247, 240, 0.92);
  --button-bg: #fff8f2;
  --chip-border: rgba(198, 108, 82, 0.18);
  --chip-bg: rgba(244, 217, 204, 0.52);
  --focus-ring: rgba(198, 108, 82, 0.12);
  --card-border-soft: rgba(234, 215, 202, 0.96);
  --card-overlay: rgba(255, 252, 247, 0.92);
  --wa-bg-end: #fff5ed;
  --qr-bg-end: rgba(245, 227, 214, 0.92);
  --chat-bg-start: rgba(255, 251, 247, 0.98);
  --chat-bg-end: rgba(250, 239, 231, 0.95);
  --bubble-user-start: #d98567;
  --bubble-user-end: #c86b52;
  --bubble-assistant-end: #fff3ea;
  --bubble-error-start: #fff4f1;
  --bubble-error-end: #ffe7e1;
  --bubble-error-border: #efc2b6;
  --toast-bg: rgba(40, 48, 45, 0.92);
  --toast-success: rgba(78, 119, 86, 0.94);
  --toast-error: rgba(177, 81, 66, 0.94);
}

body[data-theme="ocean"] {
  --bg: #eef4f8;
  --surface: #fbfeff;
  --surface-2: #f1f9fc;
  --surface-3: #ddeef4;
  --line: #cde0e8;
  --line-strong: #9fc4d2;
  --text: #24323a;
  --muted: #62727b;
  --accent: #4f8aa3;
  --accent-strong: #3f7690;
  --accent-soft: #d5e9f1;
  --shadow: 0 24px 60px rgba(67, 108, 128, 0.10);
  --shadow-soft: 0 12px 28px rgba(67, 108, 128, 0.07);
  --bg-top: #f6fbfd;
  --bg-bottom: #e9f3f7;
  --bg-orb-1: rgba(244, 251, 255, 0.96);
  --bg-orb-2: rgba(198, 224, 235, 0.72);
  --hero-start: rgba(246, 251, 255, 0.96);
  --hero-end: rgba(235, 246, 251, 0.94);
  --hero-badge-start: rgba(241, 249, 252, 0.98);
  --hero-badge-end: rgba(222, 238, 244, 0.96);
  --panel-start: #fbfeff;
  --panel-end: #eff7fb;
  --panel-soft-end: #f4fafc;
  --helper-end: #eef7fb;
  --ghost-bg: rgba(243, 250, 253, 0.92);
  --button-bg: #f5fbfd;
  --chip-border: rgba(79, 138, 163, 0.18);
  --chip-bg: rgba(213, 233, 241, 0.56);
  --focus-ring: rgba(79, 138, 163, 0.12);
  --card-border-soft: rgba(205, 224, 232, 0.96);
  --card-overlay: rgba(251, 254, 255, 0.92);
  --wa-bg-end: #eef7fb;
  --qr-bg-end: rgba(221, 238, 244, 0.94);
  --chat-bg-start: rgba(251, 254, 255, 0.98);
  --chat-bg-end: rgba(236, 246, 250, 0.95);
  --bubble-user-start: #679bb2;
  --bubble-user-end: #4f8aa3;
  --bubble-assistant-end: #eff8fb;
  --bubble-error-start: #fef4f3;
  --bubble-error-end: #fbe7e3;
  --bubble-error-border: #e8c8c0;
  --toast-bg: rgba(36, 50, 58, 0.92);
  --toast-success: rgba(66, 118, 122, 0.94);
  --toast-error: rgba(169, 92, 76, 0.94);
}

body[data-theme="forest"] {
  --bg: #f0f4ee;
  --surface: #fcfefb;
  --surface-2: #f1f6ee;
  --surface-3: #e0ebdf;
  --line: #d3dfcf;
  --line-strong: #a8c0a4;
  --text: #283129;
  --muted: #667164;
  --accent: #6d9073;
  --accent-strong: #57785d;
  --accent-soft: #dce7da;
  --shadow: 0 24px 60px rgba(84, 109, 88, 0.10);
  --shadow-soft: 0 12px 28px rgba(84, 109, 88, 0.07);
  --bg-top: #f7faf6;
  --bg-bottom: #edf3eb;
  --bg-orb-1: rgba(246, 250, 244, 0.96);
  --bg-orb-2: rgba(214, 228, 212, 0.72);
  --hero-start: rgba(247, 251, 246, 0.96);
  --hero-end: rgba(236, 244, 234, 0.94);
  --hero-badge-start: rgba(241, 246, 238, 0.98);
  --hero-badge-end: rgba(224, 235, 223, 0.96);
  --panel-start: #fcfefb;
  --panel-end: #eff5ed;
  --panel-soft-end: #f5f8f3;
  --helper-end: #eef4ec;
  --ghost-bg: rgba(244, 248, 242, 0.92);
  --button-bg: #f7faf5;
  --chip-border: rgba(109, 144, 115, 0.18);
  --chip-bg: rgba(220, 231, 218, 0.58);
  --focus-ring: rgba(109, 144, 115, 0.12);
  --card-border-soft: rgba(211, 223, 207, 0.96);
  --card-overlay: rgba(252, 254, 251, 0.92);
  --wa-bg-end: #eff5ed;
  --qr-bg-end: rgba(224, 235, 223, 0.94);
  --chat-bg-start: rgba(252, 254, 251, 0.98);
  --chat-bg-end: rgba(239, 245, 237, 0.95);
  --bubble-user-start: #7fa183;
  --bubble-user-end: #6d9073;
  --bubble-assistant-end: #eff5ed;
  --bubble-error-start: #fef4f3;
  --bubble-error-end: #fbe7e3;
  --bubble-error-border: #e8c8c0;
  --toast-bg: rgba(40, 49, 41, 0.92);
  --toast-success: rgba(80, 117, 85, 0.94);
  --toast-error: rgba(165, 89, 74, 0.94);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Instrument Sans", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-orb-1), transparent 28%),
    radial-gradient(circle at bottom right, var(--bg-orb-2), transparent 22%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 34px 24px 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 26px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero,
.card {
  background: var(--card-overlay);
  border: 1px solid var(--card-border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: 34px;
  background: linear-gradient(135deg, var(--hero-start) 0%, var(--hero-end) 100%);
}

.hero-copy-block {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--accent-strong);
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 {
  font-family: "Fraunces", Georgia, serif;
  max-width: 14ch;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.04;
}

.hero-subtitle {
  margin: 14px 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.1;
}

.help,
.muted,
.status-chip,
.status-box,
.message-role,
.message-content {
  line-height: 1.55;
}

.help,
.muted {
  color: var(--muted);
}

.hero-badge {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--hero-badge-start), var(--hero-badge-end));
}

.hero-badge-top,
.hero-badge-bottom,
.hero-metrics,
.dashboard,
.left-column,
.chat-layout,
.button-group,
.settings-grid {
  display: flex;
  gap: 14px;
}

.hero-badge-top,
.left-column,
.chat-layout {
  flex-direction: column;
}

.hero-badge-copy {
  margin: 0;
  color: var(--muted);
}

.hero-badge-bottom {
  display: grid;
  grid-template-columns: 1fr;
}

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

.metric-card,
.badge-item,
.setting-card,
.composer-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-start) 0%, var(--panel-end) 100%);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.metric-card,
.badge-item {
  padding: 13px 15px;
}

.metric-label,
.badge-label,
.section-kicker {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}

.metric-card strong,
.badge-item strong {
  font-size: 0.95rem;
  line-height: 1.35;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(0, 1.3fr);
  gap: 24px;
  align-items: start;
}

.left-column {
  gap: 24px;
}

.card {
  padding: 26px;
}

.compact-card {
  align-self: start;
  padding: 20px;
}

.compact-card .section-head {
  margin-bottom: 16px;
}

.compact-card .section-head h2 {
  font-size: 1.12rem;
}

.compact-card .panel-body {
  gap: 12px;
}

.compact-card .input {
  padding: 12px 14px;
}

.compact-card .button {
  padding: 11px 16px;
}

.compact-card .help,
.compact-card .helper-strip {
  font-size: 0.84rem;
}

.compact-card,
.training-card,
.chat-card,
.whatsapp-card {
  width: 100%;
}

.whatsapp-card {
  grid-column: 1 / -1;
}

.section-head {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-head h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.28rem;
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.status-chip,
.mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--accent-strong);
  font-size: 0.82rem;
  white-space: nowrap;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.helper-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel-start) 0%, var(--helper-end) 100%);
  color: var(--muted);
  font-size: 0.88rem;
}

.helper-strip p {
  margin: 0;
}

.helper-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.input,
.textarea,
.status-box,
.chat-window,
.qr-frame {
  width: 100%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-start) 0%, var(--panel-soft-end) 100%);
  border-radius: var(--radius-sm);
}

.input,
.textarea {
  padding: 14px 16px;
  color: var(--text);
  font-size: 0.98rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.input:focus,
.textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.textarea {
  min-height: 180px;
  resize: vertical;
}

.textarea.compact {
  min-height: 116px;
}

.training-textarea {
  min-height: 260px;
}

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

.setting-card {
  padding: 14px;
}

.button {
  padding: 13px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.button:disabled {
  opacity: 0.72;
  cursor: wait;
  transform: none;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(18, 18, 18, 0.06);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.button.ghost {
  background: var(--ghost-bg);
}

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

.full {
  width: 100%;
}

.help {
  font-size: 0.9rem;
}

.chat-card {
  min-height: 100%;
}

.chat-layout {
  gap: 16px;
}

.chat-window {
  min-height: 460px;
  max-height: 460px;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, var(--chat-bg-start), var(--chat-bg-end));
}

.empty-state {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  color: var(--muted);
  padding: 40px 24px;
}

.empty-state strong {
  font-size: 1.02rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  margin: 0;
  max-width: 34ch;
  line-height: 1.6;
}

.message {
  width: min(86%, 760px);
  padding: 12px 14px 13px;
  border: 1px solid var(--line);
  background: var(--panel-start);
  border-radius: 18px;
  box-shadow: 0 8px 18px rgba(117, 84, 60, 0.05);
}

.message + .message {
  margin-top: 0;
}

.message[data-role="user"] {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--bubble-user-start) 0%, var(--bubble-user-end) 100%);
  border-color: var(--bubble-user-end);
}

.message[data-role="assistant"] {
  align-self: flex-start;
  background: linear-gradient(180deg, var(--panel-start) 0%, var(--bubble-assistant-end) 100%);
}

.message[data-role="error"] {
  align-self: stretch;
  width: 100%;
  background: linear-gradient(180deg, var(--bubble-error-start) 0%, var(--bubble-error-end) 100%);
  border-color: var(--bubble-error-border);
}

.message-role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 700;
}

.message[data-role="user"] .message-role,
.message[data-role="user"] .message-content {
  color: rgba(255, 255, 255, 0.96);
}

.message-content {
  white-space: pre-wrap;
  font-size: 0.96rem;
  line-height: 1.62;
}

.composer-card {
  padding: 14px;
  background: linear-gradient(180deg, var(--panel-start) 0%, var(--panel-end) 100%);
}

.composer-card .textarea {
  min-height: 108px;
  margin-bottom: 12px;
}

.wa-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 20px;
}

.wa-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(180deg, var(--panel-start) 0%, var(--wa-bg-end) 100%);
}

.wa-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.wa-stat-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}

.wa-stat-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.wa-stat-card strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--text);
}

.footer-bar {
  margin-top: 22px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--card-border-soft);
  border-radius: 24px;
  background: var(--card-overlay);
  box-shadow: var(--shadow-soft);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 340px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--toast-bg);
  color: white;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 20;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: var(--toast-success);
}

.toast.error {
  background: var(--toast-error);
}

.footer-title,
.footer-text {
  margin: 0;
}

.footer-title {
  font-weight: 700;
  color: var(--text);
}

.footer-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.palette-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.palette-option {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.palette-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.palette-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: inline-block;
}

.palette-swatch.sunset {
  background: linear-gradient(135deg, #f5d9cd 0%, #c66c52 100%);
}

.palette-swatch.ocean {
  background: linear-gradient(135deg, #d5e9f1 0%, #4f8aa3 100%);
}

.palette-swatch.forest {
  background: linear-gradient(135deg, #dce7da 0%, #6d9073 100%);
}

.status-box {
  min-height: 168px;
  padding: 16px;
  margin-bottom: 14px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.wa-tip {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.qr-frame {
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  position: relative;
  background: radial-gradient(circle at top, var(--panel-start), var(--qr-bg-end));
}

#wa-qr {
  max-width: 100%;
  width: 272px;
  height: 272px;
  display: none;
}

#wa-qr-empty {
  text-align: center;
  max-width: 28ch;
}

@media (max-width: 1240px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .hero,
  .wa-grid {
    grid-template-columns: 1fr;
  }

  .hero-metrics,
  .button-group,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .wa-stats {
    grid-template-columns: 1fr;
  }

  .footer-bar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 20px 14px 32px;
  }

  .hero,
  .card {
    border-radius: 22px;
    padding: 18px;
  }

  .section-head,
  .subsection-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-window {
    min-height: 360px;
    max-height: 360px;
  }

  .message {
    width: 100%;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}
