:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --text-hint: var(--tg-theme-hint-color, #737373);
  --accent: var(--tg-theme-button-color, #3b82f6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  height: 54px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.header-icon { color: var(--accent); font-size: 18px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--text); }

/* Chat area */
.chat-area {
  position: fixed;
  top: 54px;
  bottom: 72px;
  left: 0; right: 0;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Welcome */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 24px 20px;
  gap: 10px;
}

.welcome-icon {
  font-size: 44px;
  color: var(--accent);
  margin-bottom: 4px;
  animation: pulse 3s ease-in-out infinite;
}

.welcome-state h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.welcome-state p {
  color: var(--text-hint);
  font-size: 14px;
  max-width: 260px;
  line-height: 1.5;
}

.welcome-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.chip:hover, .chip:active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Mensajes */
.message {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  animation: fadeIn 0.2s ease;
}

.message.user {
  background: var(--accent);
  color: var(--accent-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow);
}

.message.assistant {
  background: var(--bg-secondary);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  white-space: pre-wrap;
}

/* Typing */
.typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.typing span {
  width: 7px; height: 7px;
  background: var(--text-hint);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

/* Content cards */
.content-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.content-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.card-platform {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.1px;
}

.btn-copy-card {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.2s;
  white-space: nowrap;
}
.btn-copy-card:active { opacity: 0.75; }
.btn-copy-card.copied { background: #16a34a; }

.card-body {
  padding: 13px 14px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}

/* Upgrade card */
.upgrade-card {
  background: var(--bg-secondary);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.upgrade-icon { font-size: 32px; }
.upgrade-card h3 { font-size: 15px; font-weight: 700; }
.upgrade-card p  { font-size: 13px; color: var(--text-hint); }
.upgrade-note    { font-size: 11px !important; color: var(--text-hint); margin-top: -4px; }

.btn-upgrade {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: -0.1px;
}
.btn-upgrade:active { opacity: 0.85; }
.btn-upgrade.premium { background: linear-gradient(135deg, #667eea, #764ba2); }

/* Install banner (iOS) */
.install-banner {
  position: fixed;
  bottom: 72px;
  left: 12px; right: 12px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
}

.install-banner-close {
  background: none;
  border: none;
  color: var(--bg);
  font-size: 16px;
  cursor: pointer;
  opacity: 0.7;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Input */
.input-area {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  z-index: 10;
}

.posts-counter {
  font-size: 11px;
  color: var(--text-hint);
  text-align: center;
  padding-bottom: 5px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 15px;
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text);
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.4;
}
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--text-hint); }

.btn-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-send:not(:disabled):active { transform: scale(0.93); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-7px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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