/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* ===== Header ===== */
header { background: #2c3e50; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; }
.logo { color: #fff; text-decoration: none; font-size: 1.2rem; font-weight: 600; }
.header-nav { display: flex; align-items: center; gap: 10px; }
.nav-btn { color: #ccc; text-decoration: none; font-size: 0.85rem; padding: 6px 14px; border-radius: 5px; transition: background 0.2s; }
.nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-btn-primary { background: #e74c3c; color: #fff; font-weight: 600; }
.nav-btn-primary:hover { background: #c0392b; }
.nav-email { font-size: 0.8rem; color: #aaa; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

/* ===== Footer ===== */
.site-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; margin-top: 48px;
  border-top: 1px solid #e8e8e8;
  font-size: 0.78rem; color: #aaa;
}
.footer-build { font-family: monospace; }

/* ===== Home Page ===== */

/* Hero */
.hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #fff;
  padding: 64px 32px 56px;
  text-align: center;
  margin: -24px -24px 40px;
}
.hero h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.02em; color: #fff; }
.hero p { font-size: 1.05rem; color: #a0b4cc; max-width: 480px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-btn { padding: 12px 28px; border-radius: 8px; font-size: 1rem; font-weight: 600; text-decoration: none; transition: opacity 0.2s; }
.hero-btn:hover { opacity: 0.85; }
.hero-btn-primary { background: #e74c3c; color: #fff; }
.hero-btn-secondary { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.25); }

/* How it works */
.how-strip { display: flex; gap: 0; margin-bottom: 48px; border: 1px solid #e8e8e8; border-radius: 10px; overflow: hidden; background: #fff; }
.how-step { flex: 1; padding: 20px 18px; text-align: center; border-right: 1px solid #eee; }
.how-step:last-child { border-right: none; }
.how-icon { font-size: 1.8rem; margin-bottom: 6px; }
.how-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.how-desc { font-size: 0.8rem; color: #777; }

/* Category rows */
.category-row { margin-bottom: 40px; }
.category-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.category-title { font-size: 1.15rem; font-weight: 700; color: #222; }
.category-count { font-size: 0.8rem; color: #999; }
.category-see-all { margin-left: auto; font-size: 0.82rem; color: #3498db; text-decoration: none; font-weight: 600; white-space: nowrap; }
.category-see-all:hover { text-decoration: underline; }

/* Horizontal scroll strip */
.card-strip {
  display: flex; gap: 14px;
  overflow-x: auto; padding-bottom: 10px;
  scrollbar-width: thin; scrollbar-color: #ccc transparent;
  scroll-snap-type: x mandatory;
}
.card-strip::-webkit-scrollbar { height: 4px; }
.card-strip::-webkit-scrollbar-track { background: transparent; }
.card-strip::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Card tile */
.card-tile {
  flex: 0 0 160px; text-decoration: none; color: inherit;
  scroll-snap-align: start; border-radius: 10px; overflow: hidden;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s; position: relative;
}
.card-tile:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 8px 24px rgba(0,0,0,0.16); z-index: 2; }
.card-tile-img { width: 160px; height: 200px; object-fit: cover; display: block; }
.card-tile-name { padding: 8px 10px 10px; font-size: 0.78rem; font-weight: 600; color: #333; line-height: 1.3; text-align: center; }
.card-tile-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 55%);
  opacity: 0; transition: opacity 0.2s;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 12px;
}
.card-tile:hover .card-tile-overlay { opacity: 1; }
.card-tile-overlay span { color: #fff; font-size: 0.8rem; font-weight: 700; background: #e74c3c; padding: 5px 14px; border-radius: 20px; }

.home-empty { text-align: center; padding: 60px 20px; color: #999; }

/* ===== Saved Cards Page ===== */
.saved-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.btn-browse {
  background: #3498db; color: #fff; text-decoration: none;
  padding: 9px 20px; border-radius: 6px; font-size: 0.9rem; font-weight: 600;
}
.btn-browse:hover { background: #2980b9; }

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.saved-tile {
  background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: box-shadow 0.2s;
}
.saved-tile:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.14); }
.saved-tile-img-wrap { display: block; position: relative; }
.saved-tile-img-wrap img { width: 100%; height: 220px; object-fit: cover; display: block; }
.saved-tile-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 50%);
  opacity: 0; transition: opacity 0.2s;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 12px;
}
.saved-tile-img-wrap:hover .saved-tile-overlay { opacity: 1; }
.saved-tile-overlay span { color: #fff; font-size: 0.85rem; font-weight: 700; background: #e74c3c; padding: 5px 16px; border-radius: 20px; }
.saved-tile-body { padding: 12px 14px; }
.saved-tile-name { font-weight: 600; font-size: 0.85rem; color: #222; margin-bottom: 4px; }
.saved-tile-date { font-size: 0.75rem; color: #999; margin-bottom: 10px; }
.saved-tile-actions { display: flex; gap: 8px; }
.btn-edit {
  flex: 1; text-align: center; background: #3498db; color: #fff;
  text-decoration: none; padding: 7px; border-radius: 5px;
  font-size: 0.82rem; font-weight: 600;
}
.btn-edit:hover { background: #2980b9; }
.btn-delete {
  flex: 1; background: #fef0f0; color: #e74c3c; border: 1px solid #fcc;
  padding: 7px; border-radius: 5px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.btn-delete:hover { background: #e74c3c; color: #fff; border-color: #e74c3c; }

.saved-empty { text-align: center; padding: 80px 20px; color: #777; }
.saved-empty h2 { font-size: 1.3rem; margin-bottom: 10px; color: #444; }
.saved-empty p { font-size: 0.9rem; }

/* ===== Card Page ===== */
.card-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.header-actions { display: flex; gap: 10px; }

.btn-save {
  background: #fff; color: #e74c3c; border: 2px solid #e74c3c;
  padding: 9px 20px; font-size: 1rem; font-weight: 600;
  border-radius: 6px; cursor: pointer; transition: all 0.2s;
}
.btn-save:hover { background: #e74c3c; color: #fff; }

.btn-pdf {
  background: #27ae60; color: #fff; border: none;
  padding: 10px 20px; font-size: 1rem; font-weight: 600;
  border-radius: 6px; cursor: pointer; transition: background 0.2s;
}
.btn-pdf:hover { background: #1e8449; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #2c3e50; color: #fff; padding: 12px 28px;
  border-radius: 8px; font-size: 0.95rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2); z-index: 9999;
}
.toast.hidden { display: none; }

.btn-print {
  background: #e74c3c; color: #fff; border: none;
  padding: 10px 24px; font-size: 1rem; font-weight: 600;
  border-radius: 6px; cursor: pointer; transition: background 0.2s;
}
.btn-print:hover { background: #c0392b; }

/* Workspace: panels + sidebar */
.card-workspace {
  display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap;
}

.panel { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; }

.panel-label {
  font-size: 0.85rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #666; margin-bottom: 8px;
}

/* Wrapper clips the scaled panel to correct display size */
.panel-inner-wrap {
  width: 360px; height: 460px;
  overflow: hidden; border: 2px solid #bbb; border-radius: 6px;
}

.panel-inner {
  width: 720px; height: 920px;
  background: #fffef8;
  transform: scale(0.5); transform-origin: top left;
}

.panel-inner img { display: block; width: 720px; height: 920px; object-fit: cover; }

/* Tools sidebar */
.tools-sidebar {
  flex: 0 0 200px;
  display: flex; flex-direction: column; gap: 0;
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  overflow: hidden; align-self: stretch;
}

.sidebar-section {
  padding: 12px; border-bottom: 1px solid #eee;
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-bottom { margin-top: auto; }

.sidebar-section-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #999; margin-bottom: 2px;
}

.btn-tool {
  background: #3498db; color: #fff; border: none;
  padding: 8px 14px; border-radius: 5px; cursor: pointer;
  font-size: 0.88rem; transition: background 0.2s;
}
.btn-tool:hover { background: #2980b9; }
.btn-tool.btn-block { width: 100%; text-align: left; }
.btn-tool.btn-danger { background: #e74c3c; }
.btn-tool.btn-danger:hover { background: #c0392b; }
.btn-tool.btn-reset { background: #e8a020; }
.btn-tool.btn-reset:hover { background: #c8841a; }

/* Sidebar text controls */
.sidebar-label {
  font-size: 0.8rem; color: #555;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-label select {
  font-size: 0.82rem; padding: 4px 6px;
  border: 1px solid #ccc; border-radius: 4px; width: 100%;
}
.size-row { display: flex; align-items: center; gap: 6px; }
.size-row input[type="range"] { flex: 1; }
#fcSizeVal { font-size: 0.75rem; color: #777; min-width: 20px; }

.bold-italic-row { display: flex; gap: 12px; }
.toggle-label {
  font-size: 0.82rem; color: #555;
  display: flex; align-items: center; gap: 4px; cursor: pointer;
}

/* Color swatches */
.color-row { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: #555; }
.color-label { white-space: nowrap; }
.color-swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch {
  display: inline-block; width: 22px; height: 22px;
  border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; flex-shrink: 0; transition: transform 0.1s, border-color 0.1s;
}
.swatch:hover { transform: scale(1.2); border-color: #333; }
.swatch.active { border-color: #333; transform: scale(1.15); }
.swatch[data-color="#ffffff"] { border-color: #ccc; }
.swatch-custom {
  background: conic-gradient(red, yellow, green, cyan, blue, magenta, red);
  border: 2px solid #aaa;
}
.swatch-preview {
  width: 28px; height: 28px; border-radius: 4px;
  border: 2px solid #aaa; flex-shrink: 0;
}

/* ===== Sticker Panel ===== */
.sticker-panel {
  position: fixed; right: 0; top: 60px;
  width: 270px; height: calc(100vh - 60px);
  background: #fff; border-left: 2px solid #ddd;
  display: flex; flex-direction: column;
  z-index: 100; box-shadow: -2px 0 8px rgba(0,0,0,0.1);
}
.sticker-panel.hidden { display: none; }

.sticker-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid #eee; font-weight: 600;
}
.sticker-panel-header button { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: #666; }

.sticker-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; padding: 12px; overflow-y: auto; flex: 1;
  justify-items: center;
}

.sticker-thumb {
  display: block;
  width: 72px;
  height: 72px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer; border-radius: 4px;
  border: 2px solid transparent; background-color: #f5f5f5;
  transition: border-color 0.15s;
}
.sticker-thumb:hover { border-color: #3498db; background-color: #e8f4fd; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff; border-radius: 10px; width: 480px; max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid #eee;
}
.modal-header h2 { font-size: 1.2rem; }
.modal-header button { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: #666; }

.modal-body { padding: 20px; }

.print-warning {
  background: #fff3cd; border: 1px solid #ffc107;
  border-radius: 6px; padding: 10px 14px;
  font-size: 0.85rem; color: #856404; margin-bottom: 18px;
}

.print-options { display: flex; flex-direction: column; gap: 12px; }
.print-option { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.print-option input[type="radio"] { margin-top: 4px; flex-shrink: 0; }

.option-card {
  border: 2px solid #ddd; border-radius: 6px; padding: 12px 14px; flex: 1;
  transition: border-color 0.15s;
}
.print-option input:checked + .option-card { border-color: #3498db; background: #f0f8ff; }
.option-card strong { display: block; margin-bottom: 4px; }
.option-card small { color: #666; font-size: 0.82rem; }

.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 20px; border-top: 1px solid #eee;
}

.btn-print-go {
  background: #e74c3c; color: #fff; border: none;
  padding: 10px 24px; border-radius: 6px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.btn-print-go:hover { background: #c0392b; }
.btn-cancel {
  background: #eee; color: #333; border: none;
  padding: 10px 20px; border-radius: 6px; font-size: 1rem; cursor: pointer;
}
.btn-cancel:hover { background: #ddd; }

/* ===== Print Area ===== */
/* Printing is handled in a popup window (print.js) — no @media print needed here */
#print-area { display: none; }

/* ===== Category Page ===== */
.category-page-header {
  display: flex; align-items: baseline; gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.category-page-header h1 { font-size: 1.6rem; font-weight: 800; color: #222; }
.back-link { font-size: 0.85rem; color: #3498db; text-decoration: none; white-space: nowrap; }
.back-link:hover { text-decoration: underline; }

/* Subcategory chips */
.subcat-chips {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px;
}
.chip {
  padding: 6px 16px; border-radius: 20px; font-size: 0.82rem; font-weight: 600;
  border: 2px solid #ddd; background: #fff; color: #555; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: #3498db; color: #3498db; }
.chip.active { background: #3498db; border-color: #3498db; color: #fff; }

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.card-thumb {
  text-decoration: none; color: inherit; border-radius: 10px; overflow: hidden;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column;
}
.card-thumb:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.16); }
.card-thumb img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; }
.card-thumb span { font-size: 0.78rem; color: #444; padding: 6px 8px; line-height: 1.3; }
.card-thumb.hidden { display: none; }

.no-results { text-align: center; padding: 60px 20px; color: #999; font-size: 1rem; }
.no-results.hidden { display: none; }
