/* Jeanne Content Service - Premium Beige/Pastel UI */
:root {
  --bg: #f8f4ed;
  --card: #fffaf0;
  --border: #e8d9c2;
  --border-light: #f0e6d6;
  --text: #3f3a33;
  --text-dark: #24201c;
  --text-muted: #6b6359;
  --accent: #8a9a7a;        /* soft sage */
  --accent-dark: #6f7c61;
  --accent-warm: #c58f68;
  --yt-color: #c94038;
  --gt-color: #3b71ca;
  --btn-beige: #e8d9c2;
  --btn-beige-hover: #d9c8a8;
  --modal-bg: #fffaf0;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 20px 60px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-titles {
  flex: 1;
  min-width: 280px;
}

.header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-dark);
}

.header .subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
}

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

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(138, 154, 122, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 6px 18px rgba(138, 154, 122, 0.35);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Stats bar */
.stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding: 12px 20px;
  background: #f1ebd8;
  border-radius: 14px;
  border: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.buffer-criteria {
  font-size: 12px;
  opacity: 0.85;
}

/* Toolbar (Filters & Sorting) */
.toolbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.filter-group,
.sort-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.chip:hover {
  background: #f6efe2;
  border-color: #d8c6aa;
}

.chip.active {
  background: var(--text-dark);
  color: white;
  border-color: var(--text-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.chip-favorites {
  border-color: #d8c29d;
  background: #fbf5e9;
  color: #7a5823;
  font-weight: 700;
}

.chip-favorites:hover {
  background: #f5edd8;
  border-color: #c9af82;
}

.chip-favorites.active {
  background: #8b6833;
  border-color: #8b6833;
  color: white;
}

.fav-counter {
  display: inline-block;
  background: rgba(0,0,0,0.08);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 4px;
}

.chip-favorites.active .fav-counter {
  background: rgba(255,255,255,0.25);
  color: white;
}

.select-wrapper {
  position: relative;
  min-width: 240px;
}

.sort-select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 36px 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6359' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  transition: all 0.15s ease;
}

.sort-select:hover,
.sort-select:focus {
  border-color: var(--accent-dark);
  outline: none;
}

/* Trends Grid */
.trends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #d9c8af;
}

.card-top {
  margin-bottom: 16px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  gap: 8px;
  min-height: 28px;
}

.card-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.card-meta-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fav-toggle-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  height: 28px;
  box-sizing: border-box;
}

.fav-toggle-btn:hover {
  background: #fbf6ec;
  border-color: #d1b892;
  color: #7a5823;
}

.fav-toggle-btn.is-fav {
  background: #f8eedb;
  border-color: #d4b584;
  color: #926620;
}

.fav-toggle-btn.btn-remove-fav {
  background: #fdf2f2;
  border-color: #f0c4c4;
  color: #b03a3a;
}

.fav-toggle-btn.btn-remove-fav:hover {
  background: #fae4e4;
  border-color: #e49f9f;
  color: #922b2b;
}

.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.badge-макияж { background: #f0e0d0; color: #5c4633; }
.badge-уход { background: #d8e6d8; color: #2f4a2f; }
.badge-волосы { background: #ecdcd2; color: #6a3d2e; border: 1px solid #dfc3b5; }
.badge-гардероб { background: #e6d8d8; color: #4a2f2f; }
.badge-психология { background: #d8dce6; color: #2f354a; }
.badge-общее { background: #e6e0d8; color: #4a4233; }

.source-tag {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-dark);
  margin-bottom: 16px;
  min-height: 48px;
}

/* Overall viral summary */
.overall-viral {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

.overall-badge {
  font-size: 13px;
  font-weight: 800;
  color: #4a3c2c;
}

.overall-pct {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-dark);
}

/* Dual channel block */
.channels-block {
  background: #f7efe1;
  border: 1px solid #ebdcc5;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.channel-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.channel-icon-yt {
  color: var(--yt-color);
  font-size: 13px;
}

.channel-icon-gt {
  color: var(--gt-color);
  font-size: 13px;
}

.channel-val {
  font-size: 12px;
  font-weight: 700;
  color: #554839;
}

.channel-bar-bg {
  width: 100%;
  height: 6px;
  background: #e6d6be;
  border-radius: 999px;
  overflow: hidden;
}

.channel-bar-fill-yt {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9534f, #c94038);
  transition: width 0.4s ease;
}

.channel-bar-fill-gt {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5b8ad4, #3b71ca);
  transition: width 0.4s ease;
}

.channel-detail {
  font-size: 11px;
  color: #7a6e5d;
  display: flex;
  justify-content: space-between;
}

/* Format selector & generate button */
.generator-block {
  border-top: 1px dashed var(--border);
  padding-top: 16px;
}

.format-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.format-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.format-pill {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.format-pill:hover {
  background: #fdfbf7;
  border-color: #d1c0a5;
}

.format-pill.active {
  background: var(--text-dark);
  color: white;
  border-color: var(--text-dark);
}

.generate-cmd-btn {
  width: 100%;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 3px 8px rgba(138, 154, 122, 0.2);
}

.generate-cmd-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-1px);
}

/* Expand / Collapse Section */
.expand-container {
  display: flex;
  justify-content: center;
  margin-top: 36px;
  padding: 10px 0;
}

.btn-expand {
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 700;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn-expand:hover {
  background: #f4ecdc;
  border-color: #cbbba3;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

#toggle-expand-icon {
  display: inline-block;
  transition: transform 0.25s ease;
  font-size: 16px;
  line-height: 1;
}

.btn-expand.expanded #toggle-expand-icon {
  transform: rotate(180deg);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 25, 20, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f7efe1;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
}

.modal-body {
  padding: 28px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.7;
}

.modal-footer {
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: #f5eedb;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
  color: var(--text-muted);
  font-size: 15px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid #e8d9c2;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.copy-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: var(--accent-dark);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 16px;
  grid-column: 1 / -1;
  background: var(--card);
  border-radius: 16px;
  border: 1px dashed var(--border);
}

/* Custom Topic Checker Section */
.custom-checker-section {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 2px dashed #e8d9c2;
}

.custom-checker-card {
  background: #fbf7ee;
  border: 1.5px solid #dfcfb8;
  border-radius: 22px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.04);
}

.custom-checker-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.custom-checker-icon {
  font-size: 28px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #efe4d0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.custom-checker-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-dark);
}

.custom-checker-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.custom-checker-form {
  margin-bottom: 24px;
}

.custom-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
}

.custom-topic-input {
  flex: 1;
  font-family: inherit;
  font-size: 15px;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text-dark);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  transition: all 0.2s ease;
}

.custom-topic-input:focus {
  outline: none;
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 3px rgba(138, 154, 122, 0.2);
}

.custom-submit-btn {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: 12px;
  white-space: nowrap;
}

.custom-result-container {
  margin-top: 24px;
  animation: fadeIn 0.3s ease;
}

.custom-result-container .card {
  max-width: 650px;
  margin: 0 auto;
  border: 2px solid var(--accent);
  box-shadow: 0 12px 36px rgba(138, 154, 122, 0.15);
}

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

/* Mobile responsive adjustments */
@media (max-width: 860px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px;
  }

  .filter-group,
  .sort-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .select-wrapper {
    width: 100%;
    min-width: 0;
  }

  .sort-select {
    width: 100%;
    padding: 10px 36px 10px 14px;
    font-size: 14px;
  }

  .custom-input-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  .custom-submit-btn {
    width: 100%;
  }
}

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

  .header {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
  }

  .header h1 {
    font-size: 26px;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .btn {
    width: 100%;
  }

  .stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px;
  }

  .trends-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card {
    padding: 18px;
    border-radius: 16px;
  }

  .card-title {
    font-size: 16px;
    min-height: auto;
  }

  .custom-checker-section {
    margin-top: 40px;
  }

  .custom-checker-card {
    padding: 18px 14px;
    border-radius: 16px;
  }

  .custom-checker-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .custom-checker-title {
    font-size: 19px;
  }

  .btn-expand {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
  }

  .modal {
    padding: 10px;
  }

  .modal-content {
    border-radius: 16px;
    max-height: 90vh;
  }

  .modal-header {
    padding: 16px 18px;
  }

  .modal-header h3 {
    font-size: 16px;
  }

  .modal-body {
    padding: 18px;
  }

  .modal-footer {
    padding: 12px 18px;
  }
}
