/* PhotoStrip — Clean Light Mobile-First Design */

/* Custom Font Definition for Mobile Support */
@font-face {
  font-family: 'Oks Free';
  src: url('OksFree.ttf') format('truetype'),
    url('OksFree.woff2') format('woff2'),
    url('OksFree.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}

:root {
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-light: rgba(79, 70, 229, 0.08);
  --danger: #ef4444;
  --success: #16a34a;
  --radius: 4px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-bar: 0 -2px 12px rgba(0, 0, 0, 0.08);
  --transition: all 0.18s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* App Shell */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* Page Scroll */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* App Header */
.app-header {
  padding: 16px 16px 4px;
  text-align: center;
}

.header-title {
  font-family: 'Oks Free', 'Montserrat', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #4f46de;
  margin: 0;
}

/* Preview Section */
.preview-section {
  padding: 12px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  position: relative;
}

.preview-frame {
  background: #d1d5db;
  border-radius: var(--radius);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 240px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  margin: 0 auto;
}

.strip-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  transition: background-color 0.2s;
  border-radius: 2px;
  overflow: hidden;
}

.preview-hint {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.preview-hint i {
  color: var(--primary);
  margin-right: 4px;
}

/* Strip Slot */
.strip-slot {
  position: relative;
  overflow: hidden;
  background: #e5e7eb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  transition: outline 0.15s;
}

.strip-slot.selected {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
  z-index: 5;
}

.strip-slot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #9ca3af;
  pointer-events: none;
}

.strip-slot-empty i {
  font-size: 1.3rem;
}

.strip-slot-empty span {
  font-size: 0.7rem;
}

.slot-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

/* Bottom Text Area */
.strip-bottom-text {
  text-align: center;
  font-weight: 600;
  word-break: break-all;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  max-height: 100%;
}

/* Side Left Toolbar (Layout Count & Background Color) */
.bg-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 14px 6px;
  box-shadow: var(--shadow-card);
  position: absolute;
  right: calc(50% + 128px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
}

.bar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  width: 100%;
}

.bar-divider {
  width: 80%;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.bar-layout-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.bar-layout-options .layout-option {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.bar-layout-options .layout-option:hover {
  border-color: var(--primary);
}

.bar-layout-options .layout-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.bar-layout-options .layout-icon {
  width: 11px;
  height: 43px;
  aspect-ratio: 612 / 2373;
  border: 1px solid #9ca3af;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 1px;
  box-sizing: border-box;
  background: var(--card-bg);
}

.bar-layout-options .layout-icon span {
  flex: 1;
  background: #d1d5db;
  border-radius: 0.5px;
}

.bar-layout-options .layout-option.active .layout-icon {
  border-color: var(--primary);
}

.bar-layout-options .layout-option.active .layout-icon span {
  background: var(--primary);
}

.bg-bar-swatches {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.bg-bar-swatches .color-swatch {
  width: 26px;
  height: 26px;
}

/* Floating side toolbar positioned absolutely to the right of centered frame */
.slot-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  position: absolute;
  left: calc(50% + 128px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
}

.slot-bar.active {
  opacity: 1;
  pointer-events: auto;
}

.slot-bar-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.slot-bar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-bar-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.slot-bar-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.slot-bar-btn:active {
  transform: scale(0.94);
}

.slot-bar-btn.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.slot-bar-btn.danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--danger);
}

@media (max-width: 400px) {
  .preview-frame {
    max-width: 200px;
  }

  .slot-bar {
    left: calc(50% + 108px);
  }

  .bg-bar {
    right: calc(50% + 108px);
  }
}

/* Cards */
.controls-section {
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.card-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* Layout Grid */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.layout-option {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.layout-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.layout-option p {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.layout-option.active p {
  color: var(--primary);
}

.layout-icon {
  width: 22px;
  height: 46px;
  border: 2px solid #9ca3af;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px;
}

.layout-option.active .layout-icon {
  border-color: var(--primary);
}

.layout-icon span {
  display: block;
  flex: 1;
  background: #9ca3af;
  border-radius: 1px;
}

.layout-option.active .layout-icon span {
  background: var(--primary);
}

/* Color Row */
.color-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.color-swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.custom-picker {
  background: linear-gradient(135deg, #ff6b6b, #a855f7, #3b82f6) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.custom-picker input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.custom-picker i {
  font-size: 0.7rem;
  color: #fff;
  pointer-events: none;
}

/* Toggle Switch */
.card-toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #d1d5db;
  border-radius: 24px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

/* Text Controls */
.text-controls {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.text-controls.hidden {
  display: none;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
}

.text-options-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.font-select {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
}

.color-input-small {
  -webkit-appearance: none;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-save:active {
  transform: scale(0.98);
}

.btn-finish {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--card-bg);
  color: var(--success);
  border: 2px solid var(--success);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-finish:active {
  background: rgba(22, 163, 74, 0.06);
}

/* Reset Button */
.btn-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-reset:active {
  background: rgba(239, 68, 68, 0.05);
}

/* Footer */
.app-footer {
  padding: 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* Saved Badge */
.saved-badge {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  background: var(--success);
  color: #fff;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
  animation: badgePop 0.3s ease;
}

@keyframes badgePop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-x {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
}

.modal-need-more {
  text-align: center;
  padding: 8px 0;
}

.modal-need-more .big-count {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.modal-need-more p {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-need-more .need-num {
  color: var(--primary);
  font-weight: 700;
}

.modal-strips-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.modal-strip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.modal-strip-thumb {
  width: 30px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.modal-strip-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.modal-strip-del {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px;
}

.modal-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-download-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.btn-download-all:active {
  transform: scale(0.97);
}

/* Desktop */
@media (min-width: 768px) {
  .app-shell {
    max-width: 500px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-height: 100vh;
  }
}