/* ========================================================================
   Manual MyFE — 2026
   ======================================================================== */

:root {
  --bg: #f6f8fb;
  --bg-card: #ffffff;
  --bg-soft: #eef2f8;
  --border: #e4e9f2;
  --border-strong: #d4dbe7;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-dim: #9aa4b2;
  --primary: #1d4eb8;
  --primary-dark: #163a8a;
  --primary-soft: #dbe6fb;
  --primary-tint: #eef3fd;
  --sidebar-bg: #0f1d3d;
  --sidebar-bg-2: #0b1731;
  --sidebar-text: #e6ebf5;
  --sidebar-muted: #8595b8;
  --sidebar-hover: #172a58;
  --sidebar-active: #1d3a7a;
  --header-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .08);
  --radius: 12px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;

  --note-bg: #fff8e1;
  --note-border: #f0d896;
  --note-warning-bg: #fdeceb;
  --note-warning-border: #f3b8b3;
  --note-solution-bg: #e9f7ee;
  --note-solution-border: #a9dfba;
  --note-info-bg: #eaf2fe;
  --note-info-border: #b7d1f8;

  --sidebar-width: 300px;
  --header-height: 60px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-card: #111a2e;
  --bg-soft: #0f1930;
  --border: #22304d;
  --border-strong: #2e3f61;
  --text: #e6ebf5;
  --text-muted: #a3adc2;
  --text-dim: #6b7899;
  --primary: #5b8def;
  --primary-dark: #3e6fd6;
  --primary-soft: #1e2f5c;
  --primary-tint: #172444;
  --sidebar-bg: #070d1c;
  --sidebar-bg-2: #050a15;
  --sidebar-text: #e6ebf5;
  --sidebar-muted: #8595b8;
  --sidebar-hover: #101b38;
  --sidebar-active: #172a58;
  --header-bg: #111a2e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);

  --note-bg: #2b260f;
  --note-border: #574c1c;
  --note-warning-bg: #2e1917;
  --note-warning-border: #5c2d29;
  --note-solution-bg: #10281a;
  --note-solution-border: #245537;
  --note-info-bg: #101f36;
  --note-info-border: #24406b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ================= Header ================= */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  width: calc(var(--sidebar-width) - 20px);
  min-width: 220px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: .5px;
  box-shadow: var(--shadow-sm);
}
.brand-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px;
}
.brand-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; padding: 2px 8px;
}
[data-theme="dark"] .brand-badge { color: #b9caf3; }
.brand-sub {
  font-size: 11px; color: var(--text-muted);
  font-weight: 500; margin-top: 1px;
}

.mobile-menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 8px;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  color: var(--text);
}

.search-wrap {
  flex: 1;
  max-width: 620px;
  margin: 0 auto;
  position: relative;
}
.search-wrap svg.search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 44px 0 42px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="dark"] .search-input { background: var(--bg-soft); }
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.search-input::placeholder { color: var(--text-muted); }
.search-kbd {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  background: var(--bg-soft); color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.search-results {
  position: absolute;
  top: 48px; left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-results.visible { display: block; }
.search-result-item {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.active {
  background: var(--primary-tint);
  text-decoration: none;
}
.search-result-title { font-weight: 600; font-size: 14px; }
.search-result-section { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-result-snippet { font-size: 12px; color: var(--text-dim); margin-top: 4px; line-height: 1.4; }
.search-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 14px; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* ================= Sidebar ================= */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  padding: 18px 10px 40px;
  z-index: 90;
  transition: transform .25s ease;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-hover); border-radius: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-title {
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  padding: 8px 14px 12px;
}

.toc-group { margin-bottom: 6px; }
.toc-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.toc-group-header:hover { background: var(--sidebar-hover); }
.toc-group-header .chevron {
  transition: transform .18s;
  color: var(--sidebar-muted);
  flex-shrink: 0;
}
.toc-group.open .toc-group-header .chevron { transform: rotate(90deg); }

.toc-items {
  display: none;
  padding: 2px 0 4px;
}
.toc-group.open .toc-items { display: block; }
.toc-item {
  display: block;
  padding: 7px 12px 7px 34px;
  color: var(--sidebar-text);
  opacity: .78;
  font-size: 13.5px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.35;
}
.toc-item:hover {
  background: var(--sidebar-hover);
  opacity: 1;
  text-decoration: none;
  color: var(--sidebar-text);
}
.toc-item.active {
  background: var(--sidebar-active);
  color: #fff;
  opacity: 1;
  font-weight: 600;
}

/* ================= Main content ================= */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 40px 48px 80px;
}

/* ---- Landing ---- */
.landing { max-width: 1100px; }
.landing-badge {
  display: inline-block;
  background: var(--primary-tint);
  color: var(--primary-dark);
  border: 1px solid var(--primary-soft);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 22px;
}
[data-theme="dark"] .landing-badge { color: #a9c1f1; }

.landing-title {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 14px;
  color: var(--text);
}
.landing-desc {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 0 32px;
}

.stats {
  display: flex;
  gap: 48px;
  margin-bottom: 40px;
}
.stat-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  display: block;
  color: inherit;
}
.section-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-soft);
  text-decoration: none;
  color: inherit;
}
.section-card-badge {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--primary-tint);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  margin-bottom: 18px;
}
.section-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.3;
}
.section-card-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Topic viewer ---- */
.topic { max-width: 880px; }
.topic-header {
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.topic-title {
  font-size: 30px;
  font-weight: 800;
  margin: 0;
  color: var(--text);
  letter-spacing: -.01em;
}

/* ---- Contenido del tema (HTML embebido) ---- */
.topic-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text);
}
.topic-body > *:first-child { margin-top: 0; }
.topic-body > *:last-child { margin-bottom: 0; }

.topic-body p { margin: 0 0 16px; }
.topic-body h3, .topic-body h4 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -.005em;
  margin: 30px 0 12px;
}
.topic-body h3 { font-size: 20px; padding-top: 6px; border-top: 1px solid var(--border); }
.topic-body h3:first-child { border-top: none; padding-top: 0; }
.topic-body h4 { font-size: 16.5px; color: var(--primary-dark); }
[data-theme="dark"] .topic-body h4 { color: #8fb2f5; }

.topic-body ul, .topic-body ol {
  margin: 0 0 16px;
  padding-left: 24px;
}
.topic-body li { margin-bottom: 8px; }
.topic-body li:last-child { margin-bottom: 0; }

.topic-body strong { font-weight: 700; color: var(--text); }
.topic-body em { color: var(--text-muted); }

.topic-body a { color: var(--primary); text-decoration: underline; word-break: break-word; }

.topic-body .doc-figure {
  margin: 8px 0 20px;
  padding: 0;
}
.topic-body .doc-img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.topic-body .note {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--note-bg);
  border: 1px solid var(--note-border);
}
.topic-body .note-warning { background: var(--note-warning-bg); border-color: var(--note-warning-border); }
.topic-body .note-solution { background: var(--note-solution-bg); border-color: var(--note-solution-border); }
.topic-body .note-info { background: var(--note-info-bg); border-color: var(--note-info-border); }
.topic-body .note strong { display: inline; }

.topic-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
}
.topic-nav a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--text);
  flex: 1;
  max-width: 320px;
  transition: all .15s;
  text-decoration: none;
}
.topic-nav a:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.topic-nav .dir {
  font-size: 12px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.topic-nav .title { font-weight: 600; margin-top: 4px; }
.topic-nav .next { text-align: right; margin-left: auto; }

/* ================= Responsive ================= */
@media (max-width: 900px) {
  :root { --sidebar-width: 280px; }
  .mobile-menu-btn { display: flex; }
  .brand { width: auto; min-width: 0; }
  .brand-sub { display: none; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 26px 20px 60px; }
  .search-wrap { max-width: none; }
  .landing-title { font-size: 32px; }
  .stats { gap: 28px; }
  .stat-number { font-size: 26px; }
  .topic-body { padding: 22px 20px; }
  .backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 80;
    display: none;
  }
  .backdrop.visible { display: block; }
}

@media (max-width: 560px) {
  .brand-title { font-size: 15px; }
  .brand-badge { display: none; }
  .header-actions .icon-btn:not(.theme-btn) { display: none; }
  .landing-title { font-size: 26px; }
  .stats { gap: 20px; flex-wrap: wrap; }
}
