/* nosify — Clean Responsive Stylesheet */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-sky: #259fd8;
  --card-bg: rgba(13, 18, 26, 0.91);
  --card-border: rgba(255, 255, 255, 0.13);
  --surface-2: rgba(255, 255, 255, 0.055);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --emerald: #14c38e;
  --emerald-hover: #10b080;
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-border: rgba(248, 113, 113, 0.45);
  --radius-card: 22px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

html,
body {
  min-height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-sky);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Layered Blox Fruits Sky-Blue Ocean Wave Background */
.ocean-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #26a4de;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='160' viewBox='0 0 320 160'%3E%3Crect width='320' height='160' fill='%2328a7e0'/%3E%3Cpath d='M-40 24 Q 40 -6, 120 24 T 280 24 T 440 24 L 440 180 L -40 180 Z' fill='%231f96cf' stroke='%23167db3' stroke-width='2'/%3E%3Cpath d='M-40 58 Q 60 28, 160 58 T 360 58 L 360 180 L -40 180 Z' fill='%2332b2ea' stroke='%23167db3' stroke-width='2'/%3E%3Cpath d='M-40 94 Q 40 66, 120 94 T 280 94 T 440 94 L 440 180 L -40 180 Z' fill='%23229bd4' stroke='%23167db3' stroke-width='2'/%3E%3Cpath d='M-40 130 Q 60 100, 160 130 T 360 130 L 360 180 L -40 180 Z' fill='%232caae2' stroke='%23167db3' stroke-width='2'/%3E%3C/svg%3E");
  background-size: 320px 160px;
}

/* Main Page Wrapper */
.page-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* Floating Dark Dot-Grid Card */
.app-card {
  width: 100%;
  max-width: 1020px;
  background-color: var(--card-bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.065) 1px, transparent 1px);
  background-size: 16px 16px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 60px rgba(6, 16, 28, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 24px 24px 14px;
}

/* Responsive 2-Column PC / 1-Column Mobile Layout */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 880px) {
  .page-wrap {
    padding: 36px 24px;
  }

  .app-card {
    padding: 28px 28px 16px;
  }

  .layout-grid {
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 1.12fr);
    gap: 28px;
  }

  .preview-sticky {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
}

.preview-column,
.controls-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Live Preview Banner Stage (Strictly Protected Against Long-Press / Saving) */
.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 216;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background-color: #161d29;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.preview-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: background-image 0.18s ease;
}

.preview-tint {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.preview-text-wrap {
  position: relative;
  z-index: 2;
  height: 100%;
  width: 100%;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  font-family: "Montserrat", "Inter", sans-serif;
  font-weight: 800;
  line-height: 1.28;
  /* Proportional preview font size scaled by slider */
  --preview-scale: 1;
  font-size: calc(clamp(10.5px, 2.55vw, 15px) * var(--preview-scale));
}

@media (min-width: 880px) {
  .preview-text-wrap {
    font-size: calc(13.5px * var(--preview-scale));
  }
}

.preview-line-1,
.preview-line-2 {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    -1.2px -1.2px 0 #0b0f17,
     1.2px -1.2px 0 #0b0f17,
    -1.2px  1.2px 0 #0b0f17,
     1.2px  1.2px 0 #0b0f17,
     0px    1.8px 3px rgba(0, 0, 0, 0.85);
}

.txt-white {
  color: #ffffff;
}

.txt-item {
  color: #f4c430;
  transition: color 0.15s ease;
}

.preview-line-2 {
  color: #5ce65c;
  margin-top: 2px;
}

/* Transparent Anti-Save Shield Over Preview & Thumbnails */
.anti-save-shield {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Custom Error Alert */
.custom-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #fecaca;
  font-size: 13px;
  line-height: 1.4;
  animation: fadeSlideIn 0.2s ease;
}

.custom-error[hidden] {
  display: none !important;
}

.custom-error-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #180808;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-error-text {
  flex: 1;
  min-width: 0;
}

.custom-error-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #fca5a5;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.custom-error-close:hover {
  color: #ffffff;
}

/* Form Groups & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.char-hint,
.size-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
}

.text-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.text-input::placeholder {
  color: #64748b;
}

.text-input:focus {
  border-color: var(--emerald);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(20, 195, 142, 0.16);
}

.form-group.has-error .text-input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
  animation: gentleShake 0.28s ease;
}

/* Custom Dropdown Component */
.custom-dropdown {
  position: relative;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.dropdown-trigger:hover,
.dropdown-trigger[aria-expanded="true"] {
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--surface-hover);
  color: #ffffff;
}

.dropdown-chevron {
  transition: transform 0.16s ease;
}

.dropdown-trigger[aria-expanded="true"] .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 185px;
  max-width: 240px;
  list-style: none;
  padding: 5px;
  border-radius: 12px;
  background: #121824;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}

.dropdown-menu[hidden] {
  display: none !important;
}

.dropdown-menu-scroll {
  max-height: 210px;
  overflow-y: auto;
}

.dropdown-item {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.dropdown-item.is-active {
  background: rgba(20, 195, 142, 0.16);
  color: #6ee7b7;
  font-weight: 600;
}

/* 17-Background Thumbnail Grid (Clean, Compact, Protected) */
.bg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 236px;
  overflow-y: auto;
  padding-right: 2px;
}

@media (min-width: 520px) {
  .bg-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.bg-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.bg-card:hover {
  border-color: rgba(255, 255, 255, 0.32);
}

.bg-card.is-selected {
  border: 2px solid var(--emerald);
  box-shadow: 0 0 0 1px rgba(20, 195, 142, 0.35);
}

.bg-thumb-box {
  width: 100%;
  aspect-ratio: 16 / 7.5;
  background-size: cover;
  background-position: center;
  background-color: #1e2636;
  pointer-events: none;
}

.bg-card-label {
  padding: 4px 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(10, 14, 21, 0.85);
  pointer-events: none;
}

.bg-card.is-selected .bg-card-label {
  color: #ffffff;
}

/* Style Row: 5 Color Swatches + Text Size Slider */
.style-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 500px) {
  .style-row {
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
  }
}

.swatch-list {
  display: flex;
  align-items: center;
  gap: 10px;
}

.swatch-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  outline: none;
}

.swatch-btn:hover {
  transform: scale(1.07);
}

.swatch-btn.is-selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

/* Custom Emerald Range Slider */
.slider-wrap {
  height: 32px;
  display: flex;
  align-items: center;
}

.emerald-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

.emerald-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--emerald);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.emerald-slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

.emerald-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--emerald);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

/* Custom Emerald Checkbox */
.custom-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 2px 0;
}

.sr-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-box {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.26);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.checkbox-box svg {
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.sr-checkbox:checked + .checkbox-box {
  background: var(--emerald);
  border-color: var(--emerald);
}

.sr-checkbox:checked + .checkbox-box svg {
  opacity: 1;
  transform: scale(1);
}

.checkbox-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Primary Emerald Download CTA Button */
.download-btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--emerald);
  color: #061810;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 22px rgba(20, 195, 142, 0.28);
  transition: background-color 0.16s ease, transform 0.12s ease, opacity 0.16s ease;
}

.download-btn:hover:not(:disabled) {
  background: var(--emerald-hover);
  transform: translateY(-1px);
}

.download-btn:active:not(:disabled) {
  transform: translateY(0);
}

.download-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2.2px solid rgba(6, 24, 16, 0.25);
  border-top-color: #061810;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.download-btn.is-loading .btn-spinner {
  display: inline-block;
}

/* Show desktop button on PC, mobile button on phones */
.desktop-only-btn {
  display: none;
}

.mobile-only-btn {
  display: inline-flex;
  margin-top: 2px;
}

@media (min-width: 880px) {
  .desktop-only-btn {
    display: inline-flex;
  }

  .mobile-only-btn {
    display: none;
  }
}

/* Subtle Footer Watermark */
.card-footer {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: flex-end;
}

.nosify-watermark {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.28);
  user-select: none;
}

/* Custom Subtle Scrollbars */
.bg-grid::-webkit-scrollbar,
.dropdown-menu-scroll::-webkit-scrollbar {
  width: 5px;
}

.bg-grid::-webkit-scrollbar-thumb,
.dropdown-menu-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

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

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

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
