/* ShotNice 现代精细化样式表 · 纯原生 CSS3 无任何外部依赖 */

:root {
  --bg-main: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #1f2937;
  --bg-hover: #374151;
  --border-color: #374151;
  --border-subtle: #252e3d;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --header-height: 60px;
}

/* 基础重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-stack);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 整体布局 */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 顶部导航 */
.app-header {
  height: var(--header-height);
  background-color: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.72rem;
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 500;
}

.nav-tabs {
  display: flex;
  background-color: #1a2234;
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

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

.privacy-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #34d399;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 4px 10px;
  border-radius: 9999px;
}

/* 主工作区视图 */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.mode-view {
  display: none;
  flex: 1;
  width: 100%;
}

.mode-view.active {
  display: block;
}

.view-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100vh - var(--header-height));
  width: 100%;
}

/* 预览展示区域 */
.preview-area {
  display: flex;
  flex-direction: column;
  background-color: #0c111d;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border-subtle);
}

.preview-toolbar {
  height: 48px;
  background-color: rgba(17, 24, 39, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-res-badge, .stitch-count-badge {
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background-color: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.scale-factor-text {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* 视口画布容器 */
.canvas-viewport {
  flex: 1;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

.render-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s ease;
}

.render-canvas.has-image {
  display: block;
}

/* 拖拽上传空状态 */
.drop-zone {
  width: 100%;
  max-width: 540px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  background-color: rgba(31, 41, 55, 0.4);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background-color: rgba(59, 130, 246, 0.08);
  transform: translateY(-2px);
}

.drop-icon {
  margin-bottom: 16px;
  color: #60a5fa;
  display: flex;
  justify-content: center;
}

.drop-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.drop-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.drop-hint strong {
  color: #93c5fd;
}

.drop-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 控制面板侧边栏 */
.control-panel {
  background-color: var(--bg-surface);
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-group {
  background-color: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 8px;
}

.group-header label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb;
}

.group-tip, .export-spec-text {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* 预设背景方块网格 */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.preset-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.preset-swatch:hover {
  transform: scale(1.1);
  z-index: 2;
}

.preset-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.05);
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

/* 分段切换按钮组 */
.segmented-control {
  display: flex;
  background-color: #1a2234;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  gap: 2px;
}

.segmented-control.mini {
  padding: 2px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 6px 0;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.segment-btn:hover {
  color: var(--text-main);
}

.segment-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  font-weight: 500;
}

/* 滑动输入行 */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.slider-val {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: #93c5fd;
  font-weight: 500;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #374151;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #60a5fa;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  background: #3b82f6;
}

/* 开关行 */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}

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

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #374151;
  transition: .2s;
  border-radius: 34px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--primary);
}

input:checked + .slider.round:before {
  transform: translateX(16px);
}

/* 文本输入框 */
.text-input {
  width: 100%;
  background-color: #1a2234;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* 按钮规范 */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px var(--primary-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #252e3d;
  color: #e5e7eb;
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background-color: #374151;
  color: #fff;
}

.btn-subtle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-subtle:hover {
  color: var(--text-main);
  border-color: var(--border-color);
  background-color: rgba(255, 255, 255, 0.04);
}

.btn-subtle.danger-text:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
  background-color: rgba(239, 68, 68, 0.1);
}

.btn-xs {
  background-color: #252e3d;
  color: #93c5fd;
  border: 1px solid var(--border-color);
  font-size: 0.74rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-xs:hover {
  background-color: #374151;
  color: #fff;
}

/* 导出区按钮 */
.export-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-export-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-export-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-export-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #1e293b;
  color: #94a3b8;
  border: 1px solid var(--border-color);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-export-secondary:hover {
  color: #ffffff;
  background-color: #334155;
}

.btn-export-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border: none;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.btn-export-copy:hover {
  filter: brightness(1.1);
}

/* 拼接模式特定样式 */
.alert-banner {
  background-color: rgba(245, 158, 11, 0.15);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  padding: 10px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.82rem;
  color: #fef3c7;
}

.alert-banner.hidden {
  display: none;
}

.alert-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.alert-content strong {
  display: block;
  margin-bottom: 2px;
  color: #fde68a;
}

.stitch-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.stitch-item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: #1a2234;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  transition: background-color 0.15s ease;
}

.stitch-item-card:hover {
  background-color: #242e44;
}

.stitch-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background-color: #0b0f19;
  border: 1px solid rgba(255,255,255,0.08);
}

.stitch-info {
  flex: 1;
  min-width: 0;
}

.stitch-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stitch-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.stitch-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-card-ctrl {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-card-ctrl:hover {
  color: var(--text-main);
  background-color: rgba(255,255,255,0.1);
}

.btn-card-ctrl.delete:hover {
  color: var(--danger);
  background-color: rgba(239, 68, 68, 0.15);
}

.empty-tip-text {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  padding: 20px 0;
}

/* 全局 Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: #1f2937;
  color: #f9fafb;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(20px);
  opacity: 0;
  animation: toast-in 0.25s forwards;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.warn {
  border-left: 4px solid var(--warning);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

@keyframes toast-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 辅助与隐藏类 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 响应式适配：手机端（特别保障 375px 不破版、核心按钮可点） */
@media (max-width: 860px) {
  .app-header {
    padding: 0 12px;
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .header-brand h1 {
    font-size: 1.1rem;
  }

  .view-grid {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 60px);
  }

  .preview-area {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 380px;
  }

  .canvas-viewport {
    padding: 16px;
    min-height: 320px;
  }

  .control-panel {
    overflow-y: visible;
    padding: 16px 12px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .preset-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .drop-zone {
    padding: 28px 16px;
  }
}

@media (max-width: 480px) {
  .preset-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .header-status {
    display: none;
  }
}

