:root {
    --bg: #f5f3f0;
    --bg-panel: #ffffff;
    --bg-title: #f2f0ef;
    --bg-input: #f8f8f8;
    --blue: #5297ff;
    --blue-alt: #5269ff;
    --cyan: #11c2f7;
    --text: #455163;
    --text-muted: #6b7785;
    --text-strong: #2b3648;
    --border: #e2e2e2;
    --border-strong: #cfcfcf;
    --shadow: 0 4px 14px rgba(82, 151, 255, 0.10);
    --shadow-hover: 0 8px 24px rgba(82, 151, 255, 0.20);
  }
  [data-theme="dark"] {
    --bg: #1a1a1a;
    --bg-panel: #232323;
    --bg-title: #1b1c1e;
    --bg-input: #2a2a2a;
    --text: #bcd7ff;
    --text-muted: #8899aa;
    --text-strong: #e8f0ff;
    --border: #333;
    --border-strong: #444;
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 24px rgba(82, 151, 255, 0.25);
  }
  
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: "Elms Sans", sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.2s ease, color 0.2s ease;
  }
  
  /* ── Nav bar ───────────────────────────────────────────────────────── */
  .mc-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 50px;
    padding: 0 16px;
    background: var(--bg-title);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .mc-nav a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.15s;
  }
  .mc-nav a:hover { background: rgba(82,151,255,0.12); }
  .mc-nav .mc-title {
    font-weight: 900;
    letter-spacing: 1.5px;
    font-size: 14px;
    color: var(--text-strong);
  }
  .mc-nav .mc-spacer { flex: 1; }
  .mc-nav .mc-theme {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-strong);
    border-radius: 6px;
    padding: 5px 10px;
    font-family: inherit;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
  }
  
  /* ── Landing grid ──────────────────────────────────────────────────── */
  .mc-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    max-width: 1100px;
    width: 100%;
    margin: 24px auto;
    padding: 0 18px;
  }
  @media (min-width: 700px) {
    .mc-grid { grid-template-columns: 1fr 1fr; }
  }
  .mc-card {
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 22px;
    background: var(--bg-panel);
    border: 2px solid var(--border);
    border-radius: 20px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  }
  .mc-card:hover {
    transform: translateY(-3px);
    border-color: var(--blue);
    box-shadow: var(--shadow-hover);
  }
  .mc-card-icon {
    flex: 0 0 72px;
    height: 72px;
    border-radius: 14px;
    background: linear-gradient(135deg, #e8f1ff, #d0e2ff);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  [data-theme="dark"] .mc-card-icon {
    background: linear-gradient(135deg, #1f2c44, #2a3f63);
  }
  .mc-card-icon svg { width: 46px; height: 46px; }
  .mc-card-body h3 {
    margin: 0 0 6px;
    font-size: 17px;
    color: var(--text-strong);
    font-weight: 900;
  }
  .mc-card-body p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
  }
  
  /* ── Generic tool page shell ──────────────────────────────────────── */
  .mc-tool {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 20px auto 40px;
    padding: 0 16px;
  }
  .mc-tool h1 {
    font-size: 22px;
    color: var(--text-strong);
    font-weight: 900;
    margin: 0 0 4px;
  }
  .mc-tool p.sub {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 18px;
  }
  .mc-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
  }
  .mc-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  .mc-col { display: flex; flex-direction: column; gap: 4px; }
  .mc-label { font-size: 11px; font-weight: 800; color: var(--text-strong); text-transform: uppercase; letter-spacing: 0.6px; }
  
  .mc-input, .mc-select, .mc-textarea {
    background: var(--bg-input);
    color: var(--text-strong);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: "Elms Sans", monospace;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
  }
  .mc-input:focus, .mc-select:focus, .mc-textarea:focus { border-color: var(--blue); }
  .mc-textarea { resize: vertical; min-height: 60px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px; }
  
  .mc-btn {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: inherit;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    transition: filter 0.12s, transform 0.08s;
  }
  .mc-btn:hover { filter: brightness(1.08); }
  .mc-btn:active { transform: scale(0.97); }
  .mc-btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
  .mc-btn.danger { background: #e53935; }
  
  .mc-result {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    white-space: pre-wrap;
    line-height: 1.55;
    color: var(--text-strong);
    overflow-x: auto;
  }
  .mc-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
  .mc-hint code { background: var(--bg-input); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
  
  /* ── Misc ─────────────────────────────────────────────────────────── */
  .mc-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
  }
  
  /* 2-column sublayout used by graph & solver */
  .mc-two {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  @media (min-width: 800px) { .mc-two { grid-template-columns: 320px 1fr; } }

  /* ==========================================================================
   CONTENT SECTIONS & FOOTER
   ========================================================================== */
.content-section {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
  line-height: 1.9;
  font-size: 16px;
  color: var(--text);
}
.content-section h2 {
  font-size: 28px;
  color: var(--text-strong);
  margin-bottom: 16px;
  border-bottom: 2px solid var(--blue);
  display: inline-block;
  padding-bottom: 4px;
}
.content-section h3 {
  font-size: 20px;
  color: var(--text-strong);
  margin-top: 24px;
  margin-bottom: 10px;
}
.content-section p {
  margin-bottom: 16px;
}
.content-section strong {
  color: var(--text-strong);
}
.content-section ul {
  margin-bottom: 16px;
  padding-left: 24px;
}
.content-section li {
  margin-bottom: 8px;
}
.content-section code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
}
.content-section hr {
  border: none;
  border-top: 1px dashed var(--border-strong);
  margin: 40px 0;
}

/* Footer matching index.html */
#footer-section {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  min-height: 80px;
  align-items: center;
  justify-content: center;
  background: var(--bg-title);
  border-top: 1px solid var(--border);
  margin-top: auto;
  padding: 10px 0;
}
#footer-section > div {
  flex: 1;
  min-width: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
#footer-section a {
  color: var(--text-muted);
  text-decoration: underline;
  font-size: 13px;
  font-weight: 700;
  transition: color 0.15s;
}
#footer-section a:hover {
  color: var(--blue);
}
.mc-footer-bottom {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

/* ==========================================================================
   NGFINITY FOOTER (Imported from main index.html)
   ========================================================================== */
#footer-section {
    display: flex;
    width: 100%;
    min-height: 80px;
    align-items: center;
    background: var(--bg-title);
    margin-top: auto;
    border-top: 1px solid var(--border);
}
#footer-section div {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    text-decoration: underline;
}
#footer-section a {
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 700;
    text-decoration: underline;
    transition: color 0.15s;
}
#footer-section a:hover {
    color: var(--blue);
}
.footer-bottom {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg);
}
