/* ========================================
   Muse Space · 灵感收藏馆 — 最终精修版
   ======================================== */

:root {
  --bg:           #fafaf9;
  --bg-alt:       #f5f5f4;
  --surface:      #ffffff;
  --border:       #e8e6e3;
  --border-hover: #d4d1cc;
  --text:         #1c1c1b;
  --text-secondary: #787670;
  --text-tertiary:  #a8a59e;
  --accent:       #2c2c2b;
  --accent-soft:  #f0eeea;
  --tag-bg:       #eceae6; 
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    24px;
  --transition:   300ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg:           #121212; --bg-alt: #1a1a1a; --surface: #1e1e1e;
  --border:       #2e2e2e; --border-hover: #3e3e3e;
  --text:         #e4e4e4; --text-secondary: #9a9a9a; --text-tertiary: #6a6a6a;
  --accent:       #e4e4e4; --accent-soft: #262626; --tag-bg: #2a2a2a;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; min-height: 100vh; line-height: 1.6; }
button { border: none !important; background: none; cursor: pointer; outline: none !important; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: linear-gradient(to bottom, var(--border), var(--text-tertiary)); border-radius: 10px; }

/* ---------- 密码门 (要求3, 4, 9) ---------- */
#gate-overlay {
  position: fixed; inset: 0; z-index: 2000; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#gate-overlay::before { content: "✦"; position: absolute; top: 15%; left: 10%; font-size: 6rem; opacity: 0.05; }
#gate-overlay::after { content: "✦"; position: absolute; bottom: 15%; right: 10%; font-size: 8rem; opacity: 0.05; transform: rotate(20deg); }

.gate-logo { font-size: 3rem; font-weight: 500; letter-spacing: 2px; margin-bottom: 20px; opacity: 0.9; }
.gate-subtitle { font-size: 0.9rem; color: var(--text-tertiary); letter-spacing: 4px; margin-bottom: 60px; text-transform: uppercase; text-align: center; width: 100%; } /* 要求: 居中 */

#gate-input {
  width: 100%; max-width: 300px; padding: 18px 24px; border: 1px solid var(--border) !important; border-radius: 100px;
  background: linear-gradient(90deg, var(--bg-alt), var(--surface), var(--bg-alt));
  background-size: 200% 100%;
  animation: gateGradient 4s infinite linear; /* 要求: 渐变动态特效 */
  text-align: center; font-size: 1.1rem; outline: none; margin-bottom: 40px; transition: all 0.3s;
}
@keyframes gateGradient { 0% { background-position: 0% 0%; } 100% { background-position: -200% 0%; } }
#gate-input:focus { border-color: var(--text-secondary) !important; box-shadow: 0 8px 30px rgba(0,0,0,0.05); }

/* ---------- 顶部导航 ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--bg); border-bottom: 1px solid transparent; transition: all 0.3s; }
.site-header.scrolled { border-bottom: 1px solid var(--border); background: rgba(250, 250, 249, 0.85); backdrop-filter: blur(12px); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; }
.logo { 
    font-size: 1.4rem; font-weight: 800; letter-spacing: -0.8px; text-decoration: none; color: var(--text);
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-controls { display: flex; align-items: center; gap: 12px; }

/* ---------- 搜索栏 (补全美化) ---------- */
.search-bar { 
    position: fixed; top: -100px; left: 0; width: 100%; z-index: 110; 
    background: var(--surface); border-bottom: 1px solid var(--border);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px 0;
}
.search-bar.active { transform: translateY(100px); }
.search-inner { max-width: 800px; margin: 0 auto; padding: 0 32px; display: flex; gap: 16px; align-items: center; }
#search-input { 
    flex: 1; padding: 14px 24px; border-radius: 100px; border: 1px solid var(--border);
    background: var(--bg-alt); color: var(--text); font-size: 1rem; outline: none;
    transition: all 0.3s;
}
#search-input:focus { border-color: var(--text-secondary); background: var(--surface); box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
.icon-btn { width: 40px; height: 40px; border-radius: 50% !important; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); border: none !important; }
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-svg { width: 1.25em; height: 1.25em; stroke: currentColor; stroke-width: 1.5; fill: none; }

/* ---------- Hero & 分类 ---------- */
.hero { text-align: center; padding: 80px 32px 48px; }
.hero-subtitle { font-size: 0.8rem; letter-spacing: 4px; color: var(--text-tertiary); margin-bottom: 16px; text-transform: uppercase; }
.hero-title { font-size: 3rem; font-weight: 700; letter-spacing: -1.5px; margin-bottom: 16px; }
.hero-desc { font-size: 1.1rem; color: var(--text-secondary); opacity: 0.8; }

.category-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 56px; }
.cat-btn { padding: 10px 22px; border-radius: 100px !important; font-size: 0.9rem; color: var(--text-secondary); border: 1px solid var(--border) !important; background: var(--surface); display: flex; align-items: center; gap: 8px; }
.cat-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent) !important; }

/* ---------- 卡片 ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 32px; max-width: 1200px; margin: 0 auto; padding: 0 32px 100px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; cursor: pointer; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.card:hover { transform: translateY(-8px); box-shadow: 0 12px 30px rgba(0,0,0,0.08); border-color: var(--border-hover); }
.card-preview { height: 220px; background: var(--bg-alt); position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.card-preview img { width: 100%; height: 100%; object-fit: cover; }
.card-badge { position: absolute; top: 12px; left: 12px; padding: 5px 14px; border-radius: 100px; font-size: 0.75rem; background: rgba(255,255,255,0.95); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 6px; z-index: 5; color: #1c1c1b; }
[data-theme="dark"] .card-badge { background: rgba(30,30,30,0.8); color: #e4e4e4; }

.card-body { padding: 24px; }
.card-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.card-excerpt { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 12px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tag { 
  font-size: 0.75rem; color: var(--text-tertiary); transition: all 0.3s ease; 
  cursor: pointer; padding: 2px 8px; border-radius: 4px; background: var(--bg-alt);
}
.card-tag:hover { color: var(--accent); background: var(--border); transform: translateY(-1px); }

/* ---------- 详情模态框修复 (要求X位置、大小) ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.45); display: none; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(5px); }
.modal { background: var(--surface); border-radius: var(--radius-lg); max-width: 760px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal-close { 
  position: absolute; top: 20px; right: 24px; /* 要求: 居右 */
  width: 42px; height: 42px; border-radius: 50% !important; 
  background: var(--bg-alt) !important; color: var(--text-secondary); 
  display: flex; align-items: center; justify-content: center; 
  font-size: 1.8rem; line-height: 1; z-index: 100;
}
.modal-close:hover { background: var(--border) !important; color: var(--text); }
.modal-cover { width: 100%; height: 380px; object-fit: cover; border-bottom: 1px solid var(--border); }
.modal-inner { padding: 40px; }

/* ---------- 新建界面美化 (标签输入框美化回归) ---------- */
.form-content { padding: 40px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; color: var(--text-tertiary); letter-spacing: 1px; }
.form-input, .form-select { width: 100%; padding: 12px 18px; background: var(--bg-alt); border: 1px solid var(--border) !important; border-radius: var(--radius-sm); color: var(--text); outline: none; }
.form-input:focus { border-color: var(--text-secondary) !important; background: var(--surface); }

.tag-input-wrapper { 
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; background: var(--bg-alt); 
  border: 1px solid var(--border) !important; border-radius: 12px; /* 要求: 标签输入框美化 */
  transition: all 0.3s;
}
#tag-field { flex: 1; border: none !important; background: transparent; color: var(--text); padding: 4px 0; outline: none !important; min-width: 120px; font-size: 0.9rem; }
.tag-input-wrapper:focus-within { border-color: var(--text-secondary) !important; background: var(--surface); box-shadow: var(--shadow-sm); }
.tag-chip { padding: 5px 14px; background: var(--tag-bg); color: var(--text-secondary); border-radius: 50px; font-size: 0.8rem; display: flex; align-items: center; gap: 8px; }
.tag-chip button { font-weight: bold; opacity: 0.5; font-size: 1.1rem; }

.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; background: var(--bg-alt); border: 1px solid var(--border); border-bottom: none; border-radius: 12px 12px 0 0; }
.tool-btn { width: 38px; height: 38px; border-radius: 8px !important; display: flex; align-items: center; justify-content: center; opacity: 0.7; }
.tool-btn:hover { background: var(--border); opacity: 1; }
.editor-container { border: 1px solid var(--border); border-radius: 0 0 12px 12px; padding: 24px; min-height: 300px; outline: none; background: var(--surface); }

/* ---------- 按钮 & 空状态 ---------- */
.action-btn { padding: 10px 24px; border-radius: 100px !important; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--border) !important; background: var(--surface); color: var(--text-secondary); transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; }
.action-btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent) !important; }
.action-btn.danger { color: #d9776a; border-color: rgba(217,119,106,0.2) !important; }
.action-btn.danger:hover { background: #d9776a !important; color: #fff; }

.modal-actions { padding: 24px 40px; display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border); }

/* 空状态修复 (要求: 放大镜不要那么大，位置正确) */
.empty-state { 
  display: flex; flex-direction: column; align-items: center; justify-content: center; 
  padding: 100px 0; width: 100%; text-align: center; color: var(--text-tertiary); 
}
.empty-icon-svg { width: 64px; height: 64px; margin-bottom: 24px; opacity: 0.3; stroke-width: 1px; }

/* 筛选提示 */
.filter-info { 
  max-width: 1200px; margin: -20px auto 40px; padding: 0 32px; 
  display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--text-secondary); 
}
.filter-clear { 
  width: 20px; height: 20px; border-radius: 50% !important; background: var(--border) !important; 
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text);
}

.fab { 
  position: fixed; bottom: 32px; right: 32px; width: 64px; height: 64px; border-radius: 50%; 
  background: linear-gradient(135deg, #2c2c2b 0%, #555554 100%); 
  color: var(--bg); display: flex; align-items: center; justify-content: center; 
  box-shadow: 0 10px 25px rgba(0,0,0,0.2); z-index: 80; transition: all 0.4s;
}
.fab:hover { 
  transform: rotate(90deg) scale(1.1); 
  background: linear-gradient(135deg, #444443 0%, #1c1c1b 100%);
  box-shadow: 0 15px 35px rgba(0,0,0,0.3);
}
[data-theme="dark"] .fab {
  background: linear-gradient(135deg, #e4e4e4 0%, #a8a59e 100%);
  color: #121212;
}
[data-theme="dark"] .fab:hover {
  background: linear-gradient(135deg, #ffffff 0%, #e4e4e4 100%);
}

body.visitor-mode .fab, body.visitor-mode .modal-actions { display: none !important; }
