/* === 重置与变量 === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #252836;
  --border: #2a2d3a;
  --text: #e8eaf0;
  --text-dim: #8b8fa3;
  --primary: #6c5ce7;
  --primary-hover: #7d6ff0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* === 布局 === */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: 52px;
}
.app-header h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.header-actions { display: flex; gap: 6px; }

.app-main {
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  gap: 0;
  height: calc(100vh - 52px);
}

.panel { padding: 16px; overflow-y: auto; }
.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); background: #12141c; }

/* === 卡片 === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === 按钮 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-hover);
  color: var(--text);
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.2); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border: 1px solid var(--border); background: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); background: var(--bg-hover); border: none; color: var(--text); cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.btn-icon:hover { background: var(--border); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

/* === 输入 === */
.input-hex {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 10px;
  font-size: 0.9rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}
.input-hex:focus { border-color: var(--primary); }

.input-select {
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}
.input-select option { background: var(--bg-card); }

.input-range {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.color-picker-group { margin-bottom: 10px; }
.color-picker-group label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px; }
.input-row { display: flex; align-items: center; gap: 8px; }
.input-row > label { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; }
.input-row > span { font-size: 0.85rem; color: var(--text-dim); min-width: 20px; text-align: center; }

input[type="color"] {
  width: 44px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 2px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* === 预设颜色 === */
.quick-colors { margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quick-colors > span { font-size: 0.75rem; color: var(--text-dim); }
.preset-colors { display: flex; gap: 4px; flex-wrap: wrap; }
.preset-color {
  width: 22px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.preset-color:hover { transform: scale(1.2); border-color: var(--text); }

/* === 色彩理论 === */
.theory-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.radio-card { cursor: pointer; }
.radio-card input { display: none; }
.radio-card-content {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.radio-card input:checked + .radio-card-content {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.08);
}
.radio-card-content span { font-size: 0.85rem; }

.theory-preview {
  width: 50px; height: 20px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-shrink: 0;
}
.theory-preview div { flex: 1; }

/* === 上传区 === */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-dim);
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.05);
}
.upload-area p { font-size: 0.85rem; margin-top: 6px; }
.upload-hint { font-size: 0.75rem !important; opacity: 0.6; }

.image-preview {
  position: relative;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 120px;
}
.image-preview img { width: 100%; display: block; border-radius: var(--radius-sm); }
.image-preview button {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%; padding: 0; font-size: 0.8rem;
}

/* === 调色板 === */
.palette-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.palette-header h2 { font-size: 1rem; font-weight: 600; }
.palette-name-group { display: flex; align-items: center; gap: 6px; }
.palette-name { font-size: 0.85rem; color: var(--text-dim); }

.palette-container { min-height: 200px; }

.palette-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  text-align: center;
  gap: 8px;
}
.palette-empty p { font-size: 0.85rem; }

.palette-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.color-swatch {
  width: 100px; flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.color-swatch:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.color-swatch.active { border-color: var(--primary); }

.swatch-color {
  height: 80px;
  position: relative;
}
.swatch-color .delete-swatch {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff;
  border: none; cursor: pointer; font-size: 0.7rem;
  display: none; align-items: center; justify-content: center;
}
.color-swatch:hover .delete-swatch { display: flex; }

.swatch-info { padding: 8px; }
.swatch-hex {
  font-size: 0.8rem; font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
}
.swatch-name { font-size: 0.7rem; color: var(--text-dim); margin-top: 2px; }

.palette-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
}

/* === 导出 === */
.export-section h3 { font-size: 0.85rem; margin-bottom: 10px; color: var(--text-dim); }
.export-buttons { display: flex; gap: 8px; margin-bottom: 10px; }

.export-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.export-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem; font-weight: 600;
}
#exportCode {
  padding: 12px;
  font-size: 0.78rem;
  line-height: 1.6;
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 250px;
  overflow-y: auto;
  color: #a8b2c8;
}

/* === 色盲模拟预览 === */
.sim-preview {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 10px;
  min-height: 30px;
}
.sim-swatch {
  width: 36px; height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: background var(--transition);
}

/* === 预览标签页 === */
.preview-tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.preview-tabs .btn.active { background: var(--primary); color: #fff; }

/* === 网站预览 === */
.preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: calc(100% - 80px);
  min-height: 450px;
  background: #fff;
  transition: background var(--transition);
}
.preview-frame.dark { background: #1a1a2e; }

.preview-site {
  transform-origin: top left;
  width: 600px;
  height: auto;
  min-height: 450px;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}

/* 导航 */
.ps-navbar {
  display: flex; align-items: center; padding: 10px 20px;
  gap: 16px; font-size: 13px;
  transition: background var(--transition), color var(--transition);
}
.ps-brand { font-weight: 700; font-size: 15px; }
.ps-navlinks { display: flex; gap: 12px; flex: 1; }
.ps-navlinks a { text-decoration: none; color: inherit; opacity: 0.7; transition: opacity var(--transition); }
.ps-navlinks a:hover { opacity: 1; }
.ps-btn-nav {
  padding: 5px 14px; border: 1px solid currentColor; border-radius: 4px;
  background: transparent; color: inherit; cursor: pointer; font-size: 12px; font-family: inherit;
}

/* Hero */
.ps-hero {
  padding: 30px 20px;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}
.ps-hero h1 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.ps-hero p { margin-bottom: 16px; opacity: 0.75; font-size: 13px; }
.ps-hero-btns { display: flex; gap: 8px; justify-content: center; }
.ps-btn-primary, .ps-btn-outline {
  padding: 7px 18px; border-radius: 4px; border: none;
  cursor: pointer; font-size: 12px; font-weight: 600; transition: all var(--transition);
}
.ps-btn-outline {
  background: transparent;
  border: 1.5px solid currentColor;
  color: inherit;
}

/* Features */
.ps-features {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; padding: 16px 20px;
}
.ps-feature-card {
  padding: 14px; border-radius: 6px; text-align: center;
  transition: all var(--transition);
}
.ps-feature-icon { font-size: 20px; margin-bottom: 6px; }
.ps-feature-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.ps-feature-card p { font-size: 11px; opacity: 0.7; }

/* Footer */
.ps-footer {
  padding: 14px 20px;
  text-align: center;
  font-size: 11px;
  opacity: 0.5;
  transition: background var(--transition), color var(--transition);
}

/* === 模态框 === */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 0.95rem; }
.modal-body {
  padding: 14px 18px;
  overflow-y: auto; flex: 1;
}
.modal-body pre {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: #a8b2c8;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* === Toast === */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column-reverse;
  gap: 8px; z-index: 2000;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  max-width: 300px;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* === 暗色主题预览 === */
.preview-frame.dark .ps-navlinks a { color: #ccc; }
.preview-frame.dark .ps-hero p { color: #bbb; }
.preview-frame.dark .ps-feature-card p { color: #aaa; }
.preview-frame.dark .ps-footer { color: #888; }

/* === 响应式 === */
@media (max-width: 1100px) {
  .app-main {
    grid-template-columns: 260px 1fr 280px;
  }
}
