/* ── Reset & base ──────────────────────────────────────────── */
#aimt-app *,
#aimt-app *::before,
#aimt-app *::after { box-sizing: border-box; margin: 0; padding: 0; }

#aimt-app {
  font-family: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  color: #0F172A;
  --aimt-accent:   #0EA5E9;
  --aimt-accent2:  #6366F1;
  --aimt-surface:  #F8FAFC;
  --aimt-border:   #E2E8F0;
  --aimt-muted:    #64748B;
  --aimt-card-bg:  #FFFFFF;
  --aimt-radius:   14px;
  --aimt-shadow:   0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
}

/* ── Google font ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Header ────────────────────────────────────────────────── */
.aimt-header {
  background: #0F172A;
  border-radius: var(--aimt-radius) var(--aimt-radius) 0 0;
  padding: 28px 28px 0;
}

.aimt-header-top { margin-bottom: 24px; }

.aimt-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  color: #F1F5F9;
  margin-bottom: 6px;
}

.aimt-tagline {
  font-size: 13px;
  color: #64748B;
  font-weight: 400;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.aimt-tabs {
  display: flex;
  gap: 2px;
}

.aimt-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #94A3B8;
  background: transparent;
  border: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.aimt-tab:hover { color: #E2E8F0; }

.aimt-tab.active {
  background: var(--aimt-surface);
  color: #0F172A;
}

/* ── Tool grid ─────────────────────────────────────────────── */
.aimt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 24px;
  background: var(--aimt-surface);
  border-radius: 0 0 var(--aimt-radius) var(--aimt-radius);
  border: 1px solid var(--aimt-border);
  border-top: none;
}

/* ── Tool card ─────────────────────────────────────────────── */
.aimt-card {
  background: var(--aimt-card-bg);
  border: 1px solid var(--aimt-border);
  border-radius: var(--aimt-radius);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aimt-card:hover {
  box-shadow: 0 4px 24px rgba(14,165,233,.12);
  border-color: var(--aimt-accent);
  transform: translateY(-2px);
}

.aimt-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.aimt-card-icon.marketer { background: #EFF6FF; }
.aimt-card-icon.seo      { background: #F0FDF4; }
.aimt-card-icon.ads      { background: #FFF7ED; }

.aimt-card-name {
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  line-height: 1.3;
}

.aimt-card-desc {
  font-size: 12.5px;
  color: var(--aimt-muted);
  line-height: 1.55;
  flex: 1;
}

.aimt-card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.aimt-tag {
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .02em;
}
.aimt-tag.ai   { background:#EFF6FF; color:#1D4ED8; }
.aimt-tag.calc { background:#F0FDF4; color:#15803D; }
.aimt-tag.gen  { background:#FFF7ED; color:#C2410C; }

.aimt-card-arrow {
  align-self: flex-end;
  color: #CBD5E1;
  transition: color .2s, transform .2s;
}
.aimt-card:hover .aimt-card-arrow { color: var(--aimt-accent); transform: translateX(3px); }

/* ── Modal ─────────────────────────────────────────────────── */
.aimt-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.aimt-modal[hidden] { display: none; }

.aimt-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
}

.aimt-modal-panel {
  position: relative;
  background: #fff;
  border-radius: var(--aimt-radius);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,23,42,.2);
  animation: aimt-slide-up .22s ease;
}

@keyframes aimt-slide-up {
  from { opacity:0; transform: translateY(16px) scale(.98); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.aimt-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--aimt-border);
  gap: 12px;
}

.aimt-modal-title-wrap { display: flex; align-items: center; gap: 14px; }

.aimt-modal-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.aimt-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: #0F172A;
  line-height: 1.3;
}

.aimt-modal-subtitle {
  font-size: 12.5px;
  color: var(--aimt-muted);
  margin-top: 3px;
}

.aimt-modal-close {
  background: var(--aimt-surface);
  border: 1px solid var(--aimt-border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  color: var(--aimt-muted);
  display: flex;
  align-items: center;
  transition: background .15s;
  flex-shrink: 0;
}
.aimt-modal-close:hover { background: #F1F5F9; }

.aimt-modal-body { padding: 22px; display: flex; flex-direction: column; gap: 18px; }

/* ── Fields ────────────────────────────────────────────────── */
.aimt-fields { display: flex; flex-direction: column; gap: 14px; }

.aimt-field { display: flex; flex-direction: column; gap: 5px; }

.aimt-field label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.aimt-field input,
.aimt-field textarea,
.aimt-field select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  border: 1px solid var(--aimt-border);
  border-radius: 8px;
  color: #0F172A;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}

.aimt-field input:focus,
.aimt-field textarea:focus,
.aimt-field select:focus {
  border-color: var(--aimt-accent);
  box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}

.aimt-field textarea { min-height: 90px; }

/* ── Run button ────────────────────────────────────────────── */
.aimt-run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #0EA5E9 0%, #6366F1 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.aimt-run-btn:hover   { opacity: .9; }
.aimt-run-btn:active  { transform: scale(.98); }
.aimt-run-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Output ────────────────────────────────────────────────── */
.aimt-output {
  background: #F8FAFC;
  border: 1px solid var(--aimt-border);
  border-radius: 10px;
  overflow: hidden;
}

.aimt-output[hidden] { display: none; }

.aimt-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--aimt-border);
  background: #fff;
}

.aimt-output-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--aimt-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.aimt-copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--aimt-accent);
  background: none;
  border: 1px solid var(--aimt-border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .15s;
}
.aimt-copy-btn:hover { background: #EFF6FF; }

.aimt-result-text {
  padding: 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: #1E293B;
  white-space: pre-wrap;
  font-family: 'DM Mono', monospace;
  max-height: 360px;
  overflow-y: auto;
}

/* ── Spinner ───────────────────────────────────────────────── */
.aimt-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aimt-spin .7s linear infinite;
  display: inline-block;
}
@keyframes aimt-spin { to { transform: rotate(360deg); } }

/* ── Error ─────────────────────────────────────────────────── */
.aimt-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #B91C1C;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .aimt-header { padding: 20px 16px 0; }
  .aimt-grid   { padding: 16px; gap: 10px; }
  .aimt-tab    { padding: 8px 12px; font-size: 12px; }
  .aimt-grid   { grid-template-columns: 1fr 1fr; }
}

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

/* ── Provider selector ─────────────────────────────────────── */
.aimt-provider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--aimt-surface);
  border: 1px solid var(--aimt-border);
  border-radius: 10px;
}

.aimt-provider-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--aimt-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.aimt-provider-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.aimt-provider-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 20px;
  border: 1.5px solid var(--aimt-border);
  background: #fff;
  color: var(--aimt-muted);
  cursor: pointer;
  transition: all .15s;
}

.aimt-provider-pill:hover {
  border-color: #94A3B8;
  color: #374151;
}

.aimt-provider-pill.active[data-provider="anthropic"] {
  border-color: #A855F7;
  background: #FAF5FF;
  color: #7E22CE;
}

.aimt-provider-pill.active[data-provider="openai"] {
  border-color: #10B981;
  background: #ECFDF5;
  color: #065F46;
}

.aimt-provider-pill.active[data-provider="gemini"] {
  border-color: #3B82F6;
  background: #EFF6FF;
  color: #1E40AF;
}

.aimt-provider-pill .aimt-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.aimt-provider-pill[data-provider="anthropic"] .aimt-pill-dot { background: #A855F7; }
.aimt-provider-pill[data-provider="openai"]    .aimt-pill-dot { background: #10B981; }
.aimt-provider-pill[data-provider="gemini"]    .aimt-pill-dot { background: #3B82F6; }

/* Result provider badge */
.aimt-output-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .03em;
}
.aimt-output-badge[data-provider="anthropic"] { background:#FAF5FF; color:#7E22CE; }
.aimt-output-badge[data-provider="openai"]    { background:#ECFDF5; color:#065F46; }
.aimt-output-badge[data-provider="gemini"]    { background:#EFF6FF; color:#1E40AF; }

/* Hide provider wrap when no providers configured */
.aimt-provider-wrap:empty,
.aimt-provider-wrap.hidden { display: none; }

/* No-provider warning */
.aimt-no-provider {
  background: #FFFBEB;
  border: 1px solid #FCD34D;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #92400E;
  display: flex;
  align-items: center;
  gap: 8px;
}
