/* Tile — compact embedded layout */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  color: #f5f5f5;
  overflow: hidden;
}

.app-root {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  overflow: hidden;
}

.app-root::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app-header {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 12, 41, 0.7);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.25px;
}

.app-header p {
  margin: 2px 0 0;
  color: #a0aec0;
  font-size: 0.7rem;
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 8px 10px;
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.upload-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card {
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: 10px;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow:
      0 15px 40px rgba(0, 0, 0, 0.4),
      0 2px 4px rgba(0, 0, 0, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}

.upload-card h2 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #e5e7eb;
}

.upload-card > p {
  margin: 0 0 6px;
  color: #9ca3af;
  font-size: 0.68rem;
  line-height: 1.3;
}

.preview-frame {
  width: 100%;
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(99, 102, 241, 0.25);
  background: #111827;
  margin-bottom: 8px;
}

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

.primary-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.primary-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.primary-btn:hover::before {
  left: 100%;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
  padding: 8px;
  background: rgba(107, 114, 128, 0.1);
  border-radius: 8px;
  border: 1px dashed rgba(107, 114, 128, 0.3);
}

.loader-wrapper {
  margin-top: 8px;
  padding: 8px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loader-wrapper.is-visible {
  display: flex;
}

.loader-wrapper p {
  margin: 0;
  color: #e5e7eb;
  font-size: 0.72rem;
  text-align: center;
}

.loader-detail {
  margin: 0 !important;
  font-size: 0.68rem !important;
  color: #9ca3af !important;
  max-width: 100%;
  word-break: break-word;
}

.loader-detail:not([hidden]) {
  display: block !important;
}

.spinner {
  width: 28px;
  height: 28px;
  position: relative;
  animation: rotate3d 2s linear infinite;
}

.spinner::before,
.spinner::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
}

.spinner::before {
  border-top-color: #667eea;
  border-right-color: #667eea;
  animation: spin 1s linear infinite;
}

.spinner::after {
  border-bottom-color: #764ba2;
  border-left-color: #764ba2;
  animation: spin 1s linear infinite reverse;
}

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

@keyframes rotate3d {
  0% {
    transform: rotate3d(0, 0, 1, 0deg);
  }
  25% {
    transform: rotate3d(0, 1, 0, 180deg);
  }
  50% {
    transform: rotate3d(1, 0, 0, 180deg);
  }
  75% {
    transform: rotate3d(0, 1, 0, 360deg);
  }
  100% {
    transform: rotate3d(0, 0, 1, 360deg);
  }
}

.viewer-card {
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  min-height: 0;
}

.viewer-card.is-visible {
  display: flex;
}

.viewer-card h2 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewer-card h2::before {
  content: "🎨";
  font-size: 0.92rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.viewer-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid rgba(99, 102, 241, 0.2);
  position: relative;
  transition: all 0.3s ease;
}

.viewer-canvas:hover {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
}

.viewer-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.placeholder-card {
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 0;
  background: rgba(17, 24, 39, 0.5);
  border: 2px dashed rgba(99, 102, 241, 0.3);
  position: relative;
  overflow: hidden;
  display: flex;
  flex: 1 1 auto;
}

.placeholder-card.is-hidden {
  display: none !important;
}

.placeholder-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

.placeholder-card p {
  position: relative;
  z-index: 1;
  color: #9ca3af;
  font-size: 0.78rem;
  margin: 0;
}

.app-footer {
  padding: 6px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.65rem;
  color: #6b7280;
  text-align: right;
  background: rgba(15, 12, 41, 0.5);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .spinner::before,
  .spinner::after,
  .placeholder-card::before,
  .viewer-card h2::before {
    animation: none !important;
  }

  .card,
  .primary-btn,
  .viewer-canvas {
    transition: none !important;
  }
}

.app-root,
.app-main,
.left-panel,
.right-panel,
.upload-card,
.viewer-card,
.placeholder-card {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-root::-webkit-scrollbar,
.app-main::-webkit-scrollbar,
.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
.upload-card::-webkit-scrollbar,
.viewer-card::-webkit-scrollbar,
.placeholder-card::-webkit-scrollbar {
  display: none;
}
