/* Text to Phrase panel and cards */
.ttp-panel {
  background: var(--bs-surface);
  border: 1px solid var(--bs-border);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 8px 0;
}

.ttp-panel.bs-overlay-popup {
  margin: 0;
  padding: 0;
  background: var(--bs-overlay-panel);
  border-radius: 24px;
}

.ttp-panel.bs-overlay-popup .ttp-header {
  margin-bottom: 0;
}

.ttp-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ttp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.ttp-icon {
  font-size: 1rem;
}

.ttp-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bs-fg);
}

.ttp-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--bs-accent, #6366f1) 18%, var(--bs-border, rgba(255, 255, 255, 0.14)));
  border-radius: 10px;
  background: color-mix(in srgb, var(--bs-input-bg, var(--bs-bg)) 72%, transparent);
}

.ttp-input {
  flex: 1;
  min-height: 44px;
  background: transparent;
  color: var(--bs-input-text, var(--bs-fg));
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
}

.ttp-input:focus {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bs-accent, #6366f1) 52%, transparent);
}

.ttp-input::placeholder {
  color: var(--bs-input-placeholder, var(--bs-muted));
}

.ttp-btn {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bs-accent, #6366f1) 82%, #ffffff 6%),
    color-mix(in srgb, var(--bs-accent, #6366f1) 56%, #111827 16%));
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--bs-accent, #6366f1) 70%, white 10%);
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--bs-accent, #6366f1) 18%, transparent);
}

.ttp-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px color-mix(in srgb, var(--bs-accent, #6366f1) 24%, transparent);
}

.ttp-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.ttp-btn-spinner {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  font-size: 0;
  vertical-align: middle;
}

.ttp-btn-spinner::before {
  content: '';
  position: absolute;
  inset: 1px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-top-color: #fff;
  border-radius: 50%;
  animation: db-operation-spin 0.72s linear infinite;
}

.ttp-map-toggle {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--bs-muted);
  font-size: 0.74rem;
  user-select: none;
}

.ttp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}

.ttp-footer .ttp-map-toggle {
  margin-top: 0;
}

.ttp-clear-btn {
  background: none;
  border: 1px solid var(--bs-border);
  border-radius: 6px;
  color: var(--bs-muted);
  font-size: 0.74rem;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.ttp-clear-btn:hover {
  border-color: var(--bs-accent, #6366f1);
  color: var(--bs-fg);
}

.ttp-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.ttp-interpretation {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--bs-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bs-bg) 82%, var(--bs-accent, #6366f1) 8%);
}

.ttp-interpretation-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ttp-interpretation-blurb {
  min-width: 0;
  color: var(--bs-fg);
  font-size: 0.78rem;
  line-height: 1.35;
}

.ttp-interpretation-confidence,
.ttp-interpretation-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--bs-border);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--bs-muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.68rem;
  white-space: nowrap;
}

.ttp-interpretation-confidence {
  color: #fff8e1;
  border-color: rgba(245, 158, 11, 0.52);
  background: rgba(245, 158, 11, 0.18);
}

.ttp-interpretation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ttp-interpretation-chip.is-suggestion {
  color: var(--bs-fg);
  border-color: color-mix(in srgb, var(--bs-accent, #6366f1) 42%, var(--bs-border));
}

.ttp-card {
  background: var(--bs-bg);
  border: 1px solid var(--bs-border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ttp-card:hover {
  border-color: var(--bs-accent, #6366f1);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.ttp-card.active {
  border-color: var(--bs-accent, #6366f1);
  box-shadow: 0 0 0 2px var(--bs-accent, #6366f1);
}

.ttp-card-score {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 4px;
  border: 1px solid var(--bs-border);
  color: var(--bs-muted);
  background: rgba(255, 255, 255, 0.06);
}

.ttp-card-score.is-strong {
  color: #eafcf3;
  background: rgba(16, 185, 129, 0.35);
  border-color: rgba(16, 185, 129, 0.65);
}

.ttp-card-score.is-medium {
  color: #fff8e1;
  background: rgba(245, 158, 11, 0.32);
  border-color: rgba(245, 158, 11, 0.62);
}

.ttp-status {
  font-size: 0.78rem;
  color: var(--bs-muted);
  padding: 8px 0;
}

.db-operation-status {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 72px;
  padding: 14px 16px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--bs-accent, #6366f1) 28%, var(--bs-border, rgba(255, 255, 255, 0.14)));
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--bs-accent, #6366f1) 12%, transparent), transparent),
    color-mix(in srgb, var(--bs-bg, #111827) 86%, var(--bs-accent, #6366f1) 14%);
  background-size: 220% 100%, 100% 100%;
  color: var(--bs-fg, var(--bs-text, #f8fafc));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, white 4%, transparent);
  animation: db-operation-sheen 1.9s ease-in-out infinite;
}

.db-operation-status--compact {
  min-height: 52px;
  padding: 10px 12px;
}

.db-operation-status__indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bs-accent, #6366f1) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--bs-accent, #6366f1) 38%, transparent);
}

.db-operation-status__dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #fff;
  opacity: 0.42;
  animation: db-operation-pulse 1.05s ease-in-out infinite;
}

.db-operation-status__dot:nth-child(2) {
  animation-delay: 0.14s;
}

.db-operation-status__dot:nth-child(3) {
  animation-delay: 0.28s;
}

.db-operation-status__copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.db-operation-status__label {
  overflow: hidden;
  color: var(--bs-text, #f8fafc);
  font-size: 0.86rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-operation-status__detail {
  color: var(--bs-text-muted, var(--bs-muted, #94a3b8));
  font-size: 0.76rem;
  line-height: 1.35;
}

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

@keyframes db-operation-pulse {
  0%, 100% {
    opacity: 0.34;
    transform: translateY(0) scale(0.92);
  }
  45% {
    opacity: 1;
    transform: translateY(-2px) scale(1);
  }
}

@keyframes db-operation-sheen {
  0% { background-position: 180% 0, 0 0; }
  100% { background-position: -40% 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ttp-btn-spinner::before,
  .db-operation-status,
  .db-operation-status__dot {
    animation: none;
  }
}

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

.ttp-card-preview {
  display: block;
  margin-top: 7px;
  border-top: 1px solid var(--bs-border);
  padding-top: 7px;
}

.ttp-card-preview-canvas {
  display: block;
  width: 100%;
  height: 72px;
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid var(--bs-border);
  background: var(--bs-thumbnail-bg, rgba(11, 15, 31, 0.85));
}

@media (max-width: 768px) {
  .ttp-panel {
    padding: 10px 12px;
    margin: 6px 0;
  }

  .ttp-form {
    flex-direction: column;
  }

  .ttp-btn {
    padding: 8px;
    text-align: center;
  }

  .ttp-results {
    grid-template-columns: 1fr;
  }
}
