/* Layout in the spirit of LeetCode's problem set and Explore pages:
   - a left sidebar with line icons on wide screens (not in a lesson or the
     playground, which need the full width)
   - pages with a main column and a narrow right column (每日一学, numbers)
   - the problem list: topic chips with counts, category pills, plain rows
   - the course page: dark banner, chapter card on the left, roomy text
   Greys and ink only; colour is kept for status (green = done) and the three
   exercise tiers (teal / amber / red, like easy / medium / hard). */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- sidebar ---------- */
.side { display: none; }
@media (min-width: 1100px) {
  body.has-side { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
  body.has-side > .side {
    display: flex; flex-direction: column; grid-column: 1; grid-row: 1 / span 3; position: sticky; top: 0; height: 100vh; height: 100dvh;
    overflow-y: auto; padding: 16px 12px 14px; border-right: 1px solid var(--border); background: var(--surface); scrollbar-width: thin;
  }
  body.has-side > .topbar { grid-column: 2; grid-row: 1; position: static; height: 60px; padding: 0 28px; background: var(--bg); border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  body.has-side > .topbar .brand, body.has-side > .topbar .nav { display: none; }
  body.has-side > main { grid-column: 2; grid-row: 2; padding-top: 6px; }
  body.has-side > main.flush { padding-top: 0; }
  body.has-side > .footer { grid-column: 2; grid-row: 3; }
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 12px 18px; font-weight: 700; font-size: .98rem; text-decoration: none; letter-spacing: -.01em; }
.side-brand img { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 0 0 1px var(--border); flex: none; }
.side-brand span { min-width: 0; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.side-nav { display: grid; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 8px; text-decoration: none;
  color: var(--text); font-weight: 500; font-size: .95rem; transition: background .12s;
}
.side-link svg.i { width: 19px; height: 19px; flex: none; }
.side-link:hover { background: var(--surface-2); }
.side-link[aria-current="page"] { background: var(--btn); font-weight: 650; }
.side-group { display: grid; gap: 1px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.side-title { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 12px 6px; }
.side-course {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: 8px; text-decoration: none;
  color: var(--text); font-size: .88rem; transition: background .12s;
}
.side-course > span:not(.course-tile) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-course small { color: var(--faint); font-size: .76rem; font-variant-numeric: tabular-nums; }
.side-course:hover { background: var(--surface-2); }
.side-course[aria-current="page"] { background: var(--btn); font-weight: 600; }
.side-empty { margin: 0; padding: 0 12px; font-size: .8rem; color: var(--faint); line-height: 1.5; }
.side-bottom { margin-top: auto; padding-top: 14px; display: grid; gap: 1px; }
.side-bottom .side-link { height: 38px; font-size: .9rem; color: var(--muted); }
.side-bottom .side-link:hover, .side-bottom .side-link[aria-current="page"] { color: var(--text); }

/* ---------- a main column and a right column ---------- */
.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
.col-main { min-width: 0; }
.col-aside { display: grid; gap: 16px; min-width: 0; }
/* below 1280px (or 1100 to 1279 with the sidebar) the main column would get
   too narrow: the right column moves under it, its cards side by side */
@media (max-width: 1279px) {
  .with-aside { grid-template-columns: minmax(0, 1fr); }
  .col-aside { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}
@media (min-width: 1000px) and (max-width: 1099px) {
  .with-aside { grid-template-columns: minmax(0, 1fr) 300px; }
  .col-aside { grid-template-columns: minmax(0, 1fr); }
}
.col-main { container-type: inline-size; }
.col-main > .section:first-child, .col-main > .hero + .section { margin-top: 28px; }
.side-card { padding: 16px 18px; }
.side-card-title { margin: 0 0 8px; font-size: .95rem; font-weight: 650; }
.mini-stat { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: .9rem; color: var(--muted); border-top: 1px solid var(--border); }
.side-card-title + .mini-stat { border-top: 0; }
.mini-stat svg.i { width: 17px; height: 17px; }
.mini-stat b { margin-left: auto; color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.me-top { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .me-top { grid-template-columns: minmax(0, 1fr); } }

/* ---------- problem list ---------- */
.topics { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 16px; }
.topic-row { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 22px; max-height: 32px; overflow: hidden; }
.topics.open .topic-row { max-height: none; }
.topic { display: inline-flex; align-items: center; gap: 7px; height: 32px; font-size: .94rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.topic span { font-size: .74rem; line-height: 20px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums; }
.topic:hover span { background: var(--btn-hover); color: var(--text); }
.topic[aria-current="true"] { font-weight: 650; }
.topic[aria-current="true"] span { background: var(--ink); color: var(--ink-text); }
.topics-more { flex: none; display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: .88rem; cursor: pointer; }
.topics-more:hover { color: var(--text); }
.topics-more svg.i { width: 15px; height: 15px; transition: transform .2s; }
.topics.open .topics-more svg.i { transform: rotate(180deg); }
.cats { display: flex; gap: 10px; flex-wrap: wrap; padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.cat {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--btn);
  color: var(--text); text-decoration: none; font-weight: 550; font-size: .94rem; white-space: nowrap; transition: background .12s;
}
.cat svg.i { width: 18px; height: 18px; }
.cat:hover { background: var(--btn-hover); }
.cat[aria-current="true"] { background: var(--ink); color: var(--ink-text); }
.ptools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.search-pill {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--btn);
  color: var(--muted); flex: 0 1 280px; min-width: 180px; transition: box-shadow .15s;
}
.search-pill svg.i { width: 16px; height: 16px; flex: none; }
.search-pill input { border: 0; background: transparent; padding: 0; height: 100%; font-size: .9rem; min-width: 0; box-shadow: none !important; }
.search-pill:focus-within { box-shadow: 0 0 0 2px var(--border-strong); }
select.pill-select { width: auto; height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background-color: var(--btn); font-size: .88rem; cursor: pointer; }
select.pill-select:hover { background-color: var(--btn-hover); }
.solved-count { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ring.xs { width: 18px; height: 18px; font-size: 0; background: radial-gradient(closest-side, var(--bg) 64%, transparent 68% 100%), conic-gradient(var(--s-green) calc(var(--p) * 1%), var(--surface-3) 0); }
.plist { display: grid; }
.prow {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 210px) 74px; align-items: center; gap: 14px;
  min-height: 46px; padding: 0 14px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .93rem;
}
.plist.with-tags .prow { grid-template-columns: 26px minmax(0, 1fr) minmax(0, 190px) 74px 92px; }
.prow:nth-child(odd) { background: var(--surface-2); }
a.prow:hover { background: var(--surface-3); }
a.prow:hover .prow-title { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.prow-st { width: 22px; height: 22px; display: grid; place-items: center; }
.prow-st svg.i { width: 17px; height: 17px; }
.prow-st.ok { color: var(--s-green); }
.prow-st.ok svg.i { stroke-width: 2.6; }
.prow-st.lock { color: var(--faint); }
.prow-st.lock svg.i { width: 15px; height: 15px; }
.prow-title { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-src { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: .85rem; }
.prow-src > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-tier { color: var(--t); font-size: .88rem; font-weight: 500; white-space: nowrap; }
.prow-tag { display: flex; justify-content: flex-end; }
.prow-tag:empty { display: none; }
.plist.with-tags .prow-tag:empty { display: flex; }
.prow.locked { color: var(--muted); }
.prow.locked .prow-src { color: var(--faint); }
@media (max-width: 700px) {
  .prow, .plist.with-tags .prow { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; padding: 0 10px; }
  .prow-src, .prow-tag { display: none !important; }
  .topic-row { gap: 4px 16px; }
  .cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .cats::-webkit-scrollbar { display: none; }
  .cat { height: 36px; padding: 0 14px; font-size: .9rem; }
}
.solved-big { display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; }
.solved-big .ring { width: 64px; height: 64px; font-size: .78rem; }
.solved-big b { display: block; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.solved-big b small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.tier-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 8px; margin-top: 12px; font-size: .86rem; }
.tier-line > span { color: var(--t); font-weight: 550; }
.tier-line b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tier-line b small { color: var(--faint); font-weight: 500; }
.tier-line .progress { grid-column: 1 / -1; height: 4px; }
.tier-line .progress i { background: var(--t); }

/* ---------- course page, like a LeetCode Explore card ---------- */
main.flush { max-width: none; padding: 0 0 56px; }
.cx-hero { position: relative; overflow: hidden; padding: 24px 32px 104px; color: #F2F2F2; background: linear-gradient(120deg, #2B2B2B, #171717 70%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cx-hero { background: linear-gradient(120deg, #2E2E2E, #212121 70%); border-bottom: 1px solid var(--border); } }
:root[data-theme="dark"] .cx-hero { background: linear-gradient(120deg, #2E2E2E, #212121 70%); border-bottom: 1px solid var(--border); }
.cx-art { position: absolute; right: 7%; top: 50%; width: 280px; height: 280px; color: #FFFFFF; opacity: .07; transform: translateY(-50%) rotate(-10deg); pointer-events: none; }
.cx-hero-in { position: relative; max-width: 1120px; margin: 0 auto; }
.cx-back { display: inline-flex; align-items: center; gap: 4px; color: #C9C9C9; text-decoration: none; font-size: .92rem; }
.cx-back svg.i { width: 16px; height: 16px; }
.cx-back:hover { color: #FFFFFF; }
.cx-title { margin: 30px 0 0 calc(300px + 44px); }
.cx-kicker { color: #B5B5B5; font-size: .95rem; font-weight: 500; }
.cx-title h1 { color: #FFFFFF; font-size: 2.3rem; margin: 6px 0 12px; letter-spacing: -.02em; }
.cx-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: #B5B5B5; font-size: .9rem; }
.cx-meta a { display: inline-flex; align-items: center; gap: 6px; color: #E2E2E2; text-decoration-color: rgba(255, 255, 255, .3); }
.cx-meta a:hover { color: #FFFFFF; text-decoration-color: currentColor; }
.cx-body { position: relative; max-width: calc(1120px + 64px); margin: -72px auto 0; padding: 0 32px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 44px; align-items: start; }
.cx-nav {
  position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--sh-2);
}
.chap {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; padding: 16px 20px; text-align: left; cursor: pointer;
  border: 0; border-top: 1px solid var(--border); background: var(--surface); color: var(--text); transition: background .12s;
}
.chap:first-child { border-top: 0; }
.chap:hover { background: var(--surface-2); }
.chap-txt { min-width: 0; }
.chap-txt b { display: block; font-size: .98rem; font-weight: 600; line-height: 1.35; }
.chap-txt small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.chap > svg.i { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.chap-st { width: 22px; height: 22px; flex: none; margin-top: 1px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; }
.chap-st.part { border: 0; background: radial-gradient(closest-side, var(--surface) 66%, transparent 70% 100%), conic-gradient(var(--s-green) calc(var(--p) * 1%), var(--border-strong) 0); }
.chap-st.done { border: 0; background: var(--s-green); color: var(--surface); }
.chap-st.done svg.i { width: 13px; height: 13px; stroke-width: 3; }
.chap[aria-current] { background: var(--ink); color: var(--ink-text); }
.chap[aria-current] small { color: color-mix(in srgb, var(--ink-text) 68%, transparent); }
.chap[aria-current] .chap-st:not(.done) { border-color: color-mix(in srgb, var(--ink-text) 45%, transparent); }
.chap[aria-current] .chap-st.part { background: radial-gradient(closest-side, var(--ink) 66%, transparent 70% 100%), conic-gradient(var(--s-green) calc(var(--p) * 1%), color-mix(in srgb, var(--ink-text) 35%, transparent) 0); }
/* dark: the chapter in view is a raised grey, not a white block */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chap[aria-current] { background: var(--surface-3); color: var(--text); box-shadow: inset 3px 0 0 var(--text); }
  :root:not([data-theme="light"]) .chap[aria-current] small { color: var(--muted); }
  :root:not([data-theme="light"]) .chap[aria-current] .chap-st:not(.done) { border-color: var(--border-strong); }
  :root:not([data-theme="light"]) .chap[aria-current] .chap-st.part { background: radial-gradient(closest-side, var(--surface-3) 66%, transparent 70% 100%), conic-gradient(var(--s-green) calc(var(--p) * 1%), var(--border-strong) 0); }
}
:root[data-theme="dark"] .chap[aria-current] { background: var(--surface-3); color: var(--text); box-shadow: inset 3px 0 0 var(--text); }
:root[data-theme="dark"] .chap[aria-current] small { color: var(--muted); }
:root[data-theme="dark"] .chap[aria-current] .chap-st:not(.done) { border-color: var(--border-strong); }
:root[data-theme="dark"] .chap[aria-current] .chap-st.part { background: radial-gradient(closest-side, var(--surface-3) 66%, transparent 70% 100%), conic-gradient(var(--s-green) calc(var(--p) * 1%), var(--border-strong) 0); }
.cx-article { padding-top: 100px; min-width: 0; }
.chapter { padding: 4px 0 30px; scroll-margin-top: 76px; }
.chapter + .chapter { border-top: 1px solid var(--border); padding-top: 30px; }
.chapter h2 { font-size: 1.75rem; font-weight: 700; margin: 6px 0 10px; letter-spacing: -.015em; }
.chapter-kicker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; font-weight: 550; }
.chapter-kicker > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.chapter-goal { color: var(--muted); font-size: 1.04rem; line-height: 1.8; margin: 0 0 16px; }
.cx-lead { color: var(--muted); font-size: 1.12rem; line-height: 1.85; margin: 0 0 14px; max-width: 760px; }
.cx-progress { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 18px; margin: 22px 0 12px; border: 1px solid var(--border); border-radius: 12px; }
.cx-article .free-note { font-size: .85rem; }
.lessons { border-top: 1px solid var(--border); }
.lessons .list-row { padding: 14px 6px; min-height: 60px; }
.lessons .list-row:first-child { border-top: 0; }
.lessons .list-row .title { font-size: .98rem; }
.lessons .list-row .title small { font-size: .85rem; margin-top: 1px; }
@media (max-width: 1000px) {
  .cx-hero { padding: 18px 20px 90px; }
  .cx-title { margin: 22px 0 0; }
  .cx-title h1 { font-size: 1.8rem; }
  .cx-art { width: 200px; height: 200px; right: -20px; }
  .cx-body { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 0 16px; margin-top: -64px; }
  .cx-nav { position: static; max-height: none; }
  .chap { padding: 12px 16px; gap: 12px; }
  .chap-txt small { -webkit-line-clamp: 1; }
  .cx-article { padding-top: 0; }
  .chapter h2 { font-size: 1.45rem; }
}

/* ---------- lesson text: a little more room, like an article ---------- */
@media (min-width: 961px) {
  .lesson .pane-body { padding: 24px 30px 36px; }
}
.lesson .pane-body .md p, .lesson .pane-body > p { line-height: 1.75; }
.lesson .pane-body > h2 { font-size: 1.4rem; letter-spacing: -.01em; }
