:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2a2620;
  --muted: #8a8278;
  --line: #ece6dc;
  --accent: #d97706;
  --accent-soft: #fde8c8;
  --green: #10b981;
  --green-soft: #d1fae5;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --gray: #9ca3af;
  --gray-soft: #f3f4f6;
  --red: #ef4444;
  --purple: #8b5cf6;
  --purple-soft: #ede9fe;
  --yellow-soft: #fef3c7;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

/* ---------- Header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 32px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg); position: sticky; top: 0; z-index: 10;
}
.title h1 { margin: 0; font-size: 20px; display: inline-block; }
.title .sub { color: var(--muted); font-size: 12px; margin-left: 10px; }
.actions { display: flex; gap: 8px; align-items: center; }
input, select, button, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button { cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; }
button.tiny { padding: 4px 8px; font-size: 12px; }

/* ---------- Dashboard ---------- */
#dashboard {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
  padding: 18px 32px; align-items: stretch;
}
.stat-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 12px; text-align: center;
}
.stat-num { font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

.activity-feed {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; max-height: 180px; display: flex; flex-direction: column;
}
.activity-feed h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.activity-feed ul { margin: 0; padding: 0; list-style: none; overflow-y: auto; flex: 1; }
.activity-feed li { font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.activity-feed li:last-child { border: none; }
.activity-feed .ap { color: var(--accent); font-weight: 600; cursor: pointer; }
.activity-feed .ad { color: var(--muted); white-space: nowrap; }
.feed-foot { margin-top: 6px; font-size: 11px; color: var(--muted); }
.feed-foot code { background: var(--gray-soft); padding: 1px 6px; border-radius: 4px; font-size: 11px; }

/* ---------- Cards Grid ---------- */
main {
  display: grid; gap: 14px; padding: 8px 32px 32px;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; cursor: pointer; transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column; gap: 12px; min-height: 280px;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-name { font-size: 17px; font-weight: 600; }
.card-tag { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge.s-构思 { background: var(--gray-soft); color: #374151; }
.badge.s-开发中 { background: var(--blue-soft); color: #1e40af; }
.badge.s-上线 { background: var(--green-soft); color: #065f46; }
.badge.s-运营中 { background: var(--purple-soft); color: #5b21b6; }
.badge.s-暂停 { background: var(--yellow-soft); color: #92400e; }
.badge.s-归档 { background: var(--gray-soft); color: #6b7280; }

.feat-badge {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.feat-badge.shipped { background: var(--green-soft); color: #065f46; }
.feat-badge.in-dev { background: var(--blue-soft); color: #1e40af; }
.feat-badge.planned { background: var(--gray-soft); color: #6b7280; }
.feat-badge.sunset  { background: #fee2e2; color: #991b1b; }

/* progress */
.progress { background: var(--gray-soft); border-radius: 999px; height: 8px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; transition: width .3s; }
.progress > .ship { background: var(--green); }
.progress > .dev  { background: var(--blue); }
.progress-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.progress-row .progress { flex: 1; }

/* entry button */
.entry-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent); padding: 6px 10px;
  border-radius: 8px; font-size: 12px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.entry-btn:hover { background: var(--accent); color: #fff; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 2px 7px; background: #f5efe5; border-radius: 6px; color: #6b5d49; font-size: 11px; }
.chip.tech { background: #eef4ff; color: #1e3a8a; }
.chip.tag { background: #fef3c7; color: #78350f; }

.card-features {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px;
  padding: 8px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
}
.card-features .fline { display: flex; gap: 6px; align-items: center; }
.card-features .fline .fname { flex: 1; }
.card-features .more { color: var(--muted); font-size: 11px; }

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

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 100; }
.drawer.hidden { display: none; }
.drawer-inner {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(780px, 100%);
  background: var(--bg); overflow-y: auto; box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 24px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.drawer-head h2 { margin: 0; font-size: 20px; }
.drawer-head .muted { color: var(--muted); font-size: 13px; margin-top: 4px; }
.drawer-head button { font-size: 22px; background: none; border: none; }
.tabs {
  display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 80px; background: var(--bg); z-index: 1; overflow-x: auto;
}
.tab { padding: 10px 14px; border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

#dBody { padding: 18px 24px 60px; display: flex; flex-direction: column; gap: 16px; }
.section { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.section h3 { margin: 0 0 10px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 8px; }
.section h3 .count { background: var(--gray-soft); color: var(--ink); padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.section .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 8px 12px; align-items: center; }
.kv label { color: var(--muted); font-size: 12px; }
.kv input, .kv select, .kv textarea { width: 100%; }

.list-item {
  border-top: 1px dashed var(--line); padding: 10px 0;
  display: flex; justify-content: space-between; gap: 10px; font-size: 13px;
}
.list-item:first-child { border-top: none; }
.list-item .date { color: var(--muted); font-size: 11px; white-space: nowrap; }
.list-item .left { flex: 1; min-width: 0; }
.list-item .desc { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* feature item */
.feat-item {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px;
  align-items: center; padding: 8px 0; border-top: 1px dashed var(--line);
}
.feat-item:first-child { border-top: none; }
.feat-item .fname { font-weight: 500; }
.feat-item .fdesc { color: var(--muted); font-size: 12px; }
.feat-item select { font-size: 11px; padding: 3px 6px; }
.feat-item .del { background: none; border: none; color: var(--red); cursor: pointer; font-size: 16px; }

/* entry item */
.entry-item {
  display: flex; gap: 8px; align-items: center; padding: 8px 0;
  border-top: 1px dashed var(--line);
}
.entry-item:first-child { border-top: none; }
.entry-item .etype { background: var(--gray-soft); padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.entry-item .elabel { flex: 1; }
.entry-item .eurl { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; }
.entry-item.primary { background: var(--accent-soft); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: 8px; border-top: none; }

/* learning */
.learning-item {
  display: flex; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line);
  font-size: 13px; align-items: flex-start;
}
.learning-item:first-child { border-top: none; }
.learning-item .lcat {
  font-size: 10px; padding: 2px 6px; border-radius: 4px; white-space: nowrap;
  background: var(--gray-soft); color: var(--ink);
}
.learning-item .lcat.tech { background: var(--blue-soft); color: #1e40af; }
.learning-item .lcat.product { background: var(--accent-soft); color: var(--accent); }
.learning-item .lcat.ops { background: var(--purple-soft); color: #5b21b6; }

.danger { color: var(--red); }
.muted { color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 200;
  display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-inner { background: #fff; padding: 24px; border-radius: 14px; width: min(460px, 92vw); }
.modal-inner h2 { margin: 0 0 14px; font-size: 18px; }
#newForm { display: flex; flex-direction: column; gap: 10px; }
#newForm label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#newForm input, #newForm select { width: 100%; }
#newForm .row { flex-direction: row; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 900px) {
  #dashboard { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  header { flex-direction: column; gap: 10px; align-items: stretch; }
  .actions { flex-wrap: wrap; }
}
