/* ===== RESET / BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #0a0d12;
  color: #c9d1d9;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

* { scrollbar-width: thin; scrollbar-color: #2a313c #0a0d12; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #2a313c; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #3d4654; }

/* ===== TOPBAR ===== */
.topbar {
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0.5px solid #21262d;
  position: sticky; top: 0; z-index: 30;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: #f0f6fc; font-size: 16px; }
.brand-mark { color: #58a6ff; font-size: 20px; }
.topbar-nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  color: #8b949e; font-size: 13px;
  padding: 7px 12px; border-radius: 8px;
  transition: color 0.12s, background 0.12s;
  background: transparent; border: none; white-space: nowrap;
}
.nav-link:hover { color: #f0f6fc; background: #161b22; }
.nav-link-btn { color: #8b949e; }
.nav-user {
  color: #6e7681; font-size: 12px; padding: 0 8px 0 12px;
  border-left: 0.5px solid #21262d; margin-left: 4px;
}

.mobile-toggle {
  display: none;
  background: transparent; border: 0.5px solid #30363d; color: #c9d1d9;
  width: 36px; height: 36px; border-radius: 8px;
  flex-direction: column; align-items: center; justify-content: center; gap: 3.5px;
  flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s;
}
.mobile-toggle:hover { background: #161b22; border-color: #484f58; }
.mobile-toggle span { display: block; width: 16px; height: 1.5px; background: currentColor; }

/* ===== PAGE / FOOTER ===== */
.page {
  max-width: 1280px; margin: 0 auto;
  padding: 36px 24px;
  min-height: calc(100vh - 60px - 60px);
}
.footer { text-align: center; padding: 20px; color: #484f58; font-size: 11px; border-top: 0.5px solid #161b22; }

/* ===== HERO ===== */
.hero { margin-bottom: 36px; }
.hero h1 { color: #f0f6fc; font-size: 30px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.5px; }
.hero-sub { color: #8b949e; font-size: 15px; }

/* ===== ROADMAP GRID (главная) ===== */
.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.rm-card {
  position: relative;
  background: linear-gradient(180deg, #11161d 0%, #0d1117 100%);
  border: 0.5px solid #21262d;
  border-radius: 14px;
  padding: 22px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 180px;
  overflow: hidden;
}
.rm-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0;
  height: 1px; background: linear-gradient(90deg, transparent, #30363d 50%, transparent);
}
.rm-card:hover {
  border-color: #3d4654;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px -12px rgba(0,0,0,0.6);
}
.rm-card-head { display: flex; align-items: center; justify-content: space-between; }
.rm-icon { font-size: 32px; line-height: 1; }
.rm-private-badge {
  font-size: 10px; color: #d29922;
  background: rgba(210,153,34,0.14); padding: 3px 9px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500;
}
.rm-title { color: #f0f6fc; font-size: 18px; font-weight: 600; letter-spacing: -0.2px; }
.rm-desc {
  color: #8b949e; font-size: 13px; flex: 1; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rm-progress { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.rm-progress-bar { height: 6px; background: #161b22; border-radius: 3px; overflow: hidden; }
.rm-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ea043, #3fb950);
  box-shadow: 0 0 8px rgba(63,185,80,0.4);
  transition: width 0.3s;
}
.rm-progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: #6e7681; }
.rm-progress-percent { color: #3fb950; font-weight: 600; }

.empty-state { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: #8b949e; }
.empty-state p { margin-bottom: 8px; }
.empty-hint { font-size: 13px; color: #6e7681; }
.empty-state a { color: #58a6ff; }
.empty-state a:hover { text-decoration: underline; }

.loader, .loader-page { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: #6e7681; }

/* ===== LOGIN ===== */
.login-wrap { display: flex; justify-content: center; padding-top: 40px; }
.login-box {
  background: #0d1117; border: 0.5px solid #21262d; border-radius: 14px;
  padding: 32px; width: 100%; max-width: 380px;
  box-shadow: 0 16px 40px -16px rgba(0,0,0,0.6);
}
.login-box h1 { color: #f0f6fc; font-size: 24px; font-weight: 600; margin-bottom: 24px; text-align: center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 12px; color: #8b949e; }
.field input {
  background: #161b22; border: 0.5px solid #30363d; border-radius: 8px;
  color: #f0f6fc; padding: 10px 12px; font-size: 14px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { outline: none; border-color: #58a6ff; box-shadow: 0 0 0 3px rgba(88,166,255,0.15); }
.btn {
  padding: 10px 18px; border-radius: 8px; font-size: 13px;
  border: 0.5px solid transparent; font-family: inherit;
  transition: all 0.15s; font-weight: 500;
}
.btn-primary {
  background: linear-gradient(180deg, #2ea043, #238636);
  color: #fff; border-color: rgba(46,160,67,0.5); width: 100%;
}
.btn-primary:hover { background: linear-gradient(180deg, #3fb950, #2ea043); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.form-error { color: #f85149; font-size: 12px; padding: 8px 0 0; }

/* =================================================================
   ROADMAP PAGE
   ================================================================= */
.rm-page {
  display: grid; grid-template-columns: 300px 1fr;
  gap: 28px; min-height: calc(100vh - 60px - 60px);
}
.rm-sidebar {
  position: sticky; top: 84px;
  height: calc(100vh - 84px - 24px);
  overflow: hidden;
}
.rm-sidebar-inner {
  background: #0d1117; border: 0.5px solid #21262d; border-radius: 12px;
  height: 100%; padding: 18px 0;
  display: flex; flex-direction: column;
}
.sidebar-header {
  padding: 0 18px 12px; border-bottom: 0.5px solid #21262d;
  display: flex; align-items: center; justify-content: space-between;
}
.back-link { font-size: 12px; color: #6e7681; transition: color 0.12s; }
.back-link:hover { color: #58a6ff; }
.sidebar-close {
  display: none;
  background: transparent; border: none; color: #8b949e;
  font-size: 26px; line-height: 1; padding: 0 4px;
}
.sidebar-info { padding: 16px 18px; border-bottom: 0.5px solid #21262d; }
.sidebar-info h2 { color: #f0f6fc; font-size: 16px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.2px; }
.sidebar-info p { color: #8b949e; font-size: 12px; margin-bottom: 14px; line-height: 1.5; }
.sb-progress { display: flex; flex-direction: column; gap: 5px; }
.sb-progress-bar { height: 6px; background: #161b22; border-radius: 3px; overflow: hidden; }
.sb-progress-fill {
  height: 100%; background: linear-gradient(90deg, #2ea043, #3fb950);
  box-shadow: 0 0 6px rgba(63,185,80,0.4); transition: width 0.3s;
}
.sb-progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: #6e7681; }
.sb-progress-meta span:last-child { color: #3fb950; font-weight: 600; }

.sidebar-tree { padding: 8px 10px; overflow-y: auto; flex: 1; }
.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px; color: #8b949e;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1.4;
}
.tree-row:hover { background: #161b22; color: #c9d1d9; }
.tree-row.active { background: rgba(56,139,253,0.12); color: #58a6ff; }
.tree-row .tw-toggle {
  width: 12px; flex-shrink: 0; color: #484f58; font-size: 9px;
  transition: transform 0.15s; margin-top: 3px;
}
.tree-row .tw-toggle.open { transform: rotate(90deg); }
.tree-row .tw-toggle.leaf { visibility: hidden; }
.tree-row .tw-mark {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid #3d4654; background: transparent; margin-top: 4px;
}
.tree-row .tw-mark.done { background: #3fb950; border-color: #3fb950; box-shadow: 0 0 4px rgba(63,185,80,0.5); }
.tree-row .tw-mark.progress { background: #d29922; border-color: #d29922; }
.tree-row .tw-label { flex: 1; word-break: break-word; }
.tree-children { padding-left: 16px; }

/* ====== MAIN content — АККОРДЕОН ======= */
.rm-main { padding: 0 4px 40px; min-width: 0; }

/* ===== TOPIC КАРТОЧКА ===== */
.topic {
  background: #0d1117;
  border: 0.5px solid #21262d;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  scroll-margin-top: 84px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.topic::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: #30363d;
  transition: background 0.15s;
}
.topic.done::before { background: #3fb950; box-shadow: 0 0 8px rgba(63,185,80,0.4); }
.topic.progress::before { background: #d29922; box-shadow: 0 0 8px rgba(210,153,34,0.4); }
.topic.pending::before { background: #30363d; }
.topic:hover { border-color: #30363d; }
.topic.open { border-color: #30363d; box-shadow: 0 4px 12px -4px rgba(0,0,0,0.4); }

.topic-head {
  padding: 14px 18px 14px 22px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
}
.topic-check {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; border: 1.5px solid #30363d;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  font-size: 13px; font-weight: bold;
  transition: all 0.15s;
}
.topic-check:hover { border-color: #58a6ff; }
.topic.done .topic-check { background: #3fb950; border-color: #3fb950; color: #0d1117; box-shadow: 0 0 8px rgba(63,185,80,0.4); }
.topic.done .topic-check::before { content: "✓"; }
.topic.progress .topic-check { border-color: #d29922; background: transparent; }
.topic.progress .topic-check::before {
  content: ""; width: 9px; height: 9px; background: #d29922; border-radius: 50%;
  box-shadow: 0 0 6px rgba(210,153,34,0.5);
}
.topic-title {
  flex: 1; font-size: 15px; color: #f0f6fc; font-weight: 500;
  letter-spacing: -0.1px; min-width: 0;
}
.topic.pending .topic-title { font-weight: 400; color: #c9d1d9; }

/* счётчик подтем "3/7" в шапке */
.topic-kids-count {
  font-size: 11px; color: #8b949e;
  background: #161b22;
  padding: 3px 8px; border-radius: 10px;
  font-family: ui-monospace, monospace; font-weight: 500;
  white-space: nowrap;
}

.topic-status-pill {
  font-size: 10px; padding: 4px 10px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
  white-space: nowrap;
}
.topic-status-pill.done { color: #3fb950; background: rgba(63,185,80,0.12); }
.topic-status-pill.progress { color: #d29922; background: rgba(210,153,34,0.14); }
.topic-status-pill.pending { color: #8b949e; background: #161b22; }
.topic-toggle {
  background: transparent; border: none; color: #6e7681;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.topic-toggle:hover { background: #161b22; color: #c9d1d9; }
.topic-toggle span { display: inline-block; transition: transform 0.2s; }
.topic.open .topic-toggle span { transform: rotate(180deg); }

.topic-toggle-spacer {
  display: inline-block; width: 28px; height: 28px;  /* выравниваем с .topic-toggle для тем без раскрытия */
}

.topic-body { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.topic.open > .topic-body { max-height: 30000px; }
.topic-body-inner {
  padding: 6px 18px 18px 22px;
  border-top: 0.5px solid #21262d;
}

.topic-section { margin-top: 12px; }
.topic-section:first-child { margin-top: 8px; }

.section-label {
  font-size: 11px; color: #6e7681;
  text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600;
  margin: 0 0 8px;
}

.link-list { list-style: none; padding-left: 4px; }
.link-list li { padding: 6px 0; font-size: 13px; }
.link-list a {
  display: inline-flex; align-items: center; gap: 8px;
  color: #58a6ff; word-break: break-word; transition: color 0.12s;
}
.link-list a:hover { color: #79c0ff; text-decoration: underline; }
.link-list a .ext { font-size: 11px; color: #484f58; }

.note-content {
  background: #161b22; border-left: 3px solid #30363d;
  padding: 12px 16px; font-size: 13.5px; color: #c9d1d9;
  border-radius: 0 6px 6px 0; line-height: 1.65;
}
.note-content p { margin-bottom: 10px; }
.note-content p:last-child { margin-bottom: 0; }
.note-content strong { color: #f0f6fc; font-weight: 600; }
.note-content code {
  background: #0d1117; padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", monospace; font-size: 12.5px; color: #79c0ff;
  border: 0.5px solid #21262d;
}
.note-content pre {
  background: #0d1117; padding: 12px 14px; border-radius: 6px;
  overflow-x: auto; margin: 10px 0; border: 0.5px solid #21262d;
}
.note-content pre code { background: transparent; padding: 0; color: #c9d1d9; border: none; }
.note-content ul, .note-content ol { padding-left: 24px; margin-bottom: 10px; }
.note-content li { margin-bottom: 3px; }
.note-content a { color: #58a6ff; }
.note-content a:hover { text-decoration: underline; }
.note-content blockquote {
  border-left: 2px solid #30363d; padding-left: 12px; color: #8b949e; margin: 8px 0;
}

/* ===== ВЛОЖЕННЫЕ ДЕТИ (аккордеон) ===== */
.children-list {
  display: flex; flex-direction: column; gap: 8px;
  padding-left: 0;
}
/* визуальная связь с родителем — тонкая линия слева */
.children-list .topic {
  margin-bottom: 0;
  background: #0a0e14; /* чуть темнее чем родитель */
}
.children-list .topic .children-list .topic {
  background: #060a0f; /* ещё темнее на 3-м уровне */
}

/* уменьшаем размер заголовка и check'а на глубоких уровнях */
.topic.depth-1 > .topic-head { padding: 11px 16px 11px 18px; gap: 12px; }
.topic.depth-1 > .topic-head .topic-title { font-size: 14px; }
.topic.depth-2 > .topic-head { padding: 10px 14px 10px 16px; gap: 10px; }
.topic.depth-2 > .topic-head .topic-title { font-size: 13.5px; }
.topic.depth-3 > .topic-head { padding: 9px 12px 9px 14px; gap: 10px; }
.topic.depth-3 > .topic-head .topic-title { font-size: 13px; }
.topic.depth-4 > .topic-head { padding: 8px 12px 8px 14px; gap: 9px; }
.topic.depth-4 > .topic-head .topic-title { font-size: 12.5px; }

/* check тоже меньше на глубине */
.topic.depth-1 > .topic-head .topic-check,
.topic.depth-2 > .topic-head .topic-check,
.topic.depth-3 > .topic-head .topic-check,
.topic.depth-4 > .topic-head .topic-check {
  width: 20px; height: 20px;
}

/* отступ body уменьшается на глубине */
.topic.depth-1 > .topic-body > .topic-body-inner { padding: 4px 16px 14px 18px; }
.topic.depth-2 > .topic-body > .topic-body-inner { padding: 4px 14px 12px 16px; }
.topic.depth-3 > .topic-body > .topic-body-inner { padding: 4px 12px 10px 14px; }
.topic.depth-4 > .topic-body > .topic-body-inner { padding: 4px 12px 10px 14px; }

.rm-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 35;
  backdrop-filter: blur(2px);
}
.rm-overlay.show { display: block; }

/* ============= MOBILE (<= 960px) ============= */
@media (max-width: 960px) {
  .topbar-inner { padding: 12px 14px; gap: 8px; }
  .topbar-left { gap: 8px; }
  .brand-name { display: none; }
  .nav-link { padding: 6px 9px; font-size: 12.5px; }
  .nav-user { display: none; }

  .page { padding: 18px 14px; }
  .hero h1 { font-size: 22px; }

  .rm-page { grid-template-columns: 1fr; gap: 0; }

  .rm-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 300px; max-width: 86vw;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding: 0;
  }
  .rm-sidebar.open { transform: translateX(0); }
  .rm-sidebar-inner { border-radius: 0; border: none; padding-top: 14px; }
  .sidebar-close { display: block; }
  .mobile-toggle { display: flex; }

  .rm-main { padding: 0; }

  .topic { margin-bottom: 8px; border-radius: 8px; }
  .topic-head { padding: 11px 12px 11px 16px; gap: 10px; }
  .topic-title { font-size: 14px; }
  .topic-status-pill { font-size: 9px; padding: 3px 7px; letter-spacing: 0.4px; }
  .topic-kids-count { font-size: 10px; padding: 2px 6px; }
  .topic-check { width: 22px; height: 22px; }
  .topic-toggle { width: 24px; height: 24px; }
  .topic-body-inner { padding: 4px 12px 12px 16px; }

  /* на мобилке более компактные дети */
  .topic.depth-1 > .topic-head,
  .topic.depth-2 > .topic-head,
  .topic.depth-3 > .topic-head,
  .topic.depth-4 > .topic-head { padding: 9px 11px 9px 14px; gap: 9px; }
  .topic.depth-1 > .topic-head .topic-title { font-size: 13px; }
  .topic.depth-2 > .topic-head .topic-title { font-size: 12.5px; }
  .topic.depth-3 > .topic-head .topic-title { font-size: 12px; }
  .topic.depth-4 > .topic-head .topic-title { font-size: 12px; }
  .topic.depth-1 > .topic-body > .topic-body-inner,
  .topic.depth-2 > .topic-body > .topic-body-inner,
  .topic.depth-3 > .topic-body > .topic-body-inner,
  .topic.depth-4 > .topic-body > .topic-body-inner { padding: 4px 10px 10px 12px; }

  .note-content { padding: 11px 13px; font-size: 13px; }
  .note-content pre { padding: 10px; font-size: 12px; }

  .children-list { gap: 6px; }
}
