:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --card-bg: #1a1d27;
  --bg3: #22263a;
  --border: #2e3248;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --accent: #6c63ff;
  --accent2: #818cf8;
  --green: #22d3a0;
  --pink: #f472b6;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --modal-mask: rgba(10, 11, 16, 0.85);
}

[data-theme="light"] {
  --bg: #f0f4ff;
  --bg2: #ffffff;
  --card-bg: #fafafa;
  --bg3: #e8edf8;
  --border: #d1d9f0;
  --text: #1e2a3a;
  --text2: #4a5568;
  --text3: #8898aa;
  --shadow: 0 4px 24px rgba(108, 99, 255, 0.1);
  --modal-mask: rgba(240, 244, 255, 0.7);
}

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

a {
  text-decoration: none !important;
  color: inherit !important;
  display: inline-block; /* 基础重置 */
}

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

/* ===== 侧边栏 ===== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-header p {
  font-size: 11px;
  color: var(--text3);
}

/* ===== 登录界面 ===== */
/* ===== 弹窗全局重构 (性能优化版) ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--modal-mask, rgba(10, 11, 16, 0.85)); backdrop-filter: blur(8px);
  z-index: 10000; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.3s ease;
  will-change: opacity, visibility;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg2); width: 90%; max-width: 500px; max-height: 90vh;
  border-radius: 28px; position: relative; border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  will-change: transform, opacity; /* 强制开启 GPU 硬件加速 */
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
  from { transform: scale(0.92) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 24px 30px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 19px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -0.5px; }

.modal-close {
  cursor: pointer; width: 36px; height: 36px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); transition: all 0.2s; background: rgba(255, 255, 255, 0.05);
  font-size: 18px; border: none;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; transform: rotate(90deg); }

.modal-body {
  padding: 24px 30px; 
  overflow-y: auto; 
  flex: 1;
  max-height: calc(90vh - 140px); /* 扣除 header 和 footer 的高度 */
  scrollbar-width: thin;
}

.modal-footer {
  padding: 20px 30px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 12px; background: transparent;
}

.auth-box {
  width: 400px; padding: 40px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 32px; box-shadow: var(--shadow); text-align: center;
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-box h2 {
  margin-bottom: 20px;
  font-size: 24px;
  color: var(--text);
}

.auth-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}

.auth-box input:focus {
  border-color: var(--accent);
}

.auth-box .btn-primary {
  width: 100%;
  margin-top: 10px;
}

.auth-box .auth-switch {
  margin-top: 15px;
  font-size: 13px;
  color: var(--text3);
  cursor: pointer;
}

.auth-box .auth-switch span {
  color: var(--accent);
}

.user-profile {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  cursor: pointer;
  color: var(--text3);
  font-size: 16px;
}

.logout-btn:hover {
  color: var(--red);
}

.sidebar-nav {
  padding: 10px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  transition: all .15s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active {
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent2);
}

.nav-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-item .count {
  margin-left: auto;
  background: var(--bg3);
  color: var(--text3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.sidebar-section {
  padding: 4px 10px 0;
}

.sidebar-section-title {
  font-size: 11px;
  color: var(--text3);
  padding: 10px 10px 6px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.03);
  padding-top: 15px;
}
.sidebar-section-title:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 10px;
}

.sidebar-section-title button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.2;
  transition: all .15s;
}

.sidebar-section-title button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 99, 255, 0.05);
}

.project-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text2);
  font-size: 15px;
  transition: all .15s;
  margin-bottom: 3px;
  position: relative;
}

.project-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.project-item.active {
  background: rgba(108, 99, 255, 0.12);
  color: var(--text);
}

.project-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-cnt {
  font-size: 13px;
  color: var(--text3);
}

.project-expand-icon {
  font-size: 10px;
  color: var(--text3);
  transition: transform .2s;
  margin-left: auto;
  padding: 0 2px;
}

.project-item.expanded .project-expand-icon {
  transform: rotate(90deg);
}

.project-expand-icon {
  font-size: 10px;
  color: var(--text3);
  transition: transform .2s;
  padding: 0 4px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}

.project-sub {
  margin: 0 0 4px 22px;
  border-left: 2px solid var(--border);
  padding-left: 10px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .25s ease, opacity .2s;
}

.project-sub.open {
  max-height: 400px;
  opacity: 1;
}

.project-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  transition: all .12s;
  margin-bottom: 2px;
}

.project-sub-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.project-sub-item.active {
  color: var(--accent2);
  background: rgba(108, 99, 255, 0.1);
}

.project-sub-item .psi-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.project-sub-item .psi-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-sub-item .psi-cnt {
  font-size: 11px;
  color: var(--text3);
}

.project-actions {
  display: none;
  gap: 3px;
}

.project-item:hover .project-actions {
  display: flex;
}

.project-actions button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-actions button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.project-actions .del-btn:hover {
  color: var(--red);
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

.sidebar-bottom button {
  flex: 1;
  padding: 7px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  transition: all .15s;
}

.sidebar-bottom button:hover {
  border-color: var(--accent);
  color: var(--accent2);
}

/* ===== 主内容区 ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

/* ===== 顶栏 ===== */
.topbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text3);
  font-size: 13px;
  flex: 1;
}

.breadcrumb .crumb {
  color: var(--text2);
  cursor: pointer;
}

.breadcrumb .crumb:hover {
  color: var(--accent2);
}

.breadcrumb .active {
  color: var(--text);
  font-weight: 600;
}

.breadcrumb .sep {
  color: var(--text3);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text3);
  pointer-events: none;
}

.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px 7px 34px;
  border-radius: 8px;
  font-size: 13px;
  width: 200px;
  outline: none;
  transition: all .15s;
}

.search-input:focus {
  border-color: var(--accent);
  width: 260px;
}

.search-input::placeholder {
  color: var(--text3);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}

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

.btn-primary:hover {
  background: #5b52ee;
}

.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

.sort-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.theme-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  cursor: pointer;
  font-size: 16px;
  color: var(--text2);
  transition: all .15s;
  flex-shrink: 0;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent2);
}

/* ===== 功能标签栏 ===== */
.func-bar {
  display: none;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  overflow-x: auto;
}

.func-bar.show {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.func-tabs {
  display: flex;
  gap: 6px;
  padding-bottom: 10px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}

.func-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 10px;
  padding-bottom: 10px;
}

.func-tab {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text2);
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all .15s;
}

.func-tab:hover {
  background: var(--bg3);
  color: var(--text);
}

.func-tab.active {
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent2);
  border-color: rgba(108, 99, 255, 0.3);
}

.func-tab {
  position: relative;
}

.func-tab-actions {
  display: none;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

.func-tabs.managing .func-tab-actions {
  display: flex;
}

.func-tab-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text3);
  line-height: 1;
  transition: all .12s;
}

.func-tab-actions button:hover {
  background: var(--bg);
  color: var(--text);
}

.func-tab-actions .del-func:hover {
  color: var(--red);
}

/* ===== 内容区 ===== */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 链接样式规范化 */
a.project-card, a.project-item, a.project-sub-item, a.func-tab, a.nav-item, a.crumb {
  text-decoration: none !important;
  color: inherit !important;
  display: flex;
}
a.project-card { display: block; }

.content-area::-webkit-scrollbar {
  width: 5px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===== 提示词卡片网格 ===== */
.prompts-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 20px;
  row-gap: 24px;
}

@media (min-width: 640px) {
  .prompts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .prompts-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1536px) {
  .prompts-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* 提示词图片展示 */
.card-image {
  margin: -16px -16px 12px -16px;
  width: calc(100% + 32px);
  height: 180px;
  overflow: hidden;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: var(--bg3);
  position: relative;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.prompt-card:hover .card-image img {
  transform: scale(1.08);
}

.pli-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.prompt-card {
  background: var(--card-bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prompt-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.prompt-card.pinned {
  border-color: rgba(251, 191, 36, 0.4);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-emoji {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.card-meta {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pin-badge {
  color: var(--yellow);
  font-size: 12px;
}

.card-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.card-actions {
  display: none;
  gap: 4px;
}

.prompt-card:hover .card-actions {
  display: flex;
}

.card-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 13px;
  transition: all .15s;
}

.card-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

.card-btn.copy-btn:hover {
  color: var(--green);
}

.card-btn.del-btn:hover {
  color: var(--red);
}

.card-content {
  font-size: 12px;
  color: var(--text2);
  line-height: 20px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg3);
  border-radius: 6px;
  padding: 8px 10px;
  white-space: pre-wrap;
}

.card-content::-webkit-scrollbar {
  width: 3px;
}

.card-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.card-tags {
  display: none;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(108, 99, 255, 0.12);
  color: var(--accent2);
  font-size: 11px;
  border: 1px solid rgba(108, 99, 255, 0.2);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text3);
  font-size: 11px;
}

.use-count {
  display: flex;
  align-items: center;
  gap: 4px;
}

.copied-toast {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--green);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.copied-toast.show {
  opacity: 1;
}

/* ===== 快速添加区 ===== */
.quick-add {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.quick-add-title {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.quick-add-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-add-row input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border .15s;
  font-family: inherit;
}

.quick-add-row textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border .15s;
  font-family: inherit;
  min-height: 160px;
  resize: vertical;
  line-height: 1.6;
}

.quick-add-row input:focus,
.quick-add-row textarea:focus {
  border-color: var(--accent);
}

.quick-add-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ===== 空状态 ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text3);
  gap: 12px;
}

.empty-state .empty-icon {
  font-size: 56px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text2);
}

.empty-state p {
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* ===== 加载 ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text3);
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .6s linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 模态框 ===== */
.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);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease-out, visibility 0.1s ease-out;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transform: scale(0.98) translateY(5px);
  transition: transform 0.1s ease-out;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 20px;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all .15s;
}

.modal-close:hover {
  background: var(--bg3);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body::-webkit-scrollbar {
  width: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border .15s;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--accent);
}

textarea.form-control {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.emoji-opt {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  border: 2px solid transparent;
  background: var(--bg3);
  transition: all .15s;
}

.emoji-opt:hover {
  border-color: var(--accent);
}

.emoji-opt.selected {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.2);
}

.btn-cancel {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-cancel:hover {
  border-color: var(--border);
  background: var(--border);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

.btn-success {
  background: rgba(34, 211, 160, 0.15);
  color: var(--green);
  border: 1px solid rgba(34, 211, 160, 0.3);
}

.btn-success:hover {
  background: rgba(34, 211, 160, 0.25);
}

/* ===== 详情面板 ===== */
.detail-panel {
  width: 340px;
  min-width: 340px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.detail-panel.open {
  display: flex;
}

.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-emoji {
  width: 44px;
  height: 44px;
  background: var(--bg3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

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

.detail-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.detail-meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.detail-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.detail-body::-webkit-scrollbar {
  width: 4px;
}

.detail-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section-title {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}

.detail-content {
  background: var(--bg3);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.detail-note {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text2);
}

.detail-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.detail-footer .btn {
  flex: 1;
  justify-content: center;
  font-size: 13px;
}

/* ===== 历史记录 ===== */
.history-item {
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 12px;
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--text3);
}

.history-item-content {
  color: var(--text2);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-restore {
  background: none;
  border: none;
  color: var(--accent2);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(108, 99, 255, 0.3);
}

.history-restore:hover {
  background: rgba(108, 99, 255, 0.15);
}

/* ===== 通知 ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn .3s ease;
}

.toast.success {
  border-color: rgba(34, 211, 160, .4);
}

.toast.error {
  border-color: rgba(248, 113, 113, .4);
}

@keyframes slideIn {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
}

/* ===== 回到顶部 ===== */
.back-top {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  box-shadow: var(--shadow);
  transition: all .2s;
  z-index: 100;
  border: none;
}

.back-top.show {
  display: flex;
}

.back-top:hover {
  background: #5b52ee;
  transform: translateX(-50%) translateY(-2px);
}

/* 项目网格（首页） */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.project-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.pc-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.pc-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pc-count {
  font-size: 12px;
  color: var(--text3);
}

.pc-funcs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.pc-func-tag {
  font-size: 11px;
  color: var(--text2);
  padding: 2px 8px;
  background: var(--bg3);
  border-radius: 10px;
}

.pc-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  gap: 3px;
}

.project-card:hover .pc-actions {
  display: flex;
}

.pc-actions button {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 12px;
  transition: all .15s;
}

.pc-actions button:hover {
  color: var(--text);
}

/* 新建项目卡片 */
.project-card.add-card {
  border-style: dashed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text3);
  min-height: 140px;
}

.project-card.add-card:hover {
  color: var(--accent2);
  border-color: var(--accent);
}

.add-icon {
  font-size: 28px;
}

/* ===== 视图切换按钮组 ===== */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.view-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--text3);
  font-size: 14px;
  transition: all .15s;
  line-height: 1;
}

.view-toggle-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(108, 99, 255, 0.4);
}

.view-toggle-btn:not(.active):hover {
  color: var(--text);
  background: var(--bg);
}

/* 列表视图 */
.prompts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-list-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  overflow: hidden;
}

.prompt-list-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.prompt-list-item .pli-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.prompt-list-item .pli-body {
  flex: 1;
  min-width: 0;
}

.prompt-list-item .pli-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-list-item .pli-desc {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-list-item .pli-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.prompt-list-item .pli-cnt {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.prompt-list-item .pli-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg3);
  color: var(--text3);
  white-space: nowrap;
}

.prompt-list-item .pli-actions {
  display: none;
  gap: 4px;
}

.prompt-list-item:hover .pli-actions {
  display: flex;
}

.prompt-list-item .pli-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text3);
  transition: all .12s;
}

.prompt-list-item .pli-actions button:hover {
  background: var(--bg3);
  color: var(--text);
}

.prompt-list-item .pin-indicator {
  font-size: 12px;
  opacity: .7;
}

/* 颜色选择器 */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-opt {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all .15s;
}

.color-opt.selected {
  border-color: var(--text);
  transform: scale(1.2);
}

/* ===== 添加分类模态框 ===== */
#func-modal .modal {
  max-width: 480px;
}

.func-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.func-icon-preview {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.2), rgba(244, 114, 182, 0.2));
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: all .2s;
}

.func-emoji-section {
  margin-bottom: 4px;
}

.func-emoji-section-title {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.func-emoji-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.func-emoji-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}

.func-emoji-opt {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  border: 2px solid transparent;
  background: var(--bg3);
  transition: all .15s;
  user-select: none;
}

.func-emoji-opt:hover {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.1);
  transform: scale(1.12);
}

.func-emoji-opt.selected {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .sidebar.show {
    display: flex;
  }

  .detail-panel {
    /* override previous display: none if present, although we just remove it */
  }
}

/* AI 工作台样式 */
.workbench-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 15px;
}

.wb-top {
  background: var(--bg2);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.wb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  flex: 1;
  min-height: 0;
}

.wb-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wb-card-header {
  padding: 10px 15px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wb-chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  font-size: 13px;
  line-height: 1.6;
}

.msg {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
}

.msg.user {
  background: rgba(108, 99, 255, 0.1);
  border-left: 3px solid var(--accent);
  color: var(--text);
}

.msg.ai {
  background: var(--bg3);
  border-left: 3px solid var(--green);
  color: var(--text);
  white-space: pre-wrap;
}

.wb-tool-btn {
  height: 50px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  transition: all 0.2s;
}

.wb-tool-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(108, 99, 255, 0.05);
}

/* ===== 批量操作 ===== */
.batch-check,
.batch-check-card {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
}

.batch-check-card {
  top: 16px;
  left: 16px;
}

.prompt-card.selected,
.prompt-list-item.selected {
  border-color: var(--accent) !important;
  background: rgba(108, 99, 255, 0.05) !important;
}

/* ===== 拖拽排序 ===== */
.sortable-ghost {
  opacity: 0.4;
  border: 2px dashed var(--accent) !important;
}

/* ===== 滚动加载 & 加载中 ===== */
.loading-more {
  font-size: 12px;
  color: var(--text3);
  padding: 20px;
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 动态占位符 ===== */
.placeholders-box {
  margin-bottom: 20px;
}

.ph-input:focus {
  border-color: var(--accent) !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.2);
}

/* ===== 响应式优化 ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 0;
    min-width: 0;
    position: fixed;
    z-index: 1000;
  }

  .sidebar.show {
    width: 280px;
  }

  .topbar {
    padding: 12px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }

  .search-wrap {
    flex: 1;
    min-width: 140px;
  }

  .search-input {
    width: 100%;
  }

  .search-input:focus {
    width: 100%;
  }

  .func-bar.show {
    flex-wrap: wrap;
  }

  .func-actions {
    width: 100%;
    margin-left: 0;
    padding-top: 5px;
    justify-content: flex-start;
  }

  .prompts-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .project-card {
    padding: 10px;
    min-height: 90px;
  }
  
  .pc-icon {
    font-size: 18px;
  }
  
  .pc-name {
    font-size: 13px;
  }

  .content-area {
    padding: 10px;
  }

  .home-guide {
    padding: 25px 15px !important;
  }

  .home-guide .guide-header h2 {
    font-size: 18px !important;
  }

  .home-guide .feature-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .home-guide .feature-card {
    padding: 20px !important;
    border-radius: 16px !important;
  }

  .home-guide .feature-card h3 {
    font-size: 15px !important;
  }

  .home-guide .card-bg-text {
    font-size: 60px !important;
  }

  .home-guide .step-grid {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }

  .home-guide .step-item {
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }

  .home-guide .step-num {
    margin: 0 !important;
  }

  .modal {
    width: 96%;
    max-width: 96%;
    margin: 8px;
    border-radius: 20px;
  }
}

/* ===== 历史版本样式 ===== */
.history-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--text3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.history-restore {
  background: rgba(108, 99, 255, 0.1);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.history-restore:hover {
  background: var(--accent);
  color: #fff;
}

.btn-history-del {
  background: transparent;
  color: var(--text3);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.btn-history-del:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}


.history-item-content {
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 100px;
  max-height: 350px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg2);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  margin-top: 8px;
}

/* 历史列表滚动条美化 */
.history-list::-webkit-scrollbar {
  width: 4px;
}
.history-list::-webkit-scrollbar-track {
  background: transparent;
}
.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

@media (max-width: 768px) {
  .detail-columns {
    flex-direction: column !important;
    gap: 20px !important;
  }
  .detail-side-col {
    width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--border) !important;
    padding-left: 0 !important;
    padding-top: 20px !important;
  }
  .history-list {
    max-height: 300px !important;
  }
}

#ai-tools-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 768px) {
  #ai-tools-grid {
    gap: 4px; /* 手机端极致间距 */
  }
  #ai-tools-grid .btn {
    padding: 6px 2px !important; /* 手机端极致高度 */
    font-size: 10px !important;  /* 手机端微缩文字 */
  }
  #ai-tools-grid img {
    width: 14px !important;      /* 手机端微缩图标 */
    height: 14px !important;
  }
}

#share-card-el {
  transition: transform 0.3s ease;
}

#share-card-el:hover {
  transform: translateY(-5px);
}

.btn-text:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* 自定义工具列表滚动条 */
#tools-list-container::-webkit-scrollbar {
  width: 4px;
}
#tools-list-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* 详情面板间距优化 */
.detail-main-col {
  padding: 0 12px; /* 调小间距，保持适度呼吸感 */
  transition: padding 0.3s;
}

.detail-side-col {
  padding-left: 15px !important; /* 对应调小历史栏间距 */
}

/* 手机版适配：还原紧凑间距 */
@media (max-width: 768px) {
  .detail-main-col {
    padding: 0 5px; /* 手机版保持紧凑 */
  }
  .detail-side-col {
    padding-left: 10px !important;
    width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
    margin-top: 15px;
    padding-top: 15px;
  }
  .detail-columns {
    flex-direction: column;
    gap: 15px !important;
  }
}