/* styles.css: 全站共用的版面與主題設定，若要調整配色、排版或動畫可在此修改 */
:root {
  --bg: #f9fafb;
  --text: #1f2933;
  --muted: #5f6c7b;
  --primary: #1d4ed8;
  --primary-soft: rgba(29, 78, 216, 0.1);
  --card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  --transition: 200ms ease;
}

body.dark-mode {
  --bg: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --primary-soft: rgba(96, 165, 250, 0.1);
  --card: #111827;
  --border: #1f2937;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', 'Noto Sans TC', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: #0b57d0;
}

header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.dark-mode header {
  background: rgba(17, 24, 39, 0.85);
}

.navbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  margin-right: 8px;
}

.brand:hover {
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.nav-links a {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
}

.nav-links a:hover, .nav-links a.active {
  background: var(--primary-soft);
  border-color: var(--border);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-action-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
}

.nav-action-link:hover {
  background: var(--primary-soft);
  border-color: var(--border);
  color: var(--text);
}


.toggle-btn, .menu-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}

.toggle-btn {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 6px;
  gap: 0;
}

.toggle-btn:hover {
  background: var(--primary-soft);
  box-shadow: none;
}

.toggle-btn #theme-icon {
  font-size: 18px;
  line-height: 1;
}

.icon-btn {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--primary-soft);
}

.menu-btn {
  display: none;
}

main {
  max-width: 960px;
  margin: 40px auto 60px;
  padding: 0 20px;
  opacity: 0;
  animation: fade-in 0.6s ease forwards;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero {
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero.hero-cover {
  position: relative;
  top: auto;
  z-index: 0;
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  overflow: hidden;
  color: #f8fafc;
  background: transparent;
  border: none;
  backdrop-filter: none;
}

.hero.hero-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 24, 0.72);
  z-index: 1;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 1.6s ease;
  z-index: 0;
}

.hero-bg.is-active {
  opacity: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 720px;
  text-align: left;
  background: rgba(8, 12, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 22px 26px;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.hero-eyebrow {
  font-size: 14px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.85);
  margin: 0 0 12px;
}

.hero-title {
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  font-weight: 800;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.hero-subtitle {
  font-size: 1.05rem;
  margin: 0;
  color: rgba(248, 250, 252, 0.9);
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.hero-scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.6);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: float-hint 2.4s ease-in-out infinite;
}

@keyframes float-hint {
  0%, 100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, -6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-scroll-hint {
    animation: none;
  }

  .hero-bg {
    transition: none;
  }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  min-height: 72px;
}

.page-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 28px;
  margin: 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.search-bar {
  margin: 14px 0 22px;
}

.search-input {
  width: min(100%, 420px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 15px;
}

.search-input::placeholder {
  color: var(--muted);
}

.card-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.category-meta-row {
  font-size: 14px;
  color: var(--muted);
}

.category-link {
  font-size: 14px;
  color: var(--primary);
}

.category-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.page-header .back-button {
  position: relative;
  top: 0;
}

.back-button:hover {
  transform: translateY(-1px);
  border-color: var(--primary-soft);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.12);
}

.category-listing {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.related-section {
  margin-top: 22px;
}

.related-section .section-title {
  font-size: 18px;
  margin: 18px 0 10px;
  letter-spacing: -0.01em;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.pager-btn,
.pager-page,
.pager-ellipsis {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 0 12px;
  min-width: 44px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 600;
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager-page.active {
  background: #e5e7eb;
  color: var(--text);
  border-color: #d1d5db;
}

.pager-ellipsis {
  font-weight: 700;
}

.pager-input {
  width: 64px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  height: 40px;
  text-align: center;
  background: var(--card);
  color: var(--text);
}

.pager-icon {
  width: 18px;
  height: 18px;
}

.category-article {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.category-article-date {
  font-size: 14px;
  color: var(--muted);
  min-width: 90px;
}

.category-article a {
  color: var(--text);
  font-weight: 600;
}

.category-article a:hover {
  color: var(--primary);
}

/* 搜尋列：搜尋框 + 排序控制同一排 */
.search-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.search-row input{
  flex: 1;
}

/* 排序控制（右側） */
.sort-controls{
  display:flex;
  align-items:center;
  gap:8px;
}

/* 圓角 icon 按鈕：外觀像你圖二那種「獨立小方塊按鈕」 */
.sort-dir-btn{
  width:38px;
  height:38px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color: var(--text);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:all .15s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.sort-dir-btn:hover{
  background: rgba(0,0,0,0.04);
}

/* SVG 尺寸（小箭頭） */
.sort-icon{
  width:18px;
  height:18px;
  color:currentColor;
}

/* 文字按鈕（依照時間/依照字母） */
.sort-mode-btn{
  height:38px;
  padding:0 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color: var(--text);
  cursor:pointer;
  transition:all .15s ease;
  white-space:nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.sort-mode-btn:hover{
  background: rgba(0,0,0,0.04);
}

.showing-count{
  margin-top: 10px;
  margin-left: 16px;
}

.contest-photo {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 24px 0 34px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-soft);
}

.card .label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.course-terms {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.term-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.term-block h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.cpp-categories {
  margin-top: 28px;
}

.category-list {
  display: grid;
  gap: 12px;
}

.category-list .accordion__content {
  display: none;
}

.category-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.accordion {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.accordion__summary {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  line-height: 1.4;
  flex-wrap: nowrap;
  text-align: left;
  width: 100%;
}

.accordion__summary > span:first-child {
  flex: 1;
  text-align: left;
  white-space: nowrap;
}

.accordion__summary .accordion__meta {
  text-align: right;
  margin-left: 16px;
}

.accordion__summary::-webkit-details-marker {
  display: none;
}

.accordion__meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  font-size: 1em;
}

.accordion__count {
  min-width: 24px;
  text-align: right;
}

.accordion__caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  transition: transform var(--transition);
}

.accordion__caret svg {
  width: 1.2em;
  height: 1.2em;
}

.accordion__content {
  padding: 0 16px 16px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 250ms ease, opacity 250ms ease, transform 250ms ease;
  overflow: hidden;
}

.accordion[open] .accordion__caret {
  transform: rotate(90deg);
}

.accordion[open] .accordion__content {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
}

.category-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.category-item summary::-webkit-details-marker {
  display: none;
}

.category-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 500;
}

.category-count {
  min-width: 24px;
  text-align: right;
}

.category-caret {
  font-size: 18px;
}

.category-item[open] .category-caret {
  transform: rotate(90deg);
}

.category-content {
  padding: 0 16px 16px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  min-height: 12px;
}

.post-grid {
  display: grid;
  gap: 12px;
}

.post-card {
  display: block;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-soft);
}

.post-card h3 {
  margin: 0;
  font-size: 18px;
}

.post-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.post-tags::before {
  content: none;
}

.post-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--text);
}

.post-tag::before {
  content: none;
}

.section-title {
  font-size: 18px;
  margin: 18px 0 10px;
  letter-spacing: -0.01em;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
}

.section-heading .section-title {
  margin: 0;
}

.section-link {
  font-size: 0.9rem;
  color: var(--muted);
}

.section-link:hover {
  color: var(--text);
}

.leetcode75-group {
  margin-top: 16px;
}

.leetcode75-group__title {
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--text);
}

.leetcode75-item {
  display: inline-block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.leetcode75-item:hover {
  text-decoration: underline;
}

.update-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.update-list li {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.update-list li:last-child {
  border-bottom: none;
}

.update-list small {
  color: var(--muted);
}


.article {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.article-toc {
  align-self: start;
  justify-self: start;
  grid-column: 1;
  grid-row: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 1;
  width: 100%;
  transform: none;
}


.article-toc strong {
  display: block;
  margin-bottom: 10px;
  font-size: 15px;
}

.article-toc ul {
  list-style: none;
  padding: 0 0 0 6px;
  margin: 0;
  display: grid;
  gap: 8px;
}

.article-toc a {
  color: var(--text);
}

.article-toc a:hover {
  color: var(--primary);
}

.article-toc a.active {
  color: var(--primary);
  font-weight: 600;
}

.article-toc a.active::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1.1em;
  margin-right: 8px;
  background: var(--primary);
  border-radius: 999px;
  vertical-align: -2px;
}

.article-box section + section,
.article-content section + section {
  margin-top: 24px;
}

.article-box h2,
.article-content h2 {
  margin: 24px 0 14px;
  font-size: 24px;
}

.article-box h2:first-child,
.article-content h2:first-child {
  margin-top: 0;
}

.article-box h2::after,
.article-content h2::after {
  content: "";
  display: block;
  width: 100%;
  height: 1.5px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--border);
}

.article-box h3,
.article-content h3 {
  margin: 22px 0 10px;
  font-size: 19px;
  color: var(--text);
}

.article-box h4,
.article-content h4 {
  margin: 20px 0 8px;
  font-size: 17px;
  color: var(--text);
}

.article-box p,
.article-content p {
  margin: 0;
  color: #111827;
}

.article-box p + p,
.article-content p + p {
  margin-top: 12px;
}

body.dark-mode .article-box p,
body.dark-mode .article-content p {
  color: #e5e7eb;
}

.article-box section,
.article-content section {
  scroll-margin-top: 110px;
}

.article-box hr,
.article-content hr {
  border: 0;
  border-top: 1.5px solid var(--border-strong, var(--border));
  margin: 18px 0;
}

.article-box :not(pre) > code,
.article-content :not(pre) > code {
  background: #f5f5f5;
  border: 0;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.92em;
  color: #0f172a;
}

.article-box pre,
.article-content pre {
  background: #f5f7fb;
  color: #111827;
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 12px 0;
}

body.dark-mode .article-box pre,
body.dark-mode .article-content pre {
  background: #0a0f1c;
  color: #e5e7eb;
}

body.dark-mode .article-box :not(pre) > code,
body.dark-mode .article-content :not(pre) > code {
  background: #3a3f47;
  border: 0;
  color: #e5e7eb;
}

.article-box pre code,
.article-content pre code {
  display: block;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
}

pre code[class*="language-"] {
  color: inherit;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6b7280;
}

.token.string,
.token.char {
  color: #34d399;
}

.token.number {
  color: #fbbf24;
}

.token.keyword {
  color: #c084fc;
}

.token.builtin,
.token.class-name,
.token.type {
  color: #60a5fa;
}

.token.function {
  color: #f59e0b;
}

.token.directive,
.token.macro,
.token.hashbang {
  color: #f472b6;
}

.token.operator,
.token.punctuation {
  color: #e5e7eb;
}

.token.variable,
.token.parameter,
.token.property {
  color: inherit;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--primary);
}

.breadcrumb a:hover {
  color: var(--primary-soft);
}

.breadcrumb span {
  color: var(--muted);
}

.article-footer {
  --article-card-max: 960px;
  --article-card-width: min(100%, var(--article-card-max));
  margin-top: 32px;
  width: var(--article-card-width);
  max-width: var(--article-card-max);
  margin-left: auto;
  margin-right: auto;
}

.article-footer__title {
  margin: 0 0 12px;
  font-size: 18px;
}

.article-footer section + section {
  margin-top: 24px;
}

.article-footer section h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.article-footer section h2::after {
  content: "";
  display: block;
  width: 100%;
  height: 1.5px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--border);
}

.article-footer section p {
  margin: 0;
  color: var(--muted);
}

.article-footer section p + p {
  margin-top: 12px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  color: var(--muted);
}

.meta-field {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.meta-field--full {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
}

.meta-field--full .meta-value {
  display: flex;
  align-items: center;
}

.meta-field--full .post-tags {
  align-self: center;
}

.meta-field--date {
  justify-self: center;
}

.meta-label {
  color: var(--text);
  font-weight: 600;
}

@media (min-width: 900px) {
  .meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .meta-field--date {
    grid-column: 2;
    justify-self: start;
  }

  .meta-field--full {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .back-to-top {
    right: 20px;
  }
  
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-field--right {
    justify-content: flex-start;
  }
}

/* // v1.1：cpp.html 兩欄筆記頁（左側清單 + 右側內文） */
.note-layout {
  max-width: 1200px;
  margin: 0 auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}

.note-sidebar {
  position: sticky;
  top: 90px;
  align-self: flex-start;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.toc-toggle {
  display: none;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left;
}

.note-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* // v1.2：cpp 筆記清單樣式 */
.note-toc ul ul {
  margin-left: 12px;
  gap: 6px;
}

.note-toc a {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
}

.note-toc a:hover,
.note-toc a:focus {
  background: var(--primary-soft);
  border-color: var(--border);
}

.note-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 760px;
}

.note-section h2 {
  margin-top: 0;
}

.note-content section + section {
  margin-top: 26px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.note-content h2 {
  margin-top: 0;
}

.note-intro {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
}

.note-intro ul {
  margin: 0 0 6px 18px;
  padding: 0;
}

.note-list {
  list-style: disc;
  padding-left: 20px;
  margin: 12px 0 0;
}

.note-list li {
  margin: 6px 0;
}

.placeholder {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--primary-soft);
  color: var(--muted);
}

.section-hint {
  margin: 6px 0 14px;
  color: var(--muted);
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accordion details {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion-title {
  font-weight: 700;
}

.accordion-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.accordion-caret {
  transition: transform var(--transition);
  display: inline-block;
}

.accordion details[open] .accordion-caret {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 16px 16px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.toc {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--primary-soft);
}

.toc ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.article-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.section {
  margin: 26px 0;
}

.section h3 {
  margin: 0 0 8px;
}

.anchor-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.list {
  list-style: disc;
  padding-left: 20px;
  margin: 10px 0;
  color: var(--muted);
}

.note-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.code-block {
  background: #0b1221;
  color: #e5e7eb;
  padding: 14px;
  border-radius: 12px;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  overflow-x: auto;
}

body.dark-mode .code-block {
  background: #0a0f1c;
}

.profile-hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: center;
}

.profile-avatar {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 4px solid var(--border);
  box-shadow: var(--shadow);
  object-fit: cover;
  background: var(--card);
}

.profile-identity h1 {
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: -0.02em;
}

.profile-identity p {
  margin: 0 0 10px;
  color: var(--muted);
}

.profile-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}

.profile-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #2f6efc);
  color: #fff;
  border: none;
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.3);
}

.btn.primary:hover {
  box-shadow: 0 14px 28px rgba(29, 78, 216, 0.35);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 18px 0 28px;
}

.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.profile-card h3 {
  margin: 0 0 6px;
}

.profile-card p {
  margin: 0;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.profile-section + .profile-section {
  margin-top: 28px;
}

.timeline {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
}

.timeline-item {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.timeline-item small {
  color: var(--muted);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.info-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.info-card span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

@media (max-width: 720px) {
  .navbar {
    flex-wrap: wrap;
  }

  .nav-links {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-links.open {
    display: flex;
    background: var(--card);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }

  .menu-btn {
    display: inline-flex;
  }

  .nav-actions {
    margin-left: auto;
  }

  .note-layout {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .note-sidebar {
    position: static;
    max-height: none;
    box-shadow: none;
    border: none;
    padding: 0;
  }

  .toc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
  }

  .note-toc {
    display: none;
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    box-shadow: var(--shadow);
  }

  .note-sidebar.open .note-toc {
    display: block;
  }

  .profile-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .profile-actions,
  .profile-chips {
    justify-content: center;
  }

.profile-avatar {
  margin: 0 auto;
}
}

/* =========================
   Article page layout（唯一版本）
   ========================= */

/* 文章頁：main 放寬，讓 TOC 可以去左側空白區 */
body.page-article main {
  max-width: none;
  margin: 40px auto 60px;
  padding: 0 20px;
}

/* breadcrumb & hero 仍維持跟內文卡同寬置中 */
body.page-article .breadcrumb,
body.page-article .hero {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

/* =========================
   Article page layout (桌機)
   ========================= */

body.page-article .article-layout {
  position: relative;
}

/* 內文卡：永遠置中，最大 960（不改你的電腦寬度習慣） */
body.page-article .article-content {
  width: min(100%, 960px);
  margin: 0 auto;
}

/* 文章資訊：跟內文卡同寬置中 */
body.page-article .article-footer {
  width: min(100%, 960px);
  margin: 32px auto 0;
}

/* ✅ 桌機：文章置中（不動），TOC 固定在文章左側外面 */
@media (min-width: 1100px) {
  body.page-article .article-layout {
    display: flow-root;
    width: min(100%, 960px);
    margin: 0 auto;
  }

  body.page-article .article-toc {
    --toc-w: 240px;
    --toc-gap: 20px;
    --toc-fixed-top: 120px;
    position: sticky;
    float: left;
    width: var(--toc-w);
    top: var(--toc-fixed-top);
    margin-left: calc(-1 * (var(--toc-w) + var(--toc-gap)));
    z-index: 30;
    max-height: calc(100vh - var(--toc-fixed-top) - 20px);
    overflow: auto;
  }

  body.page-article .article-content {
    width: 100%;
    margin: 0;
  }
}

/* 1100 以下（筆電較窄）：回到兩欄 grid，避免太擠 */
@media (min-width: 901px) and (max-width: 1099px) {
  body.page-article .article-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    max-width: 960px;
    margin: 0 auto;
  }

  body.page-article .article-toc {
    position: static;
  }

  body.page-article .article-content {
    width: 100%;
    max-width: 960px;
    margin: 0;
  }
}

/* ✅ 手機：一欄，TOC 變成上方區塊 */
@media (max-width: 900px) {
  body.page-article .article-layout {
    grid-template-columns: 1fr;
    max-width: 960px;
  }

  body.page-article .article-toc {
    position: static;
    max-height: none;
    overflow: visible;
  }

  body.page-article .article-content {
    grid-column: 1;
    margin: 0 auto;
    max-width: 960px;
  }
}

/* 小螢幕：TOC 變成可展開 */
@media (max-width: 900px) {
  body.page-article .article-toc ul {
    display: none;
  }
  body.page-article .article-toc.open ul {
    display: grid;
  }
}

pre code.hljs,
code.hljs {
  background: transparent !important;
}

.hljs-ln {
  border-collapse: collapse;
  width: 100%;
}

.hljs-ln td {
  padding: 0;
}

.hljs-ln-numbers {
  text-align: right;
  user-select: none;
  padding-right: 12px !important;
  opacity: 0.45;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: top;
}

.hljs-ln-code {
  padding-left: 12px !important;
}

/* ===== Home: Timeline + Recent actions ===== */
.muted {
  color: var(--muted);
}

.recent-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.muted-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.muted-link:hover {
  text-decoration: underline;
}

.timeline-section {
  margin-top: 26px;
}

.timeline-section .section-title {
  margin-bottom: 6px;
}

.timeline-section .muted {
  margin: 0 0 8px;
}

.timeline-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.timeline-date {
  font-weight: 800;
  color: var(--muted);
}

.timeline-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.timeline-desc {
  color: var(--muted);
  line-height: 1.55;
}

.timeline-link {
  display: inline-block;
  margin-top: 8px;
  text-decoration: none;
  font-weight: 700;
}
