/* --- Wall --- */
#wall {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.cell {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  opacity: 0;
  transform: translateY(12px);
  animation: cellIn 0.35s ease forwards;
}

@keyframes cellIn {
  to { opacity: 1; transform: translateY(0); }
}

.cell:hover {
  border-color: transparent;
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.cell img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.meta {
  padding: 14px 16px;
}

.meta .nm {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meta .an {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  line-height: 1.4;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.t-rec { background: var(--success-bg); color: var(--success); }
.t-mid { background: var(--warning-bg); color: var(--warning); }
.t-no  { background: var(--error-bg); color: var(--error); }
.t-orig { background: #f0f0f0; color: var(--text-secondary); }

.cell-orig { border: 2px solid var(--border); cursor: default; opacity: 0.85; }
.cell-orig:hover { transform: none; box-shadow: none; border-color: var(--border); }

/* --- Editor --- */
#editor {
  display: none;
  gap: 40px;
  align-items: flex-start;
}

#editor.on {
  display: grid;
  grid-template-columns: 1fr 300px;
}

#preview {
  position: sticky;
  top: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

#preview img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.render-spinner {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 8px 14px;
  gap: 5px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.render-spinner.on { display: flex; }

.render-spinner span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

.render-spinner span:nth-child(2) { animation-delay: 0.15s; }
.render-spinner span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

#panel { background: var(--bg-secondary); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); }

.panel-h {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.panel-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.row { margin: 16px 0; }

.row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.row label span:last-child {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-sm);
}

input[type=range]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-sm);
}

/* --- Confirm Upload --- */
#confirmUpload {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  z-index: 998;
  display: none;
  align-items: center;
  justify-content: center;
}

.confirm-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.confirm-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.confirm-close::before {
  content: '';
  width: 16px;
  height: 16px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E") center/contain no-repeat;
}

.confirm-close:hover {
  background: var(--accent-light);
  color: var(--text-primary);
  box-shadow: none;
  transform: scale(1.1);
}

.confirm-close:active {
  transform: scale(0.92);
}

.confirm-card img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 16px;
}

.confirm-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
}

.confirm-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions button {
  flex: 1;
}

/* --- Loading --- */
#loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 56px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  animation: loadingIn 0.3s ease;
}

@keyframes loadingIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.loading-brand {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
  animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

.loading-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 2px;
  animation: loadingSlide 1.8s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(400%); width: 30%; }
}

.loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.loading-step {
  font-size: 12px;
  color: var(--text-tertiary);
  min-height: 16px;
  transition: opacity 0.2s;
}

.loading-name { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-primary); }

.loading-copyright { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* --- GitHub pill --- */
.github-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  transition: all 0.2s ease;
}

.github-pill:hover {
  color: var(--text-primary);
  border-color: var(--text-tertiary);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.github-pill svg {
  flex-shrink: 0;
}

/* --- Footer --- */
footer {
  padding: 28px max(40px, calc((100% - 1250px) / 2));
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-logo {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-size: 9px;
  font-weight: 700;
}

.footer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.footer-meta {
  text-align: right;
}

.footer-tagline {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.footer-sep {
  opacity: 0.4;
}

.footer-privacy {
  opacity: 0.8;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  header { padding: 16px 20px; }
  #landing { padding: 40px 20px 32px; }
  .landing-headline h2 { font-size: 24px; }
  .upload-zone { padding: 36px 20px; }
  .features { grid-template-columns: 1fr; gap: 12px; margin-top: 40px; }
  #status { padding: 10px 20px; }
  #stage { padding: 20px; }
  #wall { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  #editor.on { grid-template-columns: 1fr; }
  #panel { margin-top: 20px; }
  #preview { position: static; }
  footer { padding: 20px; }
  .footer-inner { flex-direction: column; gap: 12px; text-align: center; }
  .footer-meta { text-align: center; }
  .footer-bottom { justify-content: center; }
}
