:root {
  --ink: #242424;
  --muted: #6b6b6b;
  --paper: #ffffff;
  --surface: #f7f7f5;
  --line: #e6e6e6;
  --accent: #1a8917;
  --accent-soft: #e8f4e7;
  --chip: #f0f0ee;
  --hw: #316fd0;
  --soc: #8164c6;
  --crypto: #c47a12;
  --chain: #4b9c6c;
  --nvm: #c2417a;
  --cim: #0f8a9c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8e8e6;
    --muted: #9a9a96;
    --paper: #161716;
    --surface: #1f201f;
    --line: #2e302e;
    --accent: #5cc458;
    --accent-soft: #1d2e1c;
    --chip: #262826;
    --hw: #6f9ff0;
    --soc: #a68de0;
    --crypto: #e3a24a;
    --chain: #74c495;
    --nvm: #e87aa8;
    --cim: #4cc3d4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e8e8e6; --muted: #9a9a96; --paper: #161716; --surface: #1f201f; --line: #2e302e;
  --accent: #5cc458; --accent-soft: #1d2e1c; --chip: #262826;
  --hw: #6f9ff0; --soc: #a68de0; --crypto: #e3a24a; --chain: #74c495; --nvm: #e87aa8; --cim: #4cc3d4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 "Noto Sans TC", "Segoe UI", system-ui, -apple-system, sans-serif;
}
a { color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: #fff; font-size: 13px;
}
.search { flex: 1; max-width: 520px; }
.search input {
  width: 100%; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang {
  margin-left: auto; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang:hover { background: var(--surface); }
.academy-link { margin-left: 4px; color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 230px 1fr; gap: 28px; padding: 20px; max-width: 1500px; margin: 0 auto; }

.side { position: sticky; top: 70px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; }
.side button {
  display: flex; justify-content: space-between; gap: 8px; width: 100%;
  padding: 5px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.side button:hover { background: var(--surface); }
.side button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.side .topic { margin-top: 14px; font-weight: 700; }
.side .topic span:first-child { display: flex; align-items: center; }
.side .topic span:first-child::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; background: var(--c, var(--accent)); }
.side .sub { padding-left: 26px; font-size: 14px; }

.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.count { margin: 0; color: var(--muted); }
.controls { display: flex; gap: 14px; flex-wrap: wrap; }
.controls label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.controls select {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit;
}

.learn {
  margin-bottom: 18px; padding: 12px 16px;
  border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
  background: var(--surface);
}
.learn h2 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.learn ul { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; }
.learn a { color: var(--accent); text-decoration: none; font-weight: 500; }
.learn a:hover { text-decoration: underline; }

.featured {
  margin-bottom: 26px; padding: 14px 16px 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
}
.featured h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--nvm); letter-spacing: .02em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px 18px; }
.card { min-width: 0; }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.thumb:hover img { transform: scale(1.03); }
.dur {
  position: absolute; right: 6px; bottom: 6px;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(0, 0, 0, .8); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.card h3 { margin: 8px 0 2px; font-size: 15px; line-height: 1.35; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.by { margin: 0; color: var(--muted); font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  padding: 1px 8px; border: 0; border-radius: 999px;
  background: var(--chip); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer;
  border-left: 3px solid var(--c, var(--accent));
}
.tag:hover { background: var(--accent-soft); }
.sum { margin-top: 6px; font-size: 13px; }
.sum summary { cursor: pointer; color: var(--muted); font-weight: 600; width: fit-content; }
.sum summary:hover { color: var(--accent); }
.sum p { margin: 6px 0 4px; line-height: 1.5; }
.sum ul { margin: 0; padding-left: 18px; color: var(--muted); }
.sum li { margin: 2px 0; }
.lesson { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--accent); text-decoration: none; }
.lesson:hover { text-decoration: underline; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.more {
  display: block; margin: 28px auto; padding: 9px 26px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.more:hover { background: var(--surface); }
[hidden] { display: none !important; }
.foot { padding: 24px 20px 40px; color: var(--muted); font-size: 13px; text-align: center; border-top: 1px solid var(--line); }

.skeleton .thumb { animation: pulse 1.2s infinite alternate; }
@keyframes pulse { to { opacity: .5; } }

@media (max-width: 820px) {
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 12px 16px; }
  .side {
    position: static; max-height: none;
    display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px;
    scrollbar-width: none;
  }
  .side button { width: auto; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
  .side .topic { margin-top: 0; }
  .side .sub { padding-left: 12px; }
  .side .sub:not(.show) { display: none; }
  .grid { grid-template-columns: 1fr; gap: 20px; }
}
