:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #24292f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #7c5cff;
  --accent-soft: #efeaff;
  --code-bg: #f3f4f6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.75;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); display: flex; gap: 8px; align-items: center; }
.topnav { display: flex; gap: 16px; font-size: 14px; margin-left: auto; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--accent); }

.layout { display: flex; max-width: 1180px; margin: 0 auto; align-items: flex-start; }
.sidebar {
  width: 232px; flex: 0 0 232px; padding: 22px 14px;
  position: sticky; top: 57px; max-height: calc(100vh - 57px); overflow-y: auto;
  font-size: 14px;
}
.sidebar a {
  display: block; padding: 5px 10px; border-radius: 6px; color: var(--text);
  margin-bottom: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 12px; color: var(--muted); padding: 0 10px; margin-bottom: 4px; letter-spacing: .04em; }

.content {
  flex: 1 1 auto; min-width: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 30px 34px; margin: 22px 22px 60px; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.content h1 { font-size: 26px; margin-top: 0; }
.content h2 { font-size: 19px; margin-top: 30px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.content h3 { font-size: 16px; margin-top: 22px; }
.content p, .content li { font-size: 15px; }
code {
  background: var(--code-bg); padding: 2px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
}
pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; }
pre code { background: none; color: inherit; padding: 0; }
blockquote {
  margin: 16px 0; padding: 10px 16px; background: var(--accent-soft);
  border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; color: #3f3d56;
}
hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }
.muted { color: var(--muted); font-size: 13px; }
.foot { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: #fafbfc; font-weight: 600; }
table.mods td:nth-child(1) { width: 22%; }
table.mods td:nth-child(2) { width: 12%; white-space: nowrap; }
table.mods td:nth-child(3) { width: 10%; white-space: nowrap; }
table.mods td:nth-child(5) { width: 9%; text-align: center; }

ul.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
ul.chips li {
  background: #f3f4f6; border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 10px; font-size: 13px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 18px 0; }
.card {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  background: #fcfcfd; display: block; color: var(--text);
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card b { display: block; margin-bottom: 4px; }
.card span { color: var(--muted); font-size: 13px; }

.prose { }

/* 配方展示 */
.recipe { display: flex; gap: 18px; align-items: flex-start; padding: 12px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.recipe:last-child { border-bottom: none; }
table.grid { border-collapse: collapse; margin: 0; width: auto; }
table.grid td {
  width: 34px; height: 34px; text-align: center; font-size: 12px; padding: 0;
  border: 1px solid var(--border); background: #fafbfc; color: var(--muted);
}
table.grid td.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-color: #d9d0ff; }
.recipe-side { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.recipe-side .arrow { font-size: 18px; color: var(--muted); }
.recipe-out { font-weight: 700; color: var(--text); }
.legend ul { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.legend li { margin: 2px 0; }
.legend b { color: var(--accent); }
.recipe-line { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.recipe-line:last-child { border-bottom: none; }
.recipe-line .recipe-ing { display: block; color: var(--muted); font-size: 13px; }

.tip .obtain { color: var(--muted); font-size: 13px; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.todo {
  margin: 26px 0 8px; padding: 14px 18px; border-radius: 10px;
  background: #fff8e6; border: 1px solid #f5dfa6; color: #6b4e00;
}
.todo b { display: block; margin-bottom: 6px; }
.todo ul { margin: 0; padding-left: 20px; }

ul.chips li.item { cursor: help; position: relative; border-bottom: 1px dashed var(--accent); }
ul.chips li.item:focus { outline: none; }
ul.chips li.item .tip {
  display: none; position: absolute; left: 0; top: calc(100% + 8px); z-index: 40;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14); padding: 12px 14px;
  min-width: 250px; max-width: 420px; white-space: normal; text-align: left; font-weight: 400;
}
ul.chips li.item:hover .tip,
ul.chips li.item:focus .tip,
ul.chips li.item:focus-within .tip { display: block; }
ul.chips li.item .tip .recipe { border: none; padding: 4px 0; margin: 0; }
ul.chips li.item .tip::after {
  content: ""; position: absolute; top: -6px; left: 18px; width: 10px; height: 10px;
  background: var(--card); border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
details.allrecipes { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 12px; }
details.allrecipes summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; flex: none; max-height: none; }
  .content { margin: 12px; padding: 20px; }
}
