:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2329;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --line: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* 顶部 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: linear-gradient(120deg, #1e3a8a, #2563eb 55%, #4f46e5);
  color: #fff;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo { font-size: 30px; line-height: 1; }
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 3px 0 0; opacity: .85; font-size: 13px; }

/* 统计 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 20px 28px 0;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 26px; color: var(--primary); }
.stat span { font-size: 12px; color: var(--muted); }

/* 工具栏 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 28px;
  align-items: center;
}
.toolbar input[type="search"] { flex: 1; min-width: 220px; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .35);
  border-color: var(--primary);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

/* 卡片 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
  margin: 0 28px 40px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h3 { margin: 0; font-size: 16px; line-height: 1.45; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
}
.badge.platform { background: #ecfdf5; color: #047857; }
.badge.play { background: #fffbeb; color: #b45309; }
.badge.status { background: #f3f4f6; color: #4b5563; }
.badge.status.ready { background: #dcfce7; color: #15803d; }
.badge.status.done { background: #dbeafe; color: #1d4ed8; }
.badge.status.dropped { background: #fee2e2; color: #b91c1c; }
.card-desc {
  color: #374151;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin: 0;
}
.tool-idea {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: #92400e;
  white-space: pre-wrap;
  line-height: 1.6;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #f3f4f6; color: #6b7280; }
.card-imgs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.card-img {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: #f3f4f6;
}
.card-link { font-size: 12px; color: var(--primary); text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  margin-top: auto;
}
.card-date { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; }
.card-actions .btn { padding: 5px 10px; font-size: 12px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  margin: 0;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal-box h2 { margin: 0 0 16px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #374151; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.img-hint { font-size: 12px; color: var(--muted); }
.img-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.img-item { position: relative; width: 84px; height: 84px; }
.img-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f3f4f6; }
.img-del {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #dc2626;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
  padding: 16px;
}
.lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 8px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 99;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: #b91c1c; }

/* ---------- 手机端适配 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 14px 16px; gap: 10px; }
  .logo { font-size: 24px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 11px; }
  .topbar .btn-primary { padding: 8px 12px; font-size: 13px; flex-shrink: 0; }

  .stats { grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 12px 0; }
  .stat { padding: 10px 14px; }
  .stat b { font-size: 20px; }

  .toolbar { margin: 10px 12px; gap: 8px; }
  .toolbar input[type="search"] { flex: 1 1 100%; min-width: 0; }
  .toolbar select { flex: 1 1 40%; min-width: 0; }
  .toolbar .btn { flex: 1 1 30%; text-align: center; padding: 8px 6px; font-size: 12px; }

  .cards { grid-template-columns: 1fr; margin: 0 12px 32px; gap: 12px; }
  .card-img { width: 96px; height: 96px; }

  /* 手机上输入框 16px 起步，避免 iOS/企微 webview 聚焦时自动放大页面 */
  input, select, textarea { font-size: 16px; padding: 10px 12px; }
  .btn { font-size: 14px; }

  /* 手机上弹窗不走 fixed 覆盖层：打开时隐藏底层页面，表单走正常文档流。
     iOS/企微 webview 在 fixed+overflow 滚动时背景来不及重绘，会把底层页面透出来 */
  body.modal-open .topbar,
  body.modal-open main { display: none; }
  body.modal-open { background: #fff; }
  .modal {
    position: static;
    display: block;
    background: #fff;
    padding: 0;
    overflow: visible;
  }
  .modal[hidden] { display: none; }
  .modal-box {
    max-width: none;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .form-grid .full { grid-column: auto; }
  label { font-size: 14px; }
  .modal-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 12px 0 calc(4px + env(safe-area-inset-bottom));
    margin-top: 16px;
  }
  .modal-actions .btn { flex: 1; padding: 12px; font-size: 16px; }
  .img-item { width: 76px; height: 76px; }
}
