/* ===== 壁纸样机生成器 ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #f0f0f2;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::selection { background: #1d1d1f; color: #fff; }
*:focus { outline: none; }

/* ===== 布局 ===== */
.app {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== 顶部导航 ===== */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #e0e0e2;
  margin-bottom: 16px;
}

.nav-brand {
  font-size: 16px;
  font-weight: 700;
  color: #1d1d1f;
  text-decoration: none;
  letter-spacing: -0.3px;
}

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

.bookmark-tip {
  font-size: 11px;
  color: #c7c7cc;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-link {
  font-size: 13px;
  color: #86868b;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: #1d1d1f;
}

/* ===== 主布局 ===== */
.layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #e0e0e2;
  border-radius: 12px;
  padding: 14px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.sidebar-left {
  width: 220px;
  display: flex;
  flex-direction: column;
}

.sidebar-left .device-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sidebar-left .device-header {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.sidebar-left .device-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin: 0 -14px;
  padding: 0 14px;
}

.sidebar-right {
  width: 250px;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #d2d2d7;
  border-radius: 2px;
}

.section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f2;
}

.section:last-of-type {
  margin-bottom: 12px;
  padding-bottom: 0;
  border-bottom: none;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 10px;
}

/* ===== 上传区域 ===== */
.upload-zone {
  border: 1.5px dashed #d2d2d7;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover {
  border-color: #0071e3;
  background: rgba(0,113,227,0.02);
}

.upload-zone.dragover {
  border-color: #0071e3;
  background: rgba(0,113,227,0.04);
}

.upload-placeholder svg {
  margin-bottom: 8px;
}

.upload-text {
  font-size: 12px;
  color: #86868b;
  line-height: 1.4;
}

.upload-hint {
  font-size: 11px;
  color: #c7c7cc;
  margin-top: 4px;
}

.upload-active {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 0;
}

.upload-active svg {
  flex-shrink: 0;
}

/* ===== 缩略图画廊 ===== */
.thumb-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.thumb-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.thumb-item:hover {
  border-color: #0071e3;
}

.thumb-item.active {
  border-color: #0071e3;
  box-shadow: 0 0 0 1px #fff, 0 0 0 3px #0071e3;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-del {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  display: none;
  font-family: inherit;
  padding: 0;
}

.thumb-item:hover .thumb-del {
  display: block;
}

/* ===== 设备网格 ===== */
.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.device-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: #f5f5f7;
  border: 1.5px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.device-btn:hover {
  background: #eeeef0;
}

.device-btn.active {
  background: #fff;
  border-color: #0071e3;
}

.device-btn.active span {
  color: #0071e3;
}

.device-btn span {
  font-size: 11px;
  font-weight: 500;
  color: #86868b;
  transition: color 0.2s;
}

/* ===== 设备颜色 ===== */
.color-options {
  display: flex;
  gap: 8px;
}

.color-opt {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.color-opt:hover {
  transform: scale(1.12);
}

.color-opt.active {
  border-color: #0071e3;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0071e3;
}

/* ===== 通用选项按钮 ===== */
.opt-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.opt-btn {
  flex: 1;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  background: #f5f5f7;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
}

.opt-btn:hover {
  background: #eeeef0;
}

.opt-btn.active {
  background: #0071e3;
  color: #fff;
}

/* ===== 尺寸选择框 ===== */
.size-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #1d1d1f;
  background: #f5f5f7;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2386868b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s;
}

.size-select:hover {
  border-color: #0071e3;
}

.size-select:focus {
  border-color: #0071e3;
  outline: none;
}

.custom-size {
  margin-top: 8px;
}

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

.csize-row input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1d1d1f;
  text-align: center;
  min-width: 0;
}

.csize-row input:focus {
  border-color: #0071e3;
}

.csize-x {
  color: #c7c7cc;
  font-size: 14px;
}

/* ===== 滑块行 ===== */
.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.slider-row:last-child {
  margin-bottom: 0;
}

.slider-label {
  font-size: 12px;
  color: #86868b;
  min-width: 36px;
  flex-shrink: 0;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #d2d2d7;
  border-radius: 2px;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #d2d2d7;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
}

.slider-val {
  font-size: 12px;
  color: #86868b;
  min-width: 38px;
  text-align: right;
  font-family: monospace;
}

/* ===== 背景颜色 ===== */
.bg-color-row,
.bg-gradient-row,
.bg-blur-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.mini-picker {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #d2d2d7;
  flex-shrink: 0;
  position: relative;
}

.mini-picker input[type="color"] {
  width: 150%;
  height: 150%;
  position: absolute;
  top: -25%;
  left: -25%;
  border: none;
  padding: 0;
  cursor: pointer;
}

.color-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
  color: #1d1d1f;
  min-width: 0;
}

.color-input:focus {
  border-color: #0071e3;
}

.grad-arr {
  color: #c7c7cc;
  font-size: 14px;
  flex-shrink: 0;
}

.gcolor-input {
  min-width: 55px;
  max-width: 70px;
  padding: 4px 6px;
  font-size: 11px;
}

.bg-gradient-row {
  gap: 4px;
}

.bg-gradient-row .mini-picker {
  width: 28px;
  height: 28px;
}

/* ===== 导出按钮 ===== */
.btn-export {
  width: 100%;
  padding: 12px 0;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-export:hover {
  background: #0062c4;
}

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

.btn-export.btn-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ===== 预览区域 ===== */
.preview-panel {
  flex: 1;
  min-width: 0;
  border: 1px solid #e0e0e2;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 90px);
  min-height: 500px;
  background-color: #e8e8ea;
  background-image:
    linear-gradient(45deg, #dcdce0 25%, transparent 25%),
    linear-gradient(-45deg, #dcdce0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dcdce0 75%),
    linear-gradient(-45deg, transparent 75%, #dcdce0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.preview-panel canvas {
  width: 100%;
  display: block;
}

.preview-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.preview-empty svg {
  margin-bottom: 12px;
}

.preview-empty p {
  font-size: 14px;
  color: #c7c7cc;
  line-height: 1.6;
}

.preview-empty .preview-empty-hint {
  font-size: 12px;
  color: #d2d2d7;
}

/* ===== 历史记录 ===== */
.history-list {
  max-height: 140px;
  overflow-y: auto;
}

.history-list::-webkit-scrollbar {
  width: 3px;
}
.history-list::-webkit-scrollbar-thumb {
  background: #d2d2d7;
  border-radius: 2px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f2;
  font-size: 11px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-info {
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.history-time {
  color: #c7c7cc;
  flex-shrink: 0;
  margin-left: 6px;
}

.history-empty {
  font-size: 11px;
  color: #c7c7cc;
  text-align: center;
  padding: 8px 0;
}

/* ===== 水印控件容器 ===== */
.wm-controls {
  margin-top: 8px;
}

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

.toggle-label {
  font-size: 12px;
  color: #86868b;
}

/* ===== 开关 ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #c7c7cc;
  border-radius: 24px;
  transition: background 0.25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: #34c759;
}

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

/* ===== 快捷键提示 ===== */
.shortcut-hint {
  font-size: 10px;
  color: #c7c7cc;
  text-align: center;
  margin-top: 8px;
  line-height: 1.4;
}

/* ===== 文件名输入行 ===== */
.filename-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.filename-label {
  font-size: 12px;
  color: #86868b;
  white-space: nowrap;
  flex-shrink: 0;
}

.filename-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
  color: #1d1d1f;
  min-width: 0;
}

.filename-input:focus {
  border-color: #0071e3;
  outline: none;
}

/* ===== 加载动画 ===== */
@keyframes spin { to { transform: rotate(360deg); } }

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e5ea;
  border-top-color: #0071e3;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: #86868b;
}

/* ===== 响应式 ===== */
@media (max-width: 960px) {
  .layout {
    flex-direction: column;
  }
  .sidebar,
  .sidebar-left,
  .sidebar-right {
    width: 100%;
    position: static;
    max-height: none;
  }
  .preview-panel {
    min-height: 300px;
    order: -1;
  }
}
