/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Arial', sans-serif; }
body { background: #f5f5f5; color: #333; display: flex; flex-direction: column; min-height: 100vh; }
.app-container { display: flex; flex-direction: column; align-items: center; padding: 10px; }

/* Header */
.header-box { text-align: center; padding: 20px; }
.header-box h1 { font-size: 2rem; color: #4F46E5; }
.header-box p { color: #555; }

/* Postcard Card Layout */
.postcard-card { display: flex; max-width: 900px; width: 100%; background: #fff; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); overflow: hidden; margin: 20px 0; }
.canvas-container { flex: 2; display: flex; align-items: center; justify-content: center; padding: 10px; background: #111; border-radius: 12px 0 0 12px; position: relative; }
.side-panel { flex: 1; display: flex; flex-direction: column; padding: 10px; }

/* Canvas */
.canvas {
  width: 100%;
  height: 500px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #000;
}
.canvas img { width: 100%; height: 100%; object-fit: contain; opacity: 0; animation: fadeIn 0.5s forwards; }

/* Loader */
.loader { position: absolute; display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; }
.loader-icon { width: 50px; height: 50px; }

/* Controls */
.controls-panel { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.input-group { display: flex; gap: 5px; }
input { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid #ccc; font-size: 0.95rem; }
input::placeholder { color: #888; font-style: italic; }

/* Square buttons with hover text */
.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.square-btn {
  position: relative;
  width: 50px;
  height: 50px;
  background: #4F46E5;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.square-btn:hover { background: #3730A3; }
.square-btn:disabled { background: #888; cursor: not-allowed; }
.square-btn .btn-text {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.square-btn:hover .btn-text { opacity: 1; }

/* Dropdowns */
.custom-select { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #ccc; font-size: 0.95rem; background: white; cursor: pointer; transition: border 0.2s, box-shadow 0.2s; }
.custom-select:hover { border-color: #4F46E5; box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2); }
.custom-select:focus { outline: none; border-color: #4F46E5; box-shadow: 0 2px 12px rgba(79, 70, 229, 0.3); }

/* Gallery Panel */
.gallery-panel { flex: 1; overflow-y: auto; max-height: 220px; margin-top: 10px; }
#galleryContainer { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: auto; gap: 5px; }
#galleryContainer img { width: 100%; height: auto; aspect-ratio: 9/16; object-fit: cover; cursor: pointer; border-radius: 8px; opacity: 0; transition: transform 0.2s, opacity 0.5s; }
#galleryContainer img:hover { transform: scale(1.05); }

/* Animations */
@keyframes fadeIn { to { opacity: 1; } }

/* Footer */
footer { text-align: center; color: #888; font-size: 0.9rem; padding: 10px; }

/* Responsive */
@media(max-width:800px) {
  .postcard-card { flex-direction: column; }
  .canvas-container { height: 400px; margin-bottom: 10px; }
  .side-panel { max-height: 300px; }
}
