/* Page content: a centred Notion-style page, then home, topic and all-problems specifics. */

.page { width: 100%; max-width: 900px; margin: 0 auto; padding: clamp(28px, 6vw, 72px) clamp(16px, 5vw, 48px) 40px; }
.page-wide { max-width: 1040px; }
.page > * + * { margin-top: 0; }

.page-icon { display: inline-block; margin-right: 0.35em; font-size: 0.88em; vertical-align: -0.06em; }

.lede { max-width: 62ch; margin-top: 12px; color: var(--muted); font-size: 1.0625rem; }
.section { margin-top: 44px; }
.section > h2 + * { margin-top: 12px; }
.section > h3 { margin-top: 24px; }
.section > h3 + * { margin-top: 8px; }
.muted { color: var(--muted); }

/* Notion "page properties" */
.props { display: grid; gap: 2px; margin-top: 20px; font-size: 0.875rem; }
.prop { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 32px; }
.prop-k { color: var(--muted); }
.prop-v { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
.prop-v .track { width: 120px; }
.prop-v .num { font-variant-numeric: tabular-nums; }
.link-btn { padding: 2px 8px; margin-left: -8px; background: none; border: 0; border-radius: var(--radius); color: var(--accent); font-size: 0.875rem; }
.link-btn:hover { background: var(--accent-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

/* ---------- home ---------- */
.loop { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px 32px; }
.loop h3 { margin-bottom: 4px; font-size: 1rem; }
.loop p { color: var(--muted); font-size: 0.9375rem; }
.calm { margin-top: 20px; padding: 14px 16px; background: var(--bg-soft); border-radius: var(--radius); color: var(--muted); font-size: 0.9375rem; }

.pick { border: 1px solid var(--line); border-radius: var(--radius); }
.pick div { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 4px 20px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 0.9375rem; }
.pick div:first-child { border-top: 0; }
.pick dt { color: var(--muted); }
.pick dd { margin: 0; font-weight: 500; }
.pick dd a { text-decoration: none; }
.pick dd a:hover { text-decoration: underline; }
@media (max-width: 560px) { .pick div { grid-template-columns: 1fr; } }

.tile-label { margin-top: 20px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 8px; }
.tile {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.tile:hover, .tile:focus-visible {
  background: var(--bg-hover);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.tile b { font-weight: 600; }
.tile span { color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.tile .track { margin-top: 8px; }

/* icon + title row; needs (0,2,0) specificity to beat the ".tile span" rule above */
.tile .tile-top { display: flex; align-items: center; gap: 7px; color: var(--ink); }
.tile .tile-top .ico { flex: 0 0 auto; font-size: 1.05rem; line-height: 1; transition: transform 0.15s ease; }
.tile:hover .tile-top .ico { transform: scale(1.12) rotate(-4deg); }

/* a one-line teaser that reveals on hover, like Notion's page-preview hover card */
.tile-desc {
  margin: 0;
  max-height: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.22s ease, opacity 0.18s ease, margin-top 0.22s ease;
}
.tile:hover .tile-desc, .tile:focus-visible .tile-desc {
  max-height: 3.6em;
  margin-top: 2px;
  opacity: 1;
}

/* ---------- theory ---------- */
.theory, .watch { padding-left: 1.4em; display: grid; gap: 10px; list-style: disc; }
.theory li::marker, .watch li::marker { color: var(--faint); }
.theory strong { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.chips li { padding: 0 6px; background: var(--tag-gray-bg); color: var(--tag-gray-fg); border-radius: 3px; font-size: 0.75rem; line-height: 20px; }
.callout { margin-top: 14px; padding: 12px 16px; background: var(--bg-soft); border-radius: var(--radius); color: var(--muted); font-size: 0.9375rem; }
.watch { color: var(--muted); font-size: 0.9375rem; }

/* ---------- code ---------- */
.code { background: var(--bg-soft); border-radius: var(--radius); overflow: hidden; }
.code + .code { margin-top: 12px; }
.code figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 0 16px; font-size: 0.75rem; color: var(--muted); }
.code figcaption small { font-size: inherit; }
.copy { padding: 2px 8px; background: none; border: 0; border-radius: var(--radius); font-size: 0.75rem; color: var(--muted); }
.copy:hover { background: var(--bg-hover); color: var(--ink); }
.code pre { margin: 0; padding: 8px 16px 16px; overflow-x: auto; font: 0.8125rem / 1.65 var(--font-mono); tab-size: 2; }
.code pre code { padding: 0; background: none; color: var(--ink); border-radius: 0; font: inherit; }
.k { color: var(--syn-kw); }
.s { color: var(--syn-str); }
.c { color: var(--syn-com); }
.n { color: var(--syn-num); }

/* ---------- problems (a Notion-style table) ---------- */
.grp { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 20px 0 6px; font-size: 1.0625rem; }
.grp span { font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.plist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.prob { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 6px; border-bottom: 1px solid var(--line); }
.prob:hover { background: var(--bg-hover); }
.prob input[type="checkbox"] { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); cursor: pointer; }
.pnum { display: inline-block; min-width: 1.9em; font: 0.75rem var(--font-mono); color: var(--faint); }
.pname { font-weight: 500; cursor: pointer; }
.hint { margin-top: 1px; padding-left: 1.9em; color: var(--muted); font-size: 0.875rem; }
.ptags { display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; justify-content: flex-end; gap: 4px 6px; max-width: 230px; padding-top: 1px; }
.prob.done .pname { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.note {
  width: 100%;
  margin: 8px 0 0 1.9em;
  max-width: calc(100% - 1.9em);
  padding: 5px 9px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.note:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note::placeholder { color: var(--faint); }
.after { margin-top: 16px; color: var(--muted); font-size: 0.9375rem; }
@media (max-width: 620px) {
  .prob { grid-template-columns: 22px minmax(0, 1fr); }
  .ptags { grid-column: 2; justify-content: flex-start; max-width: none; padding-left: 1.9em; margin-top: 2px; }
}

/* ---------- all problems ---------- */
.filters {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
@media (max-width: 720px) { .filters { position: static; } }   /* it wraps to ~170px on a phone: too much to pin */
.filters input[type="search"], .filters select {
  padding: 5px 9px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.filters input[type="search"] { flex: 1 1 220px; min-width: 0; }
.filters input:focus, .filters select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { padding: 5px 10px; background: none; border: 0; border-left: 1px solid var(--line); font-size: 0.8125rem; color: var(--muted); }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--bg-hover); }
.seg button[aria-pressed="true"] { background: var(--bg-active); color: var(--ink); font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.f-count { margin-left: auto; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.grp-block { margin-top: 28px; }
.grp-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; font-size: 1.125rem; }
.grp-h a { text-decoration: none; }
.grp-h a:hover { text-decoration: underline; }
.grp-h span { font-size: 0.8125rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { margin-top: 40px; color: var(--muted); text-align: center; }
.no-hints .hint { display: none; }

/* ---------- previous / next topic ---------- */
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }
.pager a { display: grid; gap: 0; min-width: 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }
.pager a:hover { background: var(--bg-hover); }
.pager small { font-size: 0.75rem; color: var(--muted); }
.pager .next { margin-left: auto; text-align: right; }

/* ---------- home: progress card and revisit list ---------- */
.progress-card { margin-top: 28px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 8px; }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; }
.pc-head h2 { font-size: 1rem; font-weight: 600; letter-spacing: 0; }
.pc-pct { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.pc-nums { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.pc-big { font-size: 2.5rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pc-of { color: var(--muted); }
.stack { display: flex; height: 10px; margin-top: 14px; background: var(--line-strong); border-radius: 5px; overflow: hidden; }
.pseg { display: block; height: 100%; width: 0; transition: width 0.3s ease; }
.pseg-e { background: var(--c-easy); }
.pseg-m { background: var(--c-med); }
.pseg-h { background: var(--c-hard); }
.pc-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 12px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.875rem; }
.pc-legend b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
.dot-e { background: var(--c-easy); }
.dot-m { background: var(--c-med); }
.dot-h { background: var(--c-hard); }
.btn:disabled { opacity: 0.6; cursor: default; }
.revisit-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.link-row { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 6px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.link-row:hover { background: var(--bg-hover); }

/* ---------- problem rows: LeetCode link, revisit star, current row ---------- */
.pline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.pactions { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; opacity: 0; transition: opacity 0.12s; }
.prob:hover .pactions, .prob:focus-within .pactions, .prob.is-current .pactions, .prob.revisit .pactions { opacity: 1; }
@media (hover: none) { .pactions { opacity: 1; } }
.lc { padding: 1px 6px; border-radius: 4px; color: var(--muted); font-size: 0.75rem; text-decoration: none; white-space: nowrap; }
.lc:hover { background: var(--accent-soft); color: var(--accent); }
.star { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; background: none; border: 0; border-radius: 4px; color: var(--faint); }
.star:hover { background: var(--bg-hover); color: var(--ink); }
.star svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.star[aria-pressed="true"] { color: #dfab01; }
.star[aria-pressed="true"] svg { fill: currentColor; }
.tag-premium { background: var(--tag-brown-bg); color: var(--tag-brown-fg); }

.prob { scroll-margin-block: calc(var(--topbar-h) + 90px) 24px; }
.pname { transition: color 0.15s; }
.prob input[type="checkbox"] { transition: transform 0.1s; }
.prob input[type="checkbox"]:active { transform: scale(0.88); }
.prob.is-current { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.prob.flash { animation: row-flash 1.4s ease-out; }
@keyframes row-flash { 0%, 35% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ---------- topic page: on-this-page outline (wide screens only) ---------- */
.topic-shell { display: block; }
.outline { display: none; }
@container (min-width: 1180px) {
  .topic-shell { display: grid; grid-template-columns: minmax(0, 900px) 200px; justify-content: center; column-gap: 24px; }
  .outline {
    display: block;
    position: sticky;
    top: calc(var(--topbar-h) + 72px);
    align-self: start;
    margin-top: calc(clamp(28px, 6vw, 72px) + 64px);
  }
  .outline p { margin-bottom: 6px; color: var(--faint); font-size: 0.75rem; font-weight: 600; }
  .outline button { display: block; width: 100%; padding: 4px 10px; background: none; border: 0; border-left: 2px solid var(--line); color: var(--muted); font-size: 0.8125rem; text-align: left; }
  .outline button:hover { color: var(--ink); }
  .outline button[aria-current="true"] { border-left-color: var(--accent); color: var(--ink); font-weight: 500; }
}

/* On a narrow screen the LeetCode link and star wrap onto their own line; keep them visible so the row has no blank gap. */
@media (max-width: 620px) { .pactions { opacity: 1; } }

/* The "ask the assistant" button on each problem row shares the row's other quick actions. */
.ask { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; background: none; border: 0; border-radius: 4px; color: var(--faint); }
.ask:hover { background: var(--accent-soft); color: var(--accent); }
.ask svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
