/* ═════════════════════════════════════════════════════════════════════
   Skill 共享空间 — 响应式样式表 (Mobile First)
   ════════════════════════════════════════════════════════════════════ */

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

:root {
  --bg: #0f1117;
  --surface: #1a1b23;
  --surface-2: #24252e;
  --border: #2e3040;
  --text: #e4e5ea;
  --text-dim: #9095a6;
  --accent: #7c6ff7;
  --accent-hover: #9185f9;
  --accent-soft: rgba(124, 111, 247, 0.12);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
  --max-width: 1100px;
}

html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ── 头部 (Mobile First) ───────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
  text-align: center;
}
.header-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; }
.logo {
  font-size: 1.4rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle { color: var(--text-dim); margin-top: 0.2rem; font-size: 0.85rem; }

/* ── 工具栏 (sticky) ──────────────────────────────────────────── */
.toolbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0.6rem 0; position: sticky; top: 0; z-index: 10;
}
.toolbar-inner {
  max-width: var(--max-width); margin: 0 auto; padding: 0 1rem;
  display: flex; gap: 0.6rem; align-items: center;
}
.search-box { flex: 1; position: relative; }
.search-box input {
  width: 100%; padding: 0.5rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 0.85rem; outline: none;
  transition: border-color 0.15s;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus { border-color: var(--accent); }

/* ── 按钮 ──────────────────────────────────────────────────────── */
.btn {
  padding: 0.5rem 1rem; border: none; border-radius: var(--radius);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap; font-family: inherit;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-secondary:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ── 标签栏 ────────────────────────────────────────────────────── */
.tags-bar {
  max-width: var(--max-width); margin: 0.8rem auto 0; padding: 0 1rem;
  display: flex; gap: 0.35rem; flex-wrap: wrap;
}
.tag-chip {
  padding: 0.25rem 0.65rem; border-radius: 50px; font-size: 0.75rem;
  cursor: pointer; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-dim);
  transition: all 0.15s; user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.tag-chip:hover { border-color: var(--accent); color: var(--text); }
.tag-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ── 统计 ──────────────────────────────────────────────────────── */
.stats {
  max-width: var(--max-width); margin: 0.4rem auto 0; padding: 0 1rem;
  color: var(--text-dim); font-size: 0.8rem;
}

/* ── 卡片网格 (Mobile: 1列) ─────────────────────────────────── */
.card-grid {
  max-width: var(--max-width); margin: 0.8rem auto 2rem; padding: 0 1rem;
  display: grid; grid-template-columns: 1fr; gap: 0.75rem;
}

/* ── 卡片 ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  transition: all 0.15s; display: flex; flex-direction: column;
}
.card:active { transform: scale(0.99); }
.card-name { font-size: 1rem; font-weight: 700; margin-bottom: 0.3rem; }
.card-desc {
  font-size: 0.82rem; color: var(--text-dim); flex: 1; margin-bottom: 0.6rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; gap: 0.5rem; font-size: 0.73rem; color: var(--text-dim); margin-bottom: 0.5rem; align-items: center; flex-wrap: wrap; }
.card-version { background: var(--accent-soft); color: var(--accent); padding: 0.1rem 0.45rem; border-radius: 50px; font-weight: 600; font-size: 0.68rem; }
.card-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.card-tag { font-size: 0.68rem; padding: 0.12rem 0.45rem; border-radius: 50px; background: var(--surface-2); color: var(--text-dim); }
.card-actions { display: flex; gap: 0.4rem; margin-top: auto; }
.card-actions .btn { font-size: 0.75rem; padding: 0.35rem 0.75rem; flex: 1; text-align: center; }

/* ── 空状态 ────────────────────────────────────────────────────── */
.empty-state {
  max-width: var(--max-width); margin: 3rem auto; text-align: center;
  color: var(--text-dim); padding: 0 1rem;
}
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state h2 { color: var(--text); margin-bottom: 0.4rem; font-size: 1.15rem; }
.empty-state p { font-size: 0.85rem; }
.empty-state code {
  display: inline-block; margin-top: 0.6rem; padding: 0.4rem 0.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Fira Code','Cascadia Code','Consolas',monospace;
  font-size: 0.78rem; word-break: break-all;
}

/* ── 模态框 ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.65); display: flex;
  align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 680px;
  max-height: 85vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.05rem; }
.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.4rem; cursor: pointer; padding: 0.25rem; line-height: 1;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { color: var(--text); }
.modal-meta {
  padding: 0.6rem 1rem; display: flex; gap: 0.6rem;
  font-size: 0.78rem; color: var(--text-dim);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center;
}
.modal-body {
  padding: 0.9rem 1rem; overflow-y: auto; flex: 1;
  -webkit-overflow-scrolling: touch;
}
.modal-body pre {
  white-space: pre-wrap; word-wrap: break-word;
  font-family: 'Fira Code','Cascadia Code','Consolas',monospace;
  font-size: 0.78rem; line-height: 1.55; color: var(--text);
}
.modal-footer {
  padding: 0.75rem 1rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.5rem;
}

/* ── 表单 ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 0.75rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }
.form-label .required { color: var(--danger); }
.form-input {
  width: 100%; padding: 0.45rem 0.6rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.82rem; font-family: inherit;
  outline: none; transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-dim); opacity: 0.5; }
.form-row { display: flex; gap: 0.6rem; }
.form-preview {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem;
  font-size: 0.73rem; max-height: 100px; overflow-y: auto;
  white-space: pre-wrap; word-wrap: break-word; margin: 0;
  font-family: 'Fira Code','Cascadia Code','Consolas',monospace;
  color: var(--text-dim);
}

/* ── 拖拽区 ────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.2rem 1rem; text-align: center; cursor: pointer;
  color: var(--text-dim); transition: all 0.15s; font-size: 0.82rem;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.drop-zone.has-file { border-color: var(--success); border-style: solid; color: var(--success); }
.drop-zone small { display: block; margin-top: 0.3rem; font-size: 0.7rem; opacity: 0.6; }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 200;
  display: flex; flex-direction: column; gap: 0.4rem; max-width: calc(100vw - 2rem);
}
.toast {
  padding: 0.6rem 1rem; border-radius: var(--radius);
  font-size: 0.8rem; font-weight: 600; box-shadow: var(--shadow);
  animation: slideIn 0.25s ease-out; word-break: break-word;
}
.toast.success { background: #166534; color: var(--success); border: 1px solid var(--success); }
.toast.error { background: #7f1d1d; color: var(--danger); border: 1px solid var(--danger); }
.toast.info { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

@keyframes slideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ═════════════════════════════════════════════════════════════════════
   Tablet (>= 600px)
   ════════════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  html { font-size: 15px; }
  .header { padding: 1.8rem 0; }
  .logo { font-size: 1.55rem; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
  .card { padding: 1.1rem; }
  .modal { max-height: 80vh; }
  .modal-body { padding: 1rem 1.1rem; }
  .drop-zone { padding: 1.5rem; }
}

/* ═════════════════════════════════════════════════════════════════════
   Desktop (>= 960px)
   ════════════════════════════════════════════════════════════════════ */
@media (min-width: 960px) {
  html { font-size: 16px; }
  .header { padding: 2rem 0; }
  .logo { font-size: 1.7rem; }
  .header-inner, .toolbar-inner, .tags-bar, .stats, .card-grid { padding-left: 1.5rem; padding-right: 1.5rem; }
  .card-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
  .card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
  .card:active { transform: translateY(0); }
  .btn-primary:hover { transform: translateY(-1px); }
  .btn-primary:active { transform: translateY(0) scale(0.98); }
  .modal { max-height: 75vh; }
  .form-preview { max-height: 140px; }
}

/* ═════════════════════════════════════════════════════════════════════
   Wide Desktop (>= 1300px)
   ════════════════════════════════════════════════════════════════════ */
@media (min-width: 1300px) {
  .card-grid { grid-template-columns: repeat(4, 1fr); }
}
