:root {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-card: #1c2330;
  --border: #2b3442;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #4da3ff;
  --accent2: #7ee787;
  --warn: #ffb454;
  --diff1: #7ee787; --diff2: #4da3ff; --diff3: #ffb454; --diff4: #ff7b72; --diff5: #d2a8ff;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.65;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* header */
.site-header { background: linear-gradient(135deg, #101826 0%, #0d1117 100%); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #1f6feb, #388bfd); font-weight: 800; font-size: 18px; letter-spacing: 1px; }
.brand h1 { font-size: 20px; }
.tagline { color: var(--text-dim); font-size: 13px; }
.tabs { display: flex; gap: 6px; }
.tab { background: transparent; border: 1px solid var(--border); color: var(--text-dim); padding: 8px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; transition: .15s; }
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }

/* views */
.view { display: none; padding: 26px 0 60px; }
.view.active { display: block; }

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .num { font-size: 30px; font-weight: 800; color: var(--accent2); }
.stat-card .label { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.stat-card .bar { margin-top: 10px; height: 6px; background: #0d1117; border-radius: 3px; overflow: hidden; }
.stat-card .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px; }
.panel h2 { margin-bottom: 12px; font-size: 18px; }
.howto { padding-left: 22px; display: grid; gap: 8px; }
.note { margin-top: 14px; color: var(--text-dim); font-size: 13px; }

/* toolbar */
.toolbar { display: grid; gap: 12px; margin-bottom: 20px; }
#search { width: 100%; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-panel); color: var(--text); font-size: 15px; outline: none; }
#search:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-dim); padding: 5px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; transition: .15s; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }

/* problem cards */
.problem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.p-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; cursor: pointer; transition: .15s; display: flex; flex-direction: column; gap: 8px; }
.p-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.p-head { display: flex; align-items: center; gap: 10px; }
.p-id { font-weight: 800; color: var(--accent); font-family: ui-monospace, monospace; }
.p-score { margin-left: auto; font-size: 12px; color: #06101f; background: var(--warn); border-radius: 6px; padding: 1px 8px; font-weight: 700; }
.p-title { font-size: 15px; font-weight: 600; }
.p-title .zh { color: var(--text-dim); font-weight: 400; font-size: 13px; margin-left: 8px; }
.p-summary { color: var(--text-dim); font-size: 13px; flex: 1; }
.p-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; background: #0d1420; border: 1px solid var(--border); border-radius: 5px; padding: 1px 8px; color: var(--text-dim); }
.diff { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 5px; }
.d1 { color: var(--diff1); } .d2 { color: var(--diff2); } .d3 { color: var(--diff3); } .d4 { color: var(--diff4); } .d5 { color: var(--diff5); }
.result-count { color: var(--text-dim); font-size: 13px; margin-bottom: 12px; }

/* plan */
.week { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.week-head { padding: 16px 22px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--border); background: #131a26; }
.week-head h3 { font-size: 16px; }
.week-head .goal { margin-left: auto; color: var(--text-dim); font-size: 13px; }
.week-body { padding: 14px 22px 18px; display: grid; gap: 8px; }
.plan-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; background: var(--bg-card); border: 1px solid transparent; }
.plan-item:hover { border-color: var(--accent); }
.plan-item .pid { font-family: ui-monospace, monospace; color: var(--accent); font-weight: 700; cursor: pointer; min-width: 44px; }
.plan-item .pt { flex: 1; font-size: 14px; }

/* articles */
.article-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.article-nav { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; position: sticky; top: 96px; }
.article-nav .an-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text-dim); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.article-nav .an-item:hover { color: var(--text); background: #1c2330; }
.article-nav .an-item.active { color: var(--accent); background: #1c2330; font-weight: 600; }
.article-body { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 34px; min-height: 400px; }
.article-body h1 { font-size: 24px; margin-bottom: 6px; }
.article-body h2 { font-size: 19px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 16px; margin: 18px 0 8px; color: var(--accent2); }
.article-body p { margin: 8px 0; }
.article-body ul, .article-body ol { padding-left: 24px; margin: 8px 0; }
.article-body li { margin: 4px 0; }
.article-body code { background: #0d1420; border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-family: ui-monospace, monospace; font-size: 13px; color: var(--accent2); }
.article-body pre { background: #0d1420; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 12px 0; }
.article-body pre code { background: none; border: none; padding: 0; color: #c9d1d9; display: block; line-height: 1.55; }
.article-body table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.article-body th { background: #131a26; }
.article-body blockquote { border-left: 3px solid var(--accent); background: #131a26; margin: 12px 0; padding: 10px 16px; color: var(--text-dim); border-radius: 0 8px 8px 0; }
.placeholder { color: var(--text-dim); }

/* modal */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(4,8,15,.72); z-index: 100; padding: 30px 16px; overflow-y: auto; }
.modal-mask.open { display: block; }
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; max-width: 900px; margin: 0 auto; position: relative; padding: 30px 36px; }
.modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: var(--text-dim); font-size: 26px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal h2 { font-size: 21px; margin-bottom: 2px; }
.modal .sub { color: var(--text-dim); margin-bottom: 16px; font-size: 13px; }
.modal h4 { margin: 18px 0 8px; color: var(--accent); font-size: 15px; }
.modal ol, .modal ul { padding-left: 22px; }
.modal li { margin: 4px 0; }
.modal .code-head { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; margin-bottom: 8px; }
.copy-btn { background: var(--accent); color: #06101f; border: none; border-radius: 7px; padding: 5px 14px; font-size: 13px; cursor: pointer; font-weight: 600; }
.copy-btn:hover { filter: brightness(1.1); }
.modal pre { background: #0d1420; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; }
.modal pre code { font-family: ui-monospace, monospace; font-size: 13px; color: #c9d1d9; display: block; line-height: 1.55; background: none; }

footer.site-footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--text-dim); font-size: 13px; text-align: center; }

@media (max-width: 760px) {
  .article-layout { grid-template-columns: 1fr; }
  .article-nav { position: static; }
  .modal { padding: 22px 18px; }
}
