/* ---------- Theme tokens specific to the image formats tool ---------- */
:root {
  --accent: var(--primary);
  --accent-strong: var(--primary-strong);
  --card-bg: rgba(12, 16, 32, 0.76);
  --panel-border: rgba(255, 255, 255, 0.08);
  --surface: rgba(8, 13, 32, 0.7);
  --text-main: #f5f7ff;
  --text-muted: var(--text-secondary);
}

/* ---------- Page layout ---------- */
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 64px clamp(16px, 5vw, 64px);
}

.copy-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -24px);
  background: rgba(12, 18, 42, 0.88);
  color: #f8faff;
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(124, 93, 255, 0.45);
  box-shadow: var(--shadow-soft);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s ease, opacity 0.28s ease;
  z-index: 999;
}

.copy-toast[data-visible="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.palette-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(24px, 4vw, 32px);
  align-items: start;
}

.palette-editor {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 36px);
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  gap: clamp(22px, 3.2vw, 30px);
}

.palette-header {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vw, 20px);
}

.palette-header__titles h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  max-width: 640px;
}

.palette-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(12px, 2vw, 18px);
  align-items: center;
  justify-content: space-between;
}

.palette-base {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(10, 16, 38, 0.78);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 12px;
}

.palette-base__label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(225, 230, 255, 0.75);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.badge--light {
  background: rgba(124, 93, 255, 0.2);
  border: 1px solid rgba(124, 93, 255, 0.35);
  color: #e7e6ff;
}

.palette-form {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2vw, 20px);
}

.palette-form>.helper--warning {
  margin: 0;
  padding: 0.9rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(250, 204, 21, 0.32);
  background: rgba(250, 204, 21, 0.12);
  color: #facc15;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(18px, 3vw, 24px);
}

.swatch {
  background: rgba(9, 13, 32, 0.82);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: clamp(20px, 3vw, 26px);
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.5vw, 24px);
  box-shadow: var(--shadow-soft);
}

.swatch__column {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vw, 18px);
}

#original-preview:not([src]) {
  display: none;
}

#converted-preview:not([src]) {
  display: none;
}

.swatch__preview {
  position: relative;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 10, 28, 0.78);
  min-height: clamp(220px, 26vw, 280px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  align-self: stretch;
  margin-top: auto;
}

.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(5, 9, 24, 0.35);
  backdrop-filter: blur(8px);
  transition: opacity 0.2s ease;
}

.preview-loader[hidden] {
  display: none;
}

.preview-loader__spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(124, 93, 255, 0.85);
  animation: login-spin 0.85s linear infinite;
}

.preview-frame--image {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 22, 0.82);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.preview-frame--image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 1.5rem;
  color: rgba(189, 198, 242, 0.7);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.preview-frame--image[data-loaded="true"] .preview-placeholder {
  opacity: 0;
}

.swatch__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.swatch__actions .btn {
  flex: 1 1 160px;
  min-width: 0;
}

.format-card {
  width: 100%;
  background: rgba(7, 11, 29, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.format-card__label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(224, 228, 255, 0.72);
}

.format-card__meta {
  font-size: 0.95rem;
  color: #fff;
  word-break: break-word;
}

/* ---------- Inputs & helpers ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-weight: 600;
}

.file-drop {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.1rem;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  background: rgba(6, 10, 28, 0.65);
  transition: border 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.file-drop input[type="file"] {
  width: 100%;
  border: none;
  padding: 0.2rem;
  background: transparent;
}

.file-drop.dragover {
  border-color: rgba(124, 93, 255, 0.65);
  background: rgba(18, 26, 60, 0.72);
  box-shadow: var(--glow-primary);
}

.file-drop:hover {
  border-color: rgba(124, 93, 255, 0.6);
}

select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.75rem 1rem;
  background: rgba(6, 10, 28, 0.72);
  color: inherit;
  appearance: none;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '⌄';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: rgba(224, 228, 255, 0.65);
}

.helper {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.helper--warning {
  color: #facc15;
  font-weight: 600;
}

.status {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  position: relative;
  min-height: 22px;
  display: flex;
  align-items: center;
}

.status.success {
  color: #38e4ae;
}

.status.error {
  color: #ff6b6b;
}

/* ---------- Buttons ---------- */
.btn {
  border-radius: 999px;
  padding: 0.8rem 1.45rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  font-size: 0.95rem;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: var(--glow-primary);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-main);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

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

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 900px) {
  .palette-toolbar {
    justify-content: flex-start;
  }

  .swatch-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .swatch__preview {
    min-height: clamp(200px, 48vw, 260px);
  }
}

@media (max-width: 640px) {
  body {
    padding: 5rem 1rem 3rem;
  }

  .palette-editor {
    border-radius: 22px;
  }

  .palette-toolbar {
    gap: 12px;
  }

  .palette-base {
    width: 100%;
    justify-content: center;
  }

  .badge {
    padding: 5px 10px;
  }
}
