/* ── Tab navigation ───────────────────────────────────── */

.tab-nav {
  display: flex;
  background: var(--c-bg-3);
  border-bottom: 1px solid var(--c-border-1);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 13px 6px 11px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-2);
  border-bottom: 2px solid transparent;
  position: relative;
  white-space: nowrap;
  transition: color var(--t-base), background var(--t-base);
  min-width: 0;
}
.tab-btn__icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  transition: color var(--t-base);
}
.tab-btn:hover {
  color: var(--c-text-1);
  background: rgba(255,255,255,0.025);
}
.tab-btn.is-active { color: var(--c-text-0); }
.tab-btn.is-active .tab-btn__icon { color: var(--c-blue-400); }

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--grad-brand-h);
  opacity: 0;
  transition: opacity var(--t-base);
}
.tab-btn.is-active::after { opacity: 1; }

/* ── Tab body & panels ────────────────────────────────── */

.tab-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border-2) transparent;
}

.tab-panel {
  display: none;
  padding: var(--panel-py) var(--panel-px);
  animation: tab-in 0.18s ease;
}
.tab-panel.is-active { display: flex; flex-direction: column; gap: var(--sp-5); }

@keyframes tab-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ── Type grid ────────────────────────────────────────── */

.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
  /* Explicit, not relying on the default (stretch): without this, if any
     ancestor ends up taller than this grid's natural content height, the
     extra space gets distributed BETWEEN rows rather than left blank
     below them - buttons individually normal-sized, but spread far apart
     vertically. Pinning both axes to start guarantees tight packing
     regardless of container height. */
  align-content: start;
  justify-content: start;
}

.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-text-2);
  background: var(--c-bg-3);
  border: 1px solid var(--c-border-1);
  border-radius: var(--r-sm);
  letter-spacing: 0.03em;
  transition:
    color var(--t-base),
    background var(--t-base),
    border-color var(--t-base),
    box-shadow var(--t-base);
}
.type-btn__icon { width: 16px; height: 16px; flex-shrink: 0; }
.type-btn:hover {
  color: var(--c-text-1);
  border-color: var(--c-border-2);
  background: var(--c-bg-4);
}
.type-btn.is-active {
  color: var(--c-text-0);
  background: rgba(37,99,235,0.1);
  border-color: var(--c-blue-600);
  box-shadow: 0 0 0 1px rgba(37,99,235,0.35), 0 1px 8px rgba(37,99,235,0.2);
}
.type-btn.is-active .type-btn__icon { color: var(--c-blue-400); }

/* ── Style picker grid ────────────────────────────────── */

.style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  align-content: start;
  justify-content: start;
}
.style-grid--sm { grid-template-columns: repeat(3, 1fr); }

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: 12px 8px 10px;
  background: var(--c-bg-3);
  border: 1px solid var(--c-border-1);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition:
    border-color var(--t-base),
    background var(--t-base),
    box-shadow var(--t-base);
}
.style-card__preview {
  width: 48px; height: 48px;
  flex-shrink: 0;
}
.style-card__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-text-2);
  text-align: center;
  line-height: 1.3;
  letter-spacing: 0.03em;
}
.style-card:hover {
  border-color: var(--c-border-2);
  background: var(--c-bg-4);
}
.style-card.is-active {
  border-color: var(--c-blue-600);
  background: rgba(37,99,235,0.1);
  box-shadow: 0 0 0 1px rgba(37,99,235,0.4), 0 1px 12px rgba(37,99,235,0.2);
}
.style-card.is-active .style-card__label { color: var(--c-blue-300); }

/* ── Frame picker grid ────────────────────────────────── */

.frame-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  align-content: start;
  justify-content: start;
}

.frame-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 6px 9px;
  background: var(--c-bg-3);
  border: 1px solid var(--c-border-1);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition:
    border-color var(--t-base),
    background var(--t-base),
    box-shadow var(--t-base);
}
.frame-card__preview {
  width: 54px; height: 54px;
  flex-shrink: 0;
}
.frame-card__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-text-2);
  text-align: center;
  letter-spacing: 0.03em;
}
.frame-card:hover {
  border-color: var(--c-border-2);
  background: var(--c-bg-4);
}
.frame-card.is-active {
  border-color: var(--c-red-500);
  background: rgba(230,57,70,0.08);
  box-shadow: 0 0 0 1px rgba(230,57,70,0.38), 0 1px 12px rgba(230,57,70,0.15);
}
.frame-card.is-active .frame-card__label { color: var(--c-red-400); }

/* ── Controls footer ──────────────────────────────────── */

.controls-footer {
  padding: var(--sp-4) var(--panel-px);
  border-top: 1px solid var(--c-border-1);
  background: rgba(7,9,16,0.35);
  flex-shrink: 0;
}

/* ── Logo strip ───────────────────────────────────────── */

.logo-opts { display: flex; flex-direction: column; gap: var(--sp-4); }

.logo-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--c-bg-3);
  border: 1px solid var(--c-border-1);
  border-radius: var(--r-sm);
}

.logo-thumb {
  width: 44px; height: 44px;
  object-fit: contain;
  border-radius: var(--r-xs);
  background: var(--c-bg-4);
  flex-shrink: 0;
}

.logo-strip__info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-width: 0;
}

.logo-filename {
  font-size: var(--text-xs);
  color: var(--c-text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Preview panel ────────────────────────────────────── */

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--panel-px);
  border-bottom: 1px solid var(--c-border-1);
  background: var(--c-bg-3);
  flex-shrink: 0;
}

.preview-title {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-2);
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Download group ───────────────────────────────────── */

.download-group {
  position: relative;
  display: flex;
}

.download-group .btn--primary:first-child {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.download-group .btn--icon {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  border-left: 1px solid rgba(255,255,255,0.15);
  padding-left: 7px;
  padding-right: 7px;
}
.download-group .btn--icon svg { width: 10px; height: 6px; }

.fmt-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: var(--c-bg-3);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 50;
  animation: menu-in 0.15s ease;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.fmt-option {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  font-size: var(--text-sm);
  color: var(--c-text-1);
  transition: background var(--t-fast), color var(--t-fast);
}
.fmt-option strong {
  font-weight: 700;
  color: var(--c-text-0);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.fmt-option span { color: var(--c-text-2); font-size: var(--text-xs); }
.fmt-option:hover { background: var(--c-bg-4); color: var(--c-text-0); }
.fmt-option.is-active { background: rgba(37,99,235,0.1); }
.fmt-option.is-active strong { color: var(--c-blue-400); }
.fmt-option + .fmt-option { border-top: 1px solid var(--c-border-0); }

/* ── QR stage ─────────────────────────────────────────── */

.qr-stage {
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10);
  background-color: var(--c-bg-3);
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  border-bottom: 1px solid var(--c-border-1);
}

.qr-output {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-output svg {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  animation: qr-appear 0.28s var(--t-spring);
}

@keyframes qr-appear {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  text-align: center;
}
.qr-empty__art {
  width: 120px; height: 120px;
  opacity: 0.9;
}
.qr-empty__label {
  font-size: var(--text-sm);
  color: var(--c-text-2);
  max-width: 220px;
  line-height: 1.6;
}
.qr-empty__label strong { color: var(--c-text-1); }

.qr-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(19,26,40,0.7);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.qr-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--c-border-1);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  background: conic-gradient(from 0deg, #e63946, #7c3aed, #2563eb, transparent);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
}

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

/* ── Status bar ───────────────────────────────────────── */

.status-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--panel-px);
  font-size: var(--text-xs);
  color: var(--c-text-2);
  background: var(--c-bg-3);
  letter-spacing: 0.02em;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--c-text-2);
  flex-shrink: 0;
  transition: background var(--t-base), box-shadow var(--t-base);
}
.status-dot[data-state="generating"] {
  background: var(--c-warning);
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.status-dot[data-state="success"] {
  background: var(--c-success);
  box-shadow: 0 0 6px var(--c-success);
}
.status-dot[data-state="error"] {
  background: var(--c-error);
  box-shadow: 0 0 6px var(--c-error);
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
  }
