.themes-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay-medium);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 11050;
}

.themes-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.themes-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  width: min(960px, calc(100% - 24px));
  height: min(620px, calc(100% - 40px));
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border-subtle-4);
  box-shadow: var(--shadow-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
}

.themes-modal.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.themes-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.themes-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.themes-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.themes-header h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.themes-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted-3);
}

.themes-toolbar {
  padding: 8px 18px 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.themes-filters {
  display: inline-flex;
  gap: 6px;
}

.theme-filter {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft-3);
  background: var(--panel-3);
  font-size: 0.8rem;
  color: var(--text-muted-2);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.theme-filter:hover {
  background: var(--panel);
  border-color: var(--border-strong-3);
  color: var(--text-strong);
}

.theme-filter.active {
  background: var(--accent-soft-bg);
  border-color: var(--accent-strong);
  color: var(--text-strong);
}

.themes-content {
  flex: 1 1 auto;
  padding: 12px 18px 10px;
  overflow-y: auto;
}

.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(1fr, 1fr));
  gap: 12px;
}

.theme-card {
  border-radius: 12px;
  background: var(--bg-settings-card);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease, background 160ms ease;
  cursor: pointer;
}

.theme-card:hover {
  border-color: var(--border-strong-3);
  background: var(--panel-3);
}

.theme-card.selected {
  border-color: var(--accent-strong);
  background: var(--panel-control);
}

.theme-preview {
  height: 120px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-hero);
}

.theme-body {
  padding: 10px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.theme-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.theme-author {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted-3);
}

.theme-description {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted-2);
}

.theme-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 6px;
}

.theme-pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft-3);
  background: var(--panel-4);
  font-size: 0.7rem;
  color: var(--text-muted-2);
}

.theme-card .settings-button {
  align-self: flex-start;
  margin-top: 2px;
  padding-inline: 12px;
}

.themes-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--panel-3);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.themes-footer-text {
  color: var(--text-muted-2);
  max-width: 620px;
}

.themes-footer-text code {
  font-size: 0.78rem;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--panel-4);
  border: 1px solid var(--border-soft-2);
}

.themes-close-apply {
  justify-self: end;
}

@media (max-width: 700px) {
  .themes-modal {
    height: calc(100% - 24px);
  }
  .theme-preview {
    height: 96px;
  }
}

.theme-preview--dark-red {
  background-color: #110f0f;
  background-size: auto;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.theme-preview-popup {
  width: 100%;
  max-width: 220px;
  min-height: 100px;
  border-radius: 10px;
  background: #1b0508;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  border: 1px solid #241D1D;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 10px;
}

.theme-preview-popup-header {
    padding: 4px;
  background: #1A0F0F;
  border-bottom: 1px solid #241D1D;
  text-align: left;
}

.theme-preview-title {
  font-weight: bold !important;
  font-size: 0.68rem;
  font-weight: 500;
  color: #ffffff;
}

.theme-preview-popup-body {
  padding: 4px;
    background: #1A0F0F;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

.theme-preview-text {
    text-align: left !important;
  margin: 0;
  font-size: 0.7rem;
  color: rgba(255, 220, 220, 0.9);
}

.theme-preview-popup-footer {
    padding: 4px;
  background: #150E0E;
  border-top: 1px solid #241D1D;
  display: flex;
  justify-content: flex-end;
}

.theme-preview-button {
  border: none;
  padding: 0.18rem 0.7rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 500;
  background: #331212;
  border: 1px solid #FF2F2F;
  color: #ffffff;
  cursor: default;
  pointer-events: none;
}
