/* Folder card */
.folder-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 1.5rem; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, border-left-color 0.15s;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.folder-card:hover { border-color: var(--accent); border-left-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.folder-card .folder-icon { font-size: 1.8rem; }
.folder-card .folder-name { font-size: 1.05rem; font-weight: 600; }
.folder-card .folder-meta { font-size: 0.8rem; color: var(--text-secondary); }
.folder-card .folder-progress { height: 4px; background: var(--bg-tertiary); border-radius: 2px; margin-top: auto; overflow: hidden; }
.folder-card .folder-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.folder-card-ref { border-left-color: var(--text-muted); }
.folder-card-ref:hover { border-left-color: var(--text-secondary); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.3em; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #da3633; }
.btn-sm { padding: 0.3em 0.7em; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-learn { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-learn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.btn-quiz { background: var(--accent); color: #fff; box-shadow: 0 0 8px rgba(88,166,255,0.15); }
.btn-quiz:hover { background: var(--accent-hover); box-shadow: 0 0 14px rgba(88,166,255,0.3); text-decoration: none; color: #fff; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 0; margin-bottom: 1.25rem; }

/* Option inputs */
.option-label { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; background: var(--bg-tertiary); border-radius: var(--radius); cursor: pointer; transition: background 0.1s; }
.option-label:hover { background: var(--bg-secondary); }
.option-label input[type="radio"] { accent-color: var(--accent); width: 1rem; height: 1rem; }
.option-label.selected { background: var(--bg-secondary); border: 1px solid var(--accent); }
.option-correct { border: 1px solid var(--success) !important; }
.option-incorrect { border: 1px solid var(--danger) !important; }

/* Text input quiz */
.text-input-wrap { margin: 1.2rem 0; }
.text-input-wrap input, .text-input {
  width: 100%; padding: 0.7rem 1rem; background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; font-family: var(--font-sans);
}
.text-input-wrap input:focus, .text-input:focus { outline: none; border-color: var(--accent); }

/* Feedback */
.feedback { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: var(--radius); }
.feedback-correct { background: rgba(63,185,80,0.1); border: 1px solid var(--success); color: var(--success); }
.feedback-incorrect { background: rgba(248,81,73,0.1); border: 1px solid var(--danger); color: var(--danger); }

/* Badges */
.badge-coming { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }

/* Score ring */
.score-ring-wrap { position: relative; display: inline-flex; justify-content: center; align-items: center; margin: 1rem 0; }
.score-ring-text { position: absolute; font-size: 2rem; font-weight: 700; }

/* History */
.history-entry .btn { flex-shrink: 0; }

/* Topic hub */
.topic-hub { display: flex; flex-direction: column; gap: 0.6rem; }
.folder-header {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.75rem; margin-bottom: 1.5rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.folder-header-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.folder-header-icon { font-size: 2.2rem; }
.folder-header-title { font-size: 1.4rem; font-weight: 600; margin: 0; }
.folder-header-stats { font-size: 0.82rem; color: var(--text-secondary); }
.folder-header-progress { height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; margin-bottom: 0.4rem; }
.folder-header-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.folder-header-pct { font-size: 0.75rem; color: var(--text-secondary); }

/* Note cards */
.note-card {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.9rem 1.1rem; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.note-card:hover { border-color: var(--accent); box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 0 10px rgba(88,166,255,0.06); }
.note-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.note-info { flex: 1; min-width: 0; }
.note-name { font-size: 0.93rem; font-weight: 500; line-height: 1.3; }
.note-stats { font-size: 0.76rem; color: var(--text-secondary); margin-top: 0.15rem; }
.note-badge { display: inline-block; font-size: 0.62rem; font-weight: 600; letter-spacing: 0.06em; padding: 0.12em 0.5em; border-radius: 3px; margin-top: 0.25rem; }
.badge-new { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-progress { background: rgba(210,153,29,0.12); color: var(--warning); }
.badge-done { background: rgba(63,185,80,0.12); color: var(--success); }

/* Quiz container */
.quiz-container { max-width: 700px; margin: 0 auto; }
.quiz-question { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; margin-bottom: 1.5rem; }
.options-group { display: flex; flex-direction: column; gap: 0.6rem; margin: 1.2rem 0; }
.progress-bar { width: 100%; height: 4px; background: var(--bg-tertiary); border-radius: 2px; margin: 1rem 0; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }

/* Summary */
.summary-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem 2rem; text-align: center; max-width: 450px; margin: 2rem auto; }
.history-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* Learn view */
.learn-note { margin: 0 auto; }
.learn-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 2rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.learn-body h1 { font-size: 1.6rem; margin: 1.5rem 0 0.75rem; }
.learn-body h2 { font-size: 1.3rem; margin: 1.4rem 0 0.6rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.learn-body h3 { font-size: 1.1rem; margin: 1.2rem 0 0.5rem; }
.learn-body h4 { font-size: 1rem; margin: 1rem 0 0.4rem; }
.learn-body p { margin-bottom: 0.75rem; }
.learn-body ul, .learn-body ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.learn-body li { margin-bottom: 0.4rem; }
.learn-body li:last-child { margin-bottom: 0; }
.learn-body strong { color: #fff; }
.learn-body code { background: var(--bg-tertiary); padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; }
.learn-body pre { background: var(--bg-tertiary); padding: 1rem 1.25rem; border-radius: var(--radius); overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border); }
.learn-body pre code { background: none; padding: 0; font-size: 0.9em; }
.learn-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; table-layout: auto; }
.learn-body th, .learn-body td { padding: 0.6rem 0.85rem; text-align: left; border: 1px solid var(--border); }
.learn-body th { background: var(--bg-tertiary); font-weight: 600; }
.learn-body blockquote.callout {
  border-left: 3px solid var(--accent); padding: 0.75rem 1rem; margin: 1rem 0;
  background: var(--bg-secondary); border-radius: 0 var(--radius) var(--radius) 0;
}
.learn-body blockquote.callout strong { display: block; margin-bottom: 0.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.learn-body blockquote.callout-tip { border-left-color: var(--success); }
.learn-body blockquote.callout-tip strong { color: var(--success); }
.learn-body blockquote.callout-warning { border-left-color: var(--warning); }
.learn-body blockquote.callout-warning strong { color: var(--warning); }
.learn-body blockquote.callout-danger { border-left-color: var(--danger); }
.learn-body blockquote.callout-danger strong { color: var(--danger); }
.learn-body hr { margin: 2rem 0; }

/* Wiki links */
.wiki-link { color: var(--accent); cursor: pointer; }
.wiki-link:hover { text-decoration: underline; }
.wiki-link-missing { color: var(--text-muted); cursor: default; }

/* Syntax highlighting */
.syn-kw { color: #ff7b72; }
.syn-type { color: #79c0ff; }
.syn-func { color: #d2a8ff; }
.syn-num { color: #a5d6ff; }
.syn-string { color: #a5d6ff; }
.syn-comment { color: #8b949e; font-style: italic; }
.syn-pp { color: #f0883e; }

[data-theme="light"] .syn-kw { color: #cf222e; }
[data-theme="light"] .syn-type { color: #0550ae; }
[data-theme="light"] .syn-func { color: #8250df; }
[data-theme="light"] .syn-num { color: #0550ae; }
[data-theme="light"] .syn-string { color: #0a3069; }
[data-theme="light"] .syn-comment { color: #6e7781; }
[data-theme="light"] .syn-pp { color: #9a6700; }

/* Sidebar TOC */
.learn-toc {
  position: fixed; right: max(0px, calc((100vw - 1000px) / 2 - 170px));
  top: 76px; width: 150px; max-height: calc(100vh - 120px);
  overflow-y: auto; font-size: 0.8rem; z-index: 50;
  background: var(--bg-primary); padding: 0.5rem 0.75rem; border-radius: var(--radius);
}
.toc-link { color: var(--text-muted); padding: 0.15em 0; display: block; transition: color 0.1s; }
.toc-link:hover { color: var(--text-secondary); text-decoration: none; }
.toc-link.toc-active { color: var(--accent); font-weight: 600; }
.learn-toc h4 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }

@media (max-width: 800px) {
  .learn-toc { display: none; }
}

/* Tabs */
.tabs {
  display: flex; gap: 0; margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font-size: 0.85rem; font-weight: 500;
  padding: 0.5em 1em; cursor: pointer; transition: color 0.1s, border-color 0.1s;
  display: flex; align-items: center; gap: 0.4em;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  background: var(--bg-tertiary); color: var(--text-muted);
  font-size: 0.7rem; padding: 0.1em 0.45em; border-radius: 10px;
  font-weight: 600;
}
.tab-btn.active .tab-count { background: rgba(88,166,255,0.15); color: var(--accent); }
.tab-empty {
  text-align: center; padding: 2rem 0; color: var(--text-muted);
  font-size: 0.9rem;
}

/* Section headers in topic hub */
.section-header {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0.8rem 0.3rem 0.3rem 0.3rem;
  margin-top: 0.3rem;
  border-bottom: 1px solid var(--border);
}

/* Folder groups */
.folder-group {
  margin-bottom: 0.4rem;
}
.folder-group-header {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.65rem 0.75rem; cursor: pointer;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.folder-group-header:hover {
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), 0 0 8px rgba(88,166,255,0.06);
}
.folder-group-caret {
  font-size: 0.6rem; color: var(--text-muted); width: 10px; text-align: center;
  transition: transform 0.15s;
}
.folder-group-icon { font-size: 0.9rem; opacity: 0.5; }
.folder-group-name { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); }
.folder-group-count { font-size: 0.7rem; color: var(--text-muted); margin-left: auto; font-weight: 400; }
.folder-group-body {
  padding: 0.4rem 0 0.2rem 0.8rem;
  border-left: 1px solid var(--border);
  margin-left: 0.5rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

/* Sequential nav */
.seq-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.seq-pos { font-size: 0.8rem; color: var(--text-muted); }

/* Quiz feedback polish */
.feedback-correct { border-left: 3px solid var(--success); }
.feedback-incorrect { border-left: 3px solid var(--danger); }

/* Mobile responsive */
@media (max-width: 768px) {
  .app-header { padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .header-link { font-size: 0.75rem; padding: 0.2em 0.4em; }
  .search-wrap { display: none; }
  #app-main { padding: 1rem 0.75rem; }
  .dashboard { grid-template-columns: 1fr; }
  .folder-header { padding: 1rem 1.25rem; }
  .folder-header-icon { font-size: 1.6rem; }
  .folder-header-title { font-size: 1.2rem; }
  .tabs { overflow-x: auto; }
  .note-card { padding: 0.7rem 0.8rem; gap: 0.5rem; }
  .note-card .btn { font-size: 0.7rem; padding: 0.2em 0.5em; }
  .note-name { font-size: 0.82rem; }
  .learn-toc { display: none; }
  .learn-note { max-width: 100%; }
  .learn-layout { display: block; }
  .quiz-container { max-width: 100%; padding: 0 0.5rem; }
  .quiz-question { padding: 1.25rem; }
  .seq-nav { flex-wrap: wrap; gap: 0.5rem; }
  .seq-nav .btn { font-size: 0.7rem; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .folder-group-header { padding: 0.5rem 0.6rem; }
  .folder-group-body { padding-left: 0.3rem; margin-left: 0.2rem; }
}

.lp-link {
  display: inline-block; font-size: 0.78rem; color: var(--accent);
  margin-top: 0.5rem; text-decoration: none;
}
.lp-link:hover { text-decoration: underline; }

.topic-footer {
  margin-top: 1.2rem; padding-top: 0.8rem;
  border-top: 1px solid var(--border); text-align: right;
}
.topic-footer a {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45em 0.85em;
  background: var(--bg-secondary); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; font-size: 0.8rem;
  transition: border-color 0.15s, color 0.15s;
}
.topic-footer a:hover { border-color: var(--accent); color: var(--text-primary); text-decoration: none; }

/* Remove old header-positioned lp-link */
.lp-link { display: none; }

/* Learning Path grid */
.lp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem; margin-top: 1.5rem;
}
.lp-card, .lp-card:visited, .lp-card:link { text-decoration: none; color: inherit; }
.lp-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 1.2rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.lp-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(88,166,255,0.08);
  transform: translateY(-1px);
  text-decoration: none; color: inherit;
}
.lp-card-icon { font-size: 1.6rem; line-height: 1; }
.lp-card-name { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.lp-card-meta { font-size: 0.75rem; color: var(--text-muted); }
