@import url(https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap);

/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
#ytta-root *,
#ytta-root *::before,
#ytta-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#ytta-root {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #111111;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── CSS Variables ────────────────────────────────────────────────────────── */
#ytta-root {
  --bg:           #ffffff;
  --bg-card:      #ffffff;
  --bg-muted:     #f5f5f7;
  --bg-input:     #f5f5f7;
  --border:       #e0e0e8;
  --border-light: #ebebf0;
  --primary:      #ff0000;
  --primary-dim:  rgba(255, 0, 0, 0.08);
  --primary-glow: rgba(255, 0, 0, 0.18);
  --text:         #111111;
  --text-muted:   #555566;
  --text-dim:     #9090a8;
  --amber:        #b45309;
  --amber-dim:    rgba(180, 83, 9, 0.10);
  --blue:         #1d4ed8;
  --blue-dim:     rgba(29, 78, 216, 0.10);
  --yellow:       #92400e;
  --yellow-dim:   rgba(146, 64, 14, 0.10);
  --green:        #15803d;
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    18px;
  --shadow-card:  0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.06);
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.ytta-wrap {
  background: #ffffff;
  min-height: 600px;
}

/* ─── API Key Active Badge ─────────────────────────────────────────────────── */
.ytta-api-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #15803d;
  background: rgba(21, 128, 61, 0.08);
  border: 1px solid rgba(21, 128, 61, 0.2);
  border-radius: 999px;
  padding: 4px 12px;
}

.ytta-api-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #15803d;
  animation: pulse 2s infinite;
}

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

/* ─── Quota Banner ─────────────────────────────────────────────────────────── */
.ytta-quota-banner {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(180, 83, 9, 0.08);
  border-bottom: 1px solid rgba(180, 83, 9, 0.2);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ytta-quota-banner p {
  flex: 1;
  font-size: 13px;
  color: #92400e;
  margin: 0;
}

.ytta-quota-banner strong { color: #78350f; }

.ytta-quota-close {
  background: none;
  border: none;
  color: #b45309;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}

/* ─── Steps Container ──────────────────────────────────────────────────────── */
.ytta-steps {
  max-width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 50px;
}

/* ─── Step Card ────────────────────────────────────────────────────────────── */
.ytta-card {
  background: #ffffff;
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: none;
  transition: border-color 0.2s;
}

.ytta-card:not(.ytta-card--disabled):hover {
  border-color: rgba(255, 0, 0, 0.2);
}

.ytta-card--disabled {
  opacity: 0.38;
  pointer-events: none;
  user-select: none;
}

.ytta-card-header {
  padding: 30px 30px 0;
}

.ytta-card-header-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.ytta-card-icon {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: rgba(255, 0, 0, 0.08);
  border: 1px solid rgba(255, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ff0000;
}

.ytta-step-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 0, 0, 0.7);
  margin-bottom: 2px;
}

.ytta-card-title {
  font-size: 24px;
  font-weight: 800;
  color: #111111;
  line-height: 1.2;
  margin: 0 0 4px;
}

.ytta-card-subtitle {
  font-size: 16px;
  color: #555566;
}

.ytta-card-body {
    padding: 16px 30px 30px;
}

/* ─── Form Elements ────────────────────────────────────────────────────────── */
.ytta-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555566;
  margin-bottom: 8px;
}

.ytta-input,
.ytta-textarea {
  width: 100%;
  background: #f5f5f7;
  border: 1px solid #e0e0e8;
  border-radius: var(--radius-md);
  color: #111111;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ytta-input:focus,
.ytta-textarea:focus {
  border-color: rgba(255, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.07);
}

.ytta-input::placeholder,
.ytta-textarea::placeholder {
  color: #9090a8;
}

.ytta-textarea {
  resize: vertical;
  min-height: 100px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.ytta-input-row {
  display: flex;
  gap: 10px;
}

.ytta-input-row .ytta-input { flex: 1; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.ytta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  padding: 10px 20px;
}

.ytta-btn:active { transform: scale(0.98); }
.ytta-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ytta-btn-primary {
  background: #ff0000;
  color: #ffffff;
}

.ytta-btn-primary:hover:not(:disabled) {
  background: #cc0000;
}

.ytta-btn-outline {
  background: transparent;
  color: #555566;
  border: 1px solid #e0e0e8;
}

.ytta-btn-outline:hover:not(:disabled) {
  border-color: rgba(255, 0, 0, 0.4);
  color: #ff0000;
}

.ytta-btn-full { width: 100%; height: 44px; }

/* ─── Info Row ─────────────────────────────────────────────────────────────── */
.ytta-info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: #555566;
}

.ytta-info-row a {
  color: #ff0000;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ytta-info-row a:hover { text-decoration: underline; }

/* ─── Field Group ──────────────────────────────────────────────────────────── */
.ytta-field-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.ytta-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ytta-row-between p {
  font-size: 12px;
  color: #555566;
  flex: 1;
  margin: 0;
}

.ytta-row-between strong { color: #111111; }

/* ─── Channel Grid ─────────────────────────────────────────────────────────── */
.ytta-channels-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #ebebf0;
}

.ytta-channels-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ytta-channels-header p {
  font-size: 13px;
  color: #555566;
  margin: 0;
}

.ytta-channels-header p span { color: #ff0000; font-weight: 700; }

.ytta-channels-controls {
  display: flex;
  gap: 12px;
}

.ytta-text-btn {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color 0.15s;
}

.ytta-text-btn-primary { color: #ff0000; }
.ytta-text-btn-primary:hover { text-decoration: underline; }
.ytta-text-btn-muted { color: #555566; }
.ytta-text-btn-muted:hover { color: #111111; }

.ytta-channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.ytta-channel-grid::-webkit-scrollbar { width: 4px; }
.ytta-channel-grid::-webkit-scrollbar-track { background: transparent; }
.ytta-channel-grid::-webkit-scrollbar-thumb { background: #e0e0e8; border-radius: 4px; }

.ytta-channel-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid #e0e0e8;
  background: #f5f5f7;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  font-family: inherit;
}

.ytta-channel-card:hover {
  border-color: rgba(255, 0, 0, 0.3);
  background: rgba(255, 0, 0, 0.03);
}

.ytta-channel-card--selected {
  border-color: rgba(255, 0, 0, 0.5);
  background: rgba(255, 0, 0, 0.05);
}

.ytta-channel-thumb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #e0e0e8;
}

.ytta-channel-thumb-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #f5f5f7;
  border: 1px solid #e0e0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #555566;
}

.ytta-channel-info { flex: 1; min-width: 0; }

.ytta-channel-name {
  font-size: 13px;
  font-weight: 600;
  color: #111111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.ytta-channel-subs {
  font-size: 11px;
  color: #555566;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.ytta-channel-check { flex-shrink: 0; color: #ff0000; }
.ytta-channel-uncheck { flex-shrink: 0; color: #9090a8; }

.ytta-selected-count {
  font-size: 12px;
  color: #555566;
  margin-top: 8px;
}

.ytta-selected-count span { color: #ff0000; font-weight: 700; }

/* ─── Preset Cards ─────────────────────────────────────────────────────────── */
.ytta-presets {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.ytta-preset {
  flex: 1;
  min-width: 160px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
}

.ytta-preset--red {
  border-color: rgba(255, 0, 0, 0.2);
  background: rgba(255, 0, 0, 0.04);
}

.ytta-preset--amber {
  border-color: rgba(180, 83, 9, 0.2);
  background: rgba(180, 83, 9, 0.04);
}

.ytta-preset-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ytta-preset-views-red { font-weight: 700; font-size: 14px; color: #ff0000; }
.ytta-preset-views-amber { font-weight: 700; font-size: 14px; color: #b45309; }

.ytta-preset-period {
  font-size: 12px;
  font-weight: 600;
  color: #111111;
  margin-bottom: 2px;
}

.ytta-preset-desc { font-size: 11px; color: #555566; }

.ytta-preset-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #9090a8;
  padding: 0 4px;
}

.ytta-format-labels {
  display: flex;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.ytta-format-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555566;
}

.ytta-format-label strong { color: #111111; }

/* ─── Video Results ────────────────────────────────────────────────────────── */
.ytta-results {
  margin-top: 24px;
}

.ytta-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.ytta-results-title {
  font-size: 14px;
  font-weight: 700;
  color: #111111;
  margin: 0;
}

.ytta-results-title span { color: #555566; font-weight: 400; }

.ytta-table-section {
  border: 1px solid #e0e0e8;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.ytta-table-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f5f5f7;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}

.ytta-table-toggle:hover { background: #ebebf0; }

.ytta-table-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: #111111;
}

.ytta-table-count {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.ytta-table-count--blue {
  background: rgba(29, 78, 216, 0.10);
  color: #1d4ed8;
  border: 1px solid rgba(29, 78, 216, 0.2);
}

.ytta-table-count--yellow {
  background: rgba(146, 64, 14, 0.10);
  color: #92400e;
  border: 1px solid rgba(146, 64, 14, 0.2);
}

.ytta-table-chevron { margin-left: auto; color: #555566; }

.ytta-table-wrap { overflow-x: auto; }

.ytta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ytta-table thead tr {
  border-bottom: 1px solid #e0e0e8;
  background: #f5f5f7;
}

.ytta-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: #555566;
}

.ytta-table th:last-child,
.ytta-table th:nth-child(3) { text-align: right; }

.ytta-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #555566;
  font-family: inherit;
  padding: 0;
  transition: color 0.15s;
}

.ytta-sort-btn:hover { color: #111111; }
.ytta-sort-btn--active { color: #ff0000; }

.ytta-table tbody tr {
  border-bottom: 1px solid #ebebf0;
  transition: background 0.1s;
}

.ytta-table tbody tr:hover { background: #fafafa; }
.ytta-table tbody tr:nth-child(even) { background: #fafafa; }
.ytta-table tbody tr:last-child { border-bottom: none; }

.ytta-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

.ytta-table td:nth-child(3),
.ytta-table td:last-child { text-align: right; }

.ytta-video-link {
  color: #111111;
  text-decoration: none;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  transition: color 0.15s;
}

.ytta-video-link:hover { color: #ff0000; }

.ytta-channel-cell {
  color: #555566;
  font-size: 12px;
  white-space: nowrap;
}

.ytta-views-cell {
  font-weight: 700;
  color: #ff0000;
  white-space: nowrap;
}

.ytta-date-cell {
  color: #555566;
  font-size: 12px;
  white-space: nowrap;
}

.ytta-table-more {
  padding: 10px 14px;
  text-align: center;
  font-size: 12px;
  color: #555566;
  border-top: 1px solid #e0e0e8;
  background: #fafafa;
}

.ytta-empty-state {
  padding: 40px 24px;
  text-align: center;
  color: #555566;
  font-size: 14px;
}

/* ─── Strategy Cards ───────────────────────────────────────────────────────── */
.ytta-strategy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.ytta-strategy-title {
  font-size: 14px;
  font-weight: 700;
  color: #111111;
  margin: 0;
}

.ytta-strategy-hint {
  font-size: 12px;
  color: #555566;
}

.ytta-strategy-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.ytta-strategy-input-row .ytta-input { flex: 1; }

.ytta-month-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ytta-month-card {
  border: 1px solid #e0e0e8;
  border-radius: var(--radius-lg);
  background: #ffffff;
  overflow: hidden;
  transition: border-color 0.15s;
}

.ytta-month-card:hover { border-color: rgba(255, 0, 0, 0.2); }

.ytta-month-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}

.ytta-month-toggle:hover { background: #fafafa; }

.ytta-month-num {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.ytta-month-info { flex: 1; min-width: 0; }

.ytta-month-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ytta-month-name {
  font-size: 14px;
  font-weight: 700;
  color: #111111;
}

.ytta-month-theme {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.ytta-month-focus {
  font-size: 12px;
  color: #555566;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ytta-month-chevron { flex-shrink: 0; color: #555566; }

.ytta-month-body {
  padding: 14px 16px 16px;
  border-top: 1px solid #ebebf0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ytta-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ff0000;
  margin-bottom: 8px;
}

.ytta-video-ideas {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ytta-video-idea {
  background: #f5f5f7;
  border: 1px solid #ebebf0;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.ytta-idea-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.ytta-idea-content { flex: 1; min-width: 0; }

.ytta-idea-title {
  font-size: 13px;
  font-weight: 600;
  color: #111111;
  line-height: 1.4;
  margin-bottom: 4px;
}

.ytta-idea-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ytta-format-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: #ebebf0;
  color: #555566;
  border: 1px solid #e0e0e8;
}

.ytta-hook {
  font-size: 11px;
  color: #555566;
  font-style: italic;
}

.ytta-tactic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 500px) {
  .ytta-tactic-grid { grid-template-columns: 1fr; }
}

.ytta-tactic-card {
  background: #f5f5f7;
  border: 1px solid #ebebf0;
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.ytta-tactic-text {
  font-size: 13px;
  color: #111111;
  line-height: 1.5;
  margin: 0;
}

/* ─── Loading Spinner ──────────────────────────────────────────────────────── */
.ytta-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 0, 0, 0.2);
  border-top-color: #ff0000;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.ytta-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ytta-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  animation: slideIn 0.25s ease;
  pointer-events: all;
  max-width: 340px;
}

.ytta-toast--success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.ytta-toast--error   { background: #fff1f2; border: 1px solid #fecdd3; color: #be123c; }
.ytta-toast--info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

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

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ytta-steps { padding: 16px 12px 60px; }
  .ytta-card-header { padding: 20px 20px 0; }
  .ytta-card-body { padding: 12px 20px 20px; }
  .ytta-presets { flex-direction: column; }
  .ytta-preset-divider { display: none; }
  .ytta-row-between { flex-direction: column; align-items: flex-start; }

  /* Full-width inputs on mobile */
  .ytta-input,
  .ytta-textarea {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 16px !important;
    padding: 12px 14px !important;
    box-sizing: border-box !important;
  }

  /* Stack the API key row vertically */
  .ytta-input-row {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .ytta-input-row .ytta-input {
    width: 100% !important;
    flex: none !important;
  }

  .ytta-input-row .ytta-btn {
    width: 100% !important;
    height: 46px !important;
  }

  /* Strategy channel input row */
  .ytta-strategy-input-row {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .ytta-strategy-input-row .ytta-input {
    width: 100% !important;
  }

  .ytta-strategy-input-row .ytta-btn {
    width: 100% !important;
    height: 46px !important;
  }
}

