* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
}
.studio {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.header-right {
  display: flex;
  justify-content: flex-end;
  margin-left: auto;
  margin-right: 15px;
}
.logo {
  display: flex;
  align-items: center;
}
.site-title {
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
}
.header-actions {
  display: flex;
  gap: 8px;
}
.btn-use-image {
  background: #10b981;
  color: #fff;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-use-image:hover {
  background: #059669;
}
.btn-use-image:disabled {
  background: #6ee7b7;
  cursor: not-allowed;
}
.btn-use-image.hidden {
  display: none;
}
.btn-use-image svg {
  width: 16px;
  height: 16px;
}
.btn-designer {
  background: #2563eb;
  color: #fff;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-designer:hover {
  background: #1d4ed8;
}
.btn-designer:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}
.btn-designer.hidden {
  display: none;
}
.btn-designer svg {
  width: 20px;
  height: 20px;
}
.btn-designer.warning {
  background: #f59e0b;
}
.btn-designer.warning:hover {
  background: #d97706;
}

/* Main Content */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Preview Area - Center */
.preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  min-width: 0;
}
.preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  margin: 16px;
  border-radius: 12px;
  /* 限制最大高度，确保图片在可视区域内完整显示 */
  max-height: calc(100vh - 250px);
  min-height: 300px;
  overflow: hidden;
}
.preview-container.checkerboard {
  background-image:
    linear-gradient(45deg, #e8e8e8 25%, transparent 25%),
    linear-gradient(-45deg, #e8e8e8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e8e8 75%),
    linear-gradient(-45deg, transparent 75%, #e8e8e8 75%);
  background-size: 20px 20px;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
}
.preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #9ca3af;
  text-align: center;
}
.preview-empty svg {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.preview-empty p {
  font-size: 14px;
  margin-bottom: 4px;
}
.preview-empty small {
  font-size: 12px;
  opacity: 0.7;
}
.preview-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  /* 确保图片在容器内居中显示，不会超出可视区域 */
  display: block;
  margin: auto;
}
.preview-image.hidden {
  display: none;
}

/* Info Bar */
.info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 0 16px 16px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 12px;
  color: #6b7280;
  flex-wrap: wrap;
}
.info-bar.hidden {
  display: none;
}
.info-bar .filename {
  font-weight: 500;
  color: #374151;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info-bar .dimensions {
  color: #374151;
}
.info-bar .dpi {
  font-weight: 500;
}
.info-bar .dpi.good {
  color: #10b981;
}
.info-bar .dpi.warning {
  color: #f59e0b;
}
.info-bar .dpi.bad {
  color: #ef4444;
}
.info-bar .result {
  color: #10b981;
  margin-left: auto;
}
.info-bar .result.error {
  color: #ef4444;
}

/* POD Assessment */
.pod-assessment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 16px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}
.pod-assessment.hidden {
  display: none;
}
.pod-assessment.excellent {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}
.pod-assessment.good {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}
.pod-assessment.warning {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.pod-assessment.poor {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.pod-assessment svg {
  width: 16px;
  height: 16px;
}
.pod-assessment .label {
  flex: 1;
}
.pod-assessment .action {
  font-size: 11px;
  opacity: 0.8;
}

/* Sidebar - Left (Favorites) */
.sidebar-left {
  width: 240px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e7eb;
  background: #fff;
  overflow-y: auto;
}

/* Sidebar - Right (Tools) */
.sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e5e7eb;
  background: #fff;
  overflow-y: auto;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.sidebar-section:last-child {
  border-bottom: none;
}
.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Upload Section */
.upload-dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: #fafafa;
}
.upload-dropzone:hover,
.upload-dropzone.dragging {
  border-color: #2563eb;
  background: #eff6ff;
}
.upload-dropzone svg {
  width: 32px;
  height: 32px;
  margin: 0 auto 8px;
  color: #9ca3af;
}
.upload-dropzone p {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 4px;
}
.upload-dropzone strong {
  color: #2563eb;
}
.upload-dropzone small {
  font-size: 11px;
  color: #9ca3af;
}

.url-section {
  margin-top: 12px;
}
.url-row {
  display: flex;
  gap: 6px;
}
.url-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.url-input:focus {
  border-color: #2563eb;
}
.url-input::placeholder {
  color: #9ca3af;
}

/* AI Tools */
.tool-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  margin-bottom: 8px;
}
.tool-btn:last-child {
  margin-bottom: 0;
}
.tool-btn:hover:not(:disabled) {
  border-color: #2563eb;
  color: #2563eb;
}
.tool-btn.active {
  border-color: #2563eb;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.05);
}
.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tool-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.undo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid #ef4444;
  border-radius: 6px;
  font-size: 12px;
  color: #ef4444;
  cursor: pointer;
  margin-top: 12px;
}
.undo-btn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.05);
}
.undo-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.undo-btn.hidden {
  display: none;
}

/* Tags */
.tags-section {
  margin-top: 12px;
}
.tags-section.hidden {
  display: none;
}
.tags-title {
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 8px;
}
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag {
  padding: 3px 8px;
  background: #e5e7eb;
  border-radius: 4px;
  font-size: 11px;
  color: #4b5563;
}

/* Favorites Section (Left Sidebar) */
.favorites-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.favorites-count {
  font-size: 11px;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 10px;
}
.favorites-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
}
.favorites-item {
  aspect-ratio: 1;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.15s;
  background: #f9fafb;
}
.favorites-item:hover {
  border-color: #d1d5db;
  transform: scale(1.02);
}
.favorites-item.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.favorites-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.favorites-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 12px;
}
.favorites-empty svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.5;
}
.favorites-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: 8px;
}
.favorites-more button {
  padding: 6px 12px;
  background: #f3f4f6;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  color: #6b7280;
  cursor: pointer;
}
.favorites-more button:hover {
  background: #e5e7eb;
}

/* Options */
.option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}
.option:last-child {
  margin-bottom: 0;
}
.option input {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}
.option-label {
  font-size: 12px;
  color: #374151;
}

/* Upload Queue */
.queue {
  margin-top: 12px;
}
.queue.hidden {
  display: none;
}
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.queue-header .sidebar-title {
  margin-bottom: 0;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
  margin-bottom: 6px;
}
.queue-item:last-child {
  margin-bottom: 0;
}
.queue-preview {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: #e5e7eb;
}
.queue-info {
  flex: 1;
  min-width: 0;
}
.queue-name {
  font-size: 12px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.queue-progress {
  flex: 1;
  height: 3px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}
.queue-progress-bar {
  height: 100%;
  background: #2563eb;
  transition: width 0.2s;
}
.queue-clear-btn {
  padding: 2px 6px;
  font-size: 10px;
  background: #f3f4f6;
  border: none;
  border-radius: 4px;
  color: #6b7280;
  cursor: pointer;
}
.queue-clear-btn:hover {
  background: #e5e7eb;
}
.queue-status {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 8px;
}
.queue-status.uploading {
  color: #2563eb;
  background: #eff6ff;
}
.queue-status.success {
  color: #10b981;
  background: #ecfdf5;
}
.queue-status.error {
  color: #ef4444;
  background: #fef2f2;
}
.queue-status.pending {
  color: #9ca3af;
  background: #f3f4f6;
}

/* Processing Overlay */
.processing {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  z-index: 10;
}
.processing.active {
  display: flex;
}
.spinner {
  width: 36px;
  height: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg transform='rotate(90 50 50)'%3E%3Cpath d='M12.6 52.6 L50 90 L90 50 L52.6 12.6' fill='none' stroke='%239ca3af' stroke-width='1' stroke-linecap='butt' stroke-linejoin='miter'/%3E%3Cline x1='10' y1='50' x2='50' y2='10' stroke='%23dc2626' stroke-width='1' stroke-linecap='butt'/%3E%3Cline x1='11.14' y1='51.14' x2='51.14' y2='11.14' stroke='%23dc2626' stroke-width='1' stroke-linecap='butt'/%3E%3Cline x1='12.29' y1='52.29' x2='52.29' y2='12.29' stroke='%23dc2626' stroke-width='1' stroke-linecap='butt'/%3E%3Cline x1='9.62' y1='49.62' x2='12.67' y2='52.67' stroke='%23dc2626' stroke-width='1' stroke-linecap='butt'/%3E%3Cline x1='49.62' y1='9.62' x2='52.67' y2='12.67' stroke='%23dc2626' stroke-width='1' stroke-linecap='butt'/%3E%3C/g%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: spin 3s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.processing p {
  font-size: 13px;
  color: #6b7280;
}

/* Buttons */
.btn {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover {
  background: #1d4ed8;
}
.btn-primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}
.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}
.btn-secondary:hover {
  background: #e5e7eb;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.btn-icon {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 20px;
  background: #1f2937;
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100000;
  opacity: 0;
  transition:
    transform 0.3s,
    opacity 0.3s;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success {
  background: #10b981;
}
.toast.error {
  background: #ef4444;
}

/* Smart Segment Overlay */
.segment-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 10;
  pointer-events: none;
}

.segment-overlay canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  pointer-events: auto;
}

.segment-instructions {
  position: relative;
  z-index: 11;
  background: white;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-align: center;
  margin-top: 20px;
  pointer-events: auto;
}

.segment-instructions p {
  margin-bottom: 4px;
  color: #1f2937;
  font-size: 14px;
}

.segment-instructions small {
  color: #6b7280;
  font-size: 12px;
  display: block;
  margin-bottom: 8px;
}

.segment-instructions > div {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.hidden {
  display: none !important;
}
.file-input {
  display: none;
}

/* 滚动条样式 - 类似 designer */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* 左侧收藏栏隐藏滚动条 */
.sidebar-left {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}
.sidebar-left::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* 收藏网格也隐藏滚动条 */
.favorites-grid {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.favorites-grid::-webkit-scrollbar {
  display: none;
}

/* Auth UI */
.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-email {
  font-size: 12px;
  color: #6b7280;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Login Modal */
.login-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-modal.hidden {
  display: none;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover {
  color: #4b5563;
}
.modal-body {
  padding: 20px;
}
.modal-info {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 16px;
  text-align: center;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
.form-group input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group small {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.form-actions .btn {
  flex: 1;
}

/* Preview Actions */
.preview-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.preview-actions.hidden {
  display: none;
}
