:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #0f172a;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  display: grid;
  place-items: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.header-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #94a3b8;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-header .btn-ghost {
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.2);
}

.app-header .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Layout */
.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.badge-neutral {
  background: #e2e8f0;
  color: #334155;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  user-select: none;
}

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

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 0.72rem 1.15rem;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-secondary:hover:not(:disabled) {
  background: #1e293b;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger-outline:hover:not(:disabled) {
  background: #fef2f2;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: #94a3b8;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-light);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--text);
}

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  grid-column: 1 / -1;
  font-weight: 500;
  color: var(--text);
}

/* SKU Section */
.sku-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.sku-input-group {
  flex: 1 1 420px;
}

.sku-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.sku-counter {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--surface-muted);
  border: 1px solid var(--border-light);
}

.sku-counter.valid {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.sku-input-wrap {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#skuInput {
  flex: 1 1 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#skuInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#skuInput.is-valid {
  border-color: var(--success);
  background: #f0fdf4;
}

.sku-feedback {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
}

.sku-feedback.valid {
  color: var(--success);
  font-weight: 600;
}

.sku-feedback.invalid {
  color: var(--text-muted);
}

.sku-folder-preview {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 190px;
}

.meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.folder-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  font-weight: 700;
  background: #0f172a;
  color: #38bdf8;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  display: inline-block;
}

.pending-queue {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.queue-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  cursor: pointer;
}

.queue-chip.active {
  background: #dbeafe;
  border-color: var(--primary);
  color: #1e40af;
  font-weight: 700;
}

.queue-chip-count {
  font-family: sans-serif;
  font-size: 0.7rem;
  background: #e2e8f0;
  color: #334155;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
}

/* Lock state */
.lock-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 1rem;
  align-items: start;
}

.workspace-grid.is-locked {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.25);
}

@media (max-width: 960px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Mode tabs */
.mode-tabs {
  display: inline-flex;
  background: var(--surface-muted);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 0.2rem;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 0.38rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Marketplace tips */
.marketplace-tips {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem 0.65rem 1.75rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #0c4a6e;
}

.marketplace-tips li + li {
  margin-top: 0.2rem;
}

/* Camera stage */
.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 460px;
  background: #0b1120;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

#cameraPreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.framing-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  padding: 10%;
}

.safe-zone {
  position: relative;
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.25);
}

.safe-zone-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.7);
  color: #f8fafc;
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.crosshair-h,
.crosshair-v {
  position: absolute;
  background: rgba(56, 189, 248, 0.55);
}

.crosshair-h {
  width: 24px;
  height: 2px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.crosshair-v {
  width: 2px;
  height: 24px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.recording-indicator {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(15, 23, 42, 0.86);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  gap: 0.85rem;
}

.camera-placeholder p {
  margin: 0;
  max-width: 340px;
  font-size: 0.9rem;
}

.capture-controls {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.live-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.live-controls .btn-lg {
  flex: 1 1 210px;
}

.native-fallbacks {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.fallback-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  font-weight: 600;
}

.fallback-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Media organization */
.section-subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.section-subhead h3 {
  margin: 0;
  font-size: 0.92rem;
}

.hint-text,
.muted-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.small-note {
  margin: 0.45rem 0 0;
}

.video-slot-section,
.photos-section,
.export-section {
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-light);
  margin-top: 0.85rem;
}

.video-slot-section {
  padding-top: 0;
  border-top: none;
  margin-top: 0;
}

.video-empty,
.photos-empty {
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.video-filled {
  background: var(--surface-muted);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.65rem;
}

#videoReviewPlayer {
  width: 100%;
  max-height: 220px;
  border-radius: 8px;
  background: #000;
  display: block;
}

.video-meta-row {
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.video-actions {
  display: flex;
  gap: 0.4rem;
}

/* Photos grid */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 0.65rem;
}

.photo-item {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
}

.photo-item.is-main {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.photo-thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fff;
  cursor: zoom-in;
}

.photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-number-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(15, 23, 42, 0.86);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.photo-item.is-main .photo-number-badge {
  background: var(--primary);
}

.photo-card-body {
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.photo-filename {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  word-break: break-all;
}

.photo-dims {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.photo-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
}

.icon-btn {
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 0.28rem 0;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  background: #e2e8f0;
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn.danger {
  color: var(--danger);
}

/* Export */
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.export-actions .btn-lg {
  flex: 1 1 180px;
}

/* Modal */
.photo-modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: min(92vw, 680px);
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.photo-modal::backdrop {
  background: rgba(15, 23, 42, 0.72);
}

.modal-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-image-wrap {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.modal-image-wrap img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(90vw, 360px);
}

.toast {
  background: #0f172a;
  color: #f8fafc;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border-left: 4px solid #38bdf8;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}
